Explorar el Código

平博下注接口

flyzto hace 2 semanas
padre
commit
633b6f3e77
Se han modificado 4 ficheros con 46 adiciones y 6 borrados
  1. 19 2
      server/models/Markets.js
  2. 25 2
      server/models/PartnerGate.js
  3. 1 1
      server/routes/partnerGate.js
  4. 1 1
      web/src/views/home.vue

+ 19 - 2
server/models/Markets.js

@@ -136,7 +136,7 @@ const getPolymarketIorInfo = async (ior, id) => {
 
   let marketTypeData, outcomesSide;
 
-  if (type === 'm') {
+  if (type === 'm' && !ratio) {
     const sideKey = side === 'h' ? 'Home' : side === 'c' ? 'Away' : 'Draw';
     const sideAction = action === 'o' ? 'No' : 'Yes';
     marketTypeData = marketsData.moneyline[sideKey];
@@ -191,7 +191,7 @@ const getPinnacleIorInfo = async (ior, id) => {
   const { lineId: straightLineId, moneyline, spreads, totals } = straightData;
   const { winningMargin, exactTotalGoals } = specials;
 
-  if (type === 'm' && moneyline) {
+  if (type === 'm' && moneyline && !action && !ratio) {
     const sideKey = side === 'h' ? 'home' : side === 'c' ? 'away' : 'draw';
     const team = side === 'h' ? 'TEAM1' : side === 'c' ? 'TEAM2' : 'DRAW';
     const odds = moneyline[sideKey];
@@ -311,6 +311,23 @@ export const getPlatformIorsDetailInfo = async (ior, platform, id) => {
   return getInfo[platform]?.();
 }
 
+/**
+ * 平台盘口下注
+ */
+export const placePlatformOrder = async (ior, platform, id, stake=0) => {
+  const iorInfo = await getPlatformIorsDetailInfo(ior, platform, id);
+  const betInfo = { ...iorInfo, stakeSize: stake };
+  const placeOrder = {
+    polymarket() {
+      return polymarketPlaceOrder(betInfo);
+    },
+    pinnacle() {
+      return pinnaclePlaceOrder(betInfo);
+    }
+  }
+  return placeOrder[platform]?.();
+}
+
 /**
  * 根据最新赔率获取策略
  */

+ 25 - 2
server/models/PartnerGate.js

@@ -1,6 +1,7 @@
 import Logs from "../libs/logs.js";
 import { receivePartnerData } from "./Partner.js";
 import eventSolutions from '../triangle/eventSolutions.js';
+import { placePlatformOrder } from "./Markets.js";
 
 /**
  * 精确浮点数字
@@ -12,6 +13,11 @@ const fixFloat = (number, x=3) => {
   return parseFloat(number.toFixed(x));
 }
 
+/**
+ * 根据赔率获取策略
+ * @param {*} params
+ * @returns
+ */
 const getSolutionWithIors = async(params) => {
   const { iors, cross_type, base_stake } = params;
   if (typeof params !== 'object' || params === null || Array.isArray(params)) {
@@ -51,16 +57,33 @@ const getSolutionWithIors = async(params) => {
   return sol;
 }
 
-export const partnerGate = async (data) => {
+/**
+ * 下注Pinnacle
+ * @param {*} data
+ * @returns
+ */
+const betPinnacle = async (params) => {
+  const { id, ior, stake=0 } = params;
+  const iorInfo = await placePlatformOrder(ior, 'pinnacle', id, stake);
+  if (!iorInfo) {
+    return Promise.reject(new Error('ior info not found'));
+  }
+  return iorInfo;
+}
+
+export const gate = async (data) => {
   return receivePartnerData(data).
   then(({ action, params }) => {
     switch (action) {
       case 'iors.solution':
         return getSolutionWithIors(params);
+      case 'bet.pinnacle':
+        return betPinnacle(params);
       default:
         return Promise.reject(new Error('invalid action'));
     }
   });
 }
 
-export default { partnerGate };
+
+export default { gate };

+ 1 - 1
server/routes/partnerGate.js

@@ -5,7 +5,7 @@ import PartnerGate from '../models/PartnerGate.js';
 
 router.post('/gate', (req, res) => {
   const data = req.body;
-  PartnerGate.partnerGate(data)
+  PartnerGate.gate(data)
   .then(result => {
     res.sendSuccess(result);
   })

+ 1 - 1
web/src/views/home.vue

@@ -85,7 +85,7 @@ const refresh = () => {
 onMounted(() => {
   // console.log('home mounted');
   refresh();
-  refreshTimer.value = setInterval(refresh, 1000 * 1);
+  refreshTimer.value = setInterval(refresh, 5_000);
 });
 
 onUnmounted(() => {