|
@@ -118,7 +118,11 @@ public class UserCouponService {
|
|
|
/*
|
|
/*
|
|
|
自动获得优惠券
|
|
自动获得优惠券
|
|
|
*/
|
|
*/
|
|
|
- public void autoGetCoupon(Long packageId, Long userId) {
|
|
|
|
|
|
|
+ public void autoGetCoupon(Long orderInfoId, Long packageId, Long userId) {
|
|
|
|
|
+ UserCoupon userCoupon = userCouponRepo.findByOrderInfoId(orderInfoId);
|
|
|
|
|
+ if (ObjectUtil.isNotNull(userCoupon)) {
|
|
|
|
|
+ throw new BusinessException("该订单已获得");
|
|
|
|
|
+ }
|
|
|
Package aPackage = packageRepo.findById(packageId).orElseThrow(new BusinessException("无套餐"));
|
|
Package aPackage = packageRepo.findById(packageId).orElseThrow(new BusinessException("无套餐"));
|
|
|
if (CollUtil.isNotEmpty(aPackage.getCouponId())) {
|
|
if (CollUtil.isNotEmpty(aPackage.getCouponId())) {
|
|
|
List<Coupon> coupons = couponRepo.findAllByIdInAndPeriodAfter(aPackage.getCouponId(), LocalDateTime
|
|
List<Coupon> coupons = couponRepo.findAllByIdInAndPeriodAfter(aPackage.getCouponId(), LocalDateTime
|
|
@@ -126,6 +130,7 @@ public class UserCouponService {
|
|
|
if (CollUtil.isNotEmpty(coupons)) {
|
|
if (CollUtil.isNotEmpty(coupons)) {
|
|
|
UserCoupon build = UserCoupon.builder()
|
|
UserCoupon build = UserCoupon.builder()
|
|
|
.period(coupons.get(0).getPeriod())
|
|
.period(coupons.get(0).getPeriod())
|
|
|
|
|
+ .orderInfoId(orderInfoId)
|
|
|
.couponId(coupons.get(0).getId())
|
|
.couponId(coupons.get(0).getId())
|
|
|
.isUse(false)
|
|
.isUse(false)
|
|
|
.userId(userId)
|
|
.userId(userId)
|