|
@@ -113,11 +113,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
json.put("unit", productInfo.getUnit());
|
|
|
|
|
|
BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
|
|
|
- frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
|
|
|
- json.put("frozenQuantity",frozenQuantity);
|
|
|
+ frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
|
|
|
+ json.put("frozenQuantity", frozenQuantity);
|
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
|
- defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
|
|
|
- json.put("defectiveQuantity",defectiveQuantity);
|
|
|
+ defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity);
|
|
|
item.setVictoriatouristJson(json.toJSONString());
|
|
|
});
|
|
|
}
|
|
@@ -178,11 +178,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
json.put("unit", productInfo.getUnit());
|
|
|
|
|
|
BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
|
|
|
- frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
|
|
|
- json.put("frozenQuantity",frozenQuantity);
|
|
|
+ frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
|
|
|
+ json.put("frozenQuantity", frozenQuantity);
|
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
|
- defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
|
|
|
- json.put("defectiveQuantity",defectiveQuantity);
|
|
|
+ defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity);
|
|
|
item.setVictoriatouristJson(json.toJSONString());
|
|
|
});
|
|
|
|
|
@@ -197,12 +197,13 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
@Override
|
|
|
public Page<StockVo> pageByProductSpu(StockSelectDto dto) {
|
|
|
IWrapper<Stock> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("s", Stock::getId);
|
|
|
wrapper.eq(Stock::getWarehouseId, dto.getId());
|
|
|
wrapper.like(Stock::getQuantity, dto.getKeyword());
|
|
|
wrapper.eq("pi.definition", dto.getDefinition());
|
|
|
- wrapper.isNotNull("pi.product_spu_id");
|
|
|
+ wrapper.isNotNull("ps.id");
|
|
|
wrapper.groupBy("pi.product_spu_id");
|
|
|
+ wrapper.orderByDesc("s", Stock::getId);
|
|
|
+
|
|
|
|
|
|
Page<StockVo> page = this.baseMapper.pageByProductSpu(dto.getPage(), wrapper);
|
|
|
List<StockVo> stockVos = page.getRecords();
|
|
@@ -228,11 +229,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
|
|
|
|
|
|
BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
|
|
|
- frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
|
|
|
- json.put("frozenQuantity",frozenQuantity);
|
|
|
+ frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
|
|
|
+ json.put("frozenQuantity", frozenQuantity);
|
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
|
- defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
|
|
|
- json.put("defectiveQuantity",defectiveQuantity);
|
|
|
+ defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity);
|
|
|
item.setVictoriatouristJson(json.toJSONString());
|
|
|
});
|
|
|
|
|
@@ -311,7 +312,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
Stock newStocks = new Stock();
|
|
|
newStocks.setWarehouseId(warehouseId);
|
|
|
newStocks.setProductId(stock.getProductId());
|
|
|
- if(ObjectUtil.isEmpty(stock.getQuantity())){
|
|
|
+ if (ObjectUtil.isEmpty(stock.getQuantity())) {
|
|
|
//判断传操作的库存是否为空 空赋值0
|
|
|
stock.setQuantity(BigDecimal.ZERO);
|
|
|
}
|
|
@@ -378,9 +379,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
}
|
|
|
Stock stock1 = getById(stock.getId());
|
|
|
String victoriatouristJson = stock1.getVictoriatouristJson();
|
|
|
- JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- json.put("quantity", json.getBigDecimal("quantity").add(stock.getQuantity()));
|
|
|
- json.put("defectiveQuantity", json.getBigDecimal("defectiveQuantity").subtract(stock.getQuantity()));
|
|
|
+ JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
|
|
|
+ BigDecimal quantity = stock1.getQuantity();
|
|
|
+ BigDecimal defectiveQuantity = ObjectUtil.isNotEmpty(json.getBigDecimal("defectiveQuantity")) ? json.getBigDecimal("defectiveQuantity") : BigDecimal.ZERO;
|
|
|
+ if (defectiveQuantity.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ throw new ServiceException("库存不足,无法转换");
|
|
|
+ }
|
|
|
+ stock1.setQuantity(quantity.add(stock.getQuantity()));
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity.subtract(stock.getQuantity()));
|
|
|
stock1.setVictoriatouristJson(json.toJSONString());
|
|
|
updateById(stock1);
|
|
|
}
|
|
@@ -412,9 +418,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
}
|
|
|
Stock stock1 = getById(stock.getId());
|
|
|
String victoriatouristJson = stock1.getVictoriatouristJson();
|
|
|
- JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- json.put("quantity", json.getBigDecimal("quantity").subtract(stock.getQuantity()));
|
|
|
- json.put("defectiveQuantity", json.getBigDecimal("defectiveQuantity").add(stock.getQuantity()));
|
|
|
+ JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
|
|
|
+ BigDecimal quantity = stock1.getQuantity();
|
|
|
+ BigDecimal defectiveQuantity = ObjectUtil.isNotEmpty(json.getBigDecimal("defectiveQuantity")) ? json.getBigDecimal("defectiveQuantity") : BigDecimal.ZERO;
|
|
|
+ if (quantity.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ throw new ServiceException("库存不足,无法转换");
|
|
|
+ }
|
|
|
+ stock1.setQuantity(quantity.subtract(stock.getQuantity()));
|
|
|
+ json.put("defectiveQuantity", defectiveQuantity.add(stock.getQuantity()));
|
|
|
stock1.setVictoriatouristJson(json.toJSONString());
|
|
|
updateById(stock1);
|
|
|
}
|