sunhao преди 5 години
родител
ревизия
66362ff156
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      app/Console/Commands/SyncMjWarehouse.php

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

@@ -62,6 +62,9 @@ class SyncMjWarehouse extends Command {
62 62
             $cost = DB::table('goods_skus')->where('code', $code)->select('referenceCost', 'is_weigh')->first(); //获取规格成本/是否称重
63 63
             if($cost){
64 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 68
                 $up['quantity'] = $quantity;
66 69
                 $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
67 70
                 if($up['quantity'] != 0 ){
@@ -72,7 +75,8 @@ class SyncMjWarehouse extends Command {
72 75
                     $up['outPrice'] = 0;
73 76
                 }
74 77
                 $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
75
-
78
+                //实际库存=库存-冻结
79
+                $up['quantity'] = $real_quantity;
76 80
                 $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
77 81
             }
78 82