|
|
@@ -23,6 +23,12 @@ const oddRebateValue = (odds, platform, key) => {
|
|
|
}
|
|
|
return odds + rebateRatio / 100;
|
|
|
}
|
|
|
+
|
|
|
+const cartesianOdds = (selection) => {
|
|
|
+ const [a, b, c] = selection;
|
|
|
+ return a.flatMap(itemA => b.flatMap(itemB => c.map(itemC => [itemA, itemB, itemC])));
|
|
|
+}
|
|
|
+
|
|
|
const getOptimalSelections = (odds, rules) => {
|
|
|
const results = [];
|
|
|
|
|
|
@@ -48,42 +54,55 @@ const getOptimalSelections = (odds, rules) => {
|
|
|
isValid = false;
|
|
|
break;
|
|
|
}
|
|
|
- selection.push({
|
|
|
+ selection.push([{
|
|
|
k: key,
|
|
|
p: 'ps',
|
|
|
v: item.ps.v,
|
|
|
r: item.ps.r,
|
|
|
s: item.ps.s,
|
|
|
o: item
|
|
|
- });
|
|
|
+ }]);
|
|
|
}
|
|
|
else {
|
|
|
- const candidates = ['ob', 'hg', 'no'].filter((k) => k in item);
|
|
|
+ const { ps, ...itemRest } = item;
|
|
|
+ // const candidates = ['ob', 'hg', 'no'].filter((k) => k in item);
|
|
|
+ const candidates = Object.keys(itemRest);
|
|
|
if (candidates.length === 0) {
|
|
|
isValid = false;
|
|
|
break;
|
|
|
}
|
|
|
// Logs.out('candidates', candidates)
|
|
|
- const best = candidates.reduce((a, b) => {
|
|
|
- const aValue = oddRebateValue(item[a].v-1, a, key);
|
|
|
- const bValue = oddRebateValue(item[b].v-1, b, key);
|
|
|
- const seletcted = aValue > bValue ? a : b;
|
|
|
- return seletcted;
|
|
|
- });
|
|
|
+ // const best = candidates.reduce((a, b) => {
|
|
|
+ // const aValue = oddRebateValue(item[a].v-1, a, key);
|
|
|
+ // const bValue = oddRebateValue(item[b].v-1, b, key);
|
|
|
+ // const seletcted = aValue > bValue ? a : b;
|
|
|
+ // return seletcted;
|
|
|
+ // });
|
|
|
// Logs.out('best', item, best)
|
|
|
- selection.push({
|
|
|
+ // selection.push({
|
|
|
+ // k: key,
|
|
|
+ // p: best,
|
|
|
+ // v: item[best].v,
|
|
|
+ // r: item[best].r,
|
|
|
+ // s: item[best].s,
|
|
|
+ // o: item
|
|
|
+ // });
|
|
|
+ selection.push(candidates.map(k => ({
|
|
|
k: key,
|
|
|
- p: best,
|
|
|
- v: item[best].v,
|
|
|
- r: item[best].r,
|
|
|
- s: item[best].s,
|
|
|
+ p: k,
|
|
|
+ v: item[k].v,
|
|
|
+ r: item[k].r,
|
|
|
+ s: item[k].s,
|
|
|
o: item
|
|
|
- });
|
|
|
+ })));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (isValid) {
|
|
|
- validOptions.push(selection);
|
|
|
+ const cartesian = cartesianOdds(selection);
|
|
|
+ cartesian.forEach(item => {
|
|
|
+ validOptions.push(item);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +119,10 @@ const getOptimalSelections = (odds, rules) => {
|
|
|
// results.push({ rule, iors, ruleIndex });
|
|
|
// }
|
|
|
});
|
|
|
-
|
|
|
+ // if (results.length) {
|
|
|
+ // Logs.outDev('results', results);
|
|
|
+ // }
|
|
|
+ // return [];
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
@@ -124,6 +146,15 @@ const sortCpr = (cpr) => {
|
|
|
return temp;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 获取平台类型
|
|
|
+ */
|
|
|
+const getPlatformKey = (cpr) => {
|
|
|
+ const platforms = sortCpr(cpr).map(item => item.p);
|
|
|
+ return [...new Set(platforms)].join('_');
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 添加返佣
|
|
|
*/
|
|
|
@@ -150,6 +181,7 @@ const attachRebate = (ior) => {
|
|
|
}
|
|
|
|
|
|
const eventsCombination = (passableEvents) => {
|
|
|
+ // Logs.outDev('passableEvents', passableEvents);
|
|
|
const { innerDefaultAmount, innerRebateRatio } = getSetting();
|
|
|
const solutions = [];
|
|
|
passableEvents.forEach(events => {
|
|
|
@@ -189,12 +221,16 @@ const eventsCombination = (passableEvents) => {
|
|
|
}
|
|
|
if (!isNaN(sol?.win_average)) {
|
|
|
const id = info.id;
|
|
|
- const sortedCpr = sortCpr(cpr);
|
|
|
- const keys = sortedCpr.map(item => `${item.k}`).join('_');
|
|
|
- const sid = crypto.createHash('sha1').update(`${id}_${keys}`).digest('hex');
|
|
|
- const crpGroup = `${id}_${sortedCpr[0].k}`;
|
|
|
+ // const sortedCpr = sortCpr(cpr);
|
|
|
+ const keys = cpr.map(item => `${item.k}-${item.p}`).join('##');
|
|
|
+ // Logs.outDev('keys', `${id}##${keys}`)
|
|
|
+ const sid = crypto.createHash('sha1').update(`${id}-${keys}`).digest('hex');
|
|
|
+ const crpGroup = `${id}_${cpr.find(item => item.p == 'ps').k}`;
|
|
|
+ // Logs.outDev('crpGroup', crpGroup)
|
|
|
+ const platformKey = getPlatformKey(cpr);
|
|
|
+ // Logs.outDev('platformKey', platformKey, cpr)
|
|
|
const timestamp = Date.now();
|
|
|
- solutions.push({sid, sol, cpr, info, group: crpGroup, rule: `${iorGroup}:${ruleIndex}`, timestamp});
|
|
|
+ solutions.push({sid, sol, cpr, cross: platformKey, info, group: crpGroup, rule: `${iorGroup}:${ruleIndex}`, timestamp});
|
|
|
}
|
|
|
});
|
|
|
});
|