diff --git a/src/fix_patch/patch_hdinfo.ts b/src/fix_patch/patch_hdinfo_20231228.ts similarity index 85% rename from src/fix_patch/patch_hdinfo.ts rename to src/fix_patch/patch_hdinfo_20231228.ts index fad15cc..bc009f6 100644 --- a/src/fix_patch/patch_hdinfo.ts +++ b/src/fix_patch/patch_hdinfo_20231228.ts @@ -17,7 +17,7 @@ class Path { console.log('这是第1个脚本执行完成') - return 12 + return _hd } @patchFun @@ -36,26 +36,28 @@ class Path { console.log('这是第2个脚本执行完成') - return 12 + return _hd } @patchFun async fun3(a: any) { //这里执行脚本的内容,加了patchFun的函数,不允许重复执行 console.log("这是第3个脚本里内容"); + let _hd = G.gc.huodong.filter(i => i.htype == 5) - let _hd = G.gc.huodong.find(i => i.htype == 5) - - if (!_hd) { + if (!_hd.length) { console.log('htype5没查到活动') return } - await G.mongodb.collection('hdinfo').updateMany({htype: 5}, {$set: {data: _hd.data}}) + _hd.map(i => { + // @ts-ignore + G.mongodb.collection('hdinfo').updateOne({hdid: i.hdid}, {$set: {...i}}, {upsert: true}) + }) console.log('这是第3个脚本执行完成') - return 12 + return _hd }