|
@@ -299,8 +299,9 @@ function isSynthesisUseCacheEnabled() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function checkIsSynthesizeTaskSkip(index) {
|
|
function checkIsSynthesizeTaskSkip(index) {
|
|
|
- let result = gSynthesizeResultDict[index];
|
|
|
|
|
- if (result) {
|
|
|
|
|
|
|
+ let data = gSynthesizeResultDict[index];
|
|
|
|
|
+ if (data && data.result) {
|
|
|
|
|
+ let result = data.result;
|
|
|
if (result.code == 200) {
|
|
if (result.code == 200) {
|
|
|
magicJS.logger.info(`序号[${index + 1}]任务已经执行成功过,无需再次执行[0]`);
|
|
magicJS.logger.info(`序号[${index + 1}]任务已经执行成功过,无需再次执行[0]`);
|
|
|
return true;
|
|
return true;
|
|
@@ -314,6 +315,45 @@ function checkIsSynthesizeTaskSkip(index) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function checkUpdateActivityDataCache(activityId) {
|
|
|
|
|
+ let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
|
|
|
|
|
+ let activityData = magicJS.data.read(key, null);
|
|
|
|
|
+ if (activityData) {
|
|
|
|
|
+ let goodsListData = activityData.goodsList;
|
|
|
|
|
+ let needUpdate = true;
|
|
|
|
|
+ for (let index in gSynthesizeResultDict) {
|
|
|
|
|
+ let detail = gSynthesizeResultDict[index];
|
|
|
|
|
+ let result = detail.result;
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ if (result.code == 200 || (result.code == 500 && (result.msg.indexOf('单品状态发生变化') != -1))) {
|
|
|
|
|
+ let costGoodsList = detail.goodsList;
|
|
|
|
|
+ let costGoodsDict = {};
|
|
|
|
|
+ for (let goodsId of costGoodsList) {
|
|
|
|
|
+ costGoodsDict[goodsId] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (let i = 0; i < goodsListData.length; i++) {
|
|
|
|
|
+ checkRemoveVerList(goodsListData[i].verList, costGoodsDict);
|
|
|
|
|
+ }
|
|
|
|
|
+ needUpdate = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (needUpdate) {
|
|
|
|
|
+ magicJS.data.write(key, activityData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function checkRemoveVerList(srcVerList, removeData) {
|
|
|
|
|
+ for (let i = srcVerList.length - 1; i >= 0; i--) {
|
|
|
|
|
+ const verInfo = srcVerList[i];
|
|
|
|
|
+ if (removeData[verInfo.goodsId]) {
|
|
|
|
|
+ srcVerList.splice(i, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return srcVerList;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function trySynthesize() {
|
|
async function trySynthesize() {
|
|
|
magicJS.logger.info(`[0]活动任务开始执行...`);
|
|
magicJS.logger.info(`[0]活动任务开始执行...`);
|
|
|
let activityData = await getWillActivityData();
|
|
let activityData = await getWillActivityData();
|
|
@@ -345,6 +385,7 @@ async function trySynthesize() {
|
|
|
magicJS.logger.info(`[3]活动任务开始执行...`);
|
|
magicJS.logger.info(`[3]活动任务开始执行...`);
|
|
|
// magicJS.logger.info(`retCvtData=${JSON.stringify(retCvtData)}`);
|
|
// magicJS.logger.info(`retCvtData=${JSON.stringify(retCvtData)}`);
|
|
|
if (!retCvtData) {
|
|
if (!retCvtData) {
|
|
|
|
|
+ magicJS.notification.appendNotifyInfo(`活动[${activityData.name}]详细合成信息数据不存在`);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (checkActivityDisable(activityId)) {
|
|
if (checkActivityDisable(activityId)) {
|
|
@@ -418,6 +459,9 @@ async function trySynthesize() {
|
|
|
setActivityDisabled(activityId, true);
|
|
setActivityDisabled(activityId, true);
|
|
|
} else {
|
|
} else {
|
|
|
setSynthesisAmount(willCount - nSuccCount);
|
|
setSynthesisAmount(willCount - nSuccCount);
|
|
|
|
|
+ if (isSynthesisUseCacheEnabled()) {
|
|
|
|
|
+ checkUpdateActivityDataCache(activityId);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
nowTime = Date.now() / 1000;
|
|
nowTime = Date.now() / 1000;
|
|
@@ -744,7 +788,7 @@ async function doCreateConvertOrder(index, activityId, goodsList) {
|
|
|
let rspData = response.body;
|
|
let rspData = response.body;
|
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
gSynthesizeResultList.push(rspData);
|
|
gSynthesizeResultList.push(rspData);
|
|
|
- gSynthesizeResultDict[index] = rspData;
|
|
|
|
|
|
|
+ gSynthesizeResultDict[index] = { activityId: activityId, result: rspData, goodsList: goodsList };
|
|
|
return rspData;
|
|
return rspData;
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
magicJS.logger.error(e);
|
|
magicJS.logger.error(e);
|
|
@@ -772,7 +816,7 @@ async function doCreateCompositeOrder(index, activityId, goodsList) {
|
|
|
let rspData = response.body;
|
|
let rspData = response.body;
|
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
gSynthesizeResultList.push(rspData);
|
|
gSynthesizeResultList.push(rspData);
|
|
|
- gSynthesizeResultDict[index] = rspData;
|
|
|
|
|
|
|
+ gSynthesizeResultDict[index] = { activityId: activityId, result: rspData, goodsList: goodsList };
|
|
|
return rspData;
|
|
return rspData;
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
magicJS.logger.error(e);
|
|
magicJS.logger.error(e);
|