diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index 6c83b6c7..34462404 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -201,6 +201,7 @@ public class HighCouponAgentController { @ResponseBody @ApiOperation(value = "根据代理商和卡券 查询分配的销售码") public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId, + @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { @@ -216,6 +217,7 @@ public class HighCouponAgentController { Map map = new HashMap<>(); map.put("agentId", userInfoModel.getHighAgent().getId()); map.put("couponId", couponId); + map.put("status", status); PageHelper.startPage(pageNum,pageSize); PageInfo pageInfo = new PageInfo<>(highCouponAgentService.getCouponCodeList(map)); 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 dbfbfccc..2ed2bb97 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 @@ -1,5 +1,6 @@ package com.hai.service.impl; +import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -20,6 +21,8 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @Auther: 胡锐 @@ -50,6 +53,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { map.put("status", 1); map.put("salesEndTimeS", new Date().getTime()); map.put("isAssignAgent", false); + List codeList = highCouponCodeService.getCouponCodeList(map); if (highCouponAgentRel.getStockCount() > codeList.size()) { @@ -58,8 +62,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { highCouponAgentRelMapper.insert(highCouponAgentRel); + List assignCouponCodeList = codeList.stream().limit(highCouponAgentRel.getStatus()).collect(Collectors.toList()); HighCouponAgentCode highCouponAgentCode; - for (HighCouponCode code : codeList) { + for (HighCouponCode code : assignCouponCodeList) { code.setAgentId(highCouponAgentRel.getAgentId()); code.setIsAssignAgent(true); highCouponCodeService.updateCouponCode(code);