Browse Source

分销订单库存

sunhao 5 years ago
parent
commit
ef23f4f64c

+ 9 - 0
app/Console/Commands/SyncOrderToMj.php

@@ -8,6 +8,7 @@ use App\OrderScript;
8 8
 use App\FxOrder;
9 9
 use App\GoodsSkus;
10 10
 use App\OrderGoodsSkus;
11
+use App\FxOrderGoodsSkus;
11 12
 use App\Goods;
12 13
 
13 14
 class SyncOrderToMj extends Command {
@@ -81,12 +82,20 @@ class SyncOrderToMj extends Command {
81 82
                 if($mjOrder['status'] == '已取消'){
82 83
                     $res = $this->updateFxOrderToMj($id);
83 84
                     echo "\n订单ID:".$id." 卖家取消订单重新更新";
85
+                    #同步到卖家云,更新order_goods_skus状态
86
+                    $mj_status = array();
87
+                    $mj_status['mj_status'] = 1;
88
+                    FxOrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
84 89
                 }
85 90
             }else{
86 91
                 $res = $this->syncFxOrderToMj($id);
87 92
                 if(!$res){
88 93
                     echo "\n订单ID:".$id." 同步失败";
89 94
                 }else{
95
+                    #同步到卖家云,更新order_goods_skus状态
96
+                    $mj_status = array();
97
+                    $mj_status['mj_status'] = 1;
98
+                    FxOrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
90 99
                     echo "\n订单ID:".$id." 同步成功";
91 100
                 }
92 101
             }

+ 2 - 1
app/GoodsSkus.php

@@ -18,7 +18,8 @@ class GoodsSkus extends Model
18 18
     	//计算实际库存 -还未到卖家云的量
19 19
     	$sku_quantity = GoodsSkus::where('id', $sku_id)->pluck('quantity');
20 20
         $w_num = OrderGoodsSkus::where('sku_id', $sku_id)->where('is_del',0)->where('mj_status',0)->sum('num');
21
-        $quantity = $sku_quantity - $w_num;
21
+        $fx_num = FxOrderGoodsSkus::where('sku_id', $sku_id)->where('is_del',0)->where('mj_status',0)->sum('num');
22
+        $quantity = $sku_quantity - $w_num - $fx_num;
22 23
         return $quantity;
23 24
     }
24 25
    

+ 24 - 1
app/Http/Controllers/Admin/FxOrderController.php

@@ -765,10 +765,17 @@ class FxOrderController extends Controller
765 765
 
766 766
         $skus = array_keys($order_skus);
767 767
         if(!empty($skus)){
768
-            $goods = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName as props_name', 'gs.price', 'gs.is_weigh')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->whereIn('gs.id', $skus)->orderBy('goods.id', 'desc')->get();
768
+            $goods = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName as props_name', 'gs.price', 'gs.is_weigh', 'gs.is_white', 'gs.quantity')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->whereIn('gs.id', $skus)->orderBy('goods.id', 'desc')->get();
769 769
             $goods = json_decode(json_encode($goods),true);
770 770
             foreach($goods as $k=>&$v){
771 771
                 $v['num'] = $order_skus[$v['sku_id']];
772
+                //计算实际库存 -还未到卖家云的量
773
+                $v['quantity'] = GoodsSkus::actualQuantity($v['sku_id']);
774
+                $v['quantity'] = $v['quantity'] + $v['num'];
775
+                $v['quantity_str'] = $v['quantity'];
776
+                if($v['is_white'] == 1){
777
+                    $v['quantity_str'] = '虚拟库存';
778
+                }
772 779
             }
773 780
             $order['goods'] = $goods;
774 781
         }
@@ -1120,6 +1127,11 @@ class FxOrderController extends Controller
1120 1127
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1121 1128
                 }
1122 1129
 
1130
+                #更新order_goods_skus状态
1131
+                $mj_status = array();
1132
+                $mj_status['mj_status'] = 2;
1133
+                FxOrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
1134
+
1123 1135
                 #记录操作日志
1124 1136
                 $self_id = session('admin_id');
1125 1137
                 $self_name = session('real_name');            
@@ -1174,6 +1186,12 @@ class FxOrderController extends Controller
1174 1186
                         throw new Exception("订单同步到卖家云失败");
1175 1187
                     }
1176 1188
                 }
1189
+
1190
+                #更新order_goods_skus状态,退回库存
1191
+                $mj_status = array();
1192
+                $mj_status['mj_status'] = 2;
1193
+                FxOrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
1194
+
1177 1195
                 #记录操作日志
1178 1196
                 $self_id = session('admin_id');
1179 1197
                 $self_name = session('real_name');            
@@ -1257,6 +1275,11 @@ class FxOrderController extends Controller
1257 1275
                     if( $syncMj == false ){
1258 1276
                         throw new Exception("订单同步到卖家云失败");
1259 1277
                     }
1278
+
1279
+                    #同步到卖家云,更新order_goods_skus状态
1280
+                    $mj_status = array();
1281
+                    $mj_status['mj_status'] = 1;
1282
+                    FxOrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
1260 1283
                 }
1261 1284
             }
1262 1285
 

+ 1 - 2
app/Http/Controllers/Admin/GoodsController.php

@@ -387,8 +387,7 @@ class GoodsController extends Controller
387 387
         $result = json_decode(json_encode($result), true);
388 388
         foreach($result as $k=>&$v){
389 389
             //计算实际库存 -还未到卖家云的量
390
-            $w_num = DB::table('order_goods_skus')->where('sku_id', $v['sku_id'])->where('is_del',0)->where('mj_status',0)->sum('num');
391
-            $v['quantity'] = $v['quantity'] - $w_num;
390
+            $v['quantity'] = GoodsSkus::actualQuantity($v['sku_id']);
392 391
         }
393 392
 
394 393
         if(empty($result)) exit('0');

+ 5 - 0
app/Http/Controllers/Admin/OrderController.php

@@ -870,6 +870,11 @@ class OrderController extends Controller
870 870
                 $v['num'] = $order_skus[$v['sku_id']];
871 871
                 //计算实际库存 -还未到卖家云的量
872 872
                 $v['quantity'] = GoodsSkus::actualQuantity($v['sku_id']);
873
+                $v['quantity'] = $v['quantity'] + $v['num'];
874
+                $v['quantity_str'] = $v['quantity'];
875
+                if($v['is_white'] == 1){
876
+                    $v['quantity_str'] = '虚拟库存';
877
+                }
873 878
             }
874 879
             $order['goods'] = $goods;
875 880
         }

+ 1 - 1
app/Http/Controllers/Api/OrderController.php

@@ -343,7 +343,7 @@ class OrderController extends Controller {
343 343
             return self::returnValue([],2000);
344 344
         }
345 345
 
346
-        $result = DB::table('customers')->select('receiverState', 'receiverCity', 'receiverAddress', 'fanTime')->where('phone', $phone)->first();
346
+        $result = DB::table('customers')->select('receiverState', 'receiverCity', 'receiverDistrict', 'receiverAddress', 'fanTime')->where('phone', $phone)->first();
347 347
         $result = json_decode(json_encode($result), true);
348 348
         return self::returnValue(['data'=>$result]);
349 349
     }

File diff suppressed because it is too large
+ 24 - 8
resources/views/fxorder/ordercreate.blade.php


File diff suppressed because it is too large
+ 19 - 5
resources/views/fxorder/orderedit.blade.php


File diff suppressed because it is too large
+ 2 - 2
resources/views/order/orderedit.blade.php