Parcourir la source

增加获取中单方案的方法

flyzto il y a 3 mois
Parent
commit
76361fb08d
2 fichiers modifiés avec 22 ajouts et 1 suppressions
  1. 10 1
      server/models/GamesPs.js
  2. 12 0
      server/routes/pstery.js

+ 10 - 1
server/models/GamesPs.js

@@ -824,6 +824,15 @@ const getSolution = async (sid) => {
   return solution;
 }
 
+/**
+ * 通过比赛 ID 获取中单方案
+ */
+const getSolutionsByIds = async (ids) => {
+  const idsSet = new Set(ids.map(item => +item));
+  const solutions = Object.values(GAMES.Solutions).filter(item => idsSet.has(item.info.id));
+  return solutions;
+}
+
 /**
  * 清理中单方案
  */
@@ -1037,7 +1046,7 @@ module.exports = {
   updateGamesList, updateGamesEvents,
   getGamesRelation,
   updateGamesResult,
-  getSolutions, getSolution,
+  getSolutions, getSolution, getSolutionsByIds,
   getTotalProfitWithSid,
   getTotalProfitWithBetInfo,
   notifyException,

+ 12 - 0
server/routes/pstery.js

@@ -91,6 +91,18 @@ router.get('/get_solution', (req, res) => {
   });
 });
 
+// 通过比赛 ID 获取中单方案
+router.post('/solutions_by_ids', (req, res) => {
+  const { ids } = req.body ?? {};
+  Games.getSolutionsByIds(ids)
+  .then(solutions => {
+    res.sendSuccess(solutions);
+  })
+  .catch(err => {
+    res.badRequest(err.message);
+  });
+});
+
 // 获取综合利润方案
 router.post('/calc_total_profit', (req, res) => {
   const [sid1, sid2, inner_base, inner_rebate] = req.body;