From ef6498c0d60bf71ceebcab63d0a1ac5b82c32e49 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Sat, 23 Dec 2023 00:44:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/email/ApiAllRemove.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_s2c/email/ApiAllRemove.ts b/src/api_s2c/email/ApiAllRemove.ts index d27b610..220bed2 100644 --- a/src/api_s2c/email/ApiAllRemove.ts +++ b/src/api_s2c/email/ApiAllRemove.ts @@ -5,7 +5,7 @@ import { ReqAllRemove, ResAllRemove } from "../../shared/protocols/email/PtlAllR export default async function (call: ApiCall) { // 筛选出没有奖励已读邮件和已经领取过奖励的邮件 let emailList = (await EmailFun.getAllEmail(call.uid, true)).filter(email => ( - (email.emailRead && email.prizeData.prize.length <= 0) || email.prizeData.isGet + (email.emailRead && email.prizeData?.prize.length <= 0) || email.prizeData.isGet )); if (emailList.length < 1) return call.error(globalThis.lng.email_2); From 14daa94dba2d9c490ffa77c75e2b556dbb5f051d Mon Sep 17 00:00:00 2001 From: dy Date: Sat, 23 Dec 2023 12:30:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=20=E9=BB=91=E5=B8=AE=E4=BA=89=E9=9C=B8?= =?UTF-8?q?=E5=88=86=E7=BB=84=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/api_s2c/hbzb/zbs/fun.ts | 91 +++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/src/api_s2c/hbzb/zbs/fun.ts b/src/api_s2c/hbzb/zbs/fun.ts index f6abd0d..9c0dd83 100644 --- a/src/api_s2c/hbzb/zbs/fun.ts +++ b/src/api_s2c/hbzb/zbs/fun.ts @@ -1,55 +1,58 @@ /** * 争霸赛分组,每300个玩家分一组 * 最后一组:如果是有100人即往上人数 那就自己一组打 -* 如果不够100 就合到前一组 + * 如果不够100 就合到前一组 */ -export async function zbsGroup(){ +export async function zbsGroup() { let arr = await G.mongodb.collection("hbzb_user_cross").find( - { "jifen": { $gt: -999999 } } - ).sort( - { "data.player.cTime": -1 } - ).project({ - uid:1, - jifen:1 - }).toArray(); - + {"jifen": {$gt: -999999}} + ).project({ + uid: 1, + jifen: 1, + 'data.player.cTime': 1 + }).toArray(); + + // 移除mongo查询里的排序,↑会造成内存超出报错, + // 在内存里按照玩家注册时间相近的排序分组 + R.sort((a, b) => b.data.player.cTime - a.data.player.cTime) + //有积分的玩家总数 let groups = []; let currGroup = []; - - arr.map((u,index)=>{ - if(currGroup.length >= 300){ + + arr.map((u, index) => { + if (currGroup.length >= 300) { //每300个丢一组 - groups.push( currGroup ); + groups.push(currGroup); currGroup = []; } currGroup.push({uid: u.uid, jifen: u.jifen}); }); //循环完毕后检查余量 - if(currGroup.length > 0){ - if(currGroup.length >= 100){ + if (currGroup.length > 0) { + if (currGroup.length >= 100) { //如果有100人 就自己一组 - groups.push( currGroup ); - }else{ + groups.push(currGroup); + } else { //不够100 就合到前一组 - groups[groups.length] = (groups[groups.length]||[]).concat(currGroup); + groups[groups.length] = (groups[groups.length] || []).concat(currGroup); } currGroup = []; } //循环groups里的数据,对每一组里按jifen降序排序,然后给每个玩家分组 - groups.map((group,groupIndex)=>{ - group.sort((a,b)=>{ + groups.map((group, groupIndex) => { + group.sort((a, b) => { return b.jifen - a.jifen; }); - for(let i=0;i { +export async function getZbsRankList(uid?: string, _zbsgroup?: string): Promise<{ myRank: any; rankList: any[]; }> { let myData; let zbsgroup = _zbsgroup; - if(uid){ - myData = await G.crossmongodb.collection("hbzb_user_cross").findOne({uid:uid}); - if(!myData || !myData?.zbsgroup)return null; + if (uid) { + myData = await G.crossmongodb.collection("hbzb_user_cross").findOne({uid: uid}); + if (!myData || !myData?.zbsgroup) return null; zbsgroup = myData?.zbsgroup; } - + let arr = await G.crossmongodb.collection("hbzb_user_cross").find( - { "zbsgroup": zbsgroup } + {"zbsgroup": zbsgroup} ).sort( - { "rank": 1 } + {"rank": 1} ).limit(100).toArray(); - + let rank = { - "myRank":{}, - "rankList" : [] + "myRank": {}, + "rankList": [] } - + let myRank = -1; - arr.map((u,index)=>{ - rank.rankList.push( { + arr.map((u, index) => { + rank.rankList.push({ player: ((u.data) as any).player || {}, roles: ((u.data) as any).roles || {}, - rank : (index+1), + rank: (index + 1), //兼容前端 - valArr: [ (index+1) ] + valArr: [(index + 1)] }); - if(u.uid == uid){ + if (u.uid == uid) { myRank = rank.rankList.length; rank.myRank = { player: ((u.data) as any).player || {}, roles: ((u.data) as any).roles || {}, - rank : (index+1), + rank: (index + 1), //兼容前端 - valArr: [ (index+1) ] + valArr: [(index + 1)] }; } }) return rank; - + } From c323a9e2553e694cc67865f0d96c79a5369a9c6e Mon Sep 17 00:00:00 2001 From: chenkai Date: Mon, 25 Dec 2023 11:06:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8A=A2=E7=BA=A2?= =?UTF-8?q?=E5=8C=85=E6=97=A5=E5=BF=97=E5=88=97=E8=A1=A8=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6=E6=9C=AA=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/payForDiamond/ApiReceive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_s2c/event/payForDiamond/ApiReceive.ts b/src/api_s2c/event/payForDiamond/ApiReceive.ts index 32cc9cb..a81b991 100644 --- a/src/api_s2c/event/payForDiamond/ApiReceive.ts +++ b/src/api_s2c/event/payForDiamond/ApiReceive.ts @@ -109,7 +109,7 @@ export default async function (call: ApiCall) { }); const showOffListKey = showOffListKeyPrefix + activityId; await G.iorediscross.lpush(showOffListKey, msg); - await G.ioredis.ltrim(showOffListKey, 0, 49); // 限制列表保存 50 条消息, 避免无限增长 + await G.iorediscross.ltrim(showOffListKey, 0, 49); // 限制列表保存 50 条消息, 避免无限增长 } } } else {