diff --git a/src/globalListener.ts b/src/globalListener.ts index 9300f46..bd10c64 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -17,6 +17,7 @@ import { PublicShared } from './shared/public/public'; 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"; export type gEventType = { /**玩家断开连接 */ @@ -194,6 +195,7 @@ export function addListener() { { $inc: { payNum: conf.money } }, { upsert: true } ); + PushGiftFun.buy(player.uid, payId) // 推送礼包 }); G.on("FIRST_LOGIN_EVERY_DAY", (gud, lastTime, curTime) => { diff --git a/src/public/pushgift.ts b/src/public/pushgift.ts index 72fcfde..e003088 100644 --- a/src/public/pushgift.ts +++ b/src/public/pushgift.ts @@ -152,4 +152,22 @@ export class PushGiftFun { // 推送客户端消息 G.server.sendMsgByUid(uid, "msg_s2c/PushGiftChange", 1); } + + static async buy(uid: string, payId: string) { + // 购买礼包 + let gift; + for (let gift_id in G.gc.tuisonglibao) { + gift = G.gc.tuisonglibao[gift_id]; + if (gift.payId.includes(payId)) break; + } + let index = gift.payId.indexOf(payId); + let info = await G.mongodb.collection("pushgift").findOne({ + uid: uid, id: gift.id.toString() + }) + if (info.passTime >= G.time) { + G.mongodb.collection("pushgift").updateOne({ + uid: uid, id: gift.id.toString() + }, {$inc: {[`buy.${index}`]: 1}}) + } + } } \ No newline at end of file