Merge remote-tracking branch 'origin/bugfix' into release
This commit is contained in:
commit
d8a7fa14d0
@ -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<ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser>) {
|
||||
let setData = {
|
||||
"data":{
|
||||
let setData: any = {
|
||||
"data": {
|
||||
player: call.req.user.player,
|
||||
roles: call.req.user.roles,
|
||||
uid: call.req.uid
|
||||
},
|
||||
};
|
||||
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({ });
|
||||
"zbsgroup": ""
|
||||
}
|
||||
}
|
||||
G.mongodb.collection('hbzb_user_cross').updateOne({uid: setData.data.uid}, {$set: setData}, {upsert: true});
|
||||
call.succ({});
|
||||
}
|
@ -29,5 +29,5 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
||||
|
||||
call.succ({})
|
||||
|
||||
HongDianChange.sendChangeKey(call.uid, ['pobinglibao']);
|
||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||
}
|
||||
|
@ -21,23 +21,18 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
|
||||
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<ReqOpen, ResOpen>) {
|
||||
*/
|
||||
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}
|
||||
}
|
@ -12,6 +12,7 @@ export default async function (call: ApiCall<ReqhdGetList, ReshdGetList>) {
|
||||
// 消费竞赛是跨服活动,活动开启时,同步当前用户信息到跨服数据库
|
||||
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})
|
||||
}
|
||||
|
@ -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<ReqOpen, ResOpen>) {
|
||||
//查看本地数据库里,刷出来的玩家数据
|
||||
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<ReqOpen, ResOpen>) {
|
||||
//积分赛时的排行榜,是本服积分排序
|
||||
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}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,34 +21,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
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]}}
|
||||
)
|
||||
}
|
||||
await checkDataAndFix(call, list)
|
||||
|
||||
// 记录玩家最大等级,颜色相关数据 注册任务用
|
||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
||||
@ -69,3 +42,63 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
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)
|
||||
}
|
||||
}
|
@ -367,17 +367,21 @@ export class HuoDongHongDianFun {
|
||||
/**破冰礼包红点 */
|
||||
static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise<hongdianVal> {
|
||||
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}
|
||||
}
|
||||
|
||||
/**元旦活动红点 */
|
||||
|
@ -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<ReqOpen, ResOpen>) {
|
||||
const dbData = await JJCFun.getMyData(call.uid);
|
||||
@ -28,6 +29,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
...enemy
|
||||
});
|
||||
|
||||
UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1);
|
||||
JJCFun.checkUpdatePlayer()
|
||||
|
||||
}
|
155
src/fix_patch/patch_20231230.ts
Normal file
155
src/fix_patch/patch_20231230.ts
Normal file
@ -0,0 +1,155 @@
|
||||
import { log } from "console";
|
||||
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; // 正式服活动id
|
||||
// let hdid = 1703917224; // 测试服活动id
|
||||
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
|
||||
}else{
|
||||
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, taskval);
|
||||
}
|
||||
|
||||
|
||||
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();
|
@ -106,7 +106,8 @@ class _G {
|
||||
|
||||
/**跨服活动——消费竞赛的开启状态 */
|
||||
huodong = {
|
||||
xfjs: false
|
||||
xfjs: false,
|
||||
xfjsId: ''
|
||||
};
|
||||
|
||||
private event = new EventEmitter();
|
||||
|
@ -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});
|
||||
|
@ -135,6 +135,10 @@ export abstract class Rank {
|
||||
|
||||
//将db里的数据,写入到 rank:xxx:sort里
|
||||
//写入的单条数据为: {uid:score}
|
||||
|
||||
// 首先清理redis中sort数据 在从数据库中初始化
|
||||
await G.ioredis.del(this.getRedisKeySort);
|
||||
|
||||
this.db.find({ type: this.type }, {
|
||||
projection: {
|
||||
"idKey": 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();
|
||||
@ -302,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 []
|
||||
}
|
||||
|
@ -39,22 +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({
|
||||
time: {
|
||||
$gte: _hd.stime,
|
||||
$lte: _hd.etime + 10
|
||||
}
|
||||
}).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',
|
||||
|
Loading…
Reference in New Issue
Block a user