|
|
@@ -45,6 +45,7 @@ const gCommonHeaders = {
|
|
|
let gRetBody;
|
|
|
|
|
|
let gSynthesizeResultList = [];
|
|
|
+let gSynthesizeResultDict = {};
|
|
|
|
|
|
async function Main() {
|
|
|
if (magicJS.isStrictRequest) {
|
|
|
@@ -297,6 +298,22 @@ function isSynthesisUseCacheEnabled() {
|
|
|
return magicJS.data.read(WuBianConstKey.SynthesisUseCacheEnabled, false);
|
|
|
}
|
|
|
|
|
|
+function checkIsSynthesizeTaskSkip(index) {
|
|
|
+ let result = gSynthesizeResultDict[index];
|
|
|
+ if (result) {
|
|
|
+ if (result.code == 200) {
|
|
|
+ magicJS.logger.info(`序号[${index + 1}]任务已经执行成功过,无需再次执行[0]`);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (result.code == 500 && (result.msg.indexOf('单品状态发生变化') != -1)) {
|
|
|
+ magicJS.logger.info(`序号[${index + 1}]任务已经执行成功过,无需再次执行[1]`);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ magicJS.logger.info(`序号[${index + 1}]任务上次执行发送异常,错误信息:${result.msg}`);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
async function trySynthesize() {
|
|
|
magicJS.logger.info(`[0]活动任务开始执行...`);
|
|
|
let activityData = await getWillActivityData();
|
|
|
@@ -314,6 +331,7 @@ async function trySynthesize() {
|
|
|
let activityId = activityData.hashId || activityData.activityId;
|
|
|
let retCvtData = null;
|
|
|
if (isSynthesisUseCacheEnabled()) {
|
|
|
+ magicJS.logger.info(`当前使用的活动数据来自缓存,如不需在设置中关闭使用缓存功能`);
|
|
|
let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
|
retCvtData = magicJS.data.read(key, null);
|
|
|
}
|
|
|
@@ -362,10 +380,14 @@ async function trySynthesize() {
|
|
|
let oneCombination = combinationLst[i];
|
|
|
let goodsList = getCombinationGoodsList(oneCombination);
|
|
|
magicJS.logger.info(`第${n}-${i}趟开始执行...`);
|
|
|
+ if (checkIsSynthesizeTaskSkip(i)) {
|
|
|
+ magicJS.logger.info(`第${n}-${i}趟跳过执行...`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (activityData.type == 0) {
|
|
|
- doCreateCompositeOrder(activityId, goodsList);
|
|
|
+ doCreateCompositeOrder(i, activityId, goodsList);
|
|
|
} else if (activityData.type == 1) {
|
|
|
- doCreateConvertOrder(activityId, goodsList);
|
|
|
+ doCreateConvertOrder(i, activityId, goodsList);
|
|
|
}
|
|
|
}
|
|
|
let costTime = Date.now() - startTime;
|
|
|
@@ -413,14 +435,14 @@ async function trySynthesize() {
|
|
|
let goodsList = getCombinationGoodsList(oneCombination);
|
|
|
let retData = null;
|
|
|
if (activityData.type == 0) {
|
|
|
- retData = await doCreateCompositeOrder(activityId, goodsList);
|
|
|
+ retData = await doCreateCompositeOrder(i, activityId, goodsList);
|
|
|
} else if (activityData.type == 1) {
|
|
|
- retData = await doCreateConvertOrder(activityId, goodsList);
|
|
|
+ retData = await doCreateConvertOrder(i, activityId, goodsList);
|
|
|
}
|
|
|
let errMsg = '';
|
|
|
if (retData && retData.code == 200) {
|
|
|
nSuccCount += 1;
|
|
|
- errMsg = `序号[${+1}]使用材料[${getCombinationGoodsLstText(oneCombination)}]兑换成功`;
|
|
|
+ errMsg = `序号[${i + 1}]使用材料[${getCombinationGoodsLstText(oneCombination)}]兑换成功`;
|
|
|
} else {
|
|
|
nFailCount += 1;
|
|
|
errMsg = `序号[${i + 1}]使用材料[${getCombinationGoodsLstText(oneCombination)}]${retData?.msg || '兑换失败'}`;
|
|
|
@@ -706,7 +728,7 @@ async function queryCompositeGoodsList(activityId) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-async function doCreateConvertOrder(activityId, goodsList) {
|
|
|
+async function doCreateConvertOrder(index, activityId, goodsList) {
|
|
|
const url = `https://api.wubian.pro/vmf/app/synthesis/createConvertOrder`;
|
|
|
const reqData = {
|
|
|
activityId: activityId,
|
|
|
@@ -722,6 +744,7 @@ async function doCreateConvertOrder(activityId, goodsList) {
|
|
|
let rspData = response.body;
|
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
gSynthesizeResultList.push(rspData);
|
|
|
+ gSynthesizeResultDict[index] = rspData;
|
|
|
return rspData;
|
|
|
} catch (e) {
|
|
|
magicJS.logger.error(e);
|
|
|
@@ -733,7 +756,7 @@ async function doCreateConvertOrder(activityId, goodsList) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-async function doCreateCompositeOrder(activityId, goodsList) {
|
|
|
+async function doCreateCompositeOrder(index, activityId, goodsList) {
|
|
|
const url = `https://api.wubian.pro/vmf/app/synthesis/createCompositeOrder`;
|
|
|
const reqData = {
|
|
|
activityId: activityId,
|
|
|
@@ -749,6 +772,7 @@ async function doCreateCompositeOrder(activityId, goodsList) {
|
|
|
let rspData = response.body;
|
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
gSynthesizeResultList.push(rspData);
|
|
|
+ gSynthesizeResultDict[index] = rspData;
|
|
|
return rspData;
|
|
|
} catch (e) {
|
|
|
magicJS.logger.error(e);
|