获取优惠券列表时, 将已过期的券更新状态

This commit is contained in:
zhl 2021-07-05 13:33:09 +08:00
parent af07065013
commit afc4a8faa7

View File

@ -155,6 +155,13 @@ class UserCouponClass extends BaseModule {
let couponMap: Map<string, any> = new Map()
for (let record of records) {
let sid = record.shop
if (record.expire) {
// 如果有过期时间设置, 且已经过期, 则将未使用和已分享但未被领取的记录更新为已过期
if (Date.now() >= record.expire && (record.status === 0 || record.status === 2) ) {
record.status = 9
await record.save()
}
}
if (!shopMap.has(record.shop)) {
let shop = await Shop.fetchByID(record.shop)
shopMap.set(record.shop, shop.showName)