'提交代码'

dev-discount
199901012 4 years ago
parent 7bc67da23f
commit 0b90ceb53d
  1. 56
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  2. 11
      hai-service/src/main/java/com/hai/model/HighCouponModel.java
  3. 5
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java

@ -21,10 +21,7 @@ import com.hai.model.HighCouponHandselModel;
import com.hai.model.HighCouponModel; import com.hai.model.HighCouponModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.HighApproveService; import com.hai.service.*;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.HighMerchantService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -38,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -60,6 +58,9 @@ public class HighCouponController {
@Resource @Resource
private HighCouponService highCouponService; private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@ -155,28 +156,43 @@ public class HighCouponController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
// 查询卡券
HighCouponModel coupon = highCouponService.getCouponById(highCoupon.getId());
if (coupon == null) {
log.error("HighCouponController -> updateCoupon() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 是否赠送卡卷 // 是否赠送卡卷
if (highCoupon.getIsPresent() == true) { if (highCoupon.getIsPresent() == true) {
if (highCoupon.getHandselCouponList() == null || highCoupon.getHandselCouponList().size() == 0) { if (highCoupon.getHandselCouponId() == null || highCoupon.getHandselCouponId().size() == 0) {
log.error("HighCouponController -> updateCoupon() error!","请选择赠送卡卷名单");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SELECT_HANDSEL_COUPON_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.SELECT_HANDSEL_COUPON_ERROR, "");
} }
for (HighCouponHandsel handsel : highCoupon.getHandselCouponList()) {
// 如果没有id 就是需要增加的 HighCouponHandselModel highCouponHandsel;
if (handsel.getId() == null) { // 查询数据库中的赠送卡卷列表
handsel.setCreateTime(new Date()); List<HighCouponHandselModel> list = highCouponHandselService.getHandselListByCoupon(highCoupon.getId());
handsel.setStatus(1); // 状态 0:删除 1:正常 // 上传数据与数据库对比,需要新增的数据
handsel.setOperatorId(userInfoModel.getSecUser().getId()); for (Long couponId : highCoupon.getHandselCouponId()) {
handsel.setOperatorName(userInfoModel.getSecUser().getUserName()); List<HighCouponHandselModel> collect = list.stream().filter(o -> o.getHandselCouponId().equals(couponId)).collect(Collectors.toList());
if (collect == null || collect.size() == 0) {
highCouponHandsel = new HighCouponHandselModel();
highCouponHandsel.setHandselCouponId(couponId);
highCouponHandsel.setCreateTime(new Date());
highCouponHandsel.setStatus(1);
highCouponHandsel.setOperatorId(userInfoModel.getSecUser().getId());
highCouponHandsel.setOperatorName(userInfoModel.getSecUser().getUserName());
highCoupon.getHandselCouponList().add(highCouponHandsel);
} }
} }
}
// 查询卡券 // 上传数据与数据库对比,需要删除的数据
HighCouponModel coupon = highCouponService.getCouponById(highCoupon.getId()); for (HighCouponHandsel handsel : list) {
if (coupon == null) { List<Long> collect = highCoupon.getHandselCouponId().stream().filter(o -> o.equals(handsel.getHandselCouponId())).collect(Collectors.toList());
log.error("HighCouponController -> updateCoupon() error!","未找到卡卷信息"); if (collect == null || collect.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); handsel.setStatus(0);
}
}
} }
// 查询商户 // 查询商户
@ -190,7 +206,7 @@ public class HighCouponController {
highCoupon.setOperatorId(userInfoModel.getSecUser().getId()); highCoupon.setOperatorId(userInfoModel.getSecUser().getId());
highCoupon.setOperatorName(userInfoModel.getSecUser().getUserName()); highCoupon.setOperatorName(userInfoModel.getSecUser().getUserName());
highCoupon.setUpdateTime(new Date()); highCoupon.setUpdateTime(new Date());
highCoupon.setStatus(3); // 状态:0.删除 1.编辑中 2.已上架 3.已下架 101.上架审批中 102.上架审批驳回
highCouponService.updateCoupon(highCoupon); highCouponService.updateCoupon(highCoupon);
return ResponseMsgUtil.success(highCoupon); return ResponseMsgUtil.success(highCoupon);

@ -12,6 +12,9 @@ import java.util.List;
*/ */
public class HighCouponModel extends HighCoupon { public class HighCouponModel extends HighCoupon {
// 商户名称
private String merchantName;
// 库存数量 // 库存数量
private Integer stockCount; private Integer stockCount;
@ -21,6 +24,14 @@ public class HighCouponModel extends HighCoupon {
// 赠送卡卷 // 赠送卡卷
private List<HighCouponHandselModel> handselCouponList; private List<HighCouponHandselModel> handselCouponList;
public String getMerchantName() {
return merchantName;
}
public void setMerchantName(String merchantName) {
this.merchantName = merchantName;
}
public Integer getStockCount() { public Integer getStockCount() {
return stockCount; return stockCount;
} }

@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -41,6 +42,9 @@ public class HighCouponServiceImpl implements HighCouponService {
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@Resource
private HighMerchantService highMerchantService;
@Resource @Resource
private HighApproveService highApproveService; private HighApproveService highApproveService;
@ -291,6 +295,7 @@ public class HighCouponServiceImpl implements HighCouponService {
if (coupons != null && coupons.size() > 0) { if (coupons != null && coupons.size() > 0) {
List<HighCouponModel> models = JSON.parseArray(JSON.toJSONString(coupons), HighCouponModel.class); List<HighCouponModel> models = JSON.parseArray(JSON.toJSONString(coupons), HighCouponModel.class);
for (HighCouponModel highCouponModel : models) { for (HighCouponModel highCouponModel : models) {
highCouponModel.setMerchantName(highMerchantService.getMerchantById(highCouponModel.getMerchantId()).getMerchantName());
highCouponModel.setStockCount(highCouponCodeService.getStockCountByCoupon(highCouponModel.getId())); highCouponModel.setStockCount(highCouponCodeService.getStockCountByCoupon(highCouponModel.getId()));
} }
return models; return models;

Loading…
Cancel
Save