|
|
|
@ -75,6 +75,11 @@ public class HighCouponController { |
|
|
|
|
try { |
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (userInfoModel.getBsCompany() == null) { |
|
|
|
|
log.error("HighCouponController -> insertCoupon() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highCoupon.getMerchantId() == null |
|
|
|
|
|| StringUtils.isBlank(highCoupon.getCouponName()) |
|
|
|
|
|| StringUtils.isBlank(highCoupon.getCouponImg()) |
|
|
|
@ -93,11 +98,8 @@ public class HighCouponController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
map.put("couponName", highCoupon.getCouponName()); |
|
|
|
|
|
|
|
|
|
if (highCouponService.getCouponByCouponName(map) > 0) { |
|
|
|
|
// 校验名称是否重复
|
|
|
|
|
if (highCouponService.getCouponByCouponName(userInfoModel.getBsCompany().getId(),highCoupon.getCouponName()) > 0) { |
|
|
|
|
log.error("HighCouponController -> insertCoupon() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_CODE_NAME, ""); |
|
|
|
|
} |
|
|
|
@ -191,11 +193,6 @@ public class HighCouponController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
map.put("couponName", highCoupon.getCouponName()); |
|
|
|
|
|
|
|
|
|
// 查询卡券
|
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(highCoupon.getId()); |
|
|
|
|
if (coupon == null) { |
|
|
|
@ -203,13 +200,12 @@ public class HighCouponController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (highCouponService.getCouponByCouponName(map) > 0 && !coupon.getCouponName().equals(highCoupon.getCouponName())) { |
|
|
|
|
log.error("HighCouponController -> updateCoupon() error!","参数错误"); |
|
|
|
|
// 校验名称是否重复
|
|
|
|
|
if (!highCoupon.getCouponName().equals(coupon.getCouponName()) && highCouponService.getCouponByCouponName(userInfoModel.getBsCompany().getId(),highCoupon.getCouponName()) > 0) { |
|
|
|
|
log.error("HighCouponController -> insertCoupon() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_CODE_NAME, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 是否赠送卡卷
|
|
|
|
|
if (highCoupon.getIsPresent()) { |
|
|
|
|
if (highCoupon.getHandselCouponId() == null || highCoupon.getHandselCouponId().size() == 0) { |
|
|
|
@ -254,16 +250,26 @@ public class HighCouponController { |
|
|
|
|
log.error("HighCouponController -> updateCoupon() error!","未找到商户"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highCoupon.setCompanyId(merchant.getCompanyId()); |
|
|
|
|
highCoupon.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
highCoupon.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
highCoupon.setUpdateTime(new Date()); |
|
|
|
|
highCoupon.setHandselCouponList(coupon.getHandselCouponList()); |
|
|
|
|
highCoupon.setStatus(3); // 状态:0.删除 1.编辑中 2.已上架 3.已下架 101.上架审批中 102.上架审批驳回
|
|
|
|
|
highCouponService.updateCoupon(highCoupon); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highCoupon); |
|
|
|
|
coupon.setCouponSource(highCoupon.getCouponSource()); |
|
|
|
|
coupon.setMerchantId(highCoupon.getMerchantId()); |
|
|
|
|
coupon.setCouponName(highCoupon.getCouponName()); |
|
|
|
|
coupon.setCouponImg(highCoupon.getCouponImg()); |
|
|
|
|
coupon.setCouponCarouselImg(highCoupon.getCouponCarouselImg()); |
|
|
|
|
coupon.setCouponDesc(highCoupon.getCouponDesc()); |
|
|
|
|
coupon.setPayType(highCoupon.getPayType()); |
|
|
|
|
coupon.setSalesEndTime(highCoupon.getSalesEndTime()); |
|
|
|
|
coupon.setRecycleDay(highCoupon.getRecycleDay()); |
|
|
|
|
coupon.setLimitNumber(highCoupon.getLimitNumber()); |
|
|
|
|
coupon.setSalesPrice(highCoupon.getSalesPrice()); |
|
|
|
|
coupon.setDiscountPrice(highCoupon.getDiscountPrice()); |
|
|
|
|
coupon.setIsPresent(highCoupon.getIsPresent()); |
|
|
|
|
coupon.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
coupon.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
coupon.setUpdateTime(new Date()); |
|
|
|
|
coupon.setStatus(3); // 状态:0.删除 1.编辑中 2.已上架 3.已下架 101.上架审批中 102.上架审批驳回
|
|
|
|
|
highCouponService.updateCoupon(coupon); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(coupon); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponController -> updateCoupon() error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|