|
@@ -1,6 +1,7 @@
|
|
|
const axios = require('axios');
|
|
const axios = require('axios');
|
|
|
const Logs = require('../libs/logs');
|
|
const Logs = require('../libs/logs');
|
|
|
const Setting = require('./Setting');
|
|
const Setting = require('./Setting');
|
|
|
|
|
+const calcTotalProfit = require('../triangle/totalProfitCalc');
|
|
|
|
|
|
|
|
const childOptions = process.env.NODE_ENV == 'development' ? {
|
|
const childOptions = process.env.NODE_ENV == 'development' ? {
|
|
|
execArgv: ['--inspect=9228']
|
|
execArgv: ['--inspect=9228']
|
|
@@ -224,16 +225,39 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
|
|
|
match
|
|
match
|
|
|
};
|
|
};
|
|
|
}).filter(item => item.match.every(entry => entry.value !== 0));
|
|
}).filter(item => item.match.every(entry => entry.value !== 0));
|
|
|
- return { ...gameInfo, matches };
|
|
|
|
|
|
|
+ return { ...gameInfo, matches, uptime: Math.min(evtime, sptime) };
|
|
|
});
|
|
});
|
|
|
- // Logs.out('baseList', baseList[marketType]);
|
|
|
|
|
|
|
+
|
|
|
submitOdds({ platform: 'ps', mk, games: gamesList });
|
|
submitOdds({ platform: 'ps', mk, games: gamesList });
|
|
|
|
|
+
|
|
|
|
|
+ const relatedGames = Object.values(GAMES.Relations).map(item => item.rel?.['ps'] ?? {});
|
|
|
|
|
+
|
|
|
|
|
+ if (!relatedGames.length) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let update = 0;
|
|
|
|
|
+ const relatedMap = new Map(relatedGames.map(item => [item.eventId, item]));
|
|
|
|
|
+
|
|
|
|
|
+ gamesList?.forEach(game => {
|
|
|
|
|
+ const { eventId, matches, uptime } = game;
|
|
|
|
|
+ const relatedGame = relatedMap.get(eventId);
|
|
|
|
|
+ if (relatedGame) {
|
|
|
|
|
+ const events = {};
|
|
|
|
|
+ matches.forEach(({ label, match }) => {
|
|
|
|
|
+ match.forEach(({ key, value }) => {
|
|
|
|
|
+ events[key] = value;
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ relatedGame.evtime = uptime;
|
|
|
|
|
+ relatedGame.events = events;
|
|
|
|
|
+ update ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return update;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 更新比赛盘口
|
|
|
|
|
- */
|
|
|
|
|
const updateGamesEvents = ({ platform, mk, games, outrights }) => {
|
|
const updateGamesEvents = ({ platform, mk, games, outrights }) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
if (!platform || (!games && !outrights)) {
|
|
if (!platform || (!games && !outrights)) {
|
|
@@ -241,7 +265,8 @@ const updateGamesEvents = ({ platform, mk, games, outrights }) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (platform == 'ps') {
|
|
if (platform == 'ps') {
|
|
|
- syncBaseEvents({ mk, games, outrights });
|
|
|
|
|
|
|
+ const update = syncBaseEvents({ mk, games, outrights });
|
|
|
|
|
+ return resolve({ update });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const relatedGames = Object.values(GAMES.Relations).map(item => item.rel?.[platform] ?? {});
|
|
const relatedGames = Object.values(GAMES.Relations).map(item => item.rel?.[platform] ?? {});
|
|
@@ -285,6 +310,9 @@ const updateGamesEvents = ({ platform, mk, games, outrights }) => {
|
|
|
* 获取比赛盘口
|
|
* 获取比赛盘口
|
|
|
*/
|
|
*/
|
|
|
const getGamesEvents = ({ platform, relIds = [] } = {}) => {
|
|
const getGamesEvents = ({ platform, relIds = [] } = {}) => {
|
|
|
|
|
+ if (!relIds.length) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
const idSet = new Set(relIds);
|
|
const idSet = new Set(relIds);
|
|
|
const relations = { ...GAMES.Relations };
|
|
const relations = { ...GAMES.Relations };
|
|
|
Object.keys(relations).forEach(id => {
|
|
Object.keys(relations).forEach(id => {
|
|
@@ -580,6 +608,33 @@ setInterval(() => {
|
|
|
solutionsCleanup();
|
|
solutionsCleanup();
|
|
|
}, 1000*30);
|
|
}, 1000*30);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取综合利润
|
|
|
|
|
+ */
|
|
|
|
|
+const getTotalProfit = (sid1, sid2, gold_side_inner) => {
|
|
|
|
|
+ const preSolution = GAMES.Solutions[sid1];
|
|
|
|
|
+ const subSolution = GAMES.Solutions[sid2];
|
|
|
|
|
+ const relId1 = preSolution?.info?.id;
|
|
|
|
|
+ const relId2 = subSolution?.info?.id;
|
|
|
|
|
+ const relIds = [relId1, relId2];
|
|
|
|
|
+ const gamesEvents = getGamesEvents({ relIds });
|
|
|
|
|
+
|
|
|
|
|
+ const gamesRelations = getGamesRelation();
|
|
|
|
|
+ const relationsMap = new Map(gamesRelations.map(item => [item.id, item.rel]));
|
|
|
|
|
+ const preRelation = relationsMap.get(relId1);
|
|
|
|
|
+ const subRelation = relationsMap.get(relId2);
|
|
|
|
|
+ preSolution.info = { id: relId1, ...preRelation };
|
|
|
|
|
+ subSolution.info = { id: relId2, ...subRelation };
|
|
|
|
|
+
|
|
|
|
|
+ const sol1 = preSolution?.sol;
|
|
|
|
|
+ const sol2 = subSolution?.sol;
|
|
|
|
|
+ if (!sol1 || !sol2 || !gold_side_inner) {
|
|
|
|
|
+ return {};
|
|
|
|
|
+ }
|
|
|
|
|
+ const profit = calcTotalProfit(sol1, sol2, gold_side_inner);
|
|
|
|
|
+ return { profit, preSolution, subSolution, gamesEvents };
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取后台设置
|
|
* 获取后台设置
|
|
|
*/
|
|
*/
|
|
@@ -632,4 +687,5 @@ module.exports = {
|
|
|
getGamesRelation,
|
|
getGamesRelation,
|
|
|
updateGamesResult,
|
|
updateGamesResult,
|
|
|
getSolutions,
|
|
getSolutions,
|
|
|
|
|
+ getTotalProfit,
|
|
|
}
|
|
}
|