1.下单添加购物车同步校验上下架商品
This commit is contained in:
@@ -50,9 +50,18 @@ public class TbProductSku implements Serializable {
|
||||
|
||||
private Integer isPauseSale = 0;
|
||||
private Integer isDel;
|
||||
private Integer isGrounding;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getIsGrounding() {
|
||||
return isGrounding;
|
||||
}
|
||||
|
||||
public void setIsGrounding(Integer isGrounding) {
|
||||
this.isGrounding = isGrounding;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,20 @@ public class CartService {
|
||||
Integer buyNum = jsonObject.getInteger("num");
|
||||
|
||||
String skuId = jsonObject.getString("skuId");
|
||||
// 判断商品是否已下架
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
if (tbProductSkuWithBLOBs ==null || tbProductSkuWithBLOBs.getIsGrounding().equals(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("商品已下架 skuId:{}", skuId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
@@ -585,6 +598,16 @@ public class CartService {
|
||||
TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
|
||||
|
||||
// 判断商品是否已下架
|
||||
if (tbProduct.getIsGrounding().equals(0)) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "商品已下架:" + tbProduct1.getName());
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cashierCart.getNumber()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user