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