|
@@ -1678,21 +1678,24 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
couponUser.setCouponId(exists.getPopularizeCouponId());
|
|
couponUser.setCouponId(exists.getPopularizeCouponId());
|
|
|
couponUser.setPopularizeId(exists.getPopularizeId());
|
|
couponUser.setPopularizeId(exists.getPopularizeId());
|
|
|
}
|
|
}
|
|
|
- //非渠道推广 推广优惠码只可使用一次
|
|
|
|
|
- if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
|
|
|
|
|
- CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
|
|
|
|
|
- if (received != null && received.getStatus() != CouponUser.Status.unused) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");
|
|
|
|
|
- }
|
|
|
|
|
- couponUser.setUserId(userId);
|
|
|
|
|
- couponUser.setStatus(CouponUser.Status.used);
|
|
|
|
|
- couponUser.setChannel(CouponUser.Channel.exCode);
|
|
|
|
|
- couponFontService.updateCouponUserValidTime(couponUser.getCouponId(), couponUser);
|
|
|
|
|
- try {
|
|
|
|
|
- couponUserMapper.insert(couponUser);
|
|
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
|
|
- log.info("用户已领取该{}优惠券", couponUser.getCouponId());
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("您已领取该优惠码对应的优惠券,请使用优惠券");
|
|
|
|
|
|
|
+ //续费优惠码可重复使用
|
|
|
|
|
+ if (exists.getUseScope() != Coupon.UseScope.renew) {
|
|
|
|
|
+ //非渠道推广 推广优惠码只可使用一次
|
|
|
|
|
+ if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
|
|
|
|
|
+ CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
|
|
|
|
|
+ if (received != null && received.getStatus() != CouponUser.Status.unused) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");
|
|
|
|
|
+ }
|
|
|
|
|
+ couponUser.setUserId(userId);
|
|
|
|
|
+ couponUser.setStatus(CouponUser.Status.used);
|
|
|
|
|
+ couponUser.setChannel(CouponUser.Channel.exCode);
|
|
|
|
|
+ couponFontService.updateCouponUserValidTime(couponUser.getCouponId(), couponUser);
|
|
|
|
|
+ try {
|
|
|
|
|
+ couponUserMapper.insert(couponUser);
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ log.info("用户已领取该{}优惠券", couponUser.getCouponId());
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("您已领取该优惠码对应的优惠券,请使用优惠券");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|