From 070edf1cb54cd9afb0bf5cad928bbd910c50375e Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 15 Dec 2023 21:11:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BC=99=E4=BC=B4?= =?UTF-8?q?=E6=8B=9B=E5=8B=9F=E7=9A=84=E5=A5=96=E5=8A=B1=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/huobanzhaomu/ApiRec.ts | 37 +++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/api_s2c/event/huobanzhaomu/ApiRec.ts b/src/api_s2c/event/huobanzhaomu/ApiRec.ts index 3b8cd45..0c1dfba 100644 --- a/src/api_s2c/event/huobanzhaomu/ApiRec.ts +++ b/src/api_s2c/event/huobanzhaomu/ApiRec.ts @@ -1,27 +1,38 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../../public/player'; -import { ReqRec, ResRec } from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; -import { HongDianChange } from "../../hongdian/fun"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../../public/player'; +import {ReqRec, ResRec} from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; +import {HongDianChange} from "../../hongdian/fun"; +import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { let conf = G.gc.huobanzhaomu[call.req.index]; - if (!conf) return call.error('', { code: -1 }); - if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', { code: -2 }); + if (!conf) return call.error('', {code: -1}); + if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', {code: -2}); - let db = await G.mongodb.cEvent('huobanzhaomu').findOne({ uid: call.uid, type: 'huobanzhaomu' }); - if (db?.rec.includes(call.req.index)) return call.error('', { code: -3 }); - if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) return call.error('', { code: -4 }); + let db = await G.mongodb.cEvent('huobanzhaomu').findOne({uid: call.uid, type: 'huobanzhaomu'}); + if (db?.rec.includes(call.req.index)) return call.error('', {code: -3}); + + if (conf.gudKey == "chaozhiyueka") { + let logs = await PayFun.getPayLog(call.uid, "chaozhiyueka"); + if (!logs || logs.slice(-1)[0].eTime < G.time) { + return call.error('', {code: -4}); + } + } else { + if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) { + return call.error('', {code: -4}); + } + } await PlayerFun.sendPrize(call, conf.prize); if (db?.rec?.length + 1 >= G.gc.huobanzhaomu.length) { - G.mongodb.collection('syncBtns').updateOne({ uid: call.uid }, { $set: { 'huobanzhaomu.active': false } }, { upsert: true }); + G.mongodb.collection('syncBtns').updateOne({uid: call.uid}, {$set: {'huobanzhaomu.active': false}}, {upsert: true}); } G.mongodb.cEvent('huobanzhaomu').updateOne( - { uid: call.uid, type: 'huobanzhaomu' }, - { $push: { rec: call.req.index } }, - { upsert: true } + {uid: call.uid, type: 'huobanzhaomu'}, + {$push: {rec: call.req.index}}, + {upsert: true} ); HongDianChange.sendChangeKey(call.uid, ['huobanzhaomuhd'])