'优化卡券分配问题'

dev-discount
199901012 4 years ago
parent 4db8ade1cc
commit d1792fa55b
  1. 10
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  2. 2
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java

@ -56,14 +56,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
@Override
public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) {
// 查询卡券库存数量
Map<String,Object> map = new HashMap<>();
map.put("couponId", highCouponAgentRel.getCouponId());
map.put("status", 1);
map.put("salesEndTimeS", new Date().getTime());
map.put("isAssignAgent", false);
List<HighCouponCode> codeList = highCouponCodeService.getCouponCodeList(map);
// 查询未销售的卡券
List<HighCouponCode> codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId());
if (stockCount > codeList.size()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量");
}

@ -220,7 +220,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
@Override
public List<HighCouponCode> getNoSaleCode(Long couponId) {
HighCouponCodeExample example = new HighCouponCodeExample();
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1).andIsAssignAgentEqualTo(false);
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1).andIsAssignAgentEqualTo(false).andSalesEndTimeGreaterThan(new Date());
return highCouponCodeMapper.selectByExample(example);
}

Loading…
Cancel
Save