|
|
|
@@ -200,24 +200,27 @@ public class WxCarController extends BaseController { |
|
|
|
logger.info(coupon.toString()); |
|
|
|
// Save to wx_counpon |
|
|
|
Date curDate = new Date(); |
|
|
|
// check 同一个模板的券分配额是否超了 |
|
|
|
if (StringUtils.isBlank(coupon.getVendorParams())) { |
|
|
|
logger.error("请填充停车厂商优免券参数"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "停车厂商参数为空"); |
|
|
|
} |
|
|
|
JSONObject vendorParamsObj = JSON.parseObject(coupon.getVendorParams()); |
|
|
|
Long templateId = vendorParamsObj.getLong("id"); |
|
|
|
Integer amount = vendorParamsObj.getInteger("amount"); |
|
|
|
Integer avaliavleNum = vendorParamsObj.getInteger("avaliavleNum"); |
|
|
|
Integer amtCount = wxCouponCarService.getAmtCountByTemplateId(templateId); |
|
|
|
Integer availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); |
|
|
|
if (amtCount >= amount) { |
|
|
|
logger.error("总库存已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "总库存已达到停车厂商优免券数量限制"); |
|
|
|
} |
|
|
|
if (availCount >= avaliavleNum) { |
|
|
|
logger.error("可用库存已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "可用库存已达到停车厂商优免券数量限制"); |
|
|
|
WxPark park = getCurrentPark(); |
|
|
|
if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { |
|
|
|
// check 同一个模板的券分配额是否超了 |
|
|
|
if (StringUtils.isBlank(coupon.getVendorParams())) { |
|
|
|
logger.error("请填充停车厂商优免券参数"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "停车厂商参数为空"); |
|
|
|
} |
|
|
|
JSONObject vendorParamsObj = JSON.parseObject(coupon.getVendorParams()); |
|
|
|
Long templateId = vendorParamsObj.getLong("id"); |
|
|
|
Integer amount = vendorParamsObj.getInteger("amount"); |
|
|
|
Integer avaliavleNum = vendorParamsObj.getInteger("avaliavleNum"); |
|
|
|
Integer amtCount = wxCouponCarService.getAmtCountByTemplateId(templateId); |
|
|
|
Integer availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); |
|
|
|
if (amtCount >= amount) { |
|
|
|
logger.error("总库存已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "总库存已达到停车厂商优免券数量限制"); |
|
|
|
} |
|
|
|
if (availCount >= avaliavleNum) { |
|
|
|
logger.error("可用库存已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "可用库存已达到停车厂商优免券数量限制"); |
|
|
|
} |
|
|
|
} |
|
|
|
// check End |
|
|
|
coupon.setTenantId(getTenantId()); |
|
|
|
@@ -231,8 +234,6 @@ public class WxCarController extends BaseController { |
|
|
|
WxCouponCar couponCar = new WxCouponCar(); |
|
|
|
couponCar.setId(coupon.getId()); |
|
|
|
couponCar.setTenantId(getTenantId()); |
|
|
|
|
|
|
|
WxPark park = getCurrentPark(); |
|
|
|
couponCar.setParkId(park.getId()); |
|
|
|
couponCar.setVendorType(park.getVendorType()); |
|
|
|
couponCar.setVendorParams(coupon.getVendorParams()); |
|
|
|
|