|
@@ -778,7 +778,13 @@ class Reorder extends Base
|
|
|
}
|
|
|
if($stock['wait_in_stock']<$info['num']){
|
|
|
$stock['wait_in_stock']=0;
|
|
|
- $stock['usable_stock'] -= $info['num']-$stock['wait_in_stock'];
|
|
|
+ if( $stock['usable_stock']>$info['num']-$stock['wait_in_stock']){
|
|
|
+ $stock['usable_stock'] -= $info['num']-$stock['wait_in_stock'];
|
|
|
+ }else{
|
|
|
+ $stock['usable_stock'] = 0;
|
|
|
+ $stock['wait_out_stock']-= $info['num']-$stock['wait_in_stock']- $stock['usable_stock'] ;
|
|
|
+ }
|
|
|
+
|
|
|
$stock['total_stock']= $stock['usable_stock']+ $stock['wait_out_stock'];
|
|
|
}else{
|
|
|
$stock['wait_in_stock']-=$info['num'];
|
|
@@ -820,11 +826,17 @@ class Reorder extends Base
|
|
|
Db::rollback();
|
|
|
return error_show(1005, '商品仓库未找到');
|
|
|
}
|
|
|
- if($stock['usable_stock']<$info['num']){
|
|
|
+ if($stock['usable_stock']+$stock['wait_out_stock']<$info['num']){
|
|
|
Db::rollback();
|
|
|
return error_show(1005, '商品可用库存不足退回数量');
|
|
|
}else{
|
|
|
- $stock['usable_stock'] -= $info['num'];
|
|
|
+
|
|
|
+ if($stock['usable_stock']>$info['num']){
|
|
|
+ $stock['usable_stock'] -= $info['num'];
|
|
|
+ }else{
|
|
|
+ $stock['usable_stock'] = 0;
|
|
|
+ $stock['wait_out_stock']-= $info['num']- $stock['usable_stock'] ;
|
|
|
+ }
|
|
|
$stock['total_stock']= $stock['usable_stock']+ $stock['wait_out_stock'];
|
|
|
}
|
|
|
$stock['updatetime'] = date("Y-m-d H:i:s");
|