From 075c60a9f83f29767f70fbde43af5064fbcda0e4 Mon Sep 17 00:00:00 2001 From: xcy Date: Thu, 28 Dec 2023 14:42:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E7=BB=88=E8=BA=AB=E5=8D=A1=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=99=A8log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_newDay.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/scheduler/scheduler_newDay.ts b/src/public/scheduler/scheduler_newDay.ts index fa4d813..b213215 100644 --- a/src/public/scheduler/scheduler_newDay.ts +++ b/src/public/scheduler/scheduler_newDay.ts @@ -58,14 +58,21 @@ export class SchedulerNewDayLocalCtor extends Scheduler { (async () => { // 每周一,发放终身卡 - if (PublicShared.getWeek(G.time) != 1) return; + if (PublicShared.getWeek(G.time) != 1) { + console.log("不是周一,不发放终身卡", PublicShared.getWeek(G.time)); + return + }; let logs = await G.mongodb.collection("payLogNew").find( { key: "zhongshengka", del_time: { $exists: false } }, { projection: { _id: 0, } } ).toArray(); + if (logs.length == 0) { + console.log("没有终身卡数据,不发放终身卡"); + } let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0]; for (let i = 0; i < logs.length; i++) { + console.log("发放终身卡", logs[i].uid); // 发送邮件 EmailFun.addEmail({ uid: logs[i].uid, From 96729c719a76dfeee74f41dad2a84ed7bab0caf9 Mon Sep 17 00:00:00 2001 From: xcy Date: Thu, 28 Dec 2023 14:48:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E7=BB=88=E8=BA=AB=E5=8D=A1=E5=8F=91?= =?UTF-8?q?=E6=94=BE=E5=A5=96=E5=8A=B1bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_newDay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/scheduler/scheduler_newDay.ts b/src/public/scheduler/scheduler_newDay.ts index b213215..585a265 100644 --- a/src/public/scheduler/scheduler_newDay.ts +++ b/src/public/scheduler/scheduler_newDay.ts @@ -64,7 +64,7 @@ export class SchedulerNewDayLocalCtor extends Scheduler { }; let logs = await G.mongodb.collection("payLogNew").find( - { key: "zhongshengka", del_time: { $exists: false } }, { projection: { _id: 0, } } + { key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } } ).toArray(); if (logs.length == 0) { From bf4f22d092803345fd902c325f1993f510214f26 Mon Sep 17 00:00:00 2001 From: xcy Date: Thu, 28 Dec 2023 15:18:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=88=E8=BA=AB?= =?UTF-8?q?=E5=8D=A1=E9=82=AE=E4=BB=B6=E6=B2=A1=E6=9C=89type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_newDay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/scheduler/scheduler_newDay.ts b/src/public/scheduler/scheduler_newDay.ts index 585a265..4ca793b 100644 --- a/src/public/scheduler/scheduler_newDay.ts +++ b/src/public/scheduler/scheduler_newDay.ts @@ -76,7 +76,7 @@ export class SchedulerNewDayLocalCtor extends Scheduler { // 发送邮件 EmailFun.addEmail({ uid: logs[i].uid, - type: con.type, + type: "system", title: con.title, content: con.content, contentInsertArr: [], From 37f2472f5d1ad4d287c6c25d1a3694a04bee4ac3 Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 28 Dec 2023 16:10:56 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=88=B7=E6=96=B0=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=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_hdinfo.ts | 79 +++++++++++++++++++++++++++++++++++ src/patch.ts | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/fix_patch/patch_hdinfo.ts diff --git a/src/fix_patch/patch_hdinfo.ts b/src/fix_patch/patch_hdinfo.ts new file mode 100644 index 0000000..fad15cc --- /dev/null +++ b/src/fix_patch/patch_hdinfo.ts @@ -0,0 +1,79 @@ +import {patchFun, patchInit} from "../patch"; + +class Path { + @patchFun + async fun1(a: any) { + //这里执行脚本的内容,加了patchFun的函数,不允许重复执行 + console.log("这是第1个脚本里内容"); + + let _hd = G.gc.huodong.find(i => i.hdid == 4000) + + if (!_hd) { + console.log('htype4没查到活动') + return + } + + await G.mongodb.collection('hdinfo').findOneAndUpdate({hdid: 4000}, {$set: {data: _hd.data}}) + + console.log('这是第1个脚本执行完成') + + return 12 + } + + @patchFun + async fun2(a: any) { + //这里执行脚本的内容,加了patchFun的函数,不允许重复执行 + console.log("这是第2个脚本里内容"); + + let _hd = G.gc.huodong.find(i => i.htype == 2) + + if (!_hd) { + console.log('htype2没查到活动') + return + } + + await G.mongodb.collection('hdinfo').updateMany({htype: 2}, {$set: {data: _hd.data}}) + + console.log('这是第2个脚本执行完成') + + return 12 + } + + @patchFun + async fun3(a: any) { + //这里执行脚本的内容,加了patchFun的函数,不允许重复执行 + console.log("这是第3个脚本里内容"); + + let _hd = G.gc.huodong.find(i => i.htype == 5) + + if (!_hd) { + console.log('htype5没查到活动') + return + } + + await G.mongodb.collection('hdinfo').updateMany({htype: 5}, {$set: {data: _hd.data}}) + + console.log('这是第3个脚本执行完成') + + return 12 + } + + + async run() { + await this.fun1(1); + await this.fun2(2); + await this.fun3(3); + } +} + +async function main() { + await patchInit() + let patch = new Path(); + await patch.run(); + setInterval(() => { + console.log(new Date().format("MM-dd hh:mm:ss")); + }, 1000); + console.log("逻辑执行完成,等待退出"); +} + +main(); diff --git a/src/patch.ts b/src/patch.ts index c5b3d7a..f572823 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -15,7 +15,7 @@ export function patchFun(target: any, key: string, descriptor: PropertyDescripto throw new Error(); } catch (e) { let caller = (e.stack.split("\n").slice(2)[0].split("\\").slice(-2)); - scriptName = caller[1].split(':')[0]; + scriptName = caller[0].split('(')[1].split(':')[0]; } if(!scriptName){