diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java new file mode 100644 index 00000000..173bc0e9 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java @@ -0,0 +1,58 @@ +package com.bweb.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighCouponCode; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighCouponCodeService; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +/** + * @Auther: 胡锐 + * @Description: 卡卷销售码 + * @Date: 2021/3/22 19:39 + */ +public class HighCouponCodeController { + + private static Logger log = LoggerFactory.getLogger(HighCouponCodeController.class); + + @Resource + private HighCouponCodeService highCouponCodeService; + + @RequestMapping(value="/getCouponCodeList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "销售码列表") + public ResponseData getCouponCodeList(@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) { + try { + Map map = new HashMap<>(); + map.put("couponId", couponId); + map.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highCouponCodeService.getCouponCodeList(map))); + } catch (Exception e) { + log.error("HighCouponController -> getCouponCodeList() error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 02852670..3a0c8ca7 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -17,6 +17,7 @@ import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.enum_type.ApproveType; +import com.hai.model.HighCouponHandselModel; import com.hai.model.HighCouponModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; @@ -90,15 +91,20 @@ public class HighCouponController { // 是否赠送卡卷 if (highCoupon.getIsPresent() == true) { - if (highCoupon.getHandselCouponList() == null || highCoupon.getHandselCouponList().size() == 0) { + if (highCoupon.getHandselCouponId() == null || highCoupon.getHandselCouponId().size() == 0) { log.error("HighCouponController -> insertCoupon() error!","请选择赠送卡卷名单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SELECT_HANDSEL_COUPON_ERROR, ""); } - for (HighCouponHandsel handsel : highCoupon.getHandselCouponList()) { - handsel.setCreateTime(new Date()); - handsel.setStatus(1); // 状态 0:删除 1:正常 - handsel.setOperatorId(userInfoModel.getSecUser().getId()); - handsel.setOperatorName(userInfoModel.getSecUser().getUserName()); + + HighCouponHandselModel highCouponHandsel; + for (Long couponId : highCoupon.getHandselCouponId()) { + highCouponHandsel = new HighCouponHandselModel(); + highCouponHandsel.setHandselCouponId(couponId); + highCouponHandsel.setCreateTime(new Date()); + highCouponHandsel.setStatus(1); // 状态 0:删除 1:正常 + highCouponHandsel.setOperatorId(userInfoModel.getSecUser().getId()); + highCouponHandsel.setOperatorName(userInfoModel.getSecUser().getUserName()); + highCoupon.getHandselCouponList().add(highCouponHandsel); } } diff --git a/hai-service/src/main/java/com/hai/model/HighCouponModel.java b/hai-service/src/main/java/com/hai/model/HighCouponModel.java index 8e47d115..2925ff0a 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponModel.java @@ -15,8 +15,11 @@ public class HighCouponModel extends HighCoupon { // 库存数量 private Integer stockCount; + // 赠送卡卷id + private List handselCouponId; + // 赠送卡卷 - List handselCouponList; + private List handselCouponList; public Integer getStockCount() { return stockCount; @@ -26,6 +29,14 @@ public class HighCouponModel extends HighCoupon { this.stockCount = stockCount; } + public List getHandselCouponId() { + return handselCouponId; + } + + public void setHandselCouponId(List handselCouponId) { + this.handselCouponId = handselCouponId; + } + public List getHandselCouponList() { return handselCouponList; } 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 3e13b7c1..882d276f 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 @@ -5,6 +5,7 @@ import com.hai.dao.HighCouponCodeMapperExt; import com.hai.entity.HighCouponCode; import com.hai.entity.HighCouponCodeExample; import com.hai.service.HighCouponCodeService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -46,7 +47,15 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { @Override public List getCouponCodeList(Map map) { HighCouponCodeExample example = new HighCouponCodeExample(); - example.createCriteria(); + HighCouponCodeExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "couponId") != null) { + criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); + } + + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } example.setOrderByClause("create_time desc"); return highCouponCodeMapper.selectByExample(example);