diff --git a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java index 6917116b..e890f887 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java @@ -34,6 +34,13 @@ public interface HighUserCouponService { **/ List getOverdueCoupon(); + /** + * @Author 胡锐 + * @Description 根据卡卷销售码id查询 + * @Date 2021/3/29 23:28 + **/ + HighUserCoupon getDetailByCodeId(Long couponCodeId); + /** * @Author 胡锐 * @Description 查询用户列表 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index b59343e2..a29517ac 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -8,13 +8,11 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; import com.hai.dao.HighCouponCodeMapper; import com.hai.dao.HighCouponCodeMapperExt; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighCouponCode; -import com.hai.entity.HighCouponCodeExample; -import com.hai.entity.HighOrder; +import com.hai.entity.*; import com.hai.model.UserInfoModel; import com.hai.service.HighCouponCodeService; import com.hai.service.HighOrderService; +import com.hai.service.HighUserCouponService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -44,6 +42,9 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { @Resource private HighOrderService highOrderService; + @Resource + private HighUserCouponService highUserCouponService; + @Override public void insertCouponCode(HighCouponCode highCouponCode) { highCouponCodeMapper.insert(highCouponCode); @@ -91,6 +92,14 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { salesCode.setStatus(3); updateCouponCode(salesCode); + //修改 用户与卡卷的关系 + HighUserCoupon userCoupon = highUserCouponService.getDetailByCodeId(salesCode.getId()); + if (userCoupon == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常"); + } + userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponService.updateUserCoupon(userCoupon); + highOrderService.childOrderComplete(salesCode.getChildOrderId()); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java index 7acee4f8..18f09549 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java @@ -43,6 +43,18 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { return highUserCouponMapper.selectByExample(example); } + @Override + public HighUserCoupon getDetailByCodeId(Long couponCodeId) { + + HighUserCouponExample example = new HighUserCouponExample(); + example.createCriteria().andStatusEqualTo(1).andCouponCodeIdEqualTo(couponCodeId); + List highUserCoupons = highUserCouponMapper.selectByExample(example); + if (highUserCoupons.size() > 0) { + return highUserCoupons.get(0); + } + return null; + } + @Override public List getUserCouponList(Map map) { HighUserCouponExample example = new HighUserCouponExample();