fix:
修复定时器重复执行导致邮件重复发送问题
This commit is contained in:
parent
dd60fe3bab
commit
c20bf92491
121
src/path_20231221.ts
Normal file
121
src/path_20231221.ts
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import {ctor} from "./global";
|
||||||
|
import {initMongoDB} from "./setMongodb";
|
||||||
|
import {yangchengmubiao} from "./shared/protocols/event/yangchengmubiao/PtlOpen";
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
await initMongoDB()
|
||||||
|
|
||||||
|
const hdid = [100, 101];
|
||||||
|
const task = {
|
||||||
|
'2001': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 50,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2002': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 100,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2003': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '626', 'n': 20}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 200,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2004': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 250,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2005': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 300,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2006': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 400,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
},
|
||||||
|
'2007': {
|
||||||
|
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
|
||||||
|
'tujing': '',
|
||||||
|
'title': 'intr_yczm_day_des_2',
|
||||||
|
'type': 2,
|
||||||
|
'pval': 500,
|
||||||
|
'cond': [],
|
||||||
|
'stype': 118
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 中间插入了2004 所以之前的任务id一次往后顺延
|
||||||
|
const change = {2004: 2005, 2005: 2006, 2006: 2007};
|
||||||
|
// 刷新活动配置
|
||||||
|
await G.mongodb.collection("hdinfo").updateMany({hdid: {$in: hdid}}, {
|
||||||
|
"$set": {'data.tasklist.2': task}
|
||||||
|
})
|
||||||
|
|
||||||
|
let datas: yangchengmubiao[] = [];
|
||||||
|
// 刷新玩家领取记录
|
||||||
|
datas = datas.concat(await G.mongodb.cEvent(`yangchengmubiao${hdid[0]}`).find(
|
||||||
|
{type: `yangchengmubiao${hdid[0]}`}
|
||||||
|
).toArray());
|
||||||
|
|
||||||
|
datas = datas.concat(await G.mongodb.cEvent(`yangchengmubiao${hdid[1]}`).find(
|
||||||
|
{type: `yangchengmubiao${hdid[1]}`}
|
||||||
|
).toArray());
|
||||||
|
|
||||||
|
for (let i = 0; i < datas.length; i++) {
|
||||||
|
let data = datas[i];
|
||||||
|
let finished = data.finishid["2"].map((task) => {
|
||||||
|
return change[task] ? change[task] : task
|
||||||
|
});
|
||||||
|
let maxtaskval = Math.max(...Object.values(data.taskval));
|
||||||
|
|
||||||
|
let taskval = {};
|
||||||
|
for (let taskid in task) {
|
||||||
|
taskval[taskid] = maxtaskval;
|
||||||
|
}
|
||||||
|
|
||||||
|
await G.mongodb.collection("event").updateOne(
|
||||||
|
{uid: data.uid, type: data.type}, {$set: {taskval: taskval, "finishid.2": finished}}
|
||||||
|
)
|
||||||
|
console.log(`修复玩家${data.uid}人才计划数据完成...`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctor();
|
||||||
|
start().then(() => {
|
||||||
|
let s = 0;
|
||||||
|
setInterval(() => {
|
||||||
|
s += 1;
|
||||||
|
console.log(new Date().format("MM-dd hh:mm:ss"));
|
||||||
|
if (s >= 3) process.exit(1);
|
||||||
|
}, 1000)
|
||||||
|
console.log("逻辑执行完成...等待退出!!!");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ export class CrossEmailPull extends Scheduler {
|
|||||||
G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => {
|
G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => {
|
||||||
if (!res.isSucc) return;
|
if (!res.isSucc) return;
|
||||||
res.res.emails.forEach(async (email) => {
|
res.res.emails.forEach(async (email) => {
|
||||||
let _prize = email?.prizeData?.prize || [];
|
let _prize = R.clone(email?.prizeData?.prize) || [];
|
||||||
if (email?.prizeData) delete email.prizeData;
|
if (email?.prizeData) delete email.prizeData;
|
||||||
|
|
||||||
email["prize"] = _prize;
|
email["prize"] = _prize;
|
||||||
|
Loading…
Reference in New Issue
Block a user