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,