|
@@ -4,6 +4,8 @@ const Cache = require('../libs/cache');
|
|
|
const Setting = require('./Setting');
|
|
const Setting = require('./Setting');
|
|
|
const { eventSolutions } = require('../triangle/eventSolutions');
|
|
const { eventSolutions } = require('../triangle/eventSolutions');
|
|
|
const { calcTotalProfit, calcTotalProfitWithFixedFirst } = require('../triangle/totalProfitCalc');
|
|
const { calcTotalProfit, calcTotalProfitWithFixedFirst } = require('../triangle/totalProfitCalc');
|
|
|
|
|
+const { getSetting, updateSetting } = require('../triangle/settings');
|
|
|
|
|
+
|
|
|
const fs = require('fs');
|
|
const fs = require('fs');
|
|
|
const path = require('path');
|
|
const path = require('path');
|
|
|
|
|
|
|
@@ -205,6 +207,8 @@ const submitOdds = ({ platform, mk, games }) => {
|
|
|
*/
|
|
*/
|
|
|
const syncBaseEvents = ({ mk, games, outrights }) => {
|
|
const syncBaseEvents = ({ mk, games, outrights }) => {
|
|
|
|
|
|
|
|
|
|
+ const { expireTimeEvents, expireTimeSpecial } = getSetting();
|
|
|
|
|
+
|
|
|
const marketType = getMarketType(mk);
|
|
const marketType = getMarketType(mk);
|
|
|
const baseList = GAMES.Baselist;
|
|
const baseList = GAMES.Baselist;
|
|
|
if (!baseList[marketType]) {
|
|
if (!baseList[marketType]) {
|
|
@@ -247,8 +251,8 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
|
|
|
if (games?.length) {
|
|
if (games?.length) {
|
|
|
const gamesList = baseList[marketType]?.map(game => {
|
|
const gamesList = baseList[marketType]?.map(game => {
|
|
|
const { evtime, events, sptime, special, ...gameInfo } = game;
|
|
const { evtime, events, sptime, special, ...gameInfo } = game;
|
|
|
- const expireTimeEv = Date.now() - 45000;
|
|
|
|
|
- const expireTimeSP = Date.now() - 60000;
|
|
|
|
|
|
|
+ const expireTimeEv = Date.now() - expireTimeEvents;
|
|
|
|
|
+ const expireTimeSP = Date.now() - expireTimeSpecial;
|
|
|
let odds = {};
|
|
let odds = {};
|
|
|
if (evtime > expireTimeEv) {
|
|
if (evtime > expireTimeEv) {
|
|
|
odds = { ...odds, ...events };
|
|
odds = { ...odds, ...events };
|
|
@@ -712,8 +716,8 @@ const updateSolutions = (solutions) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- Logs.out('solutions add %d, update %d, retain %d, remove %d',
|
|
|
|
|
- solutionUpdate.add.length, solutionUpdate.update.length, solutionUpdate.retain.length, solutionUpdate.remove.length);
|
|
|
|
|
|
|
+ // Logs.out('solutions add %d, update %d, retain %d, remove %d',
|
|
|
|
|
+ // solutionUpdate.add.length, solutionUpdate.update.length, solutionUpdate.retain.length, solutionUpdate.remove.length);
|
|
|
|
|
|
|
|
syncSolutions(solutionUpdate);
|
|
syncSolutions(solutionUpdate);
|
|
|
|
|
|
|
@@ -724,8 +728,8 @@ const updateSolutions = (solutions) => {
|
|
|
* 获取中单方案
|
|
* 获取中单方案
|
|
|
*/
|
|
*/
|
|
|
const getSolutions = async ({ win_min }) => {
|
|
const getSolutions = async ({ win_min }) => {
|
|
|
- Logs.out('getSolutions', win_min);
|
|
|
|
|
- const { minShowAmount } = await getSetting();
|
|
|
|
|
|
|
+ // Logs.out('getSolutions', win_min);
|
|
|
|
|
+ const { minShowAmount } = getSetting();
|
|
|
const solutionsList = Object.values(GAMES.Solutions);
|
|
const solutionsList = Object.values(GAMES.Solutions);
|
|
|
const gamesRelation = getGamesRelation();
|
|
const gamesRelation = getGamesRelation();
|
|
|
const relationsMap = new Map(gamesRelation.map(item => [item.id, item.rel]));
|
|
const relationsMap = new Map(gamesRelation.map(item => [item.id, item.rel]));
|
|
@@ -787,7 +791,7 @@ setInterval(() => {
|
|
|
* 获取综合利润
|
|
* 获取综合利润
|
|
|
*/
|
|
*/
|
|
|
const getTotalProfit = async (sol1, sol2, inner_base, inner_rebate) => {
|
|
const getTotalProfit = async (sol1, sol2, inner_base, inner_rebate) => {
|
|
|
- const { innerDefaultAmount, innerRebateRatio } = await getSetting();
|
|
|
|
|
|
|
+ const { innerDefaultAmount, innerRebateRatio } = getSetting();
|
|
|
inner_base = inner_base ? +inner_base : innerDefaultAmount;
|
|
inner_base = inner_base ? +inner_base : innerDefaultAmount;
|
|
|
inner_rebate = inner_rebate ? +inner_rebate : fixFloat(innerRebateRatio / 100, 3);
|
|
inner_rebate = inner_rebate ? +inner_rebate : fixFloat(innerRebateRatio / 100, 3);
|
|
|
const profit = calcTotalProfit(sol1, sol2, inner_base, inner_rebate);
|
|
const profit = calcTotalProfit(sol1, sol2, inner_base, inner_rebate);
|
|
@@ -816,7 +820,7 @@ const getTotalProfitWithSid = async (sid1, sid2, inner_base, inner_rebate) => {
|
|
|
* 通过盘口信息获取综合利润
|
|
* 通过盘口信息获取综合利润
|
|
|
*/
|
|
*/
|
|
|
const getTotalProfitWithBetInfo = async (betInfo1, betInfo2, fixed=false, inner_base, inner_rebate) => {
|
|
const getTotalProfitWithBetInfo = async (betInfo1, betInfo2, fixed=false, inner_base, inner_rebate) => {
|
|
|
- const { innerDefaultAmount, innerRebateRatio } = await getSetting();
|
|
|
|
|
|
|
+ const { innerDefaultAmount, innerRebateRatio } = getSetting();
|
|
|
inner_base = inner_base ? +inner_base : innerDefaultAmount;
|
|
inner_base = inner_base ? +inner_base : innerDefaultAmount;
|
|
|
inner_rebate = inner_rebate ? +inner_rebate : fixFloat(innerRebateRatio / 100, 3);
|
|
inner_rebate = inner_rebate ? +inner_rebate : fixFloat(innerRebateRatio / 100, 3);
|
|
|
|
|
|
|
@@ -832,9 +836,9 @@ const getTotalProfitWithBetInfo = async (betInfo1, betInfo2, fixed=false, inner_
|
|
|
/**
|
|
/**
|
|
|
* 获取后台设置
|
|
* 获取后台设置
|
|
|
*/
|
|
*/
|
|
|
-const getSetting = async () => {
|
|
|
|
|
- return Setting.get();
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// const getSetting = async () => {
|
|
|
|
|
+// return ;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 异常通知
|
|
* 异常通知
|
|
@@ -881,7 +885,7 @@ events_child.on('message', async (message) => {
|
|
|
responseData = getGamesRelation({ listEvents: true });
|
|
responseData = getGamesRelation({ listEvents: true });
|
|
|
}
|
|
}
|
|
|
else if (type == 'getSetting') {
|
|
else if (type == 'getSetting') {
|
|
|
- responseData = await getSetting();
|
|
|
|
|
|
|
+ responseData = getSetting();
|
|
|
}
|
|
}
|
|
|
// else if (type == 'getSolutionHistory') {
|
|
// else if (type == 'getSolutionHistory') {
|
|
|
// responseData = getSolutionHistory();
|
|
// responseData = getSolutionHistory();
|
|
@@ -903,9 +907,19 @@ events_child.stderr?.on('data', data => {
|
|
|
Logs.out('events_child stderr', data.toString());
|
|
Logs.out('events_child stderr', data.toString());
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-Setting.onUpdate(fields => {
|
|
|
|
|
|
|
+const settingUpdate = (fields) => {
|
|
|
|
|
+ updateSetting(fields);
|
|
|
postDataToChild('updateSetting', fields);
|
|
postDataToChild('updateSetting', fields);
|
|
|
-});
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const syncSetting = async () => {
|
|
|
|
|
+ const setting = await Setting.get();
|
|
|
|
|
+ settingUpdate(setting.toObject());
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+syncSetting();
|
|
|
|
|
+
|
|
|
|
|
+Setting.onUpdate(settingUpdate);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 保存GAMES数据到缓存文件
|
|
* 保存GAMES数据到缓存文件
|