From fe8a68a6ebfeae718bf6892c29f5e6efaa7239e8 Mon Sep 17 00:00:00 2001 From: dy Date: Fri, 15 Dec 2023 11:12:04 +0800 Subject: [PATCH] fix bug --- src/api_s2c/event/zhoumolibao/ApiOpen.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api_s2c/event/zhoumolibao/ApiOpen.ts b/src/api_s2c/event/zhoumolibao/ApiOpen.ts index ebbcce3..87bcca0 100644 --- a/src/api_s2c/event/zhoumolibao/ApiOpen.ts +++ b/src/api_s2c/event/zhoumolibao/ApiOpen.ts @@ -6,7 +6,6 @@ import {PublicShared} from "../../../shared/public/public"; export default async function (call: ApiCall) { - let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'}) let _hd = (await HuoDongFun.gethdList(call, 9))[0] @@ -17,6 +16,7 @@ export default async function (call: ApiCall) { record: data?.record || {}, buyLog: await PayFun.getPayLogs(call.uid, payIds) }) + checkResetBuyLog(call) } export async function getConf(call, args?: { id?: string; payId?: string }) { @@ -31,10 +31,10 @@ export async function checkResetBuyLog(call) { let zeroTime = PublicShared.getToDayZeroTime() let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'}) - if (data?.refreshTime <= zeroTime) { + if (!data?.refreshTime || data?.refreshTime < zeroTime) { G.mongodb.cEvent(`zhoumolibao`).updateOne( {uid: call.uid, type: `zhoumolibao`}, - {$set: {record: {}}}, + {$set: {record: {}, refreshTime: G.time}}, {upsert: true} ) } @@ -43,7 +43,7 @@ export async function checkResetBuyLog(call) { let payIds = gifts.filter(i => i.payId)?.map(i => i.payId) let payLogs = await PayFun.getPayLogs(call.uid, payIds) - let payLogLength = R.values(payLogs).filter(i => i.time < zeroTime).length + let payLogLength = R.flatten(R.values(payLogs)).filter(i => i.time < zeroTime).length if (payLogLength) { PayFun.delPayLog(call.uid, payIds.map(i => ({payId: i, val: []}))) }