|
@@ -160,6 +160,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
Page<StockVo> page = this.baseMapper.pageByProduct(dto.getPage(), wrapper);
|
|
|
List<StockVo> stockVos = page.getRecords();
|
|
|
|
|
|
+ //赋值冻结库存和次品库存
|
|
|
+ for (StockVo stockVo : stockVos) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ BigDecimal frozenQuantity = stockVo.getFrozenQuantity();
|
|
|
+ frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
|
|
|
+ json.put("frozenQuantity", frozenQuantity);
|
|
|
+ BigDecimal defectiveQuantity = stockVo.getDefectiveQuantity();
|
|
|
+ defectiveQuantity = defectiveQuantity == null ? BigDecimal.ZERO : defectiveQuantity;
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity);
|
|
|
+ stockVo.setVictoriatouristJson(json.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
//赋值产品名称
|
|
|
productInfoService.attributeAssign(stockVos, StockVo::getProductId, (item, productInfo) -> {
|
|
|
item.setType(productInfo.getType());
|
|
@@ -213,7 +225,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
//赋值关联产品数
|
|
|
List<StockVo> records = page.getRecords();
|
|
|
List<Long> spuids = records.stream().map(StockVo::getProductSpuId).collect(Collectors.toList());
|
|
|
- if(ObjectUtil.isEmpty(spuids)){
|
|
|
+ if (ObjectUtil.isEmpty(spuids)) {
|
|
|
return page;
|
|
|
}
|
|
|
List<ProductInfo> productInfoList = productInfoService.list(q -> q.in(ProductInfo::getProductSpuId, spuids));
|
|
@@ -228,7 +240,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
for (StockVo record : records) {
|
|
|
String victoriatouristJson = record.getVictoriatouristJson();
|
|
|
JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- if(json.getInteger("combination")!=1){
|
|
|
+ if (json.getInteger("combination") != 1) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONArray productCombinationList = json.getJSONArray("productCombinationList");
|
|
@@ -239,7 +251,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
// BigDecimal linkQuantity = item.getBigDecimal("linkQuantity");
|
|
|
}
|
|
|
}
|
|
|
- if(ObjectUtil.isEmpty(linkProductIds)){
|
|
|
+ if (ObjectUtil.isEmpty(linkProductIds)) {
|
|
|
return page;
|
|
|
}
|
|
|
//查询关联产品库存
|
|
@@ -248,7 +260,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
for (StockVo record : records) {
|
|
|
String victoriatouristJson = record.getVictoriatouristJson();
|
|
|
JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- if(json.getInteger("combination")!=1){
|
|
|
+ if (json.getInteger("combination") != 1) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONArray productCombinationList = json.getJSONArray("productCombinationList");
|
|
@@ -259,7 +271,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
Long linkProductId = item.getLong("linkProductId");
|
|
|
BigDecimal linkQuantity = item.getBigDecimal("linkQuantity");
|
|
|
|
|
|
- BigDecimal stockQuantity = stockMap.getOrDefault(linkProductId,BigDecimal.ZERO);
|
|
|
+ BigDecimal stockQuantity = stockMap.getOrDefault(linkProductId, BigDecimal.ZERO);
|
|
|
|
|
|
BigDecimal divide = stockQuantity.divide(linkQuantity, 0, BigDecimal.ROUND_DOWN);
|
|
|
|
|
@@ -378,6 +390,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
newStocks.setQuantity(quantity);
|
|
|
} else if (type == 2) {
|
|
|
ProductInfo productInfo = productInfoService.getById(stock.getProductId());
|
|
|
+ if (productInfo == null) {
|
|
|
+ throw new ServiceException("产品id:" + stock.getProductId() + "不存在");
|
|
|
+ }
|
|
|
throw new ServiceException("以下商品库存不足,无法出库:" + productInfo.getName());
|
|
|
}
|
|
|
|