|
|
@@ -130,12 +130,15 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
deliveryItems.setUpdateUser(SecureUtil.getUserId());
|
|
|
baseMapper.updateById(deliveryItems);
|
|
|
}
|
|
|
+ StockGoods stockGoods=null;
|
|
|
StockGoodsVO stock = this.getStock(delivery.getTradeType(), delivery.getCorpId(), delivery.getStorageId(), deliveryItems);
|
|
|
if (stock != null && delivery.getDeliveryType() == DeliveryEnum.DELIVER.getType()){//发货
|
|
|
//更新库存账
|
|
|
- this.deliverGoods(delivery.getTradeType(),stock.getId(),deliveryItems);
|
|
|
+ stockGoods = this.deliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems);
|
|
|
+
|
|
|
}else if (stock != null && delivery.getDeliveryType() == DeliveryEnum.REPEAL.getType()){ //撤销发货
|
|
|
- this.revocationDeliverGoods(delivery.getTradeType(),stock.getId(),deliveryItems);
|
|
|
+ stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems);
|
|
|
+
|
|
|
}else {
|
|
|
//新增库存账
|
|
|
throw new RuntimeException("库存为空");
|
|
|
@@ -145,6 +148,9 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (!actualQuantity.isSuccess()){
|
|
|
throw new RuntimeException("更新订单发货数量出错," + actualQuantity.getMsg());
|
|
|
}
|
|
|
+ //更新发货明细库存字段
|
|
|
+ deliveryItems.setInventoryNumber(stockGoods.getSurplusRouteQuantity());
|
|
|
+ baseMapper.updateById(deliveryItems);
|
|
|
}
|
|
|
return deliveryItemsList;
|
|
|
}
|
|
|
@@ -188,7 +194,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* @param stockId 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public void deliverGoods(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
+ public StockGoods deliverGoods(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
//查询库存账
|
|
|
R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
if (!stockById.isSuccess()){
|
|
|
@@ -231,6 +237,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (!updateStock.isSuccess()){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
+ return stockGoods;
|
|
|
}
|
|
|
/**
|
|
|
* 撤销发货
|
|
|
@@ -238,7 +245,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* @param stockId 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public void revocationDeliverGoods(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
+ public StockGoods revocationDeliverGoods(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
//查询库存账
|
|
|
R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
if (!stockById.isSuccess()){
|
|
|
@@ -278,6 +285,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (!updateStock.isSuccess()){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
+ return stockGoods;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -286,7 +294,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* @param stockId 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public void cancelStock(String tradeType,Long stockId,DeliveryItems deliveryItems)
|
|
|
+ public StockGoods cancelStock(String tradeType,Long stockId,DeliveryItems deliveryItems)
|
|
|
{
|
|
|
//查询库存账
|
|
|
R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
@@ -327,6 +335,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (!updateStock.isSuccess()){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
+ return stockGoods;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -337,7 +346,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* @param stockId 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public void receiving(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
+ public StockGoods receiving(String tradeType,Long stockId,DeliveryItems deliveryItems){
|
|
|
//查询库存账
|
|
|
R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
if (!stockById.isSuccess()){
|
|
|
@@ -362,6 +371,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (!updateStock.isSuccess()){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
+ return stockGoods;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -371,7 +381,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* @param storageId 仓库id
|
|
|
* @param deliveryItems 明细信息
|
|
|
*/
|
|
|
- public void saveStock(String tradeType,Long corpId,Long storageId,DeliveryItems deliveryItems){
|
|
|
+ public StockGoods saveStock(String tradeType,Long corpId,Long storageId,DeliveryItems deliveryItems){
|
|
|
StockGoods stockGoods = new StockGoods();
|
|
|
stockGoods.setGoodsId(deliveryItems.getItemId());//商品id
|
|
|
|
|
|
@@ -416,5 +426,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
stockGoods.setTenantId(SecureUtil.getTenantId());
|
|
|
stockGoods.setCreateTime(new Date());
|
|
|
R saveStock = stockGoodsClient.saveStock(stockGoods);
|
|
|
+ if(!saveStock.isSuccess())
|
|
|
+ {
|
|
|
+ throw new SecurityException("插入库存失败");
|
|
|
+ }
|
|
|
+ return stockGoods;
|
|
|
}
|
|
|
}
|