feat:重置bug修复
This commit is contained in:
parent
8718342e3b
commit
dd9eeca150
@ -1,11 +1,11 @@
|
||||
import {ApiCall} from "tsrpc"
|
||||
import {ReqAddHuoDong} from "../../../monopoly/protocols/PtlAddHuoDong"
|
||||
import {HuoDongFun} from "../../../public/huodongfun"
|
||||
import {PublicShared} from "../../../shared/public/public"
|
||||
import {EmailFun} from "../../../public/email"
|
||||
import {playerInfo} from "../../../shared/protocols/user/PtlLogin"
|
||||
import {PlayerFun} from "../../../public/player"
|
||||
import {TaskFun} from "../../../public/task"
|
||||
import { ApiCall } from "tsrpc"
|
||||
import { ReqAddHuoDong } from "../../../monopoly/protocols/PtlAddHuoDong"
|
||||
import { HuoDongFun } from "../../../public/huodongfun"
|
||||
import { PublicShared } from "../../../shared/public/public"
|
||||
import { EmailFun } from "../../../public/email"
|
||||
import { playerInfo } from "../../../shared/protocols/user/PtlLogin"
|
||||
import { PlayerFun } from "../../../public/player"
|
||||
import { TaskFun } from "../../../public/task"
|
||||
|
||||
// hddata.data
|
||||
export interface Data {
|
||||
@ -128,15 +128,15 @@ export default class HQJGFun {
|
||||
*/
|
||||
static async getRankList(hdid: number) {
|
||||
let uids = await G.mongodb.collection("event").find(
|
||||
{type: this.dataType(hdid), "bossres.maxdps": {$gt: 0}},
|
||||
{ type: this.dataType(hdid), "bossres.maxdps": { $gt: 0 } },
|
||||
{
|
||||
sort: {"bossres.maxdps": -1, "bossres.zhanli": -1},
|
||||
projection: {uid: 1, bossres: 1}
|
||||
sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 },
|
||||
projection: { uid: 1, bossres: 1 }
|
||||
}
|
||||
).limit(50).toArray();
|
||||
|
||||
let userinfo = await G.mongodb.collection('user').find(
|
||||
{uid: {$in: uids.map(v => v.uid)}},
|
||||
{ uid: { $in: uids.map(v => v.uid) } },
|
||||
).toArray();
|
||||
|
||||
let res = [];
|
||||
@ -144,7 +144,7 @@ export default class HQJGFun {
|
||||
let uid = uids[rank - 1].uid;
|
||||
let user = userinfo.find(v => v.uid == uid);
|
||||
if (user) {
|
||||
res.push({rank, ...user, valArr: [uids[rank - 1].bossres.maxdps]});
|
||||
res.push({ rank, ...user, valArr: [uids[rank - 1].bossres.maxdps] });
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,14 +176,14 @@ export default class HQJGFun {
|
||||
}
|
||||
let data = await G.mongodb.cEvent(this.dataType(hd.hdid)).findOne({
|
||||
uid: call.uid, type: this.dataType(hd.hdid)
|
||||
}, {projection: {_id: 0}});
|
||||
}, { projection: { _id: 0 } });
|
||||
|
||||
if (!data) {
|
||||
data = (await G.mongodb.cEvent(this.dataType(hd.hdid)).findOneAndUpdate({
|
||||
uid: call.uid, type: this.dataType(hd.hdid)
|
||||
}, {
|
||||
$set: this.defaultData
|
||||
}, {upsert: true, returnDocument: 'after', projection: {_id: 0}})).value;
|
||||
}, { upsert: true, returnDocument: 'after', projection: { _id: 0 } })).value;
|
||||
}
|
||||
|
||||
let today = this.today(hd);
|
||||
@ -195,8 +195,8 @@ export default class HQJGFun {
|
||||
data.task.val[`day${today}`][taskid] = await TaskFun.getTaskNval(call, taskcon);
|
||||
}
|
||||
await G.mongodb.collection('event').updateOne(
|
||||
{uid: call.uid, type: this.dataType(hd.hdid)},
|
||||
{$set: {[`task.val.day${today}`]: data.task.val[`day${today}`]}}
|
||||
{ uid: call.uid, type: this.dataType(hd.hdid) },
|
||||
{ $set: { [`task.val.day${today}`]: data.task.val[`day${today}`] } }
|
||||
);
|
||||
}
|
||||
|
||||
@ -206,13 +206,13 @@ export default class HQJGFun {
|
||||
/** 设置我的数据 */
|
||||
static async setMyData(uid: string, hdid: number, update: { [k in keyof Partial<PlayerData>]: PlayerData[k] }) {
|
||||
let res = await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
|
||||
{uid: uid, type: this.dataType(hdid)}, {$set: update}
|
||||
{ uid: uid, type: this.dataType(hdid) }, { $set: update }, { upsert: true }
|
||||
);
|
||||
|
||||
if (res.modifiedCount <= 0) {
|
||||
if (res.upsertedCount == 1) {
|
||||
console.log("===>", uid, hdid, update);
|
||||
await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
|
||||
{uid: uid, type: this.dataType(hdid)}, {$set: Object.assign(this.defaultData, update)}
|
||||
{ uid: uid, type: this.dataType(hdid) }, { $set: Object.assign(this.defaultData, update) }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -226,8 +226,8 @@ export default class HQJGFun {
|
||||
)
|
||||
// 取stime小于当前时间的最后一条数据
|
||||
let hdinfo = await G.mongodb.collection("hdinfo").find({
|
||||
htype: this.htype, stime: {$lte: time}
|
||||
}, {sort: {stime: -1}}).limit(1).toArray();
|
||||
htype: this.htype, stime: { $lte: time }
|
||||
}, { sort: { stime: -1 } }).limit(1).toArray();
|
||||
|
||||
// 没有活动数
|
||||
if (hdinfo.length <= 0) {
|
||||
@ -242,7 +242,7 @@ export default class HQJGFun {
|
||||
}
|
||||
|
||||
let today = PublicShared.getDiff(hd.stime, G.time - 300);
|
||||
G.mongodb.collection("event").find({type: `huangqijiuguan_${hdid}`}).toArray().then(datas => {
|
||||
G.mongodb.collection("event").find({ type: `huangqijiuguan_${hdid}` }).toArray().then(datas => {
|
||||
let hddata = hd.data as Data;
|
||||
for (let i = 0; i < datas.length; i++) {
|
||||
let data = datas[i];
|
||||
@ -288,7 +288,7 @@ export default class HQJGFun {
|
||||
|
||||
// 查询昨天23:59:00或者今天00:00:00结束的活动
|
||||
let hdinfo = await G.mongodb.collection("hdinfo").find({
|
||||
htype: this.htype, rtime: {$gt: yesterday, $lte: today}
|
||||
htype: this.htype, rtime: { $gt: yesterday, $lte: today }
|
||||
}).toArray();
|
||||
|
||||
// 没有活动数 或者发奖标识已设置
|
||||
@ -304,10 +304,10 @@ export default class HQJGFun {
|
||||
}
|
||||
|
||||
let uids = await G.mongodb.collection("event").find(
|
||||
{type: this.dataType(hdid)},
|
||||
{ type: this.dataType(hdid) },
|
||||
{
|
||||
sort: {"bossres.maxdps": -1, "bossres.zhanli": -1},
|
||||
projection: {uid: 1, bossres: 1}
|
||||
sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 },
|
||||
projection: { uid: 1, bossres: 1 }
|
||||
}
|
||||
).toArray();
|
||||
|
||||
@ -328,7 +328,7 @@ export default class HQJGFun {
|
||||
}
|
||||
// 标记已发送
|
||||
await G.mongodb.collection("hdinfo").updateOne(
|
||||
{hdid: hdid}, {$set: {"data.sendrank": true}}
|
||||
{ hdid: hdid }, { $set: { "data.sendrank": true } }
|
||||
);
|
||||
// 货币兑换
|
||||
G.mongodb.collection("user").find().toArray().then(async (users) => {
|
||||
@ -409,7 +409,7 @@ export default class HQJGFun {
|
||||
|
||||
// 设置任务
|
||||
if (isset == 1) {
|
||||
await G.mongodb.collection('event').updateOne({uid: call.uid, type: this.dataType(hd.hdid)}, {
|
||||
await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, {
|
||||
$set: {
|
||||
[`task.val.day${today}`]: mydata.task.val[`day${today}`]
|
||||
}
|
||||
@ -436,13 +436,13 @@ export default class HQJGFun {
|
||||
|
||||
let mydata = await this.getMydata(call, hd);
|
||||
if (!mydata.giftbuy[gift.id]) {
|
||||
mydata.giftbuy[gift.id] = {num: 0, select: []};
|
||||
mydata.giftbuy[gift.id] = { num: 0, select: [] };
|
||||
}
|
||||
|
||||
let prize: atn[] = [];
|
||||
if (mydata.giftbuy[gift.id].num + 1 > gift.buynum) {
|
||||
let pay = G.gc.pay[payId];
|
||||
prize.push({a: "attr", t: "rmbmoney", n: pay.payExp[0].n})
|
||||
prize.push({ a: "attr", t: "rmbmoney", n: pay.payExp[0].n })
|
||||
} else {
|
||||
prize = gift.prize;
|
||||
for (let i = 0; i < gift.dlz.length; i++) {
|
||||
@ -459,7 +459,7 @@ export default class HQJGFun {
|
||||
mydata.giftbuy[gift.id].num++;
|
||||
// 发送奖励
|
||||
await PlayerFun.sendPrize(call, prize, true);
|
||||
await this.setMyData(call.uid, hd.hdid, {giftbuy: mydata.giftbuy});
|
||||
await this.setMyData(call.uid, hd.hdid, { giftbuy: mydata.giftbuy });
|
||||
}
|
||||
|
||||
static async getHongDian(call: ApiCall, hd: ReqAddHuoDong, mydata?: PlayerData) {
|
||||
@ -471,14 +471,14 @@ export default class HQJGFun {
|
||||
for (let i = 0; i < hddata.choukajiangli.length; i++) {
|
||||
let ele = hddata.choukajiangli[i];
|
||||
if (mydata.zhaomu.num >= ele.num && !mydata.zhaomu.prize.includes(i)) {
|
||||
return {show: true}
|
||||
return { show: true }
|
||||
}
|
||||
}
|
||||
|
||||
let today = this.today(hd);
|
||||
// 当今日没有进行boss挑战时
|
||||
if (!mydata.bossres.todaydps[today]) {
|
||||
return {show: true}
|
||||
return { show: true }
|
||||
}
|
||||
|
||||
// 当每日任务界面存在可领取的任务奖励时
|
||||
@ -486,7 +486,7 @@ export default class HQJGFun {
|
||||
for (let taskid in hddata.task[`day${day}`]) {
|
||||
let task = hddata.task[`day${day}`][taskid];
|
||||
if (mydata.task.val[`day${day}`]?.[taskid] >= task.pval && !(mydata.task.rec?.[`day${day}`] || []).includes(Number(taskid))) {
|
||||
return {show: true}
|
||||
return { show: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -494,17 +494,17 @@ export default class HQJGFun {
|
||||
// 当干部挑战界面存在可领取的挑战任务奖励时
|
||||
for (let mb of hddata.bossTask) {
|
||||
if (mb.need <= mydata.bossres.maxdps && !mydata.bossres.recdpstask.includes(mb.id)) {
|
||||
return {show: true}
|
||||
return { show: true }
|
||||
}
|
||||
}
|
||||
|
||||
// 当存在可以领取的免费礼包时
|
||||
for (let gift of hddata.gift) {
|
||||
if (gift.free && (mydata.giftbuy[gift.id]?.num || 0) < gift.buynum) {
|
||||
return {show: true}
|
||||
return { show: true }
|
||||
}
|
||||
}
|
||||
|
||||
return {show: false}
|
||||
return { show: false }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user