From 7401f869206ffe9f1b248522c0f1116e41a4b4a7 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Sat, 21 Sep 2019 16:31:49 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=81=9C=E8=BD=A6][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E5=81=9C=E8=BD=A6=E5=88=B8=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/car/WxCarController.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java b/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java index 5932cd627..2b6eddba0 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java @@ -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());