1.商品查询库存不准确问题

This commit is contained in:
2024-08-14 15:41:49 +08:00
parent b0243a9ddd
commit dad47eb0c8
2 changed files with 14 additions and 1 deletions

View File

@@ -51,7 +51,7 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} ")
int decrStockUnCheck(String id, int num);
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id}")
@Select("select * from tb_product_sku where is_grounding=1 and product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductCheckGrounding(@Param("id") Integer id);
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
@@ -62,4 +62,7 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}")
int updateStock(@Param("shopId") Integer shopId, @Param("skuId") Integer skuId, @Param("stock") Integer stock);
@Select("select * from tb_product_sku where product_id=#{id} and is_del=0")
List<TbProductSku> selectByProductId(Integer id);
}

View File

@@ -192,7 +192,17 @@ public class ProductService {
// 查询sku信息
List<TbProductSku> skuWithBLOBs = tbProductSkuMapper.selectByProductCheckGrounding(it.getId());
List<TbProductSku> skus = tbProductSkuMapper.selectByProductId(it.getId());
if (it.getIsDistribute() == 0) {
int num = 0;
for (TbProductSku item : skus) {
num += item.getStockNumber();
}
it.setStockNumber(num);
}
it.setSkuList(skuWithBLOBs);
});
}
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);