From 7b0c5d203df84ac4ac8e3e40ebcb1ff79ff45474 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 9 Jun 2023 18:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=AC=A1=E6=95=B0=E9=99=90=E5=88=B6=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/alchemy.controller.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/controllers/alchemy.controller.ts b/src/controllers/alchemy.controller.ts index eb15a0c..17b7594 100644 --- a/src/controllers/alchemy.controller.ts +++ b/src/controllers/alchemy.controller.ts @@ -26,12 +26,24 @@ class AlchemyController extends BaseController { } } const tokenResult = await refreshToken(user.emailReal || user.email) - console.log(tokenResult) if (!tokenResult.success || tokenResult.returnCode !== '0000') { logger.info(`fetch pay token error::code: ${tokenResult.returnCode} msg: ${tokenResult.returnMsg}`) throw new ZError(10, 'fetch pay token error') } const { id, email, accessToken } = tokenResult.data + if (crypto.toLowerCase() === 'agor') { + let today = new Date() + today.setHours(0, 0, 0, 0) + let count = await PayRecord.countDocuments({ + account: user.id, + crypto, + status: PayStatus.SUCCESS, + createdAt: { $gte: today }, + }) + if (count >= 3) { + throw new ZError(13, 'daily limit') + } + } let record = new PayRecord({ account: user.id, address,