diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 6a76356f..325653f2 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -56,14 +56,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { @Override public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) { - // 查询卡券库存数量 - Map map = new HashMap<>(); - map.put("couponId", highCouponAgentRel.getCouponId()); - map.put("status", 1); - map.put("salesEndTimeS", new Date().getTime()); - map.put("isAssignAgent", false); - - List codeList = highCouponCodeService.getCouponCodeList(map); + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId()); if (stockCount > codeList.size()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量"); } 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 849597ad..6a113771 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 @@ -220,7 +220,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { @Override public List 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); }