Browse Source

Merge branch 'master' of http://101.200.220.49:8001/sunhao/seafood

sunhao 5 years ago
parent
commit
a8e43308a2
2 changed files with 16 additions and 12 deletions
  1. 14 10
      app/Console/Commands/SyncMjWarehouse.php
  2. 2 2
      app/Console/Commands/freightCost.php

+ 14 - 10
app/Console/Commands/SyncMjWarehouse.php

@@ -58,19 +58,23 @@ class SyncMjWarehouse extends Command {
58 58
             //2.更新商品库存总成本(有可能为空)
59 59
             //3.计算商品真实价格
60 60
             //4.计算商品外部价格
61
+            $cost = DB::table('goods_skus')->where('code', $code)->select('referenceCost', 'is_weigh')->first(); //获取规格成本/是否称重
62
+            if($cost){
63
+                $quantity = $cost->is_weigh == 1 ? $sku['quantity']/2 : $sku['quantity']; //对应规格数量
64
+                $up['quantity'] = $quantity;
65
+                $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
66
+                if($up['quantity'] != 0 ){
67
+                    $up['realPrice'] = $up['totalCost'] / $up['quantity'];
68
+                    $up['outPrice'] = ceil($up['realPrice'] * 1.1);
69
+                } else {
70
+                    $up['realPrice'] = 0;
71
+                    $up['outPrice'] = 0;
72
+                }
73
+                $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
61 74
 
62
-            $up['quantity'] = $sku['quantity'];
63
-            $up['totalCost'] = isset($sku['totalCost']) ? $sku['totalCost'] : 0;
64
-            if($up['quantity'] != 0 ){
65
-                $up['realPrice'] = $up['totalCost'] / $up['quantity'];
66
-                $up['outPrice'] = ceil($up['realPrice'] * 1.1);
67
-            } else {
68
-                $up['realPrice'] = 0;
69
-                $up['outPrice'] = 0;
75
+                $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
70 76
             }
71
-            $up['cost'] = isset($sku['cost']) ? $sku['cost'] : 0;
72 77
 
73
-            $up_re = DB::table('goods_skus')->where('code', $code)->update($up);
74 78
         }
75 79
 
76 80
         return true;

+ 2 - 2
app/Console/Commands/freightCost.php

@@ -189,10 +189,10 @@ class freightCost extends Command {
189 189
         foreach( $data as $value ) {
190 190
             if( $value['logisticsCost'] > 0 ){
191 191
                 $freightCost = $value['logisticsCost'];
192
-                $re = DB::table('order_20191115')->where('logistics_id',$value['expressCode'])->where('is_del',0)->where('warehouse',3)
192
+                $re = DB::table('order')->where('logistics_id',$value['expressCode'])->where('is_del',0)->where('warehouse',3)
193 193
                     ->update(['freight_cost'=>$freightCost]);
194 194
 //                echo $value['expressCode'].' ';
195
-                $message = ' success update code:'.$value['expressCode'];
195
+                $message = ' success update code:'.$value['expressCode'].' freight_cost:'.$freightCost.' result:'.$re;
196 196
                 $this->log($message);
197 197
             } else {
198 198
                 continue;