|
|
|
@@ -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()<oldCoupon.getValidDays()) { |
|
|
|
// 券有效期只可增加 |
|
|
|
logger.error("券有效期只可增加"); |
|
|
|
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期只可增加"); |
|
|
|
} |
|
|
|
if(wxCoupon.getValidDays().equals(oldCoupon.getValidDays())) { |
|
|
|
bChanged = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!bChanged) { |
|
|
|
logger.error("券库存有效期未修改"); |
|
|
|
return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); |
|
|
|
} |
|
|
|
|
|
|
|
wxCoupon.setOrgInventory(oldCoupon.getInventory()); |
|
|
|
|