1.下单添加购物车同步校验上下架商品

This commit is contained in:
SongZhang 2024-07-20 15:24:42 +08:00
parent 4691fa8c31
commit 90c834a37d
3 changed files with 34 additions and 1 deletions

View File

@ -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;
}

View File

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

View File

@ -26,6 +26,7 @@
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="is_pause_sale" jdbcType="INTEGER" property="isPauseSale" />
<result column="is_del" jdbcType="INTEGER" property="isDel" />
<result column="is_grounding" jdbcType="INTEGER" property="isGrounding" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
<result column="spec_info" jdbcType="LONGVARCHAR" property="specInfo" />
@ -34,7 +35,7 @@
<sql id="Base_Column_List">
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
sale_price, guide_price,suit, strategy_price, stock_number, cover_img, warn_line, weight,
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del,is_grounding
</sql>
<sql id="Blob_Column_List">
spec_info, spec_snap