🐞 fix(团购): 修复团购定时器多出记录的问题
This commit is contained in:
@@ -814,7 +814,10 @@ async function initGroupShopSchedule() {
|
||||
});
|
||||
}
|
||||
|
||||
let initSumJobs = [];
|
||||
export async function initSumSchedule() {
|
||||
|
||||
|
||||
let activities = await ActivityModel.findActivityByType(ACTIVITY_TYPE.GROUP_SHOP);
|
||||
let scheduleMap = new Map<number, { activityId: number, itemId: number, sum: number }[]>(); // 时间 => data
|
||||
for(let activity of activities) {
|
||||
@@ -828,13 +831,19 @@ export async function initSumSchedule() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('#### initSumJobs', initSumJobs.length);
|
||||
console.log('#### scheduleMap', scheduleMap);
|
||||
for(let job of initSumJobs) {
|
||||
job.cancel();
|
||||
}
|
||||
for(let [time, arr] of scheduleMap) {
|
||||
if(scheduledJobs[`groupShopSetSum${time}`]) {
|
||||
scheduledJobs[`groupShopSetSum${time}`].cancel();
|
||||
}
|
||||
scheduleJob(`groupShopSetSum${time}`, time, async () => {
|
||||
let job = scheduleJob(`groupShopSetSum${time}`, time, async () => {
|
||||
await setGroupShopToSetSum(arr);
|
||||
});
|
||||
initSumJobs.push(job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user