From 45cec859605e11793437b0bea8f3875e7aeefa0f Mon Sep 17 00:00:00 2001 From: xcy Date: Sat, 30 Dec 2023 15:10:35 +0800 Subject: [PATCH 01/11] =?UTF-8?q?patch:=20=E4=BF=AE=E5=A4=8D=E5=85=83?= =?UTF-8?q?=E6=97=A6=E6=B4=BB=E5=8A=A8=E4=BB=BB=E5=8A=A1=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_20231230.ts | 148 ++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/fix_patch/patch_20231230.ts diff --git a/src/fix_patch/patch_20231230.ts b/src/fix_patch/patch_20231230.ts new file mode 100644 index 0000000..533ac56 --- /dev/null +++ b/src/fix_patch/patch_20231230.ts @@ -0,0 +1,148 @@ +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 { _id, ...hdata } = 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 }) + } + } + + + 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(); From 6fae6cd61e4b9b0cf101e902d12dbbb7d9b8b939 Mon Sep 17 00:00:00 2001 From: dy Date: Sat, 30 Dec 2023 16:07:54 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E7=A0=B4=E5=86=B0=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/pobinglibao/ApiReceive.ts | 2 +- src/api_s2c/hongdian/fun.ts | 18 +++++++++++------- src/fix_patch/patch_20231230.ts | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) 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 index 533ac56..18a99eb 100644 --- a/src/fix_patch/patch_20231230.ts +++ b/src/fix_patch/patch_20231230.ts @@ -18,7 +18,7 @@ class Path { let uid = today_login_users[i].uid; let init: boolean = false; - let { _id, ...hdata } = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({ + let hdata:any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({ uid: uid, type: `yuandan${hdid}` }); if (!hdata) { @@ -122,6 +122,7 @@ class Path { hdata.taskval = taskval; await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true }) } + console.log('玩家执行完成',uid) } From d034105a627a252f4a4152eea715fe098cb258bf Mon Sep 17 00:00:00 2001 From: xcy Date: Sat, 30 Dec 2023 17:02:25 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=92?= =?UTF-8?q?=E5=90=8D=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20231230.ts | 18 ++++++++++++------ src/public/rank/rank.ts | 8 ++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/fix_patch/patch_20231230.ts b/src/fix_patch/patch_20231230.ts index 533ac56..d788e24 100644 --- a/src/fix_patch/patch_20231230.ts +++ b/src/fix_patch/patch_20231230.ts @@ -1,3 +1,4 @@ +import { log } from "console"; import { patchFun, patchInit } from "../patch"; import { TanXianFun } from "../public/tanxian"; import { PublicShared } from "../shared/public/public"; @@ -5,7 +6,8 @@ import { PublicShared } from "../shared/public/public"; class Path { async fun1(a: any) { - let hdid = 1703860546; + let hdid = 1703860546; // 正式服活动id + // let hdid = 1703917224; // 测试服活动id let today_zero_time = PublicShared.getToDayZeroTime(); // 查询今天登录的用户 @@ -18,7 +20,7 @@ class Path { let uid = today_login_users[i].uid; let init: boolean = false; - let { _id, ...hdata } = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({ + let hdata: any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({ uid: uid, type: `yuandan${hdid}` }); if (!hdata) { @@ -75,9 +77,10 @@ class Path { 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"] = jxdata.jx.record["2"] || 0 + }else{ + taskval["5"] = 0 } - taskval["5"] = 0 } else { taskval["5"] = 0; } @@ -87,7 +90,7 @@ class Path { 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; }); + ).toArray()).forEach(e => { taskval["6"] += -e.change; }); // taskid=7, stype=122 进行 n 次快速探险 taskval["7"] = 0; @@ -98,7 +101,7 @@ class Path { // taskid=8, stype=157 获得vip经验 let orde_logs = await G.mongodb.collection('payOrderLog' as any).find( - { uid: uid, cTime: { $gte: today_zero_time * 1000 } }, + { uid: uid, ctime: { $gte: today_zero_time * 1000 } }, ).toArray(); taskval["8"] = 0; @@ -113,6 +116,7 @@ class Path { 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}` }, @@ -122,6 +126,8 @@ class Path { hdata.taskval = taskval; await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true }) } + + console.log("玩家执行完成:", uid, taskval); } diff --git a/src/public/rank/rank.ts b/src/public/rank/rank.ts index 634f4a5..cf0c80a 100644 --- a/src/public/rank/rank.ts +++ b/src/public/rank/rank.ts @@ -135,7 +135,11 @@ export abstract class Rank { //将db里的数据,写入到 rank:xxx:sort里 //写入的单条数据为: {uid:score} - this.db.find({ type: this.type }, { + + // 首先清理redis中sort数据 在从数据库中初始化 + await G.ioredis.del(this.getRedisKeySort); + + this.db.find({ type: this.type }, { projection: { "idKey": 1, "type": 1, @@ -263,7 +267,7 @@ export abstract class Rank { } return item; }) - if(ghid.length > 0){ + if (ghid.length > 0) { let ghinfo = await G.mongodb.collection("gonghui").find( { _id: { $in: ghid } }, { projection: { name: 1 } } ).toArray(); From 18b380f620f3d1ec44b41fbb16214e697c4acbc4 Mon Sep 17 00:00:00 2001 From: xcy Date: Sat, 30 Dec 2023 17:04:56 +0800 Subject: [PATCH 04/11] =?UTF-8?q?fix:=20=E8=84=9A=E6=9C=AC=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fix_patch/patch_20231230.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fix_patch/patch_20231230.ts b/src/fix_patch/patch_20231230.ts index d788e24..ac88d05 100644 --- a/src/fix_patch/patch_20231230.ts +++ b/src/fix_patch/patch_20231230.ts @@ -20,6 +20,7 @@ class Path { 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}` }); From a177c18efe62807c1cbc77333f58d0c1d4f12400 Mon Sep 17 00:00:00 2001 From: xcy Date: Sat, 30 Dec 2023 18:04:01 +0800 Subject: [PATCH 05/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=92?= =?UTF-8?q?=E5=90=8D=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/rank/rank.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/public/rank/rank.ts b/src/public/rank/rank.ts index cf0c80a..781532f 100644 --- a/src/public/rank/rank.ts +++ b/src/public/rank/rank.ts @@ -306,7 +306,8 @@ export abstract class Rank { }) } - return res.map(ele => ele.data).sort(this.compareSort) as any; + // 按照redis uids 排序顺序排序 + return res.sort((a,b)=>uids.indexOf(a.idKey)-uids.indexOf(b.idKey)).map(ele => ele.data); } return [] } From f3ec6df093d5faa04a340adb6491d8bf2bf98d2c Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 11:24:38 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/xiaofeijingsai/ApiOpen.ts | 29 +++++++++---------- src/api_s2c/eventlist/ApihdGetList.ts | 1 + src/global.ts | 3 +- src/public/player.ts | 4 +-- .../scheduler/scheduler_xiaofeijingsai.ts | 7 +---- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts index 0f3293d..388b550 100644 --- a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts +++ b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts @@ -21,23 +21,18 @@ export default async function (call: ApiCall) { let limit = _hd.data?.rank?.slice(-1)?.[0]?.rank?.slice(-1)?.[0] || call.req.limit || 100 - let rmbuse = await G.crossmongodb.collection('rmbuse').find({ - time: { - $gte: _hd.stime, - $lte: _hd.etime + 10 - } - }).sort({change: 1}).limit(limit).toArray() + let rmbuse = await G.crossmongodb.collection('rmbuse').find({type: `xfjs_${G.huodong.xfjsId}`}).sort({change: 1}).limit(limit).toArray() let list: any = rmbuse.map(i => ({...i, total: R.negate(i.change)})) let rankList = sortRankList(_hd.data.rank, list) - let users = await G.crossmongodb.collection('huodong_user').find({uid: {$in: rankList.map(i => i._id).filter(i => i._id != 'system')}}).toArray() + let users = await G.crossmongodb.collection('huodong_user').find({uid: {$in: rankList.map(i => i._id).filter(i => i != 'system')}}).toArray() rankList = rankList.map(i => ({...i, player: users.find(v => v.uid == i.uid) || {}})) - // 活动结束前半小时,缓存过期时间改为10秒 - let exTime = (G.time + 1800) > _hd.etime ? 10 : 60 + // 活动结束前半小时,缓存过期时间改为5秒 + let exTime = (G.time + 1800) > _hd.etime ? 5 : 10 G.crossioredis.setex(`rank:xiaofeijingsai`, exTime, JSON.stringify(rankList)); @@ -53,14 +48,13 @@ export default async function (call: ApiCall) { */ export function sortRankList(rank, list) { let rankList = [] - let ccc = 0 rank.map(i => { for (let k = i.rank[0] - 1; k < i.rank[1]; k++) { - if (list[k]?.total >= i.need[0].n) { - rankList.push({...list[k - ccc], rank: k, _id: list[k - ccc].uid}) + if (list[0]?.total >= i.need[0].n) { + rankList.push({...list[0], rank: k, _id: list[0].uid}) + list = R.tail(list) } else { rankList.push({_id: 'system', total: i.need[0].n, rank: k, player: {}}) - ccc += 1 } } }) @@ -68,11 +62,14 @@ export function sortRankList(rank, list) { } // 获取自己的信息 -async function getMyData(call, rankList) { +async function getMyData(call: ApiCall, rankList) { let myData = rankList.find(i => i._id == call.uid) if (myData) return myData - let myCut: any = await G.crossmongodb.collection('rmbuse').findOne({uid: call.uid}) + let myCut: any = await G.crossmongodb.collection('rmbuse').findOne({ + uid: call.uid, + type: `xfjs_${G.huodong.xfjsId}` + }) let myUser = await G.mongodb.collection('user').findOne({uid: call.uid}) G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {$set: myUser}, {upsert: true}) @@ -81,5 +78,5 @@ async function getMyData(call, rankList) { myCut = {_id: myUser.uid, total: 0} } - return {player: myUser, ...myCut, total: R.negate(myCut.total), rank: -1, _id: myUser.uid} + return {player: myUser, ...myCut, total: R.negate(myCut.change) || 0, rank: -1, _id: myUser.uid} } \ No newline at end of file diff --git a/src/api_s2c/eventlist/ApihdGetList.ts b/src/api_s2c/eventlist/ApihdGetList.ts index fd35120..dd2934b 100644 --- a/src/api_s2c/eventlist/ApihdGetList.ts +++ b/src/api_s2c/eventlist/ApihdGetList.ts @@ -12,6 +12,7 @@ export default async function (call: ApiCall) { // 消费竞赛是跨服活动,活动开启时,同步当前用户信息到跨服数据库 G.huodong.xfjs = !!_hdList.find(i => i.htype == 11); if (G.huodong.xfjs) { + G.huodong.xfjsId = _hdList.find(i => i.htype == 11).hdid let myUser = await G.mongodb.collection('user').findOne({uid: call.uid}) G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {$set: myUser}, {upsert: true}) } diff --git a/src/global.ts b/src/global.ts index 95c369e..12d428c 100644 --- a/src/global.ts +++ b/src/global.ts @@ -106,7 +106,8 @@ class _G { /**跨服活动——消费竞赛的开启状态 */ huodong = { - xfjs: false + xfjs: false, + xfjsId: '' }; private event = new EventEmitter(); diff --git a/src/public/player.ts b/src/public/player.ts index 00c1ac6..4b48e40 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -225,8 +225,8 @@ export class PlayerFun { } G.mongodb.collection('rmbuse').insertOne(data); // 消费竞赛开启时写入跨服数据库 - if (G.huodong.xfjs && !data.isAdd) { - G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid}, { + if (G.huodong.xfjs && !data.isAdd && typeof data.change == 'number') { + G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, { $set: {time: G.time}, $inc: {change: data.change} }, {upsert: true}); diff --git a/src/public/scheduler/scheduler_xiaofeijingsai.ts b/src/public/scheduler/scheduler_xiaofeijingsai.ts index 4d4af5a..856165d 100644 --- a/src/public/scheduler/scheduler_xiaofeijingsai.ts +++ b/src/public/scheduler/scheduler_xiaofeijingsai.ts @@ -39,12 +39,7 @@ export class Scheduler_xfjs_Local_Ctor extends Scheduler { let limit = _hd.data?.rank?.slice(-1)?.[0]?.rank?.slice(-1)?.[0] || 100 - let rmbuse = await G.crossmongodb.collection('rmbuse').find({ - time: { - $gte: _hd.stime, - $lte: _hd.etime + 10 - } - }).sort({change: 1}).limit(limit).toArray() + let rmbuse = await G.crossmongodb.collection('rmbuse').find({type: `xfjs_${G.huodong.xfjsId}`}).sort({change: 1}).limit(limit).toArray() let list: any = rmbuse.map(i => ({...i, total: R.negate(i.change)})) From 42daf348b9545d920b14d80021fec8d95be10365 Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 13:35:38 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_xiaofeijingsai.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/public/scheduler/scheduler_xiaofeijingsai.ts b/src/public/scheduler/scheduler_xiaofeijingsai.ts index 856165d..8c42306 100644 --- a/src/public/scheduler/scheduler_xiaofeijingsai.ts +++ b/src/public/scheduler/scheduler_xiaofeijingsai.ts @@ -39,17 +39,20 @@ export class Scheduler_xfjs_Local_Ctor extends Scheduler { let limit = _hd.data?.rank?.slice(-1)?.[0]?.rank?.slice(-1)?.[0] || 100 - let rmbuse = await G.crossmongodb.collection('rmbuse').find({type: `xfjs_${G.huodong.xfjsId}`}).sort({change: 1}).limit(limit).toArray() + let rmbuse = await G.crossmongodb.collection('rmbuse').find({type: `xfjs_${_hd.hdid}`}).sort({change: 1}).limit(limit).toArray() let list: any = rmbuse.map(i => ({...i, total: R.negate(i.change)})) - let ranklist = sortRankList(_hd.data.rank, list) + let rankList = sortRankList(_hd.data.rank, list) + + let userList = await G.crossmongodb.collection('huodong_user').find({uid: {$in: rankList.map(i => i._id).filter(i => i != 'system')}}).toArray() + + rankList = rankList.map(i => ({...i, player: userList.find(v => v.uid == i.uid) || {}})) R.forEach(i => { - let users = R.slice(i.rank[0] - 1, i.rank[1])(ranklist) + let users = R.slice(i.rank[0] - 1, i.rank[1])(rankList).filter(i => i._id != 'system') users.map(v => { - if (v._id == 'system') return - if (G.config.serverId != users.sid) return; + if (G.config.serverId != v.player?.sid) return; EmailFun.addEmail({ uid: v._id, type: 'system', From ec1b76ed5fe2b72cbff1bb0bcd5a0b8db52021f2 Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 13:43:47 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E5=9C=BA=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=A4=B4=E5=83=8F=E6=A1=86=E6=98=AF=E5=90=A6=E6=BF=80?= =?UTF-8?q?=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/jjc/ApiOpen.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api_s2c/jjc/ApiOpen.ts b/src/api_s2c/jjc/ApiOpen.ts index 4002e1a..700ada3 100644 --- a/src/api_s2c/jjc/ApiOpen.ts +++ b/src/api_s2c/jjc/ApiOpen.ts @@ -2,6 +2,7 @@ import {ApiCall} from "tsrpc"; import {JJCFun} from '../../public/jjc'; import {ReqOpen, ResOpen} from "../../shared/protocols/jjc/PtlOpen"; import {PublicShared} from '../../shared/public/public'; +import {UserFun} from "../../public/user"; export default async function (call: ApiCall) { const dbData = await JJCFun.getMyData(call.uid); @@ -28,6 +29,7 @@ export default async function (call: ApiCall) { ...enemy }); + UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1); JJCFun.checkUpdatePlayer() } \ No newline at end of file From 09b74e349003711d965f9eedb344ac356ac576a7 Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 14:26:40 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E9=BB=91=E5=B8=AE=E4=BA=89=E9=9C=B8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=8E=A9=E5=AE=B6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts | 23 ++++++++------ src/api_s2c/hbzb/jfs/ApiOpen.ts | 32 ++++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts b/src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts index 88e3685..fce9ac4 100644 --- a/src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts +++ b/src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts @@ -1,18 +1,23 @@ -import { ApiCall } from "tsrpc"; -import { ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser } from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser"; +import {ApiCall} from "tsrpc"; +import {ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser} from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser"; /**更新跨服数据库里,黑帮争霸的玩家数据 */ export default async function (call: ApiCall) { - let setData = { - "data":{ + let setData: any = { + "data": { player: call.req.user.player, roles: call.req.user.roles, uid: call.req.uid }, - "jifen": -999999, - "rank": -999999, - "zbsgroup":"" }; - G.mongodb.collection('hbzb_user_cross').updateOne({ uid: setData.data.uid }, { $set: setData }, { upsert: true }); - call.succ({ }); + if (call.req.isNew) { + setData = { + ...setData, + "jifen": -999999, + "rank": -999999, + "zbsgroup": "" + } + } + G.mongodb.collection('hbzb_user_cross').updateOne({uid: setData.data.uid}, {$set: setData}, {upsert: true}); + call.succ({}); } \ No newline at end of file diff --git a/src/api_s2c/hbzb/jfs/ApiOpen.ts b/src/api_s2c/hbzb/jfs/ApiOpen.ts index 26a5c67..bf7901e 100644 --- a/src/api_s2c/hbzb/jfs/ApiOpen.ts +++ b/src/api_s2c/hbzb/jfs/ApiOpen.ts @@ -1,18 +1,16 @@ -import { ApiCall } from "tsrpc"; -import { Rank } from '../../../public/rank/rank'; -import { ReqOpen, ResOpen } from "../../../shared/protocols/hbzb/jfs/PtlOpen"; -import { PublicShared } from '../../../shared/public/public'; -import { getHbzbData, getMyRank, getToper200RankUid, updateHbzbCrossUser } from "./fun"; +import {ApiCall} from "tsrpc"; +import {Rank} from '../../../public/rank/rank'; +import {ReqOpen, ResOpen} from "../../../shared/protocols/hbzb/jfs/PtlOpen"; +import {PublicShared} from '../../../shared/public/public'; +import {getHbzbData, getMyRank, getToper200RankUid, updateHbzbCrossUser} from "./fun"; export default async function (call: ApiCall) { //查看本地数据库里,刷出来的玩家数据 - let dbData = await getHbzbData(call.uid ); + let dbData = await getHbzbData(call.uid); let data: typeof dbData.data = dbData?.data || {} as any; - if (dbData == null) { - //如果没有,则同步到跨服 - await updateHbzbCrossUser(await call.conn.getDefaultFightData(), true); - } + //如果没有,则同步到跨服 + await updateHbzbCrossUser(await call.conn.getDefaultFightData(), dbData == null); if (!data.refreshTime || data.refreshTime < PublicShared.getToDayZeroTime()) { data.winNum = 0; @@ -26,19 +24,21 @@ export default async function (call: ApiCall) { //积分赛时的排行榜,是本服积分排序 data.jifen = 0; //但是刷出来的对手,是跨服的玩家 - let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true }); - if (!callRes.isSucc){ + let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', {uid: call.uid, auto: true}); + if (!callRes.isSucc) { //todo 健壮性处理 return call.errorCode(-4) } if (callRes.res.enemy.length) - data.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; }); + data.enemy = callRes.res.enemy.map(e => { + return {...e, result: null}; + }); } G.mongodb.cPlayerInfo('hbzb').updateOne( - { uid: call.uid, type: 'hbzb' }, - { $set: { data: data } }, - { upsert: true } + {uid: call.uid, type: 'hbzb'}, + {$set: {data: data}}, + {upsert: true} ); } From 10908525228ea0b670daafa7e400f6728a838338 Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 15:21:41 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=A5=B0=E5=93=81=E5=92=8C=E9=85=8D?= =?UTF-8?q?=E4=BB=B6=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E8=BF=9B=E4=B8=8D=E5=8E=BB=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/hero/ApiGetList.ts | 89 +++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 28 deletions(-) diff --git a/src/api_s2c/hero/ApiGetList.ts b/src/api_s2c/hero/ApiGetList.ts index db43836..623996a 100644 --- a/src/api_s2c/hero/ApiGetList.ts +++ b/src/api_s2c/hero/ApiGetList.ts @@ -21,34 +21,7 @@ export default async function (call: ApiCall) { color[heroCon[v.heroId].colour] += 1; }); - // 修复配件数据 - let peijianids = []; - Object.values(list).map(hero => { - hero.peijian && Object.values(hero.peijian).map( - i => peijianids.push(G.mongodb.conversionId(PeijianShared.fmt(i)._id)) - ) - }); - - let peijians = (await G.mongodb.collection("peijian").find( - {uid: call.uid, _id: {$in: peijianids}}, {projection: {_id: 1}} - ).toArray()).map(temp => G.mongodb.conversionId(temp._id)); - - let changes = {}; - Object.values(list).map(hero => { - for (let pos in hero.peijian) { - if (!peijians.includes(PeijianShared.fmt(hero.peijian[pos])._id)) { - hero.peijian[pos] = ""; - changes[hero._id] = hero.peijian; - } - } - }) - - for (let oid in changes) { - // 修复数据 - G.mongodb.collection("hero").updateOne( - G.mongodb.conversionIdObj({_id: oid}), {$set: {peijian: changes[oid]}} - ) - } + checkDataAndFix(call, list) // 记录玩家最大等级,颜色相关数据 注册任务用 await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'}, @@ -68,4 +41,64 @@ export default async function (call: ApiCall) { lshd: heros || {}, gbzj: (await G.mongodb.cPlayerInfo('gbzj').findOne({uid: call.uid, type: 'gbzj'}))?.rec || {} }); +} + +/** + * 修复玩家出现的饰品和配件数据错误导致的进不去游戏 + * @param call + * @param list + */ +async function checkDataAndFix(call: ApiCall, list: ResGetList['list']) { + try { + // 修复配件数据 + let peijianids = []; + Object.values(list).map(hero => { + hero.peijian && Object.values(hero.peijian).map( + i => peijianids.push(G.mongodb.conversionId(PeijianShared.fmt(i)._id)) + ) + }); + + let peijians = (await G.mongodb.collection("peijian").find( + {uid: call.uid, _id: {$in: peijianids}}, {projection: {_id: 1}} + ).toArray()).map(temp => G.mongodb.conversionId(temp._id)); + + let shiwuIds = R.flatten(R.values(list).map(hero => R.values(hero.shiwu).map(i => G.mongodb.conversionId(i._id)))) + + let shiwus = (await G.mongodb.collection("shiwu").find( + {uid: call.uid, _id: {$in: shiwuIds}}, {projection: {_id: 1}} + ).toArray()).map(i => G.mongodb.conversionId(i._id)); + + let peijianChanges = {}; + let shiwuChanges = {}; + Object.values(list).map(hero => { + for (let pos in hero.peijian) { + if (!peijians.includes(PeijianShared.fmt(hero.peijian[pos])._id)) { + hero.peijian[pos] = ""; + peijianChanges[hero._id] = hero.peijian; + } + } + for (let pos in hero.shiwu) { + if (!shiwus.includes(hero.shiwu[pos]._id)) { + hero.shiwu = R.omit([pos], hero.shiwu) + shiwuChanges[hero._id] = hero.shiwu; + } + } + }) + + for (let oid in peijianChanges) { + // 修复数据 + G.mongodb.collection("hero").updateOne( + G.mongodb.conversionIdObj({_id: oid}), {$set: {peijian: peijianChanges[oid]}} + ) + } + + for (let oid in shiwuChanges) { + // 修复数据 + G.mongodb.collection("hero").updateOne( + G.mongodb.conversionIdObj({_id: oid}), {$set: {shiwu: shiwuChanges[oid]}} + ) + } + } catch (e) { + console.log('======修复英雄配件和饰物报错====',e) + } } \ No newline at end of file From 71c0506a72b42ddc4597f7d1504e5be2d55031c7 Mon Sep 17 00:00:00 2001 From: dy Date: Sun, 31 Dec 2023 15:22:51 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=A5=B0=E5=93=81=E5=92=8C=E9=85=8D?= =?UTF-8?q?=E4=BB=B6=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E8=BF=9B=E4=B8=8D=E5=8E=BB=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/hero/ApiGetList.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_s2c/hero/ApiGetList.ts b/src/api_s2c/hero/ApiGetList.ts index 623996a..aafd7e2 100644 --- a/src/api_s2c/hero/ApiGetList.ts +++ b/src/api_s2c/hero/ApiGetList.ts @@ -21,7 +21,7 @@ export default async function (call: ApiCall) { color[heroCon[v.heroId].colour] += 1; }); - checkDataAndFix(call, list) + await checkDataAndFix(call, list) // 记录玩家最大等级,颜色相关数据 注册任务用 await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},