加入购物车校验库存
This commit is contained in:
parent
c88b085a4e
commit
3ea12c88fe
|
|
@ -307,11 +307,26 @@ public class CartService {
|
|||
log.error("该商品不存在 productId:{}", productId);
|
||||
throw new MsgException("该商品不存在");
|
||||
}
|
||||
|
||||
Integer buyNum = jsonObject.getInteger("num");
|
||||
|
||||
if (buyNum <= 0) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "参数非法");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
jsonObject1.put("reqData", jsonObject);
|
||||
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
log.error("参数非法 productId:{}", productId);
|
||||
throw new MsgException("该商品已售罄");
|
||||
}
|
||||
|
||||
String skuId = jsonObject.getString("skuId");
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
if (tbProduct.getIsPauseSale().equals(1)) {//是否售罄
|
||||
if (tbProduct.getIsPauseSale() == 1 || tbProduct.getStockNumber() - buyNum < 0) {//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
|
|
@ -324,7 +339,7 @@ public class CartService {
|
|||
}
|
||||
} else {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
if(tbProductSkuWithBLOBs.getIsPauseSale().equals(1)){//是否售罄
|
||||
if(tbProductSkuWithBLOBs.getIsPauseSale() == 1 || tbProductSkuWithBLOBs.getStockNumber() - buyNum < 0){//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
|
|
@ -339,7 +354,6 @@ public class CartService {
|
|||
}
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
Integer buyNum = jsonObject.getInteger("num");
|
||||
|
||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
|
|
|
|||
Loading…
Reference in New Issue