|
|
@ -102,7 +102,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public HighUserCoupon getUserCoupon(Long userId, Long couponId) { |
|
|
|
public HighUserCoupon getUserCoupon(Long userId, Long couponId) { |
|
|
|
HighUserCouponExample example = new HighUserCouponExample(); |
|
|
|
HighUserCouponExample example = new HighUserCouponExample(); |
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId); |
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andStatusNotEqualTo(100); |
|
|
|
List<HighUserCoupon> coupons = highUserCouponMapper.selectByExample(example); |
|
|
|
List<HighUserCoupon> coupons = highUserCouponMapper.selectByExample(example); |
|
|
|
if (coupons != null && coupons.size() > 0) { |
|
|
|
if (coupons != null && coupons.size() > 0) { |
|
|
|
return coupons.get(0); |
|
|
|
return coupons.get(0); |
|
|
@ -133,20 +133,22 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法重新领取"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法重新领取"); |
|
|
|
} |
|
|
|
} |
|
|
|
userCoupon.setStatus(100); // 删除
|
|
|
|
userCoupon.setStatus(100); // 删除
|
|
|
|
|
|
|
|
highUserCouponMapper.updateByPrimaryKey(userCoupon); |
|
|
|
|
|
|
|
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(userCoupon.getCouponId()); |
|
|
|
HighCoupon coupon = highCouponService.getCouponById(userCoupon.getCouponId()); |
|
|
|
if (coupon == null) { |
|
|
|
if (coupon == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡卷"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡卷"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询待销售
|
|
|
|
// 查询待销售
|
|
|
|
List<HighCouponCode> list = highCouponCodeService.getNoSaleCode(coupon.getId()); |
|
|
|
List<HighCouponCode> list = highCouponCodeService.getNoSaleCode(coupon.getId()); |
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + "暂无库存,请联系客服"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + "暂无库存,请联系客服"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HighCouponCode highCouponCode = list.get(0); |
|
|
|
HighCouponCode highCouponCode = list.get(0); |
|
|
|
highCouponCode.setChildOrderId(userCoupon.getId()); |
|
|
|
//highCouponCode.setChildOrderId(userCoupon.getId());
|
|
|
|
highCouponCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
|
|
|
|
highCouponCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
|
|
|
|
|
|
|
|
highCouponCode.setReceiveTime(new Date()); |
|
|
|
highCouponCodeService.updateCouponCode(highCouponCode); |
|
|
|
highCouponCodeService.updateCouponCode(highCouponCode); |
|
|
|
|
|
|
|
|
|
|
|
// 卡卷关联用户
|
|
|
|
// 卡卷关联用户
|
|
|
@ -166,6 +168,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { |
|
|
|
highUserCoupon.setUseEndTime(userEndTime.getTime()); |
|
|
|
highUserCoupon.setUseEndTime(userEndTime.getTime()); |
|
|
|
} |
|
|
|
} |
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
highUserCoupon.setQrCodeImg(highCouponCode.getExt1()); |
|
|
|
highUserCouponMapper.insert(highUserCoupon); |
|
|
|
highUserCouponMapper.insert(highUserCoupon); |
|
|
|
|
|
|
|
|
|
|
|
return highUserCoupon; |
|
|
|
return highUserCoupon; |
|
|
@ -187,7 +190,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { |
|
|
|
// 查询卡券信息
|
|
|
|
// 查询卡券信息
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId()); |
|
|
|
HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId()); |
|
|
|
|
|
|
|
|
|
|
|
HighChildOrder childOrder = highOrderService.getChildOrderById(couponCode.getChildOrderId()); |
|
|
|
HighChildOrder childOrder = highOrderService.getChildOrderByUserGoods(highUserCoupon.getUserId(),1, highUserCoupon.getCouponCodeId()); |
|
|
|
HighOrder order = highOrderService.getOrderById(childOrder.getOrderId()); |
|
|
|
HighOrder order = highOrderService.getOrderById(childOrder.getOrderId()); |
|
|
|
|
|
|
|
|
|
|
|
// 归库记录
|
|
|
|
// 归库记录
|
|
|
|