From fc578f8ac4b51a042df38a16c40215a775b20407 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E5=AF=8C=E5=BA=B7?= <15630117759@163.com>
Date: Sun, 4 Aug 2024 17:01:11 +0800
Subject: [PATCH] =?UTF-8?q?app/product/getShareList=20=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=9D=87=E8=89=B2=E5=9D=87=E7=A0=81=E7=9A=84=E5=BA=93=E5=AD=98?=
=?UTF-8?q?=E6=95=B0=E6=9F=A5=E8=AF=A2=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hiver-admin/test-output/test-report.html | 16 +++++++--------
.../cc/hiver/mall/dao/mapper/StockMapper.java | 2 ++
.../cc/hiver/mall/pojo/vo/ProductPageVO.java | 3 +++
.../mall/service/mybatis/StockService.java | 9 +++++++++
.../mybatis/ProductServiceImpl.java | 20 +++++++++++++++++++
.../serviceimpl/mybatis/StockServiceImpl.java | 5 +++++
.../src/main/resources/mapper/StockMapper.xml | 13 ++++++++++++
7 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html
index fe5b89eb..8e73f001 100644
--- a/hiver-admin/test-output/test-report.html
+++ b/hiver-admin/test-output/test-report.html
@@ -35,7 +35,7 @@
Hiver
-���� 03, 2024 19:26:13
+���� 04, 2024 12:12:02
@@ -84,7 +84,7 @@
passTest
-
19:26:14 ���� / 0.017 secs
+
12:12:02 ���� / 0.016 secs
@@ -92,9 +92,9 @@
#test-id=1
passTest
-
08.03.2024 19:26:14
-
08.03.2024 19:26:14
-
0.017 secs
+
08.04.2024 12:12:02
+
08.04.2024 12:12:02
+
0.016 secs
@@ -104,7 +104,7 @@
| Pass |
- 19:26:14 |
+ 12:12:02 |
Test passed
|
@@ -128,13 +128,13 @@
Started
-
���� 03, 2024 19:26:13
+
���� 04, 2024 12:12:02
Ended
-
���� 03, 2024 19:26:14
+
���� 04, 2024 12:12:02
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
index 2c504b6f..5202f584 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
@@ -56,4 +56,6 @@ public interface StockMapper extends BaseMapper
{
void batchDeleteStockByProductIds(@Param("productIdList") List productIdList);
void batchReduceStockByLog(@Param("stockLogList") List stockLogList);
+
+ List getDefaultStockCount(@Param("productIdList") List productIdList);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java
index 0ccac3fe..5c1bcc2c 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java
@@ -106,4 +106,7 @@ public class ProductPageVO {
@ApiModelProperty(value = "商品子图")
private List productPictures;
+
+ @ApiModelProperty(value = "商品均色均码总库存")
+ private Integer defaultStockCount;
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
index 9d35c941..2282ef2e 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
@@ -87,4 +87,13 @@ public interface StockService extends IService {
* @param stockLogList
*/
void batchReduceStockByLog(List stockLogList);
+
+ /**
+ * 获取某些商品均色均码的库存数
+ * @author 王富康
+ * @date 2024/8/4
+ * @param productIdList
+ * @return List
+ */
+ List getDefaultStockCount(List productIdList);
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
index 2987612c..72e71e9d 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
@@ -7,6 +7,7 @@ import cc.hiver.core.entity.User;
import cc.hiver.mall.common.constant.PurchaseConstant;
import cc.hiver.mall.dao.mapper.ProductMapper;
import cc.hiver.mall.entity.Product;
+import cc.hiver.mall.entity.Stock;
import cc.hiver.mall.pojo.dto.SaleDetailDTO;
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO;
import cc.hiver.mall.pojo.dto.SaleQueryDTO;
@@ -16,6 +17,7 @@ import cc.hiver.mall.productpicture.entity.ProductPicture;
import cc.hiver.mall.productpicture.service.ProductPictureService;
import cc.hiver.mall.service.mybatis.ProductCategoryService;
import cc.hiver.mall.service.mybatis.ProductService;
+import cc.hiver.mall.service.mybatis.StockService;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -44,6 +46,9 @@ public class ProductServiceImpl extends ServiceImpl impl
@Autowired
private ProductCategoryService productCategoryService;
+ @Autowired
+ private StockService stockService;
+
@Override
public IPage getShareList(ProductPageQuery productPageQuery) {
final Page page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize());
@@ -72,6 +77,21 @@ public class ProductServiceImpl extends ServiceImpl impl
productPageVO.setProductPictures(productPictureMap.get(productId));
}
}
+ // 获取商品均色均码的库存数
+ List stockList = stockService.getDefaultStockCount(productIdList);
+ // 处理为map, key为productId
+ final Map stockMap = new HashMap<>();
+ for (Stock stock : stockList) {
+ stockMap.put(stock.getProductId(), stock);
+ }
+ for (ProductPageVO productPageVO : list) {
+ final String productId = productPageVO.getId();
+ if (stockMap.containsKey(productId)) {
+ productPageVO.setDefaultStockCount(stockMap.get(productId).getStockCount());
+ }else{
+ productPageVO.setDefaultStockCount(0);
+ }
+ }
}
page.setRecords(list);
return page;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
index 0dd583f7..860c67a0 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
@@ -1181,4 +1181,9 @@ public class StockServiceImpl extends ServiceImpl implements
public void batchReduceStockByLog(List stockLogList) {
stockMapper.batchReduceStockByLog(stockLogList);
}
+
+ @Override
+ public List getDefaultStockCount(List productIdList) {
+ return stockMapper.getDefaultStockCount(productIdList);
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml
index 37e1b968..7cf654ee 100644
--- a/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml
+++ b/hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml
@@ -686,4 +686,17 @@
update t_stock set stock_count = stock_count - #{item.productCount} WHERE product_id = #{item.productId} and attribute_list = #{item.attributeList}
+
+
\ No newline at end of file