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