diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts index 1f60117..1ca3b81 100644 --- a/src/api_s2c/event/pobinglibao/ApiReceive.ts +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -29,5 +29,5 @@ export default async function (call: ApiCall) { call.succ({}) - HongDianChange.sendChangeKey(call.uid, ['pobinglibao']); + HongDianChange.sendChangeKey(call.uid, ['huodonghd']); } diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index d451153..f8a301b 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -367,17 +367,21 @@ export class HuoDongHongDianFun { /**破冰礼包红点 */ static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise { let gift = _hd?.data?.gift?.find(i => i.free == true && !i.payId) - if (!gift) return {show: false} + if (gift) return {show: true} - let payLog = await PayFun.getPayLog(call.uid, gift.payId) - payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || [] - if (!payLog || !payLog.length) return {show: false} + let payIds = _hd?.data?.gift?.filter(i=>i.payId).map(i=>i.payId) + let payLogs = await PayFun.getPayLogs(call.uid, payIds) // 取奖励列表,判断是否有可领取奖励 let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'}) - let rec = data?.record?.[call.req.id].length - if (rec && (rec >= 3 || data?.record?.[gift.id] == call.req.recId)) return {show: false} - return {show: true} + + for (let item of _hd?.data?.gift){ + let rec = data?.record?.[item.id]?.length + if (item.free== true && !item.payId) return {show: true} + if (payLogs[item.payId]?.length && (!rec || rec < PublicShared.getDiff(payLogs[item.payId][0].time))) return {show: true} + } + + return {show:false} } /**元旦活动红点 */ diff --git a/src/fix_patch/patch_20231230.ts b/src/fix_patch/patch_20231230.ts new file mode 100644 index 0000000..18a99eb --- /dev/null +++ b/src/fix_patch/patch_20231230.ts @@ -0,0 +1,149 @@ +import { patchFun, patchInit } from "../patch"; +import { TanXianFun } from "../public/tanxian"; +import { PublicShared } from "../shared/public/public"; + +class Path { + + async fun1(a: any) { + let hdid = 1703860546; + let today_zero_time = PublicShared.getToDayZeroTime(); + + // 查询今天登录的用户 + let today_login_users = await G.mongodb.collection("user").find( + { loginTime: { $gte: today_zero_time } }, + { projection: { uid: 1 } } + ).toArray(); + + for (let i = 0; i < today_login_users.length; i++) { + let uid = today_login_users[i].uid; + + let init: boolean = false; + let hdata:any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({ + uid: uid, type: `yuandan${hdid}` + }); + if (!hdata) { + init = true; + hdata = { + uid: uid, + gift: {}, + qiandao: {}, + gameNum: 0, + exchange: {}, + taskfinish: [], + taskval: { + "1": 1, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0 + }, + qiandaoTime: 1, + refreshTime: G.time, + type: `yuandan${hdid}`, + } + } + + + let taskval = {}; + // taskid=1, stype=123 今日登录 + taskval["1"] = 1; + + // taskid=2, stype=158 今日参与抓娃娃次数 + taskval["2"] = hdata.gameNum; + + // taskid=3, stype=127 挑战 n 次清缴真主党 + let myData = await G.mongodb.cPlayerInfo('qjzzd').findOne({ uid: uid, type: 'qjzzd' }); + if (myData?.refreFightTime > PublicShared.getToDayZeroTime()) { + taskval["3"] = myData?.useFightNum || 0; + } else { + taskval["3"] = 0; + } + + // taskid=4, stype=155 领取每日任务最终宝箱 + let task = await G.mongodb.collection('task').findOne({ uid: uid, taskid: 25 }); + if (task && task.lasttime >= today_zero_time && task.finish == 1) { + taskval["4"] = 1; + } else { + taskval["4"] = 0; + } + + // taskid=5, stype=142 势力 配置xx 捐献进行 n 次捐献 + let jxdata = await G.mongodb.collection('gonghuiUser').findOne({ uid: uid }); + if (jxdata && jxdata.jx?.refreshTime > today_zero_time) { + if (jxdata.jx?.record) { + taskval["5"] = jxdata.jx?.record[2] || 0 + } + taskval["5"] = 0 + } else { + taskval["5"] = 0; + } + + // taskid=6, stype=156 每日钻石消耗 + taskval["6"] = 0; + let uselogs = (await G.mongodb.collection('rmbuse').find( + { uid: uid, cTime: { $gte: today_zero_time }, isAdd: false }, + { projection: { change: 1 } } + ).toArray()).forEach(e => { taskval["6"] += e.change; }); + + // taskid=7, stype=122 进行 n 次快速探险 + taskval["7"] = 0; + const data = await G.mongodb.collection('tanxian').findOne({ uid: uid }); + if (data?.resetTime > PublicShared.getToDayZeroTime()) { + taskval["7"] = data.useFastGuaJiNum || 0 + } + + // taskid=8, stype=157 获得vip经验 + let orde_logs = await G.mongodb.collection('payOrderLog' as any).find( + { uid: uid, cTime: { $gte: today_zero_time * 1000 } }, + ).toArray(); + + taskval["8"] = 0; + orde_logs.forEach(e => { + let pay = G.gc.pay[e.payId]; + if (pay) taskval["8"] += pay.payExp[0].n; + }) + + // taskid=9, stype=157 获得vip经验 + taskval["9"] = 0; + orde_logs.forEach(e => { + let pay = G.gc.pay[e.payId]; + if (pay) taskval["9"] += pay.payExp[0].n; + }) + if (!init) { + await G.mongodb.cEvent(`yuandan${hdid}`).updateOne( + { uid: uid, type: `yuandan${hdid}` }, + { $set: { taskval: taskval } } + ) + } else { + hdata.taskval = taskval; + await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true }) + } + console.log('玩家执行完成',uid) + } + + + return "sucess!!!" + } + + + + async run() { + await this.fun1(1); + } +} + +async function main() { + await patchInit() + let patch = new Path(); + await patch.run(); + console.log("逻辑执行完成,等待退出"); + setTimeout(function () { + console.log('结束程序'); + process.exit(); + }, 3000); +} +main();