From 28e4aca1f2b353c71eae545d6e409e3f3c0b6d43 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Mon, 18 Dec 2023 20:04:52 +0800 Subject: [PATCH] Revert "fix:" This reverts commit 404bb9a7e574532a772017693d91d16813b70216. --- src/api_s2c/event/huobanzhaomu/ApiRec.ts | 37 +++++++++--------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/api_s2c/event/huobanzhaomu/ApiRec.ts b/src/api_s2c/event/huobanzhaomu/ApiRec.ts index 0c1dfba..3b8cd45 100644 --- a/src/api_s2c/event/huobanzhaomu/ApiRec.ts +++ b/src/api_s2c/event/huobanzhaomu/ApiRec.ts @@ -1,38 +1,27 @@ -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"; +import { ApiCall } from "tsrpc"; +import { PlayerFun } from '../../../public/player'; +import { ReqRec, ResRec } from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; +import { HongDianChange } from "../../hongdian/fun"; 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 == "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}); - } - } + 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 }); 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'])