diff --git a/src/path_20231221.ts b/src/path_20231221.ts new file mode 100644 index 0000000..11098b7 --- /dev/null +++ b/src/path_20231221.ts @@ -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("逻辑执行完成...等待退出!!!"); +}); + + diff --git a/src/public/scheduler/scheduler_cross_email_pull.ts b/src/public/scheduler/scheduler_cross_email_pull.ts index e955d0c..ceee41e 100644 --- a/src/public/scheduler/scheduler_cross_email_pull.ts +++ b/src/public/scheduler/scheduler_cross_email_pull.ts @@ -22,7 +22,7 @@ export class CrossEmailPull extends Scheduler { G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => { if (!res.isSucc) return; res.res.emails.forEach(async (email) => { - let _prize = email?.prizeData?.prize || []; + let _prize = R.clone(email?.prizeData?.prize) || []; if (email?.prizeData) delete email.prizeData; email["prize"] = _prize;