修改支付接口次数限制方式
This commit is contained in:
parent
69511b567b
commit
7b0c5d203d
@ -26,12 +26,24 @@ class AlchemyController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tokenResult = await refreshToken(user.emailReal || user.email)
|
const tokenResult = await refreshToken(user.emailReal || user.email)
|
||||||
console.log(tokenResult)
|
|
||||||
if (!tokenResult.success || tokenResult.returnCode !== '0000') {
|
if (!tokenResult.success || tokenResult.returnCode !== '0000') {
|
||||||
logger.info(`fetch pay token error::code: ${tokenResult.returnCode} msg: ${tokenResult.returnMsg}`)
|
logger.info(`fetch pay token error::code: ${tokenResult.returnCode} msg: ${tokenResult.returnMsg}`)
|
||||||
throw new ZError(10, 'fetch pay token error')
|
throw new ZError(10, 'fetch pay token error')
|
||||||
}
|
}
|
||||||
const { id, email, accessToken } = tokenResult.data
|
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({
|
let record = new PayRecord({
|
||||||
account: user.id,
|
account: user.id,
|
||||||
address,
|
address,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user