Commit 725c41cd by 吕明尚

验劵一个劵码只能一个人用

parent 6ecd89ce
......@@ -72,14 +72,17 @@ public class QPServiceImpl implements QPService {
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getDealId, prepare.getDeal_id());
queryWrapper.eq(SConsumerCoupon::getCouponCode, code);
queryWrapper.eq(SConsumerCoupon::getConsumerId, user.getId());
SConsumerCoupon one = isConsumerCouponService.getOne(queryWrapper);
//判断是否领取过
if (ObjectUtils.isNotEmpty(one)) {
//领取删除原来的
isConsumerCouponService.deleteSConsumerCouponById(one.getId());
//删除redis
redisUtil.delete(ReceiptRdeisEnum.PREPARE.getValue() + prepare.getReceipt_code());
SConsumerCoupon two = isConsumerCouponService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(two)) {
//判断是否本人领取过
if (!two.getConsumerId().equals(user.getId())) {
throw new RuntimeException("该券码已被领取");
} else {
//领取删除原来的
isConsumerCouponService.deleteSConsumerCouponById(two.getId());
//删除redis
redisUtil.delete(ReceiptRdeisEnum.PREPARE.getValue() + prepare.getReceipt_code());
}
}
//根据优惠卷名称查询优惠劵配置
SCoupon sCoupon = isCouponService.selectSCouponByName(prepare.getDeal_title());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment