Browse Source

app/product/getShareList 增加均色均码的库存数查询。

dev
wangfukang 2 years ago
parent
commit
613404c14d
  1. 8
      hiver-admin/src/main/resources/application.yml
  2. 16
      hiver-admin/test-output/test-report.html
  3. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java
  4. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java
  5. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java
  6. 20
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  7. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java
  8. 13
      hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

8
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

16
hiver-admin/test-output/test-report.html

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">八月 03, 2024 19:26:13</span></a>
<a href="#"><span class="badge badge-primary">八月 04, 2024 12:12:02</span></a>
</li>
</ul>
</div>
@ -84,7 +84,7 @@
<div class="test-detail">
<span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p>
<p class="text-sm"><span>19:26:14 下午</span> / <span>0.017 secs</span></p>
<p class="text-sm"><span>12:12:02 下午</span> / <span>0.016 secs</span></p>
</div>
<div class="test-contents d-none">
<div class="detail-head">
@ -92,9 +92,9 @@
<div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>08.03.2024 19:26:14</span>
<span class='badge badge-danger'>08.03.2024 19:26:14</span>
<span class='badge badge-default'>0.017 secs</span>
<span class='badge badge-success'>08.04.2024 12:12:02</span>
<span class='badge badge-danger'>08.04.2024 12:12:02</span>
<span class='badge badge-default'>0.016 secs</span>
</div>
<div class="m-t-10 m-l-5"></div>
</div>
@ -104,7 +104,7 @@
<tbody>
<tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td>
<td>19:26:14</td>
<td>12:12:02</td>
<td>
Test passed
</td>
@ -128,13 +128,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>八月 03, 2024 19:26:13</h3>
<h3>八月 04, 2024 12:12:02</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>八月 03, 2024 19:26:14</h3>
<h3>八月 04, 2024 12:12:02</h3>
</div></div>
</div>
<div class="col-md-3">

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/StockMapper.java

@ -56,4 +56,6 @@ public interface StockMapper extends BaseMapper<Stock> {
void batchDeleteStockByProductIds(@Param("productIdList") List<String> productIdList);
void batchReduceStockByLog(@Param("stockLogList") List<StockLog> stockLogList);
List<Stock> getDefaultStockCount(@Param("productIdList") List<String> productIdList);
}

3
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<ProductPicture> productPictures;
@ApiModelProperty(value = "商品均色均码总库存")
private Integer defaultStockCount;
}

9
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/StockService.java

@ -87,4 +87,13 @@ public interface StockService extends IService<Stock> {
* @param stockLogList
*/
void batchReduceStockByLog(List<StockLog> stockLogList);
/**
* 获取某些商品均色均码的库存数
* @author 王富康
* @date 2024/8/4
* @param productIdList
* @return List<Stock>
*/
List<Stock> getDefaultStockCount(List<String> productIdList);
}

20
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<ProductMapper, Product> impl
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private StockService stockService;
@Override
public IPage<ProductPageVO> getShareList(ProductPageQuery productPageQuery) {
final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize());
@ -72,6 +77,21 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
productPageVO.setProductPictures(productPictureMap.get(productId));
}
}
// 获取商品均色均码的库存数
List<Stock> stockList = stockService.getDefaultStockCount(productIdList);
// 处理为map, key为productId
final Map<String, Stock> 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;

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java

@ -1181,4 +1181,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
public void batchReduceStockByLog(List<StockLog> stockLogList) {
stockMapper.batchReduceStockByLog(stockLogList);
}
@Override
public List<Stock> getDefaultStockCount(List<String> productIdList) {
return stockMapper.getDefaultStockCount(productIdList);
}
}

13
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}
</foreach>
</update>
<select id="getDefaultStockCount" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
t_stock s
where
s.attribute_list = '{"颜色":"均色","尺码":"均码"}'
and s.product_id in
<foreach item="item" index="index" collection="productIdList" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save