|
@@ -17,6 +17,10 @@ const WuBianConstKey = {
|
|
|
ActivityId: 'WubianActivityId',
|
|
ActivityId: 'WubianActivityId',
|
|
|
SynthesisConcurrentMode: 'WubianSynthesisConcurrentMode',
|
|
SynthesisConcurrentMode: 'WubianSynthesisConcurrentMode',
|
|
|
SynthesisRunsPerSecond: 'WubianSynthesisRunsPerSecond',
|
|
SynthesisRunsPerSecond: 'WubianSynthesisRunsPerSecond',
|
|
|
|
|
+
|
|
|
|
|
+ SynthesisCompositeGoodsListReqTime: 'WubianSynthesisCompositeGoodsListReqTime',
|
|
|
|
|
+ SynthesisConvertGoodsListReqTime: 'WubianSynthesisConvertGoodsListReqTime',
|
|
|
|
|
+ SynthesisActivityDisabled: 'WubianSynthesisActivityDisabled',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Html5Plus/1.0 (Immersed/20) uni-app`;
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Html5Plus/1.0 (Immersed/20) uni-app`;
|
|
@@ -217,7 +221,7 @@ async function getWillActivityData() {
|
|
|
|
|
|
|
|
for (let hashId in activityLstMap) {
|
|
for (let hashId in activityLstMap) {
|
|
|
let item = activityLstMap[hashId];
|
|
let item = activityLstMap[hashId];
|
|
|
- if ((indexName.length > 0 && item.name.indexOf(indexName) != -1) || (item.activityId == activityId || item.hashId == activityId)) {
|
|
|
|
|
|
|
+ if ((item.activityId == activityId || item.hashId == activityId) || (indexName.length > 0 && item.name.indexOf(indexName) != -1)) {
|
|
|
activityData = item;
|
|
activityData = item;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -231,6 +235,37 @@ async function getWillActivityData() {
|
|
|
return activityData;
|
|
return activityData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function setCompositeGoodsListReqTime(time) {
|
|
|
|
|
+ magicJS.data.write(WuBianConstKey.SynthesisCompositeGoodsListReqTime, time);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function setConvertGoodsListReqTime(time) {
|
|
|
|
|
+ magicJS.data.write(WuBianConstKey.SynthesisConvertGoodsListReqTime, time);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function checkCompositeGoodsListReqForceNeed() {
|
|
|
|
|
+ let time = magicJS.data.read(WuBianConstKey.SynthesisCompositeGoodsListReqTime, 0);
|
|
|
|
|
+ let diffTime = Date.now() - Number(time);
|
|
|
|
|
+ return diffTime > 10 * 1000;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function checkConvertGoodsListReqForceNeed() {
|
|
|
|
|
+ let time = magicJS.data.read(WuBianConstKey.SynthesisConvertGoodsListReqTime, 0);
|
|
|
|
|
+ let diffTime = Date.now() - Number(time);
|
|
|
|
|
+ return diffTime > 10 * 1000;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function checkActivityDisable(activityId) {
|
|
|
|
|
+ let key = `${WuBianConstKey.SynthesisActivityDisabled}#${activityId}`;
|
|
|
|
|
+ let bDisable = magicJS.data.read(key, false);
|
|
|
|
|
+ return bDisable;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function setActivityDisabled(activityId, bDisabled = true) {
|
|
|
|
|
+ let key = `${WuBianConstKey.SynthesisActivityDisabled}#${activityId}`;
|
|
|
|
|
+ magicJS.data.write(key, bDisabled);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function trySynthesize() {
|
|
async function trySynthesize() {
|
|
|
let activityData = await getWillActivityData();
|
|
let activityData = await getWillActivityData();
|
|
|
magicJS.logger.info(`activityData=${JSON.stringify(activityData)}`);
|
|
magicJS.logger.info(`activityData=${JSON.stringify(activityData)}`);
|
|
@@ -240,14 +275,18 @@ async function trySynthesize() {
|
|
|
let activityId = activityData.hashId || activityData.activityId;
|
|
let activityId = activityData.hashId || activityData.activityId;
|
|
|
let retCvtData = null;
|
|
let retCvtData = null;
|
|
|
if (activityData.type == 0) {
|
|
if (activityData.type == 0) {
|
|
|
- retCvtData = await getCompositeGoodsList(activityId, true);
|
|
|
|
|
|
|
+ retCvtData = await doGetCompositeGoodsList(activityId, checkCompositeGoodsListReqForceNeed());
|
|
|
} else if (activityData.type == 1) {
|
|
} else if (activityData.type == 1) {
|
|
|
- retCvtData = await getCvtGoodsList(activityId, true);
|
|
|
|
|
|
|
+ retCvtData = await doGetConvertGoodsList(activityId, checkConvertGoodsListReqForceNeed());
|
|
|
}
|
|
}
|
|
|
magicJS.logger.info(`retCvtData=${JSON.stringify(retCvtData)}`);
|
|
magicJS.logger.info(`retCvtData=${JSON.stringify(retCvtData)}`);
|
|
|
if (!retCvtData) {
|
|
if (!retCvtData) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (checkActivityDisable(activityId)) {
|
|
|
|
|
+ magicJS.notification.appendNotifyInfo(`活动[${activityData.name}]已禁用,请重新配置`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
let willCount = getActivityWillCount();
|
|
let willCount = getActivityWillCount();
|
|
|
let combinationLst = getSynthesizeCombination(retCvtData);
|
|
let combinationLst = getSynthesizeCombination(retCvtData);
|
|
|
magicJS.logger.info(`combinationLst=${JSON.stringify(combinationLst)}`);
|
|
magicJS.logger.info(`combinationLst=${JSON.stringify(combinationLst)}`);
|
|
@@ -258,7 +297,9 @@ async function trySynthesize() {
|
|
|
let ctrlMillSec = 1000 / nRuns;
|
|
let ctrlMillSec = 1000 / nRuns;
|
|
|
let isConcurrentExcute = isConcurrentMode();
|
|
let isConcurrentExcute = isConcurrentMode();
|
|
|
if (nExcuteCount == 0) {
|
|
if (nExcuteCount == 0) {
|
|
|
- tipsText += `缺少可执行的材料组合,请检查活动配置`;
|
|
|
|
|
|
|
+ tipsText += `由于缺少可执行的材料组合,该活动自动禁用\n`;
|
|
|
|
|
+ tipsText += `请检查活动重新配置,或购买相应材料,重新开启活动任务`;
|
|
|
|
|
+ setActivityDisabled(activityId, true);
|
|
|
} else {
|
|
} else {
|
|
|
if (isConcurrentExcute) {
|
|
if (isConcurrentExcute) {
|
|
|
for (let n = 0; n < nRuns; n++) {
|
|
for (let n = 0; n < nRuns; n++) {
|
|
@@ -500,11 +541,12 @@ async function queryActivityList(activityType, page, status = 0) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function getCvtGoodsList(activityId, noCache) {
|
|
|
|
|
|
|
+async function doGetConvertGoodsList(activityId, noCache) {
|
|
|
let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
|
let data = magicJS.data.read(key, null);
|
|
let data = magicJS.data.read(key, null);
|
|
|
if (!data || noCache) {
|
|
if (!data || noCache) {
|
|
|
- let ret = await queryCvtGoodsList(activityId);
|
|
|
|
|
|
|
+ setConvertGoodsListReqTime(Date.now());
|
|
|
|
|
+ let ret = await queryConvertGoodsList(activityId);
|
|
|
if (ret && ret.code == 200) {
|
|
if (ret && ret.code == 200) {
|
|
|
data = ret.data;
|
|
data = ret.data;
|
|
|
magicJS.data.write(key, data);
|
|
magicJS.data.write(key, data);
|
|
@@ -515,7 +557,7 @@ async function getCvtGoodsList(activityId, noCache) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-async function queryCvtGoodsList(activityId) {
|
|
|
|
|
|
|
+async function queryConvertGoodsList(activityId) {
|
|
|
const url = `https://api.wubian.pro/vmf/app/synthesis/convertGoodsList`;
|
|
const url = `https://api.wubian.pro/vmf/app/synthesis/convertGoodsList`;
|
|
|
const reqData = {
|
|
const reqData = {
|
|
|
activityId: activityId,
|
|
activityId: activityId,
|
|
@@ -541,10 +583,11 @@ async function queryCvtGoodsList(activityId) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-async function getCompositeGoodsList(activityId, noCache) {
|
|
|
|
|
|
|
+async function doGetCompositeGoodsList(activityId, noCache) {
|
|
|
let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
|
let data = magicJS.data.read(key, null);
|
|
let data = magicJS.data.read(key, null);
|
|
|
if (!data || noCache) {
|
|
if (!data || noCache) {
|
|
|
|
|
+ setCompositeGoodsListReqTime(Date.now());
|
|
|
let ret = await queryCompositeGoodsList(activityId);
|
|
let ret = await queryCompositeGoodsList(activityId);
|
|
|
if (ret && ret.code == 200) {
|
|
if (ret && ret.code == 200) {
|
|
|
data = ret.data;
|
|
data = ret.data;
|