From 0932d3ee4741688c0c209afd2253c7b462b17bed Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Wed, 10 Jan 2024 15:46:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?patch:=E7=BB=88=E8=BA=AB=E5=8D=A1=E5=91=A8?= =?UTF-8?q?=E5=A5=96=E5=8A=B1=E8=A1=A5=E5=8F=91=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20240110.ts | 82 +++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/src/fix_patch/patch_20240110.ts b/src/fix_patch/patch_20240110.ts index 1597954..8f48a19 100644 --- a/src/fix_patch/patch_20240110.ts +++ b/src/fix_patch/patch_20240110.ts @@ -1,8 +1,44 @@ +import { ReqEmail } from "../monopoly/protocols/PtlEmail"; import { patchInit } from "../patch"; +import { MsgEmail } from "../shared/protocols/msg_s2c/MsgEmail"; +import { PublicShared } from "../shared/public/public"; class Path { + async addEmail(email: ReqEmail & { createTime?: number; }) { + let { prize, uid, ...e } = email; + let lng = await G.redis.rawGet(`user:lng:${uid}`) + + let sendEmail: MsgEmail = { + _id: null, + uid: uid, + type: e.type, + title: e.lngTitle ? (e.lngTitle[lng] || e.lngTitle['ja']) : e.title, + content: e.lngContent ? (e.lngContent[lng] || e.lngContent['ja']) : e.content, + createTime: e.createTime || G.time, + contentInsertArr: e.contentInsertArr || [] + }; + + if (prize?.length > 0) { + sendEmail.prizeData = { + prize: email.prize, + isGet: false + }; + } + + if (email.g123log && Object.keys(email.g123log).length > 0) sendEmail.g123log = email.g123log; + + if (email.lngTitle) { + sendEmail.lngTitle = email.lngTitle + sendEmail.lngContent = email.lngContent + } + + await G.mongodb.collection('email').insertOne({ + ttl: new Date(), ...G.mongodb.conversionIdObj(sendEmail) + }); + } + async fun1(a: any) { let taskType = 2; let users = await G.mongodb.collection('user').find({ loginTime: { $gte: 1704643200 } }).toArray(); @@ -13,18 +49,56 @@ class Path { }, { projection: { taskid: 1 } }).toArray()).map(i => i.taskid); if (unFinishTask.length >= 2) { - unFinishTask.sort().slice(1); + let deltask = unFinishTask.sort().slice(1); await G.mongodb.collection("task").deleteOne({ - uid: user.uid, taskid: { $in: unFinishTask } + uid: user.uid, taskid: { $in: deltask } }); - console.log(`删除玩家${user.uid}任务:${unFinishTask}`); + console.log(`删除玩家${user.uid}任务:${deltask}`); + } + } + } + /** + * 补发玩家终身卡奖励 + */ + async fun2(a: any) { + let logs = await G.mongodb.collection("payLogNew").find( + { key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } } + ).toArray(); + + if (logs.length == 0) { + console.log("没有终身卡数据,不发放终身卡"); + } + let wzt = PublicShared.getToWeekMondayZeroTime(); + let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0]; + for (let i = 0; i < logs.length; i++) { + + // 查询玩家邮件 + let emails = await G.mongodb.collection('email').find({ + uid: logs[i].uid, title: con.title, createTime: { $gte: wzt } + }).toArray(); + + + if (emails.length == 0) { + // 发送邮件 + this.addEmail({ + uid: logs[i].uid, + type: "system", + title: con.title, + content: con.content, + contentInsertArr: [], + createTime: G.time, + prize: con.prize, + }) + console.log("发放终身卡", logs[i].uid); + } else { + console.log("本周已发送过 不发放终身卡", logs[i].uid); } } } - async run() { await this.fun1(1); + await this.fun2(1); } } From ca3e973afd18a2cf44bb76e35bdc320d341bcdc2 Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Wed, 10 Jan 2024 15:50:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?patch:=E7=BB=88=E8=BA=AB=E5=8D=A1=E5=91=A8?= =?UTF-8?q?=E5=A5=96=E5=8A=B1=E8=A1=A5=E5=8F=91=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20240110.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fix_patch/patch_20240110.ts b/src/fix_patch/patch_20240110.ts index 8f48a19..9bfeeec 100644 --- a/src/fix_patch/patch_20240110.ts +++ b/src/fix_patch/patch_20240110.ts @@ -67,7 +67,9 @@ class Path { if (logs.length == 0) { console.log("没有终身卡数据,不发放终身卡"); + return } + let wzt = PublicShared.getToWeekMondayZeroTime(); let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0]; for (let i = 0; i < logs.length; i++) {