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