diff --git a/src/api_s2c/event/leichonglibao/ApiOpen.ts b/src/api_s2c/event/leichonglibao/ApiOpen.ts index 78d89e5..b820d52 100644 --- a/src/api_s2c/event/leichonglibao/ApiOpen.ts +++ b/src/api_s2c/event/leichonglibao/ApiOpen.ts @@ -12,7 +12,7 @@ export default async function (call: ApiCall) { // 每天open红点 G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).updateOne( - {type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: change} + {type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: change}, {upsert: true} ) let temp = Object.assign((data || {}), change) as ResOpen & { opentime } diff --git a/src/api_s2c/event/leichonglibao/ApiReceive.ts b/src/api_s2c/event/leichonglibao/ApiReceive.ts index aa58d3f..2ce441f 100644 --- a/src/api_s2c/event/leichonglibao/ApiReceive.ts +++ b/src/api_s2c/event/leichonglibao/ApiReceive.ts @@ -42,6 +42,11 @@ export default async function (call: ApiCall) { _prize.push(hddata.dlz[i][call.req.select[i] || "1"]) } + // 修改领取标识 + await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).updateOne( + {type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: {sc: true}} + ) + PlayerFun.sendPrize(call, _prize) call.succ({prize: _prize}) } @@ -71,14 +76,21 @@ export async function LeiChongLiBaoBuyGift(call: ApiCall, payId: string) { {type: `leichonglibao${hdid}`, uid: call.uid} ) - if (mydata.buy.includes(gift.payId)) { + if (mydata && mydata.buy.includes(gift.payId)) { console.log(call.uid, "购买累充礼包 重复购买", payId); return } + let update; + if (mydata) { + update = {$push: {buy: payId}} + } else { + update = {$set: {opentime: G.time, sc: false, buy: [payId]}} + } + PlayerFun.sendPrize(call, gift.prize) G.mongodb.cEvent(`leichonglibao${hdid}`).updateOne( - {uid: call.uid, type: `leichonglibao${hdid}`}, {"$push": {buy: payId}} + {uid: call.uid, type: `leichonglibao${hdid}`}, update ) } diff --git a/src/globalListener.ts b/src/globalListener.ts index f4ada40..6a5bec8 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -18,6 +18,7 @@ import { setGud } from './public/gud'; import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen"; import {Christmasfun} from "./api_s2c/event/christmas/fun"; import {PushGiftFun} from "./public/pushgift"; +import {LeiChongLiBaoBuyGift} from "./api_s2c/event/leichonglibao/ApiReceive"; export type gEventType = { /**玩家断开连接 */ @@ -201,7 +202,8 @@ export function addListener() { { $inc: { payNum: conf.money } }, { upsert: true } ); - PushGiftFun.buy(player.uid, payId) // 推送礼包 + await PushGiftFun.buy(player.uid, payId) // 推送礼包 + await LeiChongLiBaoBuyGift(call, payId) // 累充礼包 }); G.on("FIRST_LOGIN_EVERY_DAY", (gud, lastTime, curTime) => {