Browse Source

修改商品库存逻辑

shensong 5 years ago
parent
commit
42eae9ca57
1 changed files with 3 additions and 9 deletions
  1. 3 9
      app/Console/Commands/SyncMjWarehouse.php

+ 3 - 9
app/Console/Commands/SyncMjWarehouse.php

@@ -71,14 +71,10 @@ class SyncMjWarehouse extends Command {
71 71
                 }
72 72
 
73 73
                 $real_quantity = $cost->is_weigh == 1 ? $real_quantity/2 : $real_quantity; //对应规格数量
74
-                $up['quantity'] = $quantity;
74
+                $up['quantity'] = $real_quantity;
75 75
                 $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
76
-                if($up['quantity'] != 0 ){
77
-                    $up['realPrice'] = $up['totalCost'] / $up['quantity'];
78
-//                    $up['outPrice'] = ceil($up['realPrice'] * 1.15);
79
-                } else {
80
-//                    $up['realPrice'] = 0;
81
-//                    $up['outPrice'] = 0;
76
+                if($sku['quantity'] != 0 ){
77
+                    $up['realPrice'] = $sku['totalCost'] / $quantity;
82 78
                 }
83 79
                 if($cost->outPrice == 0){
84 80
                     if(isset($up['realPrice']) && $up['realPrice'] != 0){
@@ -86,8 +82,6 @@ class SyncMjWarehouse extends Command {
86 82
                     }
87 83
                 }
88 84
                 $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
89
-                //实际库存=库存-冻结
90
-                $up['quantity'] = $real_quantity;
91 85
                 $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
92 86
             }
93 87