Browse Source

减去冻结库存

sunhao 5 years ago
parent
commit
66362ff156
1 changed files with 5 additions and 1 deletions
  1. 5 1
      app/Console/Commands/SyncMjWarehouse.php

+ 5 - 1
app/Console/Commands/SyncMjWarehouse.php

62
             $cost = DB::table('goods_skus')->where('code', $code)->select('referenceCost', 'is_weigh')->first(); //获取规格成本/是否称重
62
             $cost = DB::table('goods_skus')->where('code', $code)->select('referenceCost', 'is_weigh')->first(); //获取规格成本/是否称重
63
             if($cost){
63
             if($cost){
64
                 $quantity = $cost->is_weigh == 1 ? $sku['quantity']/2 : $sku['quantity']; //对应规格数量
64
                 $quantity = $cost->is_weigh == 1 ? $sku['quantity']/2 : $sku['quantity']; //对应规格数量
65
+                //实际库存=库存-冻结
66
+                $real_quantity = $sku['quantity'] - $sku['fi'];
67
+                $real_quantity = $cost->is_weigh == 1 ? $real_quantity/2 : $real_quantity; //对应规格数量
65
                 $up['quantity'] = $quantity;
68
                 $up['quantity'] = $quantity;
66
                 $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
69
                 $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
67
                 if($up['quantity'] != 0 ){
70
                 if($up['quantity'] != 0 ){
72
                     $up['outPrice'] = 0;
75
                     $up['outPrice'] = 0;
73
                 }
76
                 }
74
                 $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
77
                 $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
75
-
78
+                //实际库存=库存-冻结
79
+                $up['quantity'] = $real_quantity;
76
                 $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
80
                 $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
77
             }
81
             }
78
 
82