From e469ed0b6ab5296eb95373f2e9ca4ee91cd341e6 Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Mon, 8 Jan 2024 13:49:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=BD=E6=9D=80=E4=BB=A4=E6=97=A0?= =?UTF-8?q?=E9=99=90=E5=88=B7bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/ApiSyncBtn.ts | 63 +++++++++++++-------------- src/api_s2c/event/zhanling/ApiOpen.ts | 40 +++++++++-------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/api_s2c/ApiSyncBtn.ts b/src/api_s2c/ApiSyncBtn.ts index 7b3308a..26b0ab4 100644 --- a/src/api_s2c/ApiSyncBtn.ts +++ b/src/api_s2c/ApiSyncBtn.ts @@ -1,6 +1,4 @@ import {ApiCall} from "tsrpc"; -import {EventFun} from '../public/event/event'; -import {PayFun} from '../public/pay'; import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn"; import {PublicShared} from '../shared/public/public'; import {HuoDongFun} from "../public/huodongfun"; @@ -65,39 +63,40 @@ export default async function (call: ApiCall) { break; case 'zhanling': //30天一轮循环,不管奖励。常驻活动 - if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) { - data[key] = {active: false}; - } else { - let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'}); - if (!data[key] || data[key].round != zls?.round) { - let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time - let round = zls && zls.lastRunTime? zls.round : 1 - data[key] = {active: true, sTime: lastRunTime, round: round}; - change[key] = data[key]; + // if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) { + // data[key] = {active: false}; + // } else { + // let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'}); + // if (!data[key] || data[key].round != (zls?.round || 0)) { + // let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time + // let round = zls && zls.lastRunTime? zls.round : 1 - PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []}); + // data[key] = {active: true, sTime: lastRunTime, round: round}; + // change[key] = data[key]; - G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => { - //新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励 - data && EventFun.reissueZhanLingPrize(data, call.conn.gud); + // PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []}); - G.mongodb.cEvent('zhanling').updateOne( - {uid: call.uid, type: 'zhanling'}, - { - $set: { - lv: 1, - exp: 0, - rec: {}, - isPay: false, - taskRec: [], - refreshTime: G.time - } - }, - {upsert: true} - ); - }); - } - } + // G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => { + // //新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励 + // data && EventFun.reissueZhanLingPrize(data, call.conn.gud); + + // G.mongodb.cEvent('zhanling').updateOne( + // {uid: call.uid, type: 'zhanling'}, + // { + // $set: { + // lv: 1, + // exp: 0, + // rec: {}, + // isPay: false, + // taskRec: [], + // refreshTime: G.time + // } + // }, + // {upsert: true} + // ); + // }); + // } + // } break; case 'xianshilibao': // 到时间消失 diff --git a/src/api_s2c/event/zhanling/ApiOpen.ts b/src/api_s2c/event/zhanling/ApiOpen.ts index 95b2ce7..e72339b 100644 --- a/src/api_s2c/event/zhanling/ApiOpen.ts +++ b/src/api_s2c/event/zhanling/ApiOpen.ts @@ -1,14 +1,16 @@ -import {ApiCall} from "tsrpc"; -import {ZhanLingTasks} from '../../../public/zhanling'; -import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhanling/PtlOpen"; -import {player} from '../../../shared/protocols/user/type'; -import {PublicShared} from '../../../shared/public/public'; +import { ApiCall } from "tsrpc"; +import { ZhanLingTasks } from '../../../public/zhanling'; +import { ReqOpen, ResOpen } from "../../../shared/protocols/event/zhanling/PtlOpen"; +import { player } from '../../../shared/protocols/user/type'; +import { PublicShared } from '../../../shared/public/public'; +import { PayFun } from "../../../public/pay"; export default async function (call: ApiCall) { - let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'}); - let data = await G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}); + call.error(lng.huodong_open_1) + let zls = await G.mongodb.collection('scheduler').findOne({ type: 'zhanling' }); + let data = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' }); - if (!data || data.round != (zls?.round | 0)) { + if (!data || data.round != (zls?.round || 0)) { let set = { lv: 1, exp: 0, @@ -16,18 +18,22 @@ export default async function (call: ApiCall) { isPay: false, taskRec: [], round: zls?.round || 0, - reWeekTime:G.time, + reWeekTime: G.time, refreshTime: G.time, } + await PayFun.delPayLog( + call.uid, { payId: G.gc.zhanling.payId, val: [] } + ); + data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({ uid: call.uid, type: 'zhanling' - }, {$set: set}, {upsert: true, returnDocument: 'after'})).value; + }, { $set: set }, { upsert: true, returnDocument: 'after' })).value; } if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime || PublicShared.getToDayZeroTime() > data.refreshTime) { - let set: any = {taskRec: []}; + let set: any = { taskRec: [] }; let reType = []; if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime) { @@ -49,11 +55,11 @@ export default async function (call: ApiCall) { data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({ uid: call.uid, type: 'zhanling' - }, {$set: set}, {upsert: true, returnDocument: 'after'})).value; + }, { $set: set }, { upsert: true, returnDocument: 'after' })).value; } let tasks = G.gc.zhanling.task.map(t => { - return {type: t.type as 'day' | 'week' | 'round', key: t.taskId}; + return { type: t.type as 'day' | 'week' | 'round', key: t.taskId }; }); let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks); @@ -68,14 +74,14 @@ export default async function (call: ApiCall) { } export async function payZhanLing(player: player) { - let zlData = await G.mongodb.cEvent('zhanling').findOne({uid: player.uid, type: 'zhanling'}); + let zlData = await G.mongodb.cEvent('zhanling').findOne({ uid: player.uid, type: 'zhanling' }); let curLv = zlData?.lv || 1; let maxLv = Number(Object.keys(G.gc.zhanling.lv).slice(-1)[0]); let addLv = maxLv - curLv >= G.gc.zhanling.payAddLv ? G.gc.zhanling.payAddLv : maxLv - curLv; await G.mongodb.cEvent('zhanling').updateOne( - {uid: player.uid, type: 'zhanling'}, - {$set: {isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv}}, - {upsert: true} + { uid: player.uid, type: 'zhanling' }, + { $set: { isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv } }, + { upsert: true } ); } \ No newline at end of file