diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index 2e2671f98..22d6531dd 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -140,16 +140,6 @@ public class WxCouponController extends BaseController { } return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 } - - //有价券开启了分账,必须在30天以内。,停车券,积分券,积分停车券,卡无次限制 - private boolean validCouponDate(TenantEntity tenantEntity,WxCoupon wxCoupon) { - WxPayAccount payAccount = wxPayAccountService.getByTenantId(tenantEntity.getTenantId()); - boolean isShare = false; - if (payAccount.checkShare()) { - isShare = true; - } - return wxCoupon.validDate(isShare,true,new Date()); - } @ApiOperation("新增接口") @PostMapping("add") @@ -162,10 +152,6 @@ public class WxCouponController extends BaseController { if(null == wxCoupon.getSourceType()){ wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); } - - if(!validCouponDate(this.getTenantInfo(),wxCoupon)) { - return new ResultData(ResultData.ERROR,"券有效使用日期必须在30天以内。"); - } ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon); if (resultData.code != 200) { @@ -191,10 +177,6 @@ public class WxCouponController extends BaseController { return new ResultData(ResultData.ERROR, "缺少id"); } - if(!validCouponDate(this.getTenantInfo(),wxCoupon)) { - return new ResultData(ResultData.ERROR,"券有效使用日期必须在30天以内。"); - } - wxCoupon.updateTenantInfo(getTenantInfo()); if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){ WxCouponChannel query = new WxCouponChannel(); @@ -266,10 +248,6 @@ public class WxCouponController extends BaseController { } } - if(!validCouponDate(this.getTenantInfo(),wxCoupon)) { - return new ResultData(ResultData.ERROR,"券有效使用日期必须在30天以内。"); - } - if (wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) || wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) { logger.error("券库存有效期不支持停车券"); @@ -278,27 +256,34 @@ public class WxCouponController extends BaseController { wxCoupon.updateTenantInfo(getTenantInfo()); WxCoupon coupon = wxCouponService.findById(wxCoupon); - if (coupon != null) { - if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate())) - && wxCoupon.getInventory().equals(coupon.getInventory())) - || - (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) && - wxCoupon.getValidDays().equals(coupon.getValidDays())) - ) { - return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); - } + if (coupon == null) { + return new ResultData(ErrorCode.COUPON_IS_EMPTY); + } + if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate())) + && wxCoupon.getInventory().equals(coupon.getInventory())) + || + (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) && + wxCoupon.getValidDays().equals(coupon.getValidDays())) + ) { + return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); + } - if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) { - return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); - } - if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) { - return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); - } + if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) { + return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); + } + if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) { + return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); + } - if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) { - return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); - } + if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) { + return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); } + wxCoupon.setSalePrice(coupon.getSalePrice()); + if(!wxCouponService.validCouponDate(wxCoupon)) { + return new ResultData(ResultData.ERROR,"券有效使用日期必须在30天以内。"); + } + wxCoupon.setSalePrice(null); + //启动审批流 if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index 0b5f0724d..34181ef13 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -251,4 +251,7 @@ public interface WxCouponService { */ ResultData cardDefer(Long id,String tenantId,Date validEndDate); + + boolean validCouponDate(WxCoupon wxCoupon); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 91b3d0ab3..d85fd257b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -363,6 +363,10 @@ public class WxCouponServiceImpl implements WxCouponService { } } + if(!this.validCouponDate(record)) { + return new ResultData(ResultData.ERROR,"券有效使用日期必须在30天以内。"); + } + if (EnumCouponContentType.HTML.getCode().equals(record.getContentType())) { if (StringUtils.isEmpty(record.getHtml())) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写富文本内容"); @@ -953,5 +957,16 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(); } + //有价券开启了分账,必须在30天以内。,停车券,积分券,积分停车券,卡无次限制 + @Override + public boolean validCouponDate(WxCoupon wxCoupon) { + WxPayAccount payAccount = payAccountMapper.getByTenantId(wxCoupon.getTenantId()); + boolean isShare = false; + if (payAccount.checkShare()) { + isShare = true; + } + return wxCoupon.validDate(isShare,true,new Date()); + } + }