diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 33cd5ac4..31f26ca2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -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 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 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); diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 683b1db1..9ad7684b 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -93,6 +93,9 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/coupon/getCouponList") .excludePathPatterns("/wechatpay/*") .excludePathPatterns("/coupon/getCouponById") + .excludePathPatterns("/discount/getDiscountByQrCode") + .excludePathPatterns("/discount/getDiscountById") + .excludePathPatterns("/discount/getCouponByDiscount") .excludePathPatterns("/highMerchantStore/getMerchantStoreById") .excludePathPatterns("/highMerchantStore/getStoreListByCoupon") .excludePathPatterns("/highMerchantStore/getMerchantList") diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index 37bb1dad..7dc3e38e 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -103,7 +103,7 @@ public interface HighCouponService { * @Description 获取数量 * @Date 2021/3/15 23:12 **/ - Long getCouponByCouponName(Map map); + Long getCouponByCouponName(Long companyId,String couponName); /** * @Author 胡锐 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index b269061f..0016aa81 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -373,16 +373,9 @@ public class HighCouponServiceImpl implements HighCouponService { } @Override - public Long getCouponByCouponName(Map map) { - + public Long getCouponByCouponName(Long companyId,String couponName) { HighCouponExample example = new HighCouponExample(); - HighCouponExample.Criteria criteria = example.createCriteria(); - - if (StringUtils.isNotBlank(MapUtils.getString(map, "couponName"))) { - criteria.andCouponNameEqualTo(MapUtils.getString(map, "couponName")); - } - - + example.createCriteria().andCompanyIdEqualTo(companyId).andCouponNameEqualTo(couponName); return highCouponMapper.countByExample(example); }