|
@@ -39,6 +39,7 @@ class UserCouponService extends CrudService {
|
|
|
const canGet = this.ctx.minus(coupon.num, 1) < 0;
|
|
|
if (canGet) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '您手慢了,没抢到');
|
|
|
const res = await this.checkCouponCanGet(coupon);
|
|
|
+ console.log(res);
|
|
|
if (!res.result) return res;
|
|
|
const customer = _.get(this.ctx, 'user._id');
|
|
|
if (!customer) throw new BusinessError(ErrorCode.NOT_LOGIN, '未找到用户信息');
|
|
@@ -108,7 +109,7 @@ class UserCouponService extends CrudService {
|
|
|
// 需要找到用户
|
|
|
const customer = _.get(this.ctx, 'user._id');
|
|
|
if (!customer) throw new BusinessError(ErrorCode.NOT_LOGIN, '未找到用户信息');
|
|
|
- const num = await this.model.count({ coupon, user: customer });
|
|
|
+ const num = await this.model.count({ coupon, customer });
|
|
|
if (num >= max) {
|
|
|
res.result = false;
|
|
|
res.msg = '该优惠券已到达领取上限';
|