flyzto 2 сар өмнө
parent
commit
2d5d52df59

+ 46 - 6
server/models/GamesPs.js

@@ -246,7 +246,11 @@ const updateGamesList = (({ platform, mk, games } = {}) => {
  */
 const syncBaseEvents = ({ mk, games, outrights }) => {
 
-  const { expireTimeEvents, expireTimeSpecial, subsidyTime, subsidyAmount } = getSetting();
+  const {
+    expireTimeEvents, expireTimeSpecial,
+    subsidyTime, subsidyAmount,
+    subsidyRbWmAmount, subsidyRbOtAmount
+  } = getSetting();
   const nowTime = Date.now();
 
   const marketType = getMarketType(mk);
@@ -261,6 +265,17 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
     const { eventId, originId, stage, retime, score, wm, evtime, events } = game;
     const baseGame = baseMap.get(eventId);
     if (baseGame) {
+      const { mk } = baseGame;
+      const isRb = (mk == 2);
+      if (isRb) {
+        Object.keys(events).forEach(ior => {
+          if ((ior.startsWith('ior_r') || ior.startsWith('ior_m')) && subsidyRbWmAmount) {
+            const sourceOdds = events[ior].v;
+            events[ior].v = fixFloat(sourceOdds * (1 + subsidyRbWmAmount), 3);
+            events[ior].s = sourceOdds
+          }
+        });
+      }
       baseGame.originId = originId;
       baseGame.stage = stage;
       baseGame.retime = retime;
@@ -275,13 +290,28 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
     const { parentId, sptime, special } = outright;
     const baseGame = baseMap.get(parentId);
     if (baseGame) {
-      const { timestamp } = baseGame;
+      const { timestamp, mk } = baseGame;
+      const isRb = (mk == 2);
       const isSubsidy = timestamp > nowTime && timestamp < nowTime + 1000*60*60*subsidyTime;
       if (isSubsidy) {
         Object.keys(special).forEach(ior => {
-          if (ior.startsWith('ior_ot')) {
+          if (ior.startsWith('ior_ot') && subsidyAmount) {
             const sourceOdds = special[ior].v;
-            special[ior].v = fixFloat(sourceOdds * (1 + subsidyAmount));
+            special[ior].v = fixFloat(sourceOdds * (1 + subsidyAmount), 3);
+            special[ior].s = sourceOdds
+          }
+        });
+      }
+      else if (isRb) {
+        Object.keys(special).forEach(ior => {
+          if (ior.startsWith('ior_wm') && subsidyRbWmAmount) {
+            const sourceOdds = special[ior].v;
+            special[ior].v = fixFloat(sourceOdds * (1 + subsidyRbWmAmount), 3);
+            special[ior].s = sourceOdds
+          }
+          else if (ior.startsWith('ior_ot') && subsidyRbOtAmount) {
+            const sourceOdds = special[ior].v;
+            special[ior].v = fixFloat(sourceOdds * (1 + subsidyRbOtAmount), 3);
             special[ior].s = sourceOdds
           }
         });
@@ -1070,8 +1100,18 @@ const syncQbossConfig = () => {
       throw new Error('syncQbossConfig data is empty');
     }
     const setting = getSetting();
-    const { qboss_return_ratio, qboss_jq_add_odds, qboss_jq_add_hours } = data.data;
-    const qbossSetting = { innerRebateRatio: +qboss_return_ratio, subsidyTime: +qboss_jq_add_hours, subsidyAmount: +qboss_jq_add_odds };
+    const {
+      qboss_return_ratio,
+      qboss_jq_add_odds, qboss_jq_add_hours,
+      qboss_gq_add_dy_odds, qboss_gq_add_jq_odds,
+     } = data.data;
+    const qbossSetting = {
+      innerRebateRatio: +qboss_return_ratio,
+      subsidyTime: +qboss_jq_add_hours,
+      subsidyAmount: +qboss_jq_add_odds,
+      subsidyRbWmAmount: +qboss_gq_add_dy_odds,
+      subsidyRbOtAmount: +qboss_gq_add_jq_odds,
+    };
     const settingFields = {};
     let needUpdate = false;
     Object.keys(qbossSetting).forEach(key => {

+ 10 - 0
server/models/Setting.js

@@ -60,6 +60,16 @@ const systemSettingSchema = new Schema({
     type: Number,
     required: true,
     default: 0
+  },
+  subsidyRbWmAmount: {
+    type: Number,
+    required: true,
+    default: 0
+  },
+  subsidyRbOtAmount: {
+    type: Number,
+    required: true,
+    default: 0
   }
 }, {
   toJSON: {

+ 3 - 1
server/triangle/settings.js

@@ -11,7 +11,9 @@ const SETTING = {
   expireTimeEvents: 45000,
   expireTimeSpecial: 60000,
   subsidyTime: 0,
-  subsidyAmount: 0
+  subsidyAmount: 0,
+  subsidyRbWmAmount: 0,
+  subsidyRbOtAmount: 0
 }
 
 const getSetting = (key) => {

+ 1 - 0
server/triangle/trangleCalc.js

@@ -42,6 +42,7 @@ function getOptimalSelections(odds, rules) {
             p: 'ps',
             v: item.ps.v,
             r: item.ps.r,
+            s: item.ps.s,
             o: item
           });
         }