Procházet zdrojové kódy

[库存修改][新增]:错误提示详情添加

release_toaliyun_real
Stormeye Wu před 7 roky
rodič
revize
6b372760cb
1 změnil soubory, kde provedl 15 přidání a 0 odebrání
  1. +15
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java

+ 15
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java Zobrazit soubor

@@ -489,30 +489,45 @@ public class WxCouponServiceImpl implements WxCouponService {
// 3. check 新的有效期是否合适
// 4. 更新库存及有效期
WxCoupon oldCoupon = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId());
if(oldCoupon == null) {
logger.error(ErrorCode.COUPON_IS_EMPTY.getMessage());
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if(wxCoupon.getInventory() < wxCoupon.getRemainInventory()) {
// 总库存数要大于等于可用库存数
logger.error("总库存数要大于等于可用库存数");
return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "总库存数要大于等于可用库存数");
}
if(wxCoupon.getInventory() < wxCoupon.getRemainInventory()) {
// 总库存数要大于等于可用库存数
logger.error("总库存数要大于等于可用库存数");
return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "总库存数要大于等于可用库存数");
}
if(wxCoupon.getInventory() <= oldCoupon.getInventory() - oldCoupon.getRemainInventory()) {
// 库存可增, 可减, 但是要保证,总库存数要大于已售卖数
logger.error("总库存数要大于等于可用库存数");
return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "总库存数要大于已售卖数");
}
if(wxCoupon.getInventory()-wxCoupon.getRemainInventory() != oldCoupon.getInventory() - oldCoupon.getRemainInventory()) {
// 已售卖数不变
logger.error("已售卖数不变");
return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "已售卖数不变");
}
if(wxCoupon.getValidType() != oldCoupon.getValidType()) {
// 券有效期类型不能改变
logger.error("券有效期类型不能改变");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期类型不能改变");
}
if(oldCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) {
if(wxCoupon.getValidEndDate().before(oldCoupon.getValidEndDate())) {
// 券有效期只可增加
logger.error("券有效期只可增加");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期只可增加");
}
} else {
if(wxCoupon.getValidDays()<oldCoupon.getValidDays()) {
// 券有效期只可增加
logger.error("券有效期只可增加");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期只可增加");
}
}


Načítá se…
Zrušit
Uložit