Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
dy 2023-12-31 09:48:45 +08:00
commit eafa42880a
2 changed files with 21 additions and 10 deletions

View File

@ -1,3 +1,4 @@
import { log } from "console";
import { patchFun, patchInit } from "../patch"; import { patchFun, patchInit } from "../patch";
import { TanXianFun } from "../public/tanxian"; import { TanXianFun } from "../public/tanxian";
import { PublicShared } from "../shared/public/public"; import { PublicShared } from "../shared/public/public";
@ -5,7 +6,8 @@ import { PublicShared } from "../shared/public/public";
class Path { class Path {
async fun1(a: any) { async fun1(a: any) {
let hdid = 1703860546; let hdid = 1703860546; // 正式服活动id
// let hdid = 1703917224; // 测试服活动id
let today_zero_time = PublicShared.getToDayZeroTime(); let today_zero_time = PublicShared.getToDayZeroTime();
// 查询今天登录的用户 // 查询今天登录的用户
@ -18,7 +20,8 @@ class Path {
let uid = today_login_users[i].uid; let uid = today_login_users[i].uid;
let init: boolean = false; let init: boolean = false;
let hdata:any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({
let hdata: any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({
uid: uid, type: `yuandan${hdid}` uid: uid, type: `yuandan${hdid}`
}); });
if (!hdata) { if (!hdata) {
@ -75,9 +78,10 @@ class Path {
let jxdata = await G.mongodb.collection('gonghuiUser').findOne({ uid: uid }); let jxdata = await G.mongodb.collection('gonghuiUser').findOne({ uid: uid });
if (jxdata && jxdata.jx?.refreshTime > today_zero_time) { if (jxdata && jxdata.jx?.refreshTime > today_zero_time) {
if (jxdata.jx?.record) { 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 { } else {
taskval["5"] = 0; taskval["5"] = 0;
} }
@ -87,7 +91,7 @@ class Path {
let uselogs = (await G.mongodb.collection('rmbuse').find( let uselogs = (await G.mongodb.collection('rmbuse').find(
{ uid: uid, cTime: { $gte: today_zero_time }, isAdd: false }, { uid: uid, cTime: { $gte: today_zero_time }, isAdd: false },
{ projection: { change: 1 } } { projection: { change: 1 } }
).toArray()).forEach(e => { taskval["6"] += e.change; }); ).toArray()).forEach(e => { taskval["6"] += -e.change; });
// taskid=7, stype=122 进行 n 次快速探险 // taskid=7, stype=122 进行 n 次快速探险
taskval["7"] = 0; taskval["7"] = 0;
@ -98,7 +102,7 @@ class Path {
// taskid=8, stype=157 获得vip经验 // taskid=8, stype=157 获得vip经验
let orde_logs = await G.mongodb.collection('payOrderLog' as any).find( 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(); ).toArray();
taskval["8"] = 0; taskval["8"] = 0;
@ -113,6 +117,7 @@ class Path {
let pay = G.gc.pay[e.payId]; let pay = G.gc.pay[e.payId];
if (pay) taskval["9"] += pay.payExp[0].n; if (pay) taskval["9"] += pay.payExp[0].n;
}) })
if (!init) { if (!init) {
await G.mongodb.cEvent(`yuandan${hdid}`).updateOne( await G.mongodb.cEvent(`yuandan${hdid}`).updateOne(
{ uid: uid, type: `yuandan${hdid}` }, { uid: uid, type: `yuandan${hdid}` },
@ -122,7 +127,8 @@ class Path {
hdata.taskval = taskval; hdata.taskval = taskval;
await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true }) await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true })
} }
console.log('玩家执行完成',uid)
console.log("玩家执行完成:", uid, taskval);
} }

View File

@ -135,7 +135,11 @@ export abstract class Rank {
//将db里的数据写入到 rank:xxx:sort里 //将db里的数据写入到 rank:xxx:sort里
//写入的单条数据为: {uid:score} //写入的单条数据为: {uid:score}
this.db.find({ type: this.type }, {
// 首先清理redis中sort数据 在从数据库中初始化
await G.ioredis.del(this.getRedisKeySort);
this.db.find({ type: this.type }, {
projection: { projection: {
"idKey": 1, "idKey": 1,
"type": 1, "type": 1,
@ -263,7 +267,7 @@ export abstract class Rank {
} }
return item; return item;
}) })
if(ghid.length > 0){ if (ghid.length > 0) {
let ghinfo = await G.mongodb.collection("gonghui").find( let ghinfo = await G.mongodb.collection("gonghui").find(
{ _id: { $in: ghid } }, { projection: { name: 1 } } { _id: { $in: ghid } }, { projection: { name: 1 } }
).toArray(); ).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 [] return []
} }