增加返回礼品码状态: 已被使用
This commit is contained in:
parent
afb3317e05
commit
94ade64cd1
@ -97,10 +97,16 @@ class VoucherController extends BaseController {
|
|||||||
if (!id || !isValidVoucherCode(id)) {
|
if (!id || !isValidVoucherCode(id)) {
|
||||||
throw new ZError(10, 'invild voucher code')
|
throw new ZError(10, 'invild voucher code')
|
||||||
}
|
}
|
||||||
const record = await VoucherRecord.findOne({ code: id, status: VoucherStatusEnum.NORMAL })
|
const record = await VoucherRecord.findOne({ code: id })
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new ZError(11, 'voucher not found')
|
throw new ZError(11, 'voucher not found')
|
||||||
}
|
}
|
||||||
|
if (record.status === VoucherStatusEnum.USED) {
|
||||||
|
throw new ZError(12, 'voucher already used')
|
||||||
|
}
|
||||||
|
if (record.status !== VoucherStatusEnum.NORMAL) {
|
||||||
|
throw new ZError(11, 'voucher not found')
|
||||||
|
}
|
||||||
record.status = VoucherStatusEnum.USED
|
record.status = VoucherStatusEnum.USED
|
||||||
record.user = user.id
|
record.user = user.id
|
||||||
if (record.bonusScores.length > 0) {
|
if (record.bonusScores.length > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user