'增加销售码列表'

dev-discount
199901012 4 years ago
parent dc2e703c7c
commit 851998a07a
  1. 58
      hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java
  2. 18
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  3. 13
      hai-service/src/main/java/com/hai/model/HighCouponModel.java
  4. 11
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.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<String, Object> 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);
}
}
}

@ -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);
}
}

@ -15,8 +15,11 @@ public class HighCouponModel extends HighCoupon {
// 库存数量
private Integer stockCount;
// 赠送卡卷id
private List<Long> handselCouponId;
// 赠送卡卷
List<HighCouponHandselModel> handselCouponList;
private List<HighCouponHandselModel> handselCouponList;
public Integer getStockCount() {
return stockCount;
@ -26,6 +29,14 @@ public class HighCouponModel extends HighCoupon {
this.stockCount = stockCount;
}
public List<Long> getHandselCouponId() {
return handselCouponId;
}
public void setHandselCouponId(List<Long> handselCouponId) {
this.handselCouponId = handselCouponId;
}
public List<HighCouponHandselModel> getHandselCouponList() {
return handselCouponList;
}

@ -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<HighCouponCode> getCouponCodeList(Map<String, Object> 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);

Loading…
Cancel
Save