Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix

This commit is contained in:
ciniao 2024-01-08 14:03:23 +08:00
commit a9a5193efe
2 changed files with 54 additions and 49 deletions

View File

@ -1,6 +1,4 @@
import {ApiCall} from "tsrpc"; import {ApiCall} from "tsrpc";
import {EventFun} from '../public/event/event';
import {PayFun} from '../public/pay';
import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn"; import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn";
import {PublicShared} from '../shared/public/public'; import {PublicShared} from '../shared/public/public';
import {HuoDongFun} from "../public/huodongfun"; import {HuoDongFun} from "../public/huodongfun";
@ -65,39 +63,40 @@ export default async function (call: ApiCall<ReqSyncBtn, ResSyncBtn>) {
break; break;
case 'zhanling': case 'zhanling':
//30天一轮循环不管奖励。常驻活动 //30天一轮循环不管奖励。常驻活动
if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) { // if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) {
data[key] = {active: false}; // data[key] = {active: false};
} else { // } else {
let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'}); // let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'});
if (!data[key] || data[key].round != zls?.round) { // if (!data[key] || data[key].round != (zls?.round || 0)) {
let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time // let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time
let round = zls && zls.lastRunTime? zls.round : 1 // let round = zls && zls.lastRunTime? zls.round : 1
data[key] = {active: true, sTime: lastRunTime, round: round};
change[key] = data[key];
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 => { // PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []});
//新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
data && EventFun.reissueZhanLingPrize(data, call.conn.gud);
G.mongodb.cEvent('zhanling').updateOne( // G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => {
{uid: call.uid, type: 'zhanling'}, // //新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
{ // data && EventFun.reissueZhanLingPrize(data, call.conn.gud);
$set: {
lv: 1, // G.mongodb.cEvent('zhanling').updateOne(
exp: 0, // {uid: call.uid, type: 'zhanling'},
rec: {}, // {
isPay: false, // $set: {
taskRec: [], // lv: 1,
refreshTime: G.time // exp: 0,
} // rec: {},
}, // isPay: false,
{upsert: true} // taskRec: [],
); // refreshTime: G.time
}); // }
} // },
} // {upsert: true}
// );
// });
// }
// }
break; break;
case 'xianshilibao': case 'xianshilibao':
// 到时间消失 // 到时间消失

View File

@ -1,14 +1,16 @@
import {ApiCall} from "tsrpc"; import { ApiCall } from "tsrpc";
import {ZhanLingTasks} from '../../../public/zhanling'; import { ZhanLingTasks } from '../../../public/zhanling';
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhanling/PtlOpen"; import { ReqOpen, ResOpen } from "../../../shared/protocols/event/zhanling/PtlOpen";
import {player} from '../../../shared/protocols/user/type'; import { player } from '../../../shared/protocols/user/type';
import {PublicShared} from '../../../shared/public/public'; import { PublicShared } from '../../../shared/public/public';
import { PayFun } from "../../../public/pay";
export default async function (call: ApiCall<ReqOpen, ResOpen>) { export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'}); call.error(lng.huodong_open_1)
let data = await G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}); 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 = { let set = {
lv: 1, lv: 1,
exp: 0, exp: 0,
@ -16,18 +18,22 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
isPay: false, isPay: false,
taskRec: [], taskRec: [],
round: zls?.round || 0, round: zls?.round || 0,
reWeekTime:G.time, reWeekTime: G.time,
refreshTime: G.time, refreshTime: G.time,
} }
await PayFun.delPayLog(
call.uid, { payId: G.gc.zhanling.payId, val: [] }
);
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({ data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
uid: call.uid, uid: call.uid,
type: 'zhanling' 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) { if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime || PublicShared.getToDayZeroTime() > data.refreshTime) {
let set: any = {taskRec: []}; let set: any = { taskRec: [] };
let reType = []; let reType = [];
if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime) { if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime) {
@ -49,11 +55,11 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({ data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
uid: call.uid, uid: call.uid,
type: 'zhanling' type: 'zhanling'
}, {$set: set}, {upsert: true, returnDocument: 'after'})).value; }, { $set: set }, { upsert: true, returnDocument: 'after' })).value;
} }
let tasks = G.gc.zhanling.task.map(t => { 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); let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks);
@ -68,14 +74,14 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
} }
export async function payZhanLing(player: player) { 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 curLv = zlData?.lv || 1;
let maxLv = Number(Object.keys(G.gc.zhanling.lv).slice(-1)[0]); 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; let addLv = maxLv - curLv >= G.gc.zhanling.payAddLv ? G.gc.zhanling.payAddLv : maxLv - curLv;
await G.mongodb.cEvent('zhanling').updateOne( await G.mongodb.cEvent('zhanling').updateOne(
{uid: player.uid, type: 'zhanling'}, { uid: player.uid, type: 'zhanling' },
{$set: {isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv}}, { $set: { isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv } },
{upsert: true} { upsert: true }
); );
} }