From 613404c14d7acdca435169f0cefd17aba22bd0eb Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 14:38:18 +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 --- .../src/main/resources/application.yml | 8 ++++---- 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 ++++++++++++ 8 files changed, 64 insertions(+), 12 deletions(-) diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index 4afd4e51..5350c274 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -25,8 +25,8 @@ spring: timeout-per-shutdown-phase: 10S # 数据源 datasource: -# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true - url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true + url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true +# url: jdbc:mysql://8.140.198.243:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true username: reddoor # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 password: ENC(Zla4U4+yRLPhicvuX2TmiEgxEpzP4dk8BHzFDEtiEhwLQIIaftZrrEUJZce6efoe) @@ -67,8 +67,8 @@ spring: ddl-auto: update # Redis 若设有密码自行添加配置password redis: -# host: 154.8.162.157 - host: 8.140.198.243 + host: 154.8.162.157 +# host: 8.140.198.243 password: reddoor168 # 数据库索引 默认0 database: 1 diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index 65e80678..de2c08d2 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