|
@@ -66,10 +66,12 @@ class UserCouponService extends CrudService {
|
|
|
const { expire_type, expire_config, get_limit_config, get_limit, _id } = coupon;
|
|
|
// 1.检查优惠券是否生效: expire
|
|
|
const tr = this.checkCanGet_expire(expire_type, expire_config);
|
|
|
+ console.log(tr);
|
|
|
if (!tr.result) return tr;
|
|
|
// 2.不需要检查减免配置和使用配置,这两个配置是在使用的时候才检查
|
|
|
// 检查领取配置
|
|
|
- const gr = this.checkCanGet_get(get_limit, get_limit_config, _id);
|
|
|
+ const gr = await this.checkCanGet_get(get_limit, get_limit_config, _id);
|
|
|
+ console.log(gr);
|
|
|
if (!gr.result) return gr;
|
|
|
return { result: true };
|
|
|
}
|
|
@@ -108,7 +110,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, customer });
|
|
|
+ const num = await this.model.count({ 'coupon._id': coupon, customer });
|
|
|
if (num >= max) {
|
|
|
res.result = false;
|
|
|
res.msg = '该优惠券已到达领取上限';
|
|
@@ -342,7 +344,6 @@ class UserCouponService extends CrudService {
|
|
|
const { goods_total } = g;
|
|
|
const id = _.get(g, 'goodsSpec._id');
|
|
|
let dm = 0;
|
|
|
- console.log(goods_total, goodsTotal);
|
|
|
// 除了最后一个商品,其余的商品均按比例分配
|
|
|
if (i < goodsList.length - 1) {
|
|
|
const percent = this.ctx.divide(goods_total, goodsTotal);
|
|
@@ -352,7 +353,6 @@ class UserCouponService extends CrudService {
|
|
|
// 最后一个商品是剩余的可分配的钱
|
|
|
dm = this.ctx.minus(discountRealMoney, allReadyDiscount);
|
|
|
}
|
|
|
- console.log(dm);
|
|
|
result[id] = dm;
|
|
|
}
|
|
|
return result;
|
|
@@ -373,7 +373,6 @@ class UserCouponService extends CrudService {
|
|
|
const id = _.get(g, 'goodsSpec._id');
|
|
|
const realPay = this.ctx.multiply(goods_total, percent);
|
|
|
const discountMoney = this.ctx.minus(goods_total, realPay);
|
|
|
- console.log(discountMoney);
|
|
|
result[id] = discountMoney;
|
|
|
}
|
|
|
return result;
|