From 5794bb4228dd7ae3b83b01ecf4a8ae24bf1a2459 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 14 May 2019 14:54:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BA=93=E5=AD=98][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E5=88=B8=E5=BA=93=E5=AD=98=E6=9C=89=E6=95=88=E6=9C=9F=E6=9C=AA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/common/ErrorCode.java | 1 + .../service/impl/WxCouponServiceImpl.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index 459ea05d8..3cd142561 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -108,6 +108,7 @@ public enum ErrorCode{ COUPON_CHANNEL_IS_END(2033, "此券活动已结束"), COUPON_STOCK_ERR(2034, "券库存设置错误"), COUPON_VALID_DATE_ERR(2035, "券有效期设置错误"), + COUPON_STOCK_VALID_DATE_SETTING_ERR(2036, "券库存有效期未修改"), PUSH_LIMIT_UP_TO_1DAYLIMIT(2040, "此用户一天内发券到达疲劳度限制"), PUSH_LIMIT_UP_TO_COUPONLIMIT(2041, "此用户发此券到达疲劳度限制"), 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 cc79a82aa..6e7b96944 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -488,6 +488,7 @@ public class WxCouponServiceImpl implements WxCouponService { // 2. check 库存是否合适 // 3. check 新的有效期是否合适 // 4. 更新库存及有效期 + boolean bChanged = false; WxCoupon oldCoupon = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); if(oldCoupon == null) { logger.error(ErrorCode.COUPON_IS_EMPTY.getMessage()); @@ -508,6 +509,12 @@ public class WxCouponServiceImpl implements WxCouponService { logger.error("总库存数要大于等于可用库存数"); return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "总库存数要大于已售卖数"); } + + if((!wxCoupon.getInventory().equals(oldCoupon.getInventory())) || + (!wxCoupon.getRemainInventory().equals(oldCoupon.getRemainInventory()))) { + // 库存 是否改变 + bChanged = true; + } if(wxCoupon.getInventory()-wxCoupon.getRemainInventory() != oldCoupon.getInventory() - oldCoupon.getRemainInventory()) { // 已售卖数不变 logger.error("已售卖数不变"); @@ -524,12 +531,23 @@ public class WxCouponServiceImpl implements WxCouponService { logger.error("券有效期只可增加"); return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期只可增加"); } + if(!wxCoupon.getValidEndDate().equals(oldCoupon.getValidEndDate())) { + bChanged = true; + } } else { if(wxCoupon.getValidDays()