Explorar o código

订单 订单表添加字段warehouse_id 外键warehouse表 添加对应逻辑 需执行迁移文件

ajun %!s(int64=5) %!d(string=hai) anos
pai
achega
a303b97948

+ 85 - 35
app/Http/Controllers/TestController.php

@@ -44,6 +44,7 @@ use App\Services\common\DataHandlerService;
 use App\Services\InventoryCompareService;
 use App\Services\LogService;
 use App\Services\OracleActAllocationDetailService;
+use App\Services\OracleBasCustomerService;
 use App\Services\OracleDOCOrderHeaderService;
 use App\Services\OrderIssuePerformanceService;
 use App\Services\OrderIssueService;
@@ -52,10 +53,12 @@ use App\Services\OrderPackageService;
 use App\Services\OrderService;
 use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
+use App\Services\WarehouseService;
 use App\StoreCheckingReceive;
 use App\StoreCheckingReceiveItem;
 use App\Unit;
 use App\User;
+use App\Warehouse;
 use App\Waybill;
 use Carbon\Carbon;
 use Exception;
@@ -66,6 +69,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Support\Facades\Redis;
+use Ramsey\Collection\Collection;
 use Zttp\Zttp;
 
 class TestController extends Controller
@@ -81,6 +85,7 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
+
     /*dd('IN_Warehouse:'.$doc_asn_detail->warehouseid,
                      'In_ASNNo_C:'.$doc_asn_detail->docno,
                      'In_ASNLineNo_C:'.$doc_asn_detail->asnlineno,
@@ -105,22 +110,24 @@ class TestController extends Controller
                      'In_UserID:'.$doc_asn_detail->addwho,
                      'OUT_Return_Code:'.$result
                  );*/
-    public function test4(){
-        $r=Redis::connection();
+    public function test4()
+    {
+        $r = Redis::connection();
         $controller = new \App\Http\Controllers\Api\thirdPart\flux\StoreController();
         return $controller->quickStorage('JSCS202010210001');
     }
 
-    public function test2(){
+    public function test2()
+    {
         $db = DB::connection('oracle');
         $db->beginTransaction();
-        try{
+        try {
             $bas = $db->select("SELECT * FROM BAS_CODES where codeid = 'IVC_STS' and code = '00'");
             foreach ($bas as $a) {
                 $row = $db->update(DB::raw("UPDATE BAS_CODES set codename_c = '创建' WHERE codeid = ? and code = ?"), [$a->codeid, $a->code]);
                 if ($row > 0) $db->commit();
             }
-        }catch (\Exception $e){
+        } catch (\Exception $e) {
             $db->rollBack();
         }
     }
@@ -478,56 +485,57 @@ class TestController extends Controller
         }
     }
 
-    public function test5(){
-        ini_set('max_execution_time',2500);
-        ini_set('memory_limit','1526M');
+    public function test5()
+    {
+        ini_set('max_execution_time', 2500);
+        ini_set('memory_limit', '1526M');
         //清理冗余条码
 //        $this->cleanBarcode();
 
-        while(true){
+        while (true) {
             $toDay = Carbon::now();
             $skus = DB::select(DB::raw('select sku from commodities group by sku,owner_id having count(*)>1 limit 500 '));
-            $skus = array_column($skus,'sku');
+            $skus = array_column($skus, 'sku');
 
-            $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku',$skus)->get();
+            $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku', $skus)->get();
 
 
-            if (count($commodities) < 1)return "SUCCESS";
+            if (count($commodities) < 1) return "SUCCESS";
             $commodityMap = [];
             $commodityDel = [];
             $commodityTag = [];
             $commodityBar = [];
             $createBarcodes = [];
             $logs = [];
-            foreach ($commodities as $commodity){
-                if ($commodityMap[$commodity->sku.'_'.$commodity->owner_id] ?? false){
-                    $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
+            foreach ($commodities as $commodity) {
+                if ($commodityMap[$commodity->sku . '_' . $commodity->owner_id] ?? false) {
+                    $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
                     $logs[] = [
                         'id' => $commodity->id,
                         'sku' => $commodity->sku,
-                        'owner_id'=>$commodity->owner_id,
-                        'code'=>$codes,
+                        'owner_id' => $commodity->owner_id,
+                        'code' => $codes,
                     ];
                     $commodityDel[] = $commodity->id;
-                    $commodityTag[$commodity->id] = $commodityMap[$commodity->sku.'_'.$commodity->owner_id];
+                    $commodityTag[$commodity->id] = $commodityMap[$commodity->sku . '_' . $commodity->owner_id];
 
-                    $arr = array_diff($codes,$commodityBar[$commodity->sku.'_'.$commodity->owner_id]);
-                    foreach ($arr as $code){
-                        if (!$code)continue;
+                    $arr = array_diff($codes, $commodityBar[$commodity->sku . '_' . $commodity->owner_id]);
+                    foreach ($arr as $code) {
+                        if (!$code) continue;
                         $createBarcodes[] = [
                             'code' => $code,
-                            'commodity_id' => $commodityMap[$commodity->sku.'_'.$commodity->owner_id],
+                            'commodity_id' => $commodityMap[$commodity->sku . '_' . $commodity->owner_id],
                             'created_at' => $toDay,
                         ];
                     }
-                }else{
-                    $commodityMap[$commodity->sku.'_'.$commodity->owner_id] = $commodity->id;
-                    $commodityBar[$commodity->sku.'_'.$commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
+                } else {
+                    $commodityMap[$commodity->sku . '_' . $commodity->owner_id] = $commodity->id;
+                    $commodityBar[$commodity->sku . '_' . $commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
                 }
             }
-            dd($commodityMap,$commodityDel,$commodityTag);
-            LogService::log(__METHOD__,'清理商品',json_encode($logs,JSON_UNESCAPED_UNICODE));
-            LogService::log(__METHOD__,'重新分配商品',json_encode($commodityTag,JSON_UNESCAPED_UNICODE));
+            dd($commodityMap, $commodityDel, $commodityTag);
+            LogService::log(__METHOD__, '清理商品', json_encode($logs, JSON_UNESCAPED_UNICODE));
+            LogService::log(__METHOD__, '重新分配商品', json_encode($commodityTag, JSON_UNESCAPED_UNICODE));
 
             app('inventoryAccountMissionService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存盘点任务
             app('inventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
@@ -536,13 +544,14 @@ class TestController extends Controller
             app('storeCheckingReceiveItemService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新入库盘收一体
             app('orderPackageCommoditiesService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新订单商品
 
-            LogService::log(__METHOD__,'删除商品与对应条码',json_encode($commodityDel,JSON_UNESCAPED_UNICODE));
-            CommodityBarcode::query()->whereIn('commodity_id',$commodityDel)->delete();
+            LogService::log(__METHOD__, '删除商品与对应条码', json_encode($commodityDel, JSON_UNESCAPED_UNICODE));
+            CommodityBarcode::query()->whereIn('commodity_id', $commodityDel)->delete();
             Commodity::destroy($commodityDel);
         }
     }
 
-    private function cleanBarcode(){
+    private function cleanBarcode()
+    {
 
         $logCommodityBarcodes = CommodityBarcode::query()->where('code', "")->get();
         if (count($logCommodityBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-删除空条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
@@ -627,7 +636,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
             }
             $updateCommodities[$del->commodity_id] = $target->commodity_id;
         }
-        if (count($updateCommodities) > 0){
+        if (count($updateCommodities) > 0) {
             app('inventoryAccountMissionService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存盘点任务
             app('inventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
             app('inventoryDailyLogService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存每日记录
@@ -714,7 +723,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         /** @var OrderService $orderService */
         $orderService = app(OrderService::class);
         $owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
-        $startDate = \Illuminate\Support\Carbon::parse('2020-10-10 00:00:00')->toDateTimeString();
+        $startDate = \Illuminate\Support\Carbon::parse('2020-10-28 00:00:00')->toDateTimeString();
         $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
             ->where('addTime', '>=', $startDate)
             ->whereIn('customerID', data_get($owners, '*.code'))
@@ -722,8 +731,10 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         $orderService->updateByWmsOrders($orderHeaders);
         $orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
     }
-    public function test11(){
-        $orderHeader = OracleDOCOrderHeader::query()->with('actAllocationDetails')->where('orderNo','SO201024001172')->get();
+
+    public function test11()
+    {
+        $orderHeader = OracleDOCOrderHeader::query()->with('actAllocationDetails')->where('orderNo', 'SO201024001172')->get();
         dd(app(OrderService::class)->createByWmsOrder($orderHeader));
     }
 
@@ -732,4 +743,43 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         dd(Request::all());
     }
 
+    public function updateOrdersWarehouse()
+    {
+        /**
+         * @var DataHandlerService $dataHandlerService
+         * @var OrderService $orderService
+         */
+        $dataHandlerService = app(DataHandlerService::class);
+        $orderService = app(OrderService::class);
+        $page = 500;
+        $count = Order::query()->count();
+        $warehouse = Warehouse::query()->get();
+        $warehouse_map = $dataHandlerService->dataHeader(['code'], $warehouse);
+        for ($i = 0; $i < $count; $i += $page) {
+            $min = $i;$max = $i + $page;
+            $orders = Order::query()->where('id', '>=', $min)->where('id', '<=', $max)->get();
+            $orderNos = array_diff(array_unique(data_get($orders, '*.code')), ['', ' ', '*', null]);
+            if (count($orderNos)==0) continue;
+            /** @var Collection $orderHeaders */
+            $orderHeaders = OracleDOCOrderHeader::query()->whereIn('orderno', $orderNos)->get();
+            if ($orderHeaders->count() == 0) continue;
+            $orderHeader_map = $dataHandlerService->dataHeader(['orderno'], $orderHeaders);
+            $update_params = [];
+            $update_params[] = ['id', 'warehouse_id'];
+            foreach ($orders as $order) {
+                $orderHeader = $dataHandlerService->getKeyValue(['orderno' => $order->code], $orderHeader_map);
+                if ($orderHeader == null) continue;
+                $warehouse = $dataHandlerService->getKeyValue(['code' => $orderHeader->warehouseid], $warehouse_map);
+                if ($warehouse == null) continue;
+                $update_params[] = [
+                    'id' => $order->id,
+                    'warehouse_id' => $warehouse->id
+                ];
+            }
+            $orderService->batchUpdate($update_params);
+            unset($orders, $orderHeaders, $update_params);
+        }
+        unset($warehouse);
+    }
+
 }

+ 16 - 9
app/Order.php

@@ -13,12 +13,13 @@ class Order extends Model
     protected $fillable = [
         'created_at', 'code', 'shop_id', 'owner_id', 'client_code',
         'logistic_id', 'consignee_name', 'consignee_phone', 'province',
-        'city', 'district', 'address', 'wms_status'];
+        'city', 'district', 'address', 'wms_status','warehouse_id'];
 
     /*
-     * wms订单号     code=>DOC_ORDER_HEADER[orderno]
-     * 客户订单号     client_code=>DOC_ORDER_HEADER['soreference1']
-     * wms订单状态    wms_status=>
+     * wms订单号             code=>DOC_ORDER_HEADER[orderno]
+     * wms客户订单号         client_code=>DOC_ORDER_HEADER['soreference1']
+     * wms订单状态           wms_status=>
+     * 仓库                 warehouse_id=>DOC_ORDER_HEADER['WAREHOUSEID']
      */
 
     protected $appends = [
@@ -29,27 +30,33 @@ class Order extends Model
 
     public function logistic()
     {
-        return $this->hasOne('App\Logistic', 'id', 'logistic_id');
+        return $this->hasOne(Logistic::class, 'id', 'logistic_id');
     }
 
     public function issue()
     {
-        return $this->belongsTo('App\OrderIssue', 'id', 'order_id');
+        return $this->belongsTo(OrderIssue::class, 'id', 'order_id');
     }
 
     public function shop()
     {
-        return $this->belongsTo('App\Shop', 'shop_id', 'id');
+        return $this->belongsTo(Shop::class, 'shop_id', 'id');
     }
 
     public function owner()
     {
-        return $this->hasOne('App\Owner', 'id', 'owner_id');
+        return $this->hasOne(Owner::class, 'id', 'owner_id');
     }
 
     public function packages()
     {
-        return $this->hasMany('App\OrderPackage','order_id','id');
+        return $this->hasMany(OrderPackage::class,'order_id','id');
+    }
+
+    public function warehouse()
+    {
+        return $this->hasOne(Warehouse::class, 'id', 'owner_id');
+
     }
 
     public function getLogisticNumbersAttribute()

+ 17 - 0
app/Services/OracleBasCustomerService.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Services;
+
+use App\OracleBasCustomer;
+
+Class OracleBasCustomerService
+{
+    public function getWareHouse($customerIDs = null)
+    {
+        if(!$customerIDs){
+            return OracleBasCustomer::query()->where('Customer_Type','WH')->get();
+        }
+        return  OracleBasCustomer::query()->where('Customer_Type','WH')->get();
+    }
+
+}

+ 34 - 13
app/Services/OrderService.php

@@ -16,6 +16,7 @@ use App\RejectedBill;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
 use App\Shop;
+use App\Warehouse;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Support\Facades\App;
@@ -480,20 +481,26 @@ class OrderService
     public function createByWmsOrder($orderHeaders)
     {
         if($orderHeaders->isEmpty())return null;
-        /** @var OwnerService $ownerService */
-        /** @var LogisticService $logisticService */
-        /** @var ShopService $shopService */
-        /** @var OrderPackageService $orderPackageService */
+        /**
+         * @var OwnerService $ownerService
+         * @var WarehouseService $warehouseService
+         * @var LogisticService $logisticService
+         * @var ShopService $shopService
+         * @var OrderPackageService $orderPackageService
+         */
+        $warehouseService =app(WarehouseService::class);
         $ownerService = app(OwnerService::class);
         $logisticService = app(LogisticService::class);
         $shopService = app(ShopService::class);
         $orderPackageService = app(OrderPackageService::class);
 
-        $owners_code_map = [];$logistics_code_map = [];$shop_name_map=[]; $owners_id_map = [];
+        $owners_code_map = [];$logistics_code_map = [];$shop_name_map=[]; $owners_id_map = [];$warehouses_code_map =[];
 
         $owners = $ownerService->getByWmsOrders($orderHeaders);
         $logistics = $logisticService->getByWmsOrders($orderHeaders);
         $shops = $shopService->getByWmsOrders($orderHeaders);
+        $warehouses=$warehouseService->getByWmsOrders($orderHeaders);
+
 
         foreach ($owners as $owner) {
             $owners_code_map[$owner->code] = $owner;
@@ -508,7 +515,12 @@ class OrderService
             $key = ' owner_code='.$owner_code.' name='.$shop->name;
             $shop_name_map[$key] = $shop;
         }
-        $insert_params = $this->getParamsByOrderHeader($orderHeaders,$owners_code_map,$logistics_code_map,$shop_name_map);
+
+        foreach ($warehouses as $warehouse) {
+            $warehouses_code_map[$warehouse->code] = $warehouse;
+        }
+
+        $insert_params = $this->getParamsByOrderHeader($orderHeaders,$owners_code_map,$logistics_code_map,$shop_name_map,$warehouses_code_map);
 
         if(count($insert_params)> 0){
             $this->create($insert_params);
@@ -520,7 +532,7 @@ class OrderService
     }
 
 
-    public function getParamsByOrderHeader($orderHeaders_map,$owners_code_map,$logistics_code_map,$shop_name_map)
+    public function getParamsByOrderHeader($orderHeaders_map,$owners_code_map,$logistics_code_map,$shop_name_map,$warehouses_code_map)
     {
         $params = [];
         $orders = Order::query()->whereIn('code',data_get($orderHeaders_map,'*.orderno'))->get();
@@ -532,6 +544,7 @@ class OrderService
              if($order_code_map[$orderHeader->orderno] ?? false)continue;
             $owner = $owners_code_map[$orderHeader->customerid] ?? null;
             $logistic =  $logistics_code_map[$orderHeader->userdefine1] ?? null;
+            $warehouse=$warehouses_code_map[$orderHeader->warehouseid] ?? null;
             $key = ' owner_code='.$orderHeader->customerid.' name='.$orderHeader->issuepartyname ?? '';
             $shop = $shop_name_map[$key] ?? '';
             $params[] = [
@@ -548,7 +561,8 @@ class OrderService
                 'district' => $orderHeader->c_district,
                 'address' => $orderHeader->c_address1,
                 'client_code' => $orderHeader->soreference1,
-                'wms_edittime' =>$orderHeader->edittime
+                'wms_edittime' =>$orderHeader->edittime,
+                'warehouse_id' =>$warehouse->id??''
             ];
         }
         return $params;
@@ -585,8 +599,10 @@ class OrderService
         $shops = app(ShopService::class)->getByWmsOrders($orderHeaders);
         $shops_map = $dataHandlerService->dataHeader(['owner_id','name'],$shops);
 
+        $warehouses = app(WarehouseService::class)->getByWmsOrders($orderHeaders);
+        $warehouses_map = $dataHandlerService->dataHeader(['code'],$warehouses);
         $updateParams = [[
-            'id','owner_id','wms_status','logistic_id','shop_id','consignee_name','consignee_phone','province','city','district','address','client_code','updated_at','wms_edittime'
+            'id','owner_id','wms_status','logistic_id','shop_id','consignee_name','consignee_phone','province','city','district','address','client_code','updated_at','wms_edittime','warehouse_id'
         ]];
         $updated_at = Carbon::now()->toDateTimeString();
         foreach ($orderHeaders as $orderHeader) {
@@ -595,10 +611,11 @@ class OrderService
             $logistic = $dataHandlerService->getKeyValue(['code'=>$orderHeader->userdefine1] ,$logistics_code_map);
             $owner = $dataHandlerService->getKeyValue(['code'=>$orderHeader->customerid] ,$owner_code_map);
             $shop = $dataHandlerService->getKeyValue(['owner_id'=>$owner->id ?? '','name'=> $orderHeader->issuepartyname] ,$shops_map);
+            $warehouse=$dataHandlerService->getKeyValue(['code'=>$orderHeader->warehouseid],$warehouses_map);
             $shop_id = $shop->id ?? null;
             $logistic_id = $logistic->id ?? null;
             $owner_id = $owner->id ?? null;
-
+            $warehouse_id=$warehouse->id??null;
             if($order->wms_status != $orderHeader->oracleBASCode_codename_c ||
                 $order->logistic_id != $logistic_id ||
                 $order->shop_id != $shop_id ||
@@ -610,7 +627,8 @@ class OrderService
                 $order->district != $orderHeader->c_district ||
                 $order->address != $orderHeader->c_address1 ||
                 $order->client_code != $orderHeader->soreference1 ||
-                $order->wms_edittime != $orderHeader->edittime){
+                $order->wms_edittime != $orderHeader->edittime||
+                $order->warehouse_id!=$warehouse_id){
                 $updateParams[] = [
                     'id'=>$order->id,
                     'owner_id' => $owner_id,
@@ -625,7 +643,8 @@ class OrderService
                     'address' => $orderHeader->c_address1,
                     'client_code' => $orderHeader->soreference1,
                     'updated_at' =>$updated_at,
-                    'wms_edittime' =>$orderHeader->edittime];
+                    'wms_edittime' =>$orderHeader->edittime,
+                    'warehouse_id'=>$warehouse_id];
             }
         }
         if(count($updateParams) > 1){
@@ -671,6 +690,7 @@ class OrderService
         $logistic = Logistic::query()->where('code',$orderHeader->userdefine1)->first();
         $owner = Owner::query()->where('code',$orderHeader->customerid ?? '')->first();
         $shop = Shop::query()->where('name',$orderHeader->issuepartyname)->where('owner_id',$owner->id)->first();
+        $warehouse = app('warehouseService')->firstOrCreate(["code"=>$orderHeader->warehouseid],["code"=>$orderHeader->warehouseid,"name"=>$orderHeader->warehouseid]);
         return [
             'code' =>$orderHeader->orderno,
             'owner_id' =>$owner->id,
@@ -685,7 +705,8 @@ class OrderService
             'client_code' =>$orderHeader->soreference1,
             'wms_edittime' => $orderHeader->edittime,
             'wms_status' => $orderHeader->oracleBASCode_codename_c ?? '',
-            'update_at' => Carbon::now()->format('Y-m-d H:i:s')
+            'update_at' => Carbon::now()->format('Y-m-d H:i:s'),
+            'warehouse_id' => $warehouse->id ?? ''
         ];
     }
 

+ 42 - 4
app/Services/WarehouseService.php

@@ -1,14 +1,52 @@
-<?php 
+<?php
 
-namespace App\Services; 
+namespace App\Services;
 
+use App\OracleBasCustomer;
 use App\Warehouse;
+use Illuminate\Support\Collection;
 
 Class WarehouseService
-{ 
+{
     public function firstOrCreate(array $params, array $values = null){
         if ($values)return Warehouse::query()->firstOrCreate($params,$values);
         return Warehouse::query()->firstOrCreate($params);
     }
 
-}
+    public function getByWmsOrders($orderHeaders)
+    {
+        $wareHouse_Ids=array_diff(array_unique(data_get($orderHeaders,'*.warehouseid')),['',' ','*',null]);
+        $wareHouses=Warehouse::query()->whereIn('code',$wareHouse_Ids)->get();
+        if(count($wareHouse_Ids)>$wareHouses->count()){
+            $需要添加_仓库编码=[];
+            foreach ($wareHouse_Ids as $warehouse_id) {
+                if($wareHouses->where('code')->count()==0){
+                    $需要添加_仓库编码[]=$warehouse_id;
+                }
+            }
+            $create_wareHouse=$this->syncWmsWareHouse($需要添加_仓库编码);
+            $wareHouses->concat($create_wareHouse);
+        }
+        return $wareHouses;
+    }
+
+    public function syncWmsWareHouse($warehouse_ids)
+    {
+        $collet = new Collection();
+        if(!$warehouse_ids)return null;
+        /** @var Collection $oracleBasCustomers */
+        $oracleBasCustomers=app(OracleBasCustomerService::class)->getWareHouse($warehouse_ids);
+        $warehouses=Warehouse::query()->where('code',data_get($oracleBasCustomers,'*.CustomerID'))->get();
+        $oracleBasCustomers=$oracleBasCustomers->filter(function($oracleBasCustomer)use($warehouses){
+            return $warehouses->where('code',$oracleBasCustomer->warehouseid)->count()>0;
+        });
+        foreach ($oracleBasCustomers as $oracleBasCustomer){
+            $wereHouse=Warehouse::query()->create([
+                'code'=>$oracleBasCustomer->customerid,
+                'name'=>$oracleBasCustomer->descr_c
+            ]);
+            $collet->push($wereHouse);
+        }
+        return  $collet;
+    }
+}

+ 32 - 0
database/migrations/2020_10_29_092202_add_order_table_column_warehouse_id.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddOrderTableColumnWarehouseId extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->integer('warehouse_id')->index()->nullable()->comment('仓库')->after('id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->dropColumn('warehouse_id');
+        });
+    }
+}