|
@@ -1082,21 +1082,23 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public Integer updateDeliver(SalesOrder salesOrder) {
|
|
|
+ public synchronized Integer updateDeliver(SalesOrder salesOrder) {
|
|
|
+ Integer flag = salesOrderMapper.updateDeliver(salesOrder);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("出库失败,订单出库失败。");
|
|
|
+ }
|
|
|
+
|
|
|
if(salesOrder.getSalesDeliver() == 2){//标记出库,修改库存
|
|
|
if(!salesOrderService.updateInventory(salesOrder.getSalesId(),salesOrder.getSalesWarehouseId())){
|
|
|
- return 0;
|
|
|
+ throw new RuntimeException("出库失败,【出库】库存修改失败。");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(salesOrder.getSalesDeliver() == 1){//标记未出库,修改库存
|
|
|
if(!salesOrderService.returnInventory(salesOrder.getSalesId(),salesOrder.getSalesWarehouseId())){
|
|
|
- return 0;
|
|
|
+ throw new RuntimeException("出库失败,【返还库存】库存修改失败。");
|
|
|
}
|
|
|
}
|
|
|
- Integer flag = salesOrderMapper.updateDeliver(salesOrder);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("出库失败,订单出库失败。");
|
|
|
- }
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
@@ -1119,7 +1121,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
if(info != null){
|
|
|
if(info.getInventoryGoodProductNum() >= item.getItemNum()){
|
|
|
info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() - item.getItemNum());
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"出库:"+item.getItemNum()+"件");
|
|
|
+ info.setInventoryRecentRecord(sdf.format(new Date())+"出库:"+item.getItemNum()+"件,订单号:"+item.getItemOrderId());
|
|
|
Integer flag = inventoryMapper.updateById(info);
|
|
|
if(flag < 1){
|
|
|
throw new RuntimeException("【出库】更新库存失败,库存修改失败。");
|
|
@@ -1131,18 +1133,18 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
inventoryLog.setLogRemainingNum(item.getItemNum());
|
|
|
inventoryLog.setLogType(2);
|
|
|
inventoryLog.setLogOperationType(2);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"待发货标记出库:"+item.getItemNum()+"件");
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"待发货标记出库:"+item.getItemNum()+"件,订单号:"+item.getItemOrderId());
|
|
|
inventoryLog.setLogQualityType(1);
|
|
|
inventoryLog.setLogWarehouseId(salesWarehouseId);
|
|
|
flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
if(flag < 1){
|
|
|
- throw new RuntimeException("更新库存失败,增加库存记录失败。");
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,增加库存记录失败。");
|
|
|
}
|
|
|
}else{
|
|
|
- throw new RuntimeException("更新库存失败,"+ warehouseName +"["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存不足。");
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,"+ warehouseName +"["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存不足。");
|
|
|
}
|
|
|
}else{
|
|
|
- throw new RuntimeException("更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -1153,7 +1155,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
public boolean returnInventory(Integer salesId,Integer salesWarehouseId){
|
|
|
OrderWarehouse orderWarehouse = orderWarehouseService.getOrderWarehouseById(salesWarehouseId);
|
|
|
if(orderWarehouse == null){
|
|
|
- throw new RuntimeException("【出库】更新库存失败,查询仓库信息失败。");
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,查询仓库信息失败。");
|
|
|
}
|
|
|
String warehouseName = orderWarehouse.getWarehouseName();
|
|
|
|
|
@@ -1165,7 +1167,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
InventoryInfo info = inventoryMapper.getByInventoryByBar(item.getItemColorBar(),salesWarehouseId);
|
|
|
if(info != null){
|
|
|
info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() + item.getItemNum());
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存:"+item.getItemNum()+"件");
|
|
|
+ info.setInventoryRecentRecord(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存:"+item.getItemNum()+"件,订单号:"+item.getItemOrderId());
|
|
|
Integer flag = inventoryMapper.updateById(info);
|
|
|
if(flag < 1){
|
|
|
throw new RuntimeException("【返还库存】更新库存失败,库存修改失败。");
|
|
@@ -1177,15 +1179,15 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
inventoryLog.setLogRemainingNum(item.getItemNum());
|
|
|
inventoryLog.setLogType(1);
|
|
|
inventoryLog.setLogOperationType(1);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存:"+item.getItemNum()+"件");
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存:"+item.getItemNum()+"件,订单号:"+item.getItemOrderId());
|
|
|
inventoryLog.setLogQualityType(1);
|
|
|
inventoryLog.setLogWarehouseId(salesWarehouseId);
|
|
|
flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
if(flag < 1){
|
|
|
- throw new RuntimeException("更新库存失败,增加库存记录失败。");
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,增加库存记录失败。");
|
|
|
}
|
|
|
}else{
|
|
|
- throw new RuntimeException("更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
}
|
|
|
|
|
|
}
|