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()