修改支付接口次数限制方式

This commit is contained in:
zhl 2023-06-09 18:54:30 +08:00
parent 69511b567b
commit 7b0c5d203d

View File

@ -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,