|
@@ -248,6 +248,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
if(CollectionUtils.isEmpty(activityDtos)){
|
|
|
throw new BizException("当前分部暂未开通活动");
|
|
|
}
|
|
|
+ logger.error("activeBuy params goodsId: {},liveId: {}",memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
Integer activityId = null;
|
|
|
//判断当前商品是否可以购买(库存、上架状态、是否购买过)
|
|
@@ -281,23 +282,32 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
//扣减库存
|
|
|
liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
|
|
|
} else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
|
|
|
- StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
|
|
|
- RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
|
|
|
- List<Integer> list = bucket.get();
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
- list = new ArrayList<>();
|
|
|
- }
|
|
|
- //当前用户是否购买过免费直播课
|
|
|
- if(list.contains(sysUser.getId())){
|
|
|
+ TempBuyFreeLiveTheoryCourse temp = tempBuyFreeLiveTheoryCourseDao.findByGoodsIdAndUserId(memberPayParamDto.getLiveGoodsId(),student.getUserId());
|
|
|
+ if(Objects.nonNull(temp)){
|
|
|
throw new BizException("您已领取过本轮免费直播课");
|
|
|
}
|
|
|
+// StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
|
|
|
+// RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
|
|
|
+// List<Integer> list = bucket.get();
|
|
|
+// if(CollectionUtils.isEmpty(list)){
|
|
|
+// list = new ArrayList<>();
|
|
|
+// }
|
|
|
+// //当前用户是否购买过免费直播课
|
|
|
+// if(list.contains(sysUser.getId())){
|
|
|
+// throw new BizException("您已领取过本轮免费直播课");
|
|
|
+// }
|
|
|
+ //购买次数是否超过2次
|
|
|
+// int count = tempBuyFreeLiveTheoryCourseDao.countByUserId(sysUser.getId());
|
|
|
+// if(count >= 2){
|
|
|
+// throw new BizException("免费直播课已达到领取次数上限");
|
|
|
+// }
|
|
|
//保存购买记录
|
|
|
tempBuyFreeLiveTheoryCourseDao.insert(
|
|
|
new TempBuyFreeLiveTheoryCourse(sysUser.getId(),memberPayParamDto.getLiveId(),memberPayParamDto.getLiveGoodsId()));
|
|
|
//扣减库存
|
|
|
liveGoodsService.reduceGoodsStock(memberPayParamDto.getLiveGoodsId(),memberPayParamDto.getLiveId());
|
|
|
- list.add(sysUser.getId());
|
|
|
- bucket.set(list);
|
|
|
+// list.add(sysUser.getId());
|
|
|
+// bucket.set(list);
|
|
|
return BaseController.succeed();
|
|
|
}else {
|
|
|
throw new BizException("当前商品不可购买");
|
|
@@ -350,17 +360,27 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
}
|
|
|
}
|
|
|
} else if (memberPayParamDto.getLiveGoodsId() == 2 || memberPayParamDto.getLiveGoodsId() == 3 || memberPayParamDto.getLiveGoodsId() == 4){
|
|
|
- StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
|
|
|
- RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
|
|
|
- List<Integer> list = bucket.get();
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
- list = new ArrayList<>();
|
|
|
- }
|
|
|
- //当前用户是否购买过免费直播课
|
|
|
- if(list.contains(sysUser.getId())){
|
|
|
- succeed.setMsg("您已领取过本轮免费直播课");
|
|
|
- return succeed;
|
|
|
+ TempBuyFreeLiveTheoryCourse temp = tempBuyFreeLiveTheoryCourseDao.findByGoodsIdAndUserId(memberPayParamDto.getLiveGoodsId(),sysUser.getId());
|
|
|
+ if(Objects.nonNull(temp)){
|
|
|
+ throw new BizException("您已领取过本轮免费直播课");
|
|
|
}
|
|
|
+// StringBuffer sb = new StringBuffer(RedisKeyConstant.LIVE_GOODS_ZERO_CACHE_KEY).append(memberPayParamDto.getLiveGoodsId());
|
|
|
+// RBucket<List<Integer>> bucket = redissonClient.getBucket(sb.toString());
|
|
|
+// List<Integer> list = bucket.get();
|
|
|
+// if(CollectionUtils.isEmpty(list)){
|
|
|
+// list = new ArrayList<>();
|
|
|
+// }
|
|
|
+// //当前用户是否购买过免费直播课
|
|
|
+// if(list.contains(sysUser.getId())){
|
|
|
+// succeed.setMsg("您已领取过本轮免费直播课");
|
|
|
+// return succeed;
|
|
|
+// }
|
|
|
+ //购买次数是否超过2次
|
|
|
+// int count = tempBuyFreeLiveTheoryCourseDao.countByUserId(sysUser.getId());
|
|
|
+// if(count >= 2){
|
|
|
+// succeed.setMsg("免费直播课已达到领取次数上限");
|
|
|
+// return succeed;
|
|
|
+// }
|
|
|
}else {
|
|
|
succeed.setMsg("当前商品不可购买");
|
|
|
return succeed;
|