Просмотр исходного кода

Merge branch 'master' into yang

# Conflicts:
#	app/Console/Kernel.php
#	app/Http/Controllers/TestController.php
#	database/factories/WarehouseFactory.php
ANG YU 5 лет назад
Родитель
Сommit
8bd1809888
100 измененных файлов с 3034 добавлено и 281 удалено
  1. 2 0
      .gitignore
  2. 5 1
      app/Batch.php
  3. 3 2
      app/Console/Commands/CreateOwnerBillReport.php
  4. 146 19
      app/Console/Commands/SyncBatchTask.php
  5. 16 8
      app/Console/Commands/SyncWMSOrderTask.php
  6. 3 3
      app/Console/Kernel.php
  7. 1 1
      app/Exceptions/Handler.php
  8. 8 17
      app/Http/Controllers/LogController.php
  9. 85 0
      app/Http/Controllers/MaterialBoxController.php
  10. 35 0
      app/Http/Controllers/OrderCommodityAssignController.php
  11. 1 1
      app/Http/Controllers/OrderTrackingController.php
  12. 90 0
      app/Http/Controllers/StationController.php
  13. 85 0
      app/Http/Controllers/StationRuleBatchController.php
  14. 85 0
      app/Http/Controllers/StationTaskBatchController.php
  15. 85 0
      app/Http/Controllers/StationTaskBatchTypeController.php
  16. 85 0
      app/Http/Controllers/StationTaskCommodityController.php
  17. 85 0
      app/Http/Controllers/StationTaskController.php
  18. 85 0
      app/Http/Controllers/StationTaskMaterialBoxController.php
  19. 85 0
      app/Http/Controllers/StationTaskTypeController.php
  20. 85 0
      app/Http/Controllers/StationTypeController.php
  21. 7 1
      app/Http/Controllers/StoreCheckingReceiveController.php
  22. 74 55
      app/Http/Controllers/TestController.php
  23. 11 6
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  24. 27 0
      app/Http/Controllers/api/thirdPart/haiq/LightController.php
  25. 9 4
      app/Http/Controllers/api/thirdPart/haiq/PickStationController.php
  26. 24 8
      app/Http/Controllers/api/thirdPart/haiq/StorageController.php
  27. 1 0
      app/Http/Controllers/api/thirdPart/haochuang/SortingController.php
  28. 153 0
      app/Imports/UpdatePickZone.php
  29. 44 0
      app/Jobs/OrderCreateInstantBill.php
  30. 44 0
      app/Jobs/ProcessCreateInstantBill.php
  31. 45 0
      app/Jobs/StoreCreateInstantBill.php
  32. 7 0
      app/Log.php
  33. 10 0
      app/MaterialBox.php
  34. 3 0
      app/OracleDOCOrderHeader.php
  35. 4 1
      app/Order.php
  36. 33 0
      app/OrderCommodityAssign.php
  37. 2 0
      app/OwnerFeeDetail.php
  38. 14 2
      app/Providers/AppServiceProvider.php
  39. 49 0
      app/Services/BatchService.php
  40. 63 0
      app/Services/CommodityService.php
  41. 15 0
      app/Services/DocWaveHeaderService.php
  42. 25 0
      app/Services/ForeignHaiRoboticsService.php
  43. 28 0
      app/Services/LogisticService.php
  44. 24 0
      app/Services/OracleBasCustomerService.php
  45. 8 3
      app/Services/OracleDOCOrderHeaderService.php
  46. 31 0
      app/Services/OrderCommodityAssignService.php
  47. 212 0
      app/Services/OrderCommodityService.php
  48. 15 2
      app/Services/OrderIssueService.php
  49. 46 33
      app/Services/OrderPackageCommoditiesService.php
  50. 9 1
      app/Services/OrderPackageService.php
  51. 147 38
      app/Services/OrderService.php
  52. 22 35
      app/Services/OrderTrackingService.php
  53. 20 0
      app/Services/OwnerFeeDetailService.php
  54. 16 11
      app/Services/OwnerPriceExpressService.php
  55. 29 10
      app/Services/OwnerPriceOperationService.php
  56. 21 0
      app/Services/OwnerService.php
  57. 20 0
      app/Services/ProcessService.php
  58. 9 0
      app/Services/ProvinceService.php
  59. 33 0
      app/Services/ShopService.php
  60. 39 0
      app/Services/StationService.php
  61. 61 0
      app/Services/StationTaskBatchService.php
  62. 26 0
      app/Services/StationTaskBatchTypeService.php
  63. 28 0
      app/Services/StoreService.php
  64. 37 5
      app/Services/WarehouseService.php
  65. 43 0
      app/Services/WaybillService.php
  66. 17 0
      app/Station.php
  67. 10 0
      app/StationRuleBatch.php
  68. 10 0
      app/StationTask.php
  69. 10 0
      app/StationTaskBatch.php
  70. 10 0
      app/StationTaskBatchType.php
  71. 10 0
      app/StationTaskCommodity.php
  72. 10 0
      app/StationTaskMaterialBox.php
  73. 10 0
      app/StationTaskType.php
  74. 10 0
      app/StationType.php
  75. 11 0
      app/Utils/helpers.php
  76. 3 0
      composer.json
  77. 9 1
      config/api.php
  78. 7 5
      config/cache.php
  79. 1 0
      config/sync.php
  80. 12 0
      database/factories/MaterialBoxFactory.php
  81. 18 0
      database/factories/OracleActAllocationDetailsFactory.php
  82. 14 0
      database/factories/OracleBasCodeFactory.php
  83. 14 0
      database/factories/OracleBasCustomerFactory.php
  84. 19 0
      database/factories/OracleBasSKUFactory.php
  85. 16 0
      database/factories/OracleDOCOrderDetailFactory.php
  86. 35 0
      database/factories/OrcaleDOCOrderHeaderFactory.php
  87. 1 1
      database/factories/ShopFactory.php
  88. 12 0
      database/factories/StationFactory.php
  89. 12 0
      database/factories/StationMissionBatchFactory.php
  90. 12 0
      database/factories/StationMissionBatchTypeFactory.php
  91. 12 0
      database/factories/StationMissionCommodityFactory.php
  92. 12 0
      database/factories/StationMissionMaterialBoxFactory.php
  93. 12 0
      database/factories/StationRuleBatchFactory.php
  94. 12 0
      database/factories/StationTaskFactory.php
  95. 12 0
      database/factories/StationTaskTypeFactory.php
  96. 12 0
      database/factories/StationTypeFactory.php
  97. 2 4
      database/factories/WarehouseFactory.php
  98. 1 1
      database/migrations/2020_01_02_172739_change_waybill_price_model_field.php
  99. 1 1
      database/migrations/2020_03_09_153510_create_stores_table.php
  100. 2 1
      database/migrations/2020_04_09_111540_change_tutorial_table.php

+ 2 - 0
.gitignore

@@ -9,6 +9,7 @@
 /public/mix-manifest.json
 /public/js/app.js
 /public/css/app.csscd
+/public/css/app.css
 /storage/*.key
 /vendor
 .env
@@ -27,3 +28,4 @@ yarn-error.log
 /public/icon/img404-thumbnail.jpg
 /public/phpMyAdmin4.8.5/
 /public/fonts
+/phpunit.xml

+ 5 - 1
app/Batch.php

@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
 class Batch extends Model
 {
     protected $fillable = [
-        'id','code','type', 'wms_type', 'status', 'wms_status', 'wms_created_at',
+        'id','code','type', 'wms_type', 'status', 'wms_status', 'wms_created_at',"remark","owner_id",
     ];
     public function orders(){
         return $this->hasMany('App\Order','batch_id','id');
@@ -33,5 +33,9 @@ class Batch extends Model
         });
         return parent::delete(); // TODO: Change the autogenerated stub
     }
+    public function owner()
+    {
+        return $this->hasOne(Owner::class,"id","owner_id");
+    }
 
 }

+ 3 - 2
app/Console/Commands/CreateOwnerBillReport.php

@@ -46,7 +46,8 @@ class CreateOwnerBillReport extends Command
             $year--;
             $lastMonth = '12';
         }else $lastMonth = ($month-1) < 10 ? "0".($month-1) : ($month-1);
-        $bills = DB::select(DB::raw("select owner_id,SUM(work_fee)+SUM(logistic_fee) as total from owner_fee_details where worked_at like ? GROUP BY owner_id"),[$year."-".$lastMonth."%"]);
+        $sql = "SELECT owner_id,SUM(work_fee)+SUM(logistic_fee) AS total FROM owner_fee_details WHERE worked_at LIKE ? AND (type = '发货' AND logistic_fee IS NOT NULL AND work_fee IS NOT NULL) OR (type <> '发货' AND work_fee IS NOT NULL)  GROUP BY owner_id";
+        $billDetails = DB::select(DB::raw($sql),[$year."-".$lastMonth."%"]);
 
         $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel")->where("counting_month","like",$year."-".$lastMonth."%")->get();
         $map = [];
@@ -62,7 +63,7 @@ class CreateOwnerBillReport extends Command
             }
         }
 
-        $chunks = array_chunk($bills,50);
+        $chunks = array_chunk($billDetails,50);
         foreach ($chunks as $bills){
             $date = date('Y-m-d H:i:s');
             $createOwnerBillReport = [];

+ 146 - 19
app/Console/Commands/SyncBatchTask.php

@@ -2,42 +2,169 @@
 
 namespace App\Console\Commands;
 
+use App\Services\BatchService;
+use App\Services\CacheService;
+use App\Services\common\BatchUpdateService;
 use App\Services\DocWaveHeaderService;
+use App\Services\LogService;
+use App\ValueStore;
+use Carbon\Carbon;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
 
 class SyncBatchTask extends Command
 {
-    /**
-     * @var string
-     */
     protected $signature = 'sync:batch';
 
-    /**
-     * @var string
-     */
     protected $description = 'sync wms batch task';
 
-    /**
-     * @return void
-     */
+    /** @var DocWaveHeaderService $service */
+    private $service;
+    /** @var BatchService $batchService */
+    private $batchService;
+
     public function __construct()
     {
         parent::__construct();
+        $this->service = app(DocWaveHeaderService::class);
+        $this->batchService = app(BatchService::class);
     }
 
-    /**
-     * Execute the console command.
-     *
-     * @return void
-     */
     public function handle()
     {
-        /** @var DocWaveHeaderService $service */
-        $service = app(DocWaveHeaderService::class);
-        $date = $service->getSyncDate();
-        $flux = $service->get(["edittime"=>$date],["edittime"=>"gtOrEqual"]);
-        if (!$flux)return;
+        $this->disposeHeader();
+        $this->disposeDetail();
+    }
+
+    private function disposeHeader()
+    {
+        //获取更新时间与WMS数据
+        $date = $this->service->getSyncDate();
+        $waves = $this->service->get(["edittime"=>$date],["edittime"=>"gtOrEqual"]);
+        if (count($waves) < 1)return;
 
+        //获取本地数据对比差异
+        $codes = array_column($waves->toArray(),"waveno");
+        $map = [];
+        $batches = $this->batchService->get(["code"=>$codes]);
+        if ($batches){
+            foreach ($batches as $batch)$map[$batch->code] = $batch->id;
+        }
+        $update = [["id","wms_status","remark","updated_at"]];
+        $insert = [];
+        foreach ($waves as $wave){
+            if (isset($map[$wave->waveno])){
+                $update[] = [
+                    "id" => $map[$wave->waveno],
+                    "wms_status" => $this->wms_status($wave),
+                    "remark"=>$wave->descr,
+                    "updated_at"=>$wave->edittime,
+                ];
+                continue;
+            }
+            $owner = app("OwnerService")->codeGetOwner($wave->customerid);
+            $insert[] = [
+                "code" => $wave->waveno,
+                "remark"=>$wave->descr,
+                "status" => '未处理',
+                "wms_status" => $this->wms_status($wave),
+                "created_at"=>$wave->addtime,
+                "updated_at"=>$wave->edittime,
+                "owner_id"=>$owner->id,
+            ];
+        }
 
+        //存在则更新
+        if (count($update)>1){
+            $bool = app(BatchUpdateService::class)->batchUpdate("batches",$update);
+            if ($bool)LogService::log(__METHOD__,"SUCCESS-同步更新波次成功",json_encode($update));
+            else{
+                LogService::log(__METHOD__,"ERROR-同步更新波次失败",json_encode($update));
+                return;
+            }
+        }
+
+        //不存在则录入
+        if ($insert){
+            $this->batchService->insert($insert);
+            LogService::log(__METHOD__,"SUCCESS-同步插入波次成功",json_encode($insert));
+        }
+        $lastDate = $waves[0]->edittime;
+        $this->service->setSyncDate($lastDate);
+    }
+
+    public function disposeDetail()
+    {
+        $date = app(CacheService::class)->getOrExecute("wave_detail_last_sync_date",function (){
+            $valueStore = ValueStore::query()->where("name","wave_detail_last_sync_date")->first();
+            return $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
+        });
+        $sql = "SELECT WM_CONCAT(ORDERNO) orderno,WAVENO FROM DOC_WAVE_DETAILS WHERE EDITTIME > TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')  GROUP BY WAVENO";
+        $details = DB::connection("oracle")->select(DB::raw($sql),[$date]);
+        if (count($details) < 1)return;
+        $map = [];
+        $nos = [];
+        foreach ($details as $detail){
+            $map[$detail->waveno] = explode(",",$detail->orderno);
+            $nos[] = $detail->waveno;
+        }
+        $batches = $this->batchService->get(["code"=>$nos]);
+        foreach ($batches as $batch){
+            app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
+            unset($map[$batch->code]);
+        }
+        if ($map){
+            $waveCodes = array_keys($map);
+            $waves = $this->service->get(["waveno"=>$waveCodes],["waveno"=>"in"]);
+            $insert = [];
+            foreach ($waves as $wave){
+                $owner = app("OwnerService")->codeGetOwner($wave->customerid);
+                $insert[] = [
+                    "code" => $wave->waveno,
+                    "status" => '未处理',
+                    "wms_status" => $this->wms_status($wave),
+                    "remark"=>$wave->descr,
+                    "created_at"=>$wave->addtime,
+                    "updated_at"=>$wave->edittime,
+                    "owner_id"=>$owner->id,
+                ];
+            }
+            if ($insert){
+                $this->batchService->insert($insert);
+                LogService::log(__METHOD__,"SUCCESS-同步插入波次成功",json_encode($insert));
+                $batches = $this->batchService->get(["code"=>$waveCodes]);
+                foreach ($batches as $batch){
+                    app("OrderService")->update(["code"=>$map[$batch->code]],["batch_id"=>$batch->id]);
+                }
+            }
+        }
+//        $this->batchService->assignTasks($batches);
+
+
+        ValueStore::query()->where("name","wave_last_sync_date")->update(["value"=>Carbon::now()->subSeconds(1)->toDateTimeString()]);
+    }
+
+    /**
+     * @param $wave
+     * @return string
+     */
+    public function wms_status($wave): string
+    {
+        switch ($wave->wavestatus) {
+            case 00:
+                $wms_status = '创建';
+                break;
+            case 40:
+                $wms_status = '部分收货';
+                break;
+            case 90:
+                $wms_status = '取消';
+                break;
+            case 99:
+                $wms_status = '完成';
+                break;
+            default:null;
+        }
+        return $wms_status;
     }
 }

+ 16 - 8
app/Console/Commands/SyncWMSOrderTask.php

@@ -38,6 +38,8 @@ class SyncWMSOrderTask extends Command
      */
     public function handle()
     {
+        $is_enabled= config('sync.order_sync.cache_prefix.enabled');
+        if($is_enabled=='false')return;
         $this->syncCreatedOrder();
         $this->syncUpdatedOrder();
     }
@@ -52,24 +54,27 @@ class SyncWMSOrderTask extends Command
         $newest_list    = config('sync.order_sync.cache_prefix.newest_list');
         $hasKey         = config('sync.order_sync.cache_prefix.newest_has');
         $prefixKey      = config('sync.order_sync.cache_prefix.newest');
-
+        ini_set('memory_limit', '512M');
         $orderService = app('OrderService');
         $oracleDOCOrderHeaderService = app('OracleDocOrderHeaderService');
 
-        $last_date = $orderService->getOrderSyncAt($newest,'newest');                              // 获取时间点
-        $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnStartDate($last_date);           // WMS订单
-        if(!$orderHeaders)return;
+        $last_date = $orderService->getOrderSyncAt($newest,'newest');                             // 获取时间点
+
+        $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnStartDate($last_date);               // WMS订单
+        if($orderHeaders->count()==0)return;
         $last_order = $orderHeaders->first();                                                           // 时间点靠后的
-        $renewal_orders = $orderHeaders->where('addtime',$last_order->addtime);
+        $newest_orders = $orderHeaders->where('addtime',$last_order->addtime);
 
         $orderHeaders = $orderService->filterOrderByCache($orderHeaders,$newest_list);                  // 对比缓存
 
-        if(count($orderHeaders)>0 && count($orderHeaders) >0){
+        if(count($newest_orders)>0 && count($orderHeaders) >0){
+
             $orderService->syncOrder($orderHeaders);                                                //  同步订单
             $orderService->cancelOrderCache($newest_list,$prefixKey);                                   //  清除缓存
-            $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$newest_list);             //  添加缓存
+            $orderService->pushOrderCache($newest_orders,$prefixKey,$hasKey,$newest_list);              //  添加缓存
             $orderService->setOrderSyncAt($newest,$last_order->addtime,count($orderHeaders)>0);   //  更新时间
         }
+
     }
 
     public function syncUpdatedOrder()
@@ -82,20 +87,23 @@ class SyncWMSOrderTask extends Command
         $renewal_list   = config('sync.order_sync.cache_prefix.renewal_list');
         $hasKey         = config('sync.order_sync.cache_prefix.renewal_has');
         $prefixKey      = config('sync.order_sync.cache_prefix.renewal');
+        ini_set('memory_limit', '512M');
 
         $orderService = app('OrderService');
         $oracleDOCOrderHeaderService = app('OracleDocOrderHeaderService');
 
         $last_date = $orderService->getOrderSyncAt($renewal,'renewal');                               // 获取时间点
+
         $orderHeaders = $oracleDOCOrderHeaderService->getWMSOrderOnEditDate($last_date);                   // WMS订单
 
-        if(!$orderHeaders)return;
+        if($orderHeaders->count()==0)return;
         $renewal_order = $orderHeaders->first();                                                            // 时间点靠后的
         $renewal_orders =  $orderHeaders->where('edittime',$renewal_order->edittime);
 
         $orderHeaders = $orderService->filterOrderByCache($orderHeaders,$renewal_list);                     // 对比缓存
 
         if(count($renewal_orders)>0 && count($orderHeaders)>0){
+
             $orderService->syncOrder($orderHeaders);                                                    // 同步订单
             $orderService->cancelOrderCache($renewal_list,$prefixKey);                                      // 清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$renewal_list);                // 添加缓存

+ 3 - 3
app/Console/Kernel.php

@@ -2,6 +2,7 @@
 
 namespace App\Console;
 
+use App\Console\Commands\SyncBatchTask;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
@@ -21,7 +22,7 @@ class Kernel extends ConsoleKernel
         \App\Console\Commands\SyncLogCacheTask::class,
         \App\Console\Commands\SyncUserVisitMenuLogsCacheTask::class,
         \App\Console\Commands\TestTemp::class,
-        \App\Console\Commands\SyncOrderCountingRecordTask::class,
+        SyncBatchTask::class,
     ];
 
     /**
@@ -35,13 +36,12 @@ class Kernel extends ConsoleKernel
         $schedule->command('LogExpireDelete')->dailyAt('00:01');
         $schedule->command('InventoryDailyLoggingOwner')->dailyAt('08:00');
         $schedule->command('FluxOrderFix')->hourlyAt(1);
-//        $schedule->command('FluxOrderFix')->cron('* * * * *');
         $schedule->command('WASSyncWMSOrderInformation')->everyMinute();
         $schedule->command('syncLogCacheTask')->everyMinute();
         $schedule->command('createOwnerReport')->monthlyOn(1);
         $schedule->command('createOwnerBillReport')->monthlyOn(1);
         $schedule->command('createOwnerAreaReport')->monthlyOn(25);
-        $schedule->command('syncOrderCountingRecordTask')->dailyAt('23:59');
+        $schedule->command('sync:batch')->everyMinute();
     }
 
     /**

+ 1 - 1
app/Exceptions/Handler.php

@@ -58,7 +58,7 @@ class Handler extends ExceptionHandler
         try{
             if (method_exists($exception,'getStatusCode')) {
             $code = $exception->getStatusCode();
-            Controller::logS('exception',$code,$exception->getTraceAsString().'|| ||'.json_encode($request));
+            Controller::logS('exception',$code,$exception->getTraceAsString().'|| '.$exception->getMessage().' ||'.json_encode($request));
             switch ($code){
                 case 419:return response()->view('exception.login');
                 case 404:return response()->view('exception.404');

+ 8 - 17
app/Http/Controllers/LogController.php

@@ -7,6 +7,7 @@ use App\Services\LogService;
 use Exception;
 use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
@@ -34,7 +35,8 @@ class LogController extends Controller
             !$request->has('created_at_end') &&
             !$request->has('operation') &&
             !$request->has('type') &&
-            !$request->has('description')
+            !$request->has('description') &&
+            !$request->has("is_exception")
         ) {
             $logs = Log::query()
                 ->orderBy('id', 'desc')
@@ -65,6 +67,11 @@ class LogController extends Controller
         if ($request->has('created_at_end')) {
             $query->where('created_at', '<=', $request->created_at_end);
         }
+        if ($request->has("is_exception")){
+            $query->where(function(Builder $query){
+                $query->where("type","like","ERROR%")->orWhere("type","like","EXCEPTION%");
+            });
+        }
         $query->orderByDesc('id');
         $logs = $query->paginate($request->paginate??50);
         return view('maintenance.log.index', ['logs' => $logs]);
@@ -81,22 +88,6 @@ class LogController extends Controller
         return view('maintenance.log.show', ['log' => $log]);
     }
 
-
-    /**
-     * Remove the specified resource from storage.
-     *
-     * @param Log $log
-     * @return array|Response
-     * @throws Exception
-     */
-    public function destroy(Log $log)
-    {
-//        if(!Gate::allows('物流公司-删除')){ return redirect(url('/'));  }
-//        app('LogService')->log(__METHOD__,__FUNCTION__,$log->toJson(),Auth::user()['id']);
-//        $re=$log->delete();
-//        return ['success'=>$re];
-    }
-
     public function syncRedisLogs()
     {
         LogService::syncRedisLogs();

+ 85 - 0
app/Http/Controllers/MaterialBoxController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\MaterialBox;
+use Illuminate\Http\Request;
+
+class MaterialBoxController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function show(MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, MaterialBox $materialBox)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\MaterialBox  $materialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(MaterialBox $materialBox)
+    {
+        //
+    }
+}

+ 35 - 0
app/Http/Controllers/OrderCommodityAssignController.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Imports\UpdatePickZone;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Gate;
+use Maatwebsite\Excel\Facades\Excel;
+
+class OrderCommodityAssignController extends Controller
+{
+    public function index()
+    {
+        if(!Gate::allows('商品配置-查询')){ return redirect(url('denied'));  }
+        $assigns = app("OrderCommodityAssignService")->paginate();
+        return view("order.index.index",compact("assigns"));
+    }
+
+    public function import(Request $request)
+    {
+        if(!Gate::allows('商品配置-编辑')){ return ["success"=>false,"data"=>"无权操作!"];  }
+        $fileSuffix=$request->file('file')->getClientOriginalExtension();
+        if ($fileSuffix != 'xlsx' && $fileSuffix != 'xls' && $fileSuffix != 'csv')
+            return ['success'=>false,'data'=>'不支持该文件类型'];
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
+        $fileSuffix = ucwords($fileSuffix);
+
+        Excel::import(new UpdatePickZone(),$request->file('file')->path(),null,$fileSuffix);
+        if (Cache::has('commodityAssign'))return Cache::pull('commodityAssign');
+
+        return ["success"=>false,"data"=>"导入发生错误,数据无响应"];
+    }
+}

+ 1 - 1
app/Http/Controllers/OrderTrackingController.php

@@ -202,7 +202,7 @@ class OrderTrackingController extends Controller
                 $order_client_code,
                 $web_order_number,
                 $pick_up_at=='0000-00-00'?'':$pick_up_at,
-                $orderTracking->sala,
+                $orderTracking->sale,
                 $orderTracking->client,
                 $orderTracking->commodities->commodity->sku ?? '',
                 $orderTracking->commodities->commodity->name ?? '',

+ 90 - 0
app/Http/Controllers/StationController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Station;
+use Illuminate\Http\Request;
+
+class StationController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return void
+     */
+    public function index()
+    {
+
+    }
+    public function monitorIndex()
+    {
+        $stations = Station::query()->with('type:name','parent:name')->whereHas('type',function($query){
+            $query->where('name','料箱监视器');
+        })->paginate(100);
+        return view('station.monitor.index',compact('stations'));
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    public function show(Station $station)
+    {
+        //
+    }
+    public function monitorShow(Station $station)
+    {
+        return view('station.monitor.show',compact('station'));
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(Station $station)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, Station $station)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Station  $station
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Station $station)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationRuleBatchController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationRuleBatch;
+use Illuminate\Http\Request;
+
+class StationRuleBatchController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationRuleBatch  $stationRuleBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationRuleBatch $stationRuleBatch)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskBatchController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskBatch;
+use Illuminate\Http\Request;
+
+class StationTaskBatchController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskBatch  $stationMissionBatch
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskBatch $stationMissionBatch)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskBatchTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskBatchType;
+use Illuminate\Http\Request;
+
+class StationTaskBatchTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskBatchType  $stationMissionBatchType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskBatchType $stationMissionBatchType)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskCommodityController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskCommodity;
+use Illuminate\Http\Request;
+
+class StationTaskCommodityController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskCommodity  $stationMissionCommodity
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskCommodity $stationMissionCommodity)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTask;
+use Illuminate\Http\Request;
+
+class StationTaskController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTask $stationTask)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTask  $stationTask
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTask $stationTask)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskMaterialBoxController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskMaterialBox;
+use Illuminate\Http\Request;
+
+class StationTaskMaterialBoxController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskMaterialBox  $stationMissionMaterialBox
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskMaterialBox $stationMissionMaterialBox)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTaskTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationTaskType;
+use Illuminate\Http\Request;
+
+class StationTaskTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationTaskType $stationTaskType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationTaskType  $stationTaskType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationTaskType $stationTaskType)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StationTypeController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StationType;
+use Illuminate\Http\Request;
+
+class StationTypeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StationType $stationType)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StationType  $stationType
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StationType $stationType)
+    {
+        //
+    }
+}

+ 7 - 1
app/Http/Controllers/StoreCheckingReceiveController.php

@@ -390,7 +390,7 @@ class StoreCheckingReceiveController extends Controller
         if(!Gate::allows('入库管理-盘收一体-盘收-编辑')){ return ['success'=>false, 'data'=>'无权操作!'];  }
         $id = $request->id ?? null;
         $counted_amount = $request->counted_amount ?? null;
-        if (!$id || !$counted_amount)return ['success'=>false, 'data'=>'参数传递错误!'];
+        if (!$id)return ['success'=>false, 'data'=>'参数传递错误!'];
         $item = app('StoreCheckingReceiveItemService')->find($id);
         if (!$item)return ['success'=>false, 'data'=>'被盘项不存在'];
         $params = ["counted_amount"=>$counted_amount];
@@ -435,4 +435,10 @@ class StoreCheckingReceiveController extends Controller
             app('LogService')->log(__METHOD__,"修改差异状态",json_encode($scr,JSON_UNESCAPED_UNICODE));
         }
     }
+
+    public function destroyItem(Request $request)
+    {
+        if (app("StoreCheckingReceiveItemService")->destroy($request->input("id")))return ["success"=>true];
+        return ["success"=>false,"data"=>"删除失败"];
+    }
 }

+ 74 - 55
app/Http/Controllers/TestController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 
 use App\Authority;
+use App\Batch;
 use App\Carrier;
 use App\Commodity;
 use App\CommodityBarcode;
@@ -45,6 +46,7 @@ use App\Services\OrderService;
 use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
 use App\Services\OwnerService;
+use App\Services\ShopService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
 use App\StoreCheckingReceiveItem;
@@ -139,16 +141,14 @@ class TestController extends Controller
         }
     }
 
-    private function dd()
+    public function test4(){
+        $arr=[['id'=>3],['id'=>33],];
+        dd(data_get($arr,'*.id'));
+    }
+    public function t($a)
     {
-        StoreCheckingReceiveItem::query()->insert([[
-            "imported_amount" => 1,
-            "produced_at" => null,
-            "invalid_at" => null,
-            "batch_code" => null,
-            "unique_code" => null,
-            "commodity_id" => 36,
-            "store_checking_receive_id" => 2]]);
+        $r = new \ReflectionClass('App\Http\Controllers\UnitsController');
+        dd($r->getMethods(),$r->getConstants());
     }
 
     public function updateLaborRemark(){
@@ -173,14 +173,6 @@ class TestController extends Controller
         }
     }
     public function test2(){
-        $date=['startAt'=>Carbon::now()->subDays(2),'endAt'=>Carbon::now()->addDays(2)];
-        $startAt = Carbon::parse($date['startAt']);
-        $endAt = Carbon::parse($date['endAt']);
-        $dayArray=collect($startAt->yearsUntil($endAt, 1)->toArray())
-            ->map(function(Carbon $date){
-                return $date->firstOfYear();
-            });
-        dd($startAt,$endAt,$dayArray);
     }
 
     function packageFromLog(Request $request)
@@ -331,28 +323,6 @@ class TestController extends Controller
         }
     }
 
-    public function delme()
-    {
-        $fields = [
-            'doc_order_header.userdefine1',
-            'doc_order_header.userdefine2',
-            'doc_order_header.SOReference5',
-            'doc_order_header.waveno',
-            'doc_order_header.orderno',
-            'doc_order_header.customerid',
-            'doc_order_header.Consigneename'
-        ];
-        if ('') {
-            $resultOracleObj = OracleDOCOrderHeader::select($fields)->where('orderno', 'SO200603004708');
-        } else {
-            $resultOracleObj = OracleActAllocationDetails::select($fields);
-            $resultOracleObj->where('picktotraceid', '546152742096');
-            $resultOracleObj->leftJoin('DOC_Order_Header', 'act_allocation_details.orderno', 'doc_order_header.orderno');
-        }
-        $_temOracleInfo = $resultOracleObj->first();
-
-        dd($_temOracleInfo);
-    }
 
     public function mergerPackageData()
     {
@@ -839,21 +809,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
     }
 
 
-    public function test3()
-    {
-        /** @var OrderTrackingService $orderTrackingService */
-        $orderTrackingService = app('OrderTrackingService');
-        /** @var OrderService $orderService */
-        $orderService = app(OrderService::class);
-        $owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
-        $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'))
-            ->get();
-        $orderService->updateByWmsOrders($orderHeaders);
-        $orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
-    }
+
 
     public function test11()
     {
@@ -1202,8 +1158,71 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
     }
 
     public function OrderSync(){
+        dump(Carbon::now());
         $tack = new SyncWMSOrderTask();
         $tack->handle();
-        dump(11);
+        dump(Carbon::now());
+    }
+
+    public function reNewBatches3()
+    {
+        $batches=Batch::query()->where('id','>',324)->get('code');
+//        $batchCodes = $batches->map(function($batch){
+//            return $batch['code'];
+//        })->toArray();
+        $batchCodes = ['W201201000037',
+            'W201201000038',
+            'W201201000039',
+            'W201201000040',
+            'W201201000041',
+            'W201201000052',
+            'W201201000053',
+            'W201201000054',
+            'W201201000055',
+            'W201201000056',
+            'W201201000057',
+            'W201201000071',
+            'W201201000074',
+            'W201201000075',
+            'W201201000076',];
+        $requests=[];
+//        $logs=Log::query()->select('description')->where('CREATED_AT','>','2020-11-11')
+//            ->where('type',"issued_newBatch")
+//            ->get();
+//        dd($logs);
+        foreach($batchCodes as $code){
+//            $request=Cache::get('temp'.$code)['description'];
+            $request=Log::query()->select('description')->where('CREATED_AT','>','2020-12-01')
+                ->where('type',"issued_newBatch")
+                ->where('description','like',"%{$code}%")
+                ->first();
+            if($request){
+                $response=Zttp::post('https://wcs.baoshi56.com/api/thirdPart/flux/sorting/newBatch',
+                    json_decode($request['description'])
+                );
+                app('LogService')->log(__METHOD__,__FUNCTION__,$response->body());
+                $requests[]=$response->body();
+            }
+//            Cache::put('temp'.$code,$request);
+//            $requests[]=$request;
+        }
+        dd($requests);
+    }
+
+    public function syncOrderTracking()
+    {
+        /** @var OrderTrackingService $orderTrackingService */
+        $orderTrackingService = app('OrderTrackingService');
+        /** @var OrderService $orderService */
+        $orderService = app(OrderService::class);
+        /*$owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();*/
+        /*$startDate = \Illuminate\Support\Carbon::parse('2020-10-28 00:00:00')->toDateTimeString();*/
+        $orderNos = ['SO201205001735','SO201204003891','SO201204003706','SO201204002877','SO201203003771'];
+        $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
+            ->whereIn('orderno',$orderNos)
+            ->get();
+        $orderService->updateByWmsOrders($orderHeaders);
+        $orderTrackingService->createByWmsOrderHeader($orderHeaders);
     }
+
 }

+ 11 - 6
app/Http/Controllers/api/thirdPart/flux/SortingController.php

@@ -86,12 +86,17 @@ class SortingController extends Controller
                         /** @var CommodityService $commodityService */
                         $commodityService=app('CommodityService');
                         $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
-                        $orderCommodity = new OrderCommodity([
-                            'order_id' => $order['id'],
-                            'commodity_id' => $commodity['id'],
-                            'amount' => $requestBarcode['fmqty_each']??0,
-                            'wms_ptltaskid' => $requestBarcode['ptltaskid'],
-                        ]);
+                        $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
+                        if(!$orderCommodity){
+                            $orderCommodity = new OrderCommodity([
+                                'order_id' => $order['id'],
+                                'commodity_id' => $commodity['id'],
+                                'amount' => $requestBarcode['fmqty_each']??0,
+                                'wms_ptltaskid' => $requestBarcode['ptltaskid'],
+                            ]);
+                        }
+                        if(!$orderCommodity['amount'])$orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
+                        if(!$orderCommodity['wms_ptltaskid'])$orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid'];
                         $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
                         if($allocation)
                             $orderCommodity['location'] = $allocation['location'];

+ 27 - 0
app/Http/Controllers/api/thirdPart/haiq/LightController.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\haiq;
+
+
+
+
+use App\Services\ForeignHaiRoboticsService;
+use Illuminate\Http\Request;
+
+class LightController
+{
+    protected $request;
+
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
+    public function __construct(){
+        $this->service=app('ForeignHaiRoboticsService');
+    }
+
+    public function lightOn(Request $request){
+    }
+    public function lightOff(Request $request){
+    }
+
+}

+ 9 - 4
app/Http/Controllers/api/thirdPart/haiq/PickStationController.php

@@ -6,19 +6,24 @@ namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 
+use App\Services\ForeignHaiRoboticsService;
 use Illuminate\Http\Request;
 
 class PickStationController
 {
-    protected $request;
 
-    public function __construct()
-    {
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
+    public function __construct(){
+        $this->service=app('ForeignHaiRoboticsService');
     }
 
     public function processed(Request $request){
         $success = $request->input('success');
-        $code= $success?200:0;
+        $code = $success?200:0;
+        $this->service->markBinProcessed();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
         return ['code'=>$code,'errMsg'=>'','data'=>$request->all()];
     }
+
 }

+ 24 - 8
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -4,16 +4,19 @@
 namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
-use App\Services\LogService;
+use App\Services\ForeignHaiRoboticsService;
+use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Request;
 
 class StorageController
 {
     protected $request;
 
+    /** @var ForeignHaiRoboticsService $service */
+    private $service;
     public function __construct()
     {
+        $this->service=app('ForeignHaiRoboticsService');
         $stockInfo = [
             "skuCode" => "TEST-BSSKU",//商品编码 sku
             "qty" => 9,//数量
@@ -34,12 +37,12 @@ class StorageController
             "bins" => [$bin],//可执行货箱任务
         ]];*/
         $this->request = [[
-            "taskMode"      => 8,
+            "taskMode"      => 2,
             "bins"=>[[
                 "taskCode"  =>"TEST-BS2011160004",
-                "binCode"   => "TESTBINCODE-0",
-                "fromLocCode" => "BIN-IN1",
-                //"toLocCode" => "BIN-OUT1",
+                "binCode"   => "IDE0000034",
+//                "fromLocCode" => "BIN-IN1",
+                "toLocCode" => "BIN-OUT1",
             ]],
             "groupCode"     => 4,
             "priority"      => 20,
@@ -48,10 +51,10 @@ class StorageController
     }
 
     public function relocate(Request $request){
-        $response = Http::post(config('api.haiq.storage.relocate'),$this->request);return $response;
+        $response = Http::post(config('api.haiq.storage.moveBin'),$this->request);
         if (!$response->ok()){
             app('LogService')->log(__METHOD__,"haiq-请求失败,路径异常","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
-            return ['success'=>false,"data"=>"接口异常"];
+            return ['success'=>false,"data"=>$response->body()];
         }
         if (($response["code"] ?? false) && $response["code"] != 200){
             app('LogService')->log(__METHOD__,"haiq-料箱出库失败","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
@@ -64,4 +67,17 @@ class StorageController
         app('LogService')->log(__METHOD__,"haiq-料箱出库成功","REQUEST:".json_encode($this->request)." | RESPONSE:".$response);
         return ["success"=>true];
     }
+    public function moveBin(Request $request){
+
+    }
+    public function taskUpdate(Request $request){
+        $this->service->taskUpdate();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
+        return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
+    }
+    public function exception(Request $request){
+        $this->service->taskUpdate();
+        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
+        return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
+    }
 }

+ 1 - 0
app/Http/Controllers/api/thirdPart/haochuang/SortingController.php

@@ -50,6 +50,7 @@ class SortingController extends Controller
         ]);
     }
 
+
     function process(Request $request){
         $token = trim($request->input('token'));
         $station_id = $request->input('station_id');

+ 153 - 0
app/Imports/UpdatePickZone.php

@@ -0,0 +1,153 @@
+<?php
+
+namespace App\Imports;
+
+use App\OracleDOCOrderDetail;
+use App\Services\LogService;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
+use Maatwebsite\Excel\Concerns\ToCollection;
+use Maatwebsite\Excel\Concerns\WithHeadingRow;
+use Maatwebsite\Excel\Imports\HeadingRowFormatter;
+
+HeadingRowFormatter::default('none');
+class UpdatePickZone implements ToCollection,WithHeadingRow
+{
+    /**
+    * @param Collection $collection
+    * @return bool
+    * @throws
+    */
+    public function collection(Collection $collection)
+    {
+        $row = $collection->first();
+        $headers = ["订单编号","商品条码","数量","生产日期","失效日期"];
+        foreach ($headers as $header){
+            if (!isset($row[$header])){
+                Cache::put("commodityAssign",["success"=>false, "data"=>"表头不存在“".$header."”"],86400);
+                return false;
+            }
+        }
+
+        $errors = [];
+        $ids = [];
+        foreach ($collection as $index=>$item){
+            if ($item["生产日期"]) $item["生产日期"] = formatExcelDate($item["生产日期"]);
+            if ($item["失效日期"]) $item["失效日期"] = formatExcelDate($item["失效日期"]);
+
+            if (!$item["订单编号"]){
+                $errors[] = "第“" . ($index + 2) . "”行订单编号为空";
+                continue;
+            }
+            if (!$item["商品条码"]){
+                $errors[] = "第“" . ($index + 2) . "”行商品条码为空";
+                continue;
+            }
+            if (!$item["生产日期"] && !$item["失效日期"]){
+                $errors[] = "第“" . ($index + 2) . "”行不存在日期";
+                continue;
+            }
+            $detail = OracleDOCOrderDetail::query()->select("customerid","sku")
+                ->where("orderno",$item["订单编号"])
+                ->whereHas("sku",function ($query)use($item){
+                    /** @var Builder $query */
+                    $query->where("alternate_sku1",$item["商品条码"]);
+                })->first();
+            if (!$detail){
+                $errors[] = "第“" . ($index + 2) . "”行未知订单商品";
+                continue;
+            }
+            $sql = "select INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM,BAS_LOCATION.PICKZONE,INV_LOT_LOC_ID.QTY from INV_LOT_ATT LEFT JOIN
+                        INV_LOT_LOC_ID ON INV_LOT_ATT.LOTNUM = INV_LOT_LOC_ID.LOTNUM LEFT JOIN BAS_LOCATION ON INV_LOT_LOC_ID.LOCATIONID = BAS_LOCATION.LOCATIONID
+                    where INV_LOT_ATT.LOTNUM in (select LOTNUM from INV_LOT_LOC_ID where CUSTOMERID = ? AND SKU = ? GROUP BY LOTNUM)";
+            $bindings = [$detail->customerid,$detail->sku];
+            if ($item["生产日期"]){
+                $sql .= " AND LOTATT01 = ?";
+                $bindings[] = $item["生产日期"];
+            }else $sql .= " AND LOTATT01 IS NULL";
+            if ($item["失效日期"]){
+                $sql .= " AND LOTATT02 = ?";
+                $bindings[] = $item["失效日期"];
+            }else $sql .= " AND LOTATT02 IS NULL";
+
+            $lot = DB::connection("oracle")->select(DB::raw($sql),$bindings);
+            if (!$lot){
+                $errors[] = "第“" . ($index + 2) . "”行未找到库位";
+                continue;
+            }
+            $result = null;
+            if (count($lot)>1){
+                $min = null;
+                $max = null;
+                $map = [];
+                foreach ($lot as $i => $l){
+                    $qty = (int)$l->quty;
+                    $map[$qty] = $i;
+                    if ($qty >= (int)$item["数量"] && $qty<=$max)$max = $qty;
+                    if ($qty < (int)$item["数量"] && $qty>=$min)$min = $qty;
+                }
+                if ($max !== null)$result = $lot[$map[$max]];
+                else $result = $lot[$map[$min]];
+            }
+            if (count($lot) == 1)$result = $lot[0];
+            if ($result){dd($result);
+                try{
+                    $detail->update([
+                        "lotnum" => $result->lotnum,
+                        "pickzone" => $result->pickzone,
+                        "kitreferenceno" => '0',
+                        "d_edi_09" => '0',
+                        "d_edi_10" => '0',
+                    ]);
+                    DB::connection("oracle")->commit();
+                    LogService::log(__METHOD__,"SUCCESS-指定效期分配修改库位",json_encode($detail)." | ".json_encode($result));
+                    $order = app("OrderService")->first(["code"=>$item["订单编号"]]);
+                    if (!$order){
+                        $errors[] = "第“" . ($index + 2) . "”行已成功修改FLUX库位但在本地未找到订单";
+                        continue;
+                    }
+                    $barcode = app("CommodityBarcodeService")->first(["code"=>$item["商品条码"]]);
+                    if (!$barcode){
+                        $errors[] = "第“" . ($index + 2) . "”行已成功修改FLUX库位但在本地未找到条码";
+                        continue;
+                    }
+                    $model = app("OrderCommodityAssignService")->create([
+                        "order_id"      =>  1,//$order->id,
+                        "commodity_id"  =>  1,//$barcode->commodity_id,
+                        "amount"        =>  $item["数量"],
+                        "produced_at"   =>  $item["生产日期"],
+                        "valid_at"      =>  $item["失效日期"],
+                        "batch_number"  =>  $result->lotnum,
+                        "location"      =>  $result->locationid,
+                        "region"        =>  $result->pickzone,
+                        "user_id"       =>  Auth::id(),
+                    ]);
+                    LogService::log(__METHOD__,"SUCCESS-生成配置记录",json_encode($model));
+                    $ids[] = $model->id;
+                }catch (\Exception $e){
+                    LogService::log(__METHOD__,"ERROR-指定效期分配修改库位",json_encode($detail)." | ".json_encode($result));
+                }
+            }else $errors[] = "第“" . ($index + 2) . "”行未找到可分配库位";
+        }
+        $assigns = app("OrderCommodityAssignService")->get(["id"=>$ids]);
+        $models = [];
+        foreach ($assigns as $assign){
+            $models[] = [
+                "orderNumber"   => $assign->order ? $assign->order->code : '',
+                "barcode"       => $assign->commodity ? $assign->commodity->barcode : '',
+                "amount"        => $assign->amount,
+                "producedAt"    => $assign->produced_at,
+                "validAt"       => $assign->valid_at,
+                "batchNumber"   => $assign->batch_number,
+                "location"      => $assign->location,
+                "region"        => $assign->region,
+                "createdAt"     => $assign->created_at,
+                "userName"      => $assign->user ? $assign->user->name : 'system',
+            ];
+        }
+        Cache::put("commodityAssign",["success"=>true,"data"=>$models,"errors"=>$errors]);
+    }
+}

+ 44 - 0
app/Jobs/OrderCreateInstantBill.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Order;
+use App\Services\LogService;
+use App\Services\OrderService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class OrderCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+
+    protected $order;
+    /**
+     * Create a new job instance.
+     *
+     * @param Order $order
+     * @return void
+     */
+    public function __construct(Order $order)
+    {
+        $this->order = $order;
+    }
+
+    /**
+     *
+     * @param OrderService $service
+     * @return void
+     */
+    public function handle(OrderService $service)
+    {
+        try{
+            $service->createInstantBill($this->order);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-订单生成即时账单",$this->order->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 44 - 0
app/Jobs/ProcessCreateInstantBill.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Process;
+use App\Services\LogService;
+use App\Services\ProcessService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class ProcessCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $process;
+    /**
+     * Create a new job instance.
+     *
+     * @param Process $process
+     * @return void
+     */
+    public function __construct(Process $process)
+    {
+        $this->process = $process;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @param ProcessService $service
+     * @return void
+     */
+    public function handle(ProcessService $service)
+    {
+        try{
+            $service->createInstantBill($this->process);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->process->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 45 - 0
app/Jobs/StoreCreateInstantBill.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\LogService;
+use App\Services\StoreService;
+use App\Store;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class StoreCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+
+    protected $store;
+    /**
+     * Create a new job instance.
+     *
+     * @param Store $store
+     * @return void
+     */
+    public function __construct(Store $store)
+    {
+        $this->store = $store;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @param StoreService $service
+     * @return void
+     */
+    public function handle(StoreService $service)
+    {
+        try{
+            $service->createInstantBill($this->store);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->store->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 7 - 0
app/Log.php

@@ -4,6 +4,7 @@ namespace App;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Traits\ModelTimeFormat;
+use Illuminate\Support\Str;
 
 class Log extends Model
 {
@@ -19,4 +20,10 @@ class Log extends Model
         }
         return '';
     }
+    public function getExceptionMarkAttribute(){
+        if (Str::upper(substr($this->type,0,1)) != 'E')return 'N';
+        if (Str::upper(substr($this->type,0,5)) == 'ERROR' || Str::upper(substr($this->type,0,9)) == 'EXCEPTION')
+            return 'Y';
+        return 'N';
+    }
 }

+ 10 - 0
app/MaterialBox.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class MaterialBox extends Model
+{
+    protected $fillable=['code'];
+}

+ 3 - 0
app/OracleDOCOrderHeader.php

@@ -50,4 +50,7 @@ class OracleDOCOrderHeader extends Model
     public function hasUn(){
         return $this->hasMany('App\OracleDOCOrderDetail','orderno','orderno');
     }
+    public function orderType(){
+        return $this->hasOne('App\OracleBasCode','code','ordertype')->where('codeid','SO_TYP');
+    }
 }

+ 4 - 1
app/Order.php

@@ -14,7 +14,8 @@ class Order extends Model
         'id', 'batch_id',  'owner_id', 'status',
         'created_at', 'code', 'shop_id',  'client_code',
         'logistic_id', 'consignee_name', 'consignee_phone', 'province',
-        'city', 'district', 'address', 'wms_status','warehouse_id','wms_edittime'];
+        'city', 'district', 'address','warehouse_id',
+        'wms_edittime', 'wms_status','order_type'];
 
     /*
      * wms订单号             code=>DOC_ORDER_HEADER[orderno]
@@ -148,6 +149,7 @@ class Order extends Model
             $this['client_code'] = $order['client_code'] &&
             $this['wms_status'] == $order['wms_status'] &&
             $this['wms_edittime'] == $order['wms_edittime'] &&
+            $this['order_type'] == $order['order_type'] &&
             (string)$this['created_at'] == (string)$order['created_at'];
     }
 
@@ -167,6 +169,7 @@ class Order extends Model
         $this['client_code'] = $order['client_code'] ;
         $this['wms_status'] = $order['wms_status'] ;
         $this['wms_edittime'] = $order['wms_edittime'];
+        $this['order_type'] = $order['order_type'];
         $this['created_at'] =$order['created_at'];
     }
 }

+ 33 - 0
app/OrderCommodityAssign.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrderCommodityAssign extends Model
+{
+    protected $fillable = [
+        "order_id",         //外键订单
+        "commodity_id",     //外键商品
+        "amount",           //数量  default 0
+        "produced_at",      //生产日期
+        "valid_at",         //失效日期
+        "batch_number",     //批次号
+        "location",         //库位
+        "region",           //库区
+        "user_id",          //操作人
+    ];
+
+    public function order()
+    {   //订单
+        return $this->hasOne(Order::class,"id","order_id");
+    }
+    public function commodity()
+    {   //商品
+        return $this->hasOne(Commodity::class,"id","commodity_id");
+    }
+    public function user()
+    {   //用户
+        return $this->hasOne(User::class,"id","user_id");
+    }
+}

+ 2 - 0
app/OwnerFeeDetail.php

@@ -24,6 +24,8 @@ class OwnerFeeDetail extends Model
         "work_fee",         //作业费
         "logistic_fee",     //物流费
         "created_at",       //创建时间
+        "outer_id",         //关联表ID
+        "outer_table_name", //关联表名
     ];
     public $timestamps = false;
 

+ 14 - 2
app/Providers/AppServiceProvider.php

@@ -2,9 +2,9 @@
 
 namespace App\Providers;
 
-use App\Customer;
 use App\Http\Controllers\Controller;
 use App\Services\AuthorityService;
+use App\Services\BatchService;
 use App\Services\CacheService;
 use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
@@ -13,6 +13,7 @@ use App\Services\common\DataHandlerService;
 use App\Services\CustomerService;
 use App\Services\DepositoryService;
 use App\Services\FeatureService;
+use App\Services\ForeignHaiRoboticsService;
 use App\Services\InventoryAccountMissionService;
 use App\Services\InventoryCompareService;
 use App\Services\LaborReportsCountingRecordService;
@@ -22,8 +23,9 @@ use App\Services\OracleBasCustomerService;
 use App\Services\OracleBasSkuService;
 use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDOCOrderHeaderService;
+use App\Services\OrderCommodityService;
+use App\Services\OrderCommodityAssignService;
 use App\Services\OrderCountingRecordService;
-use App\Services\OracleDocAsnHerderService;
 use App\Services\OrderIssuePerformanceService;
 use App\Services\AllInventoryService;
 use App\Services\InventoryDailyLogService;
@@ -58,6 +60,9 @@ use App\Services\RejectedBillItemService;
 use App\Services\RejectedBillService;
 use App\Services\ShopService;
 use App\Services\RejectedService;
+use App\Services\StationTaskBatchService;
+use App\Services\StationTaskBatchTypeService;
+use App\Services\StationService;
 use App\Services\StoreCheckingReceiveItemService;
 use App\Services\StoreCheckingReceiveService;
 use App\Services\StoreItemService;
@@ -122,6 +127,7 @@ class AppServiceProvider extends ServiceProvider
     }
 
     private function loadingService(){
+        app()->singleton('BatchService',BatchService::class);
         app()->singleton('CacheService',CacheService::class);
         app()->singleton('UserService',UserService::class);
         app()->singleton('AuthorityService',AuthorityService::class);
@@ -138,6 +144,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('PackageStatisticsService',PackageStatisticsService::class);
         app()->singleton('OracleActAllocationDetailService',OracleActAllocationDetailService::class);
         app()->singleton('ShopService',ShopService::class);
+        app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
         app()->singleton('OrderPackageService',OrderPackageService::class);
         app()->singleton('OrderIssueService',OrderIssueService::class);
         app()->singleton('OrderService',OrderService::class);
@@ -154,6 +161,9 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
         app()->singleton('ProcessesContentService',ProcessesContentService::class);
         app()->singleton('StoreService',StoreService::class);
+        app()->singleton('StationTaskBatchService',StationTaskBatchService::class);
+        app()->singleton('StationTaskBatchTypeService',StationTaskBatchTypeService::class);
+        app()->singleton('StationService',StationService::class);
         app()->singleton('WarehouseService',WarehouseService::class);
         app()->singleton('StoreItemService',StoreItemService::class);
         app()->singleton('PackageService',PackageService::class);
@@ -165,6 +175,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OwnerPriceExpressService',OwnerPriceExpressService::class);
         app()->singleton('OwnerPriceLogisticService',OwnerPriceLogisticService::class);
         app()->singleton('OwnerPriceDirectLogisticService',OwnerPriceDirectLogisticService::class);
+        app()->singleton('OrderCommodityAssignService',OrderCommodityAssignService::class);
 
         $this->loadingOrderModuleService();
         $this->loadingBasedModuleService();
@@ -187,6 +198,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OracleDocOrderHeaderService',OracleDOCOrderHeaderService::class);
         app()->singleton('OracleActAllocationDetailService',OracleActAllocationDetailService::class);
         app()->singleton('OrderIssueProcessLogService',OrderIssueProcessLogService::class);
+        app()->singleton('OrderCommodityService',OrderCommodityService::class);
     }
 
     private function loadingBasedModuleService(){

+ 49 - 0
app/Services/BatchService.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Services;
+
+use App\Batch;
+use Exception;
+
+Class BatchService
+{
+    /** @var StationTaskBatchService $stationTaskBatchService */
+    private $stationTaskBatchService;
+    public function __construct(){
+        $this->stationTaskBatchService=null;
+    }
+
+    public function get(array $params)
+    {
+        $query = Batch::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->get();
+    }
+
+    public function insert(array $insert)
+    {
+        $result = Batch::query()->insert($insert);
+        if($result)$this->assignTasks($insert);
+        return $result;
+    }
+
+    public function updateWhereIn($key,$values,$updateKeyValues){
+        Batch::query()->whereIn($key,$values)->update($updateKeyValues);
+    }
+
+    /**
+     * 为波次附加任务,已附加的重复任务不影响
+     * @param Batch[] $batches
+     * @throws Exception
+     */
+    public function assignTasks(array $batches)
+    {
+        $this->stationTaskBatchService=app('StationTaskBatchService');
+        $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches);
+
+    }
+
+}

+ 63 - 0
app/Services/CommodityService.php

@@ -8,12 +8,26 @@ use App\CommodityBarcode;
 use App\OracleBasSKU;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
+use App\Shop;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Support\Facades\Cache;
 
 Class CommodityService
 {
+
+    /**
+     * @var CacheService $cacheService
+     * @var OwnerService $ownerService
+     */
+    private $cacheService;
+    private $ownerService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+        $this->ownerService=app('OwnerService');
+    }
+
     public function firstOrCreate($param,$column = null):Commodity{
         if ($column) return Commodity::query()->firstOrCreate($param,$column);
         return Commodity::query()->firstOrCreate($param);
@@ -332,4 +346,53 @@ Class CommodityService
         if ($query->count() > 0)return true;
         return false;
     }
+
+    public function getCommoditiesByMap($map)
+    {
+        $collect = collect();
+        if(count($map)==0)return $collect;
+        foreach ($map as $item) {
+            $commodity = $this->getCommodityByOwnerCodeAndSKU($item['owner_code'],$item['sku']);
+            $collect->push($commodity);
+        }
+        return $collect;
+    }
+
+    public function getCommodityByOwnerCodeAndSKU($ownerCode,$sku){
+        $commodity_key = "owner_code_{$ownerCode}_sku_{$sku}";
+        return Cache::remember($commodity_key,300,function()use($ownerCode,$sku){
+            $commodity = Commodity::query()->where('sku',$sku)->whereHas('owner',function($query)use($ownerCode){
+                $query->where('code',$ownerCode);
+            })->first();
+            if(isset($commodity))return $commodity;
+            $basSKu =  app('OracleBasSkuService')->first(['sku'=>$sku,'customerid'=>$ownerCode]);
+            return Commodity::query()->create($this->getParamsByBasSku($basSKu));
+        });
+    }
+
+    public function getParamsByBasSku($basSku,$owner = null){
+        if(empty($owner)){
+            $owner = app('OwnerService')->getOwnerByCode($basSku['customerid']);
+        }
+        return  [
+            'owner_id' => $owner['id'] ?? '',
+            'sku' => $basSku['sku'],
+            'name' =>$basSku['descr_c'],
+            'length' =>$basSku['skulength'],
+            'width' => $basSku['skuwidth'],
+            'height' => $basSku['skuhigh'],
+            'volumn' => $basSku['cube']
+        ];
+    }
+
+    private function pushToCache($commodities)
+    {
+        if (count($commodities) < 1) return null;
+        foreach ($commodities as $commodity) {
+            $commodity_key = "owner_code_{$commodity['owner']['code']}_sku_{$commodity['sku']}";
+            Cache::remember($commodity_key, config('cache.expirations.forever'), function () use ($commodity) {
+                return $commodity;
+            });
+        }
+    }
 }

+ 15 - 0
app/Services/DocWaveHeaderService.php

@@ -26,6 +26,15 @@ Class DocWaveHeaderService
             case "gtOrEqual":
                 $query->where($column,">=",$value);
                 break;
+            case "gt":
+                $query->where($column,">",$value);
+                break;
+            case "raw":
+                $query->whereRaw($value);
+                break;
+            case "in":
+                $query->whereIn($column,$value);
+                break;
         }
         return $query;
     }
@@ -36,4 +45,10 @@ Class DocWaveHeaderService
         $valueStore = ValueStore::query()->where("name","wave_last_sync_date")->first();
         return $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
     }
+
+    public function setSyncDate(string $value)
+    {
+        $valueStore = ValueStore::query()->where("name","wave_last_sync_date");
+        return $valueStore->update(["value"=>$value]);
+    }
 }

+ 25 - 0
app/Services/ForeignHaiRoboticsService.php

@@ -0,0 +1,25 @@
+<?php
+
+
+namespace App\Services;
+
+
+use Illuminate\Http\Request;
+
+class ForeignHaiRoboticsService
+{
+
+    public function moveBin(){
+
+    }
+
+    public function markBinProcessed(){
+
+    }
+    public function taskUpdate(){
+
+    }
+    public function throwException(){
+
+    }
+}

+ 28 - 0
app/Services/LogisticService.php

@@ -4,9 +4,11 @@ namespace App\Services;
 
 use App\Logistic;
 use App\OracleBasCustomer;
+use App\Shop;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Str;
 
 Class LogisticService
@@ -88,5 +90,31 @@ Class LogisticService
         return Logistic::query()->find($id);
     }
 
+    public function getLogisticByCodes($codes)
+    {
+        $collect = collect();
+        if(count($codes) == 0) return $collect;
+        foreach ($codes as $code) {
+            $collect->push($this->getLogisticByCode($code));
+        }
+        return $collect;
+    }
+
+    public function getLogisticByCode($code){
+        return Cache::remember("getLogisticByCode_{$code}", config('database.cache.expirations.logistic'), function()use($code){
+            $logistic = Logistic::query()->where('code',$code)->first();
+            if($logistic)return $logistic;
+            $baseCustomers = app('OracleBasCustomerService')->first(['Customer_Type'=>'CA','CustomerID'=>'$code']);
+            if(!$baseCustomers)return null;
+            try {
+                $logistic = Logistic::query()->create(['name' => $baseCustomers['descr_c'], 'code' => $baseCustomers['customerid']]);
+                app('LogService')->log(__METHOD__, __FUNCTION__,'创建Logistic SUCCESS'." || ". json_encode($logistic));
+                return $logistic;
+            } catch (\Exception $e) {
+                app('LogService')->log(__METHOD__, __FUNCTION__,'创建Logistic ERROR'." || ". json_encode($logistic)." || ".json_encode($e->getMessage())." || ".json_encode($e->getTraceAsString()));
+                return null;
+            }
+        });
+    }
 
 }

+ 24 - 0
app/Services/OracleBasCustomerService.php

@@ -8,9 +8,33 @@ Class OracleBasCustomerService
 {
     /** @var CacheService $cacheService */
     private $cacheService;
+
     function __construct(){
         $this->cacheService=app('CacheService');
     }
+
+    public function get(array $params){
+        $query = $this->query($params);
+        return $query->get();
+    }
+    public function first(array $params){
+        return $this->query($params)->first();
+    }
+
+    public function count(array $params){
+        $query = $this->query($params);
+        return $query->count();
+    }
+
+    private function query(array $params){
+        $query = OracleBasCustomer::query();
+        foreach ($params as $column => $value){
+            if (is_array($value))$query->whereIn($column,$value);
+            else $query->where($column,$value);
+        }
+        return $query;
+    }
+
     public function getWareHouse($customerIDs = null)
     {
         if(!$customerIDs){

+ 8 - 3
app/Services/OracleDOCOrderHeaderService.php

@@ -20,7 +20,7 @@ Class OracleDOCOrderHeaderService
         'DOC_Order_Header.CarrierName', 'DOC_Order_Header.LastShipmentTime','DOC_Order_Header.EDISendFlag',
         'DOC_Order_Header.SOReference5', 'DOC_Order_Header.C_Tel2','DOC_Order_Header.Transportation',
         'DOC_Order_Header.WareHouseId','DOC_Order_Header.SOStatus','DOC_Order_Header.C_Tel1','DOC_Order_Header.C_District',
-        'DOC_Order_Header.IssuePartyName'
+        'DOC_Order_Header.IssuePartyName','DOC_Order_Header.OrderType'
     ];
 
     function first(array $params){
@@ -71,13 +71,16 @@ Class OracleDOCOrderHeaderService
             ->with(['oracleBASCustomer'=>function($query){
                 $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
             },'oracleDOCOrderDetails'=>function($query){
-                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
+                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered,doc_order_details.Location');
             }, 'actAllocationDetails'=>function($query){
                 $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
             },'oracleBASCode'=>function($query){
                 $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
+            },'orderType'=>function($query){
+                $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
             }])
             ->where('DOC_Order_Header.addTime','>=',$startDate)
+            ->whereColumn('DOC_Order_Header.editTime','=','DOC_Order_Header.addTime')
             ->orderByDesc('DOC_Order_Header.addTime')
             ->get();
     }
@@ -87,11 +90,13 @@ Class OracleDOCOrderHeaderService
             ->with(['oracleBASCustomer'=>function($query){
                 $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
             },'oracleDOCOrderDetails'=>function($query){
-                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
+                $query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered,doc_order_details.Location');
             }, 'actAllocationDetails'=>function($query){
                 $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
             },'oracleBASCode'=>function($query){
                 $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
+            },'orderType'=>function($query){
+                $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
             }])
             ->where('DOC_Order_Header.editTime','>=',$startDate)
             ->whereColumn('DOC_Order_Header.editTime','!=','DOC_Order_Header.addTime')

+ 31 - 0
app/Services/OrderCommodityAssignService.php

@@ -0,0 +1,31 @@
+<?php 
+
+namespace App\Services; 
+
+use App\OrderCommodityAssign;
+
+Class OrderCommodityAssignService
+{ 
+
+    public function paginate(array $params = null)
+    {
+        $query = OrderCommodityAssign::query()->with(["order","commodity.barcodes","user"])->orderByDesc("id");
+        return $query->paginate($params["paginate"] ?? 50);
+    }
+
+    public function create(array $params)
+    {
+        return OrderCommodityAssign::query()->create($params);
+    }
+
+    public function get(array $params)
+    {
+        $query = OrderCommodityAssign::query()->with(["order","commodity.barcodes","user"]);
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->get();
+    }
+
+}

+ 212 - 0
app/Services/OrderCommodityService.php

@@ -0,0 +1,212 @@
+<?php
+
+namespace App\Services;
+
+use App\Order;
+use App\OrderCommodity;
+use Carbon\Carbon;
+
+Class OrderCommodityService
+{
+    public function syncOrderCommodities(&$orderHeaders)
+    {
+        /**
+         * @var CommodityService $commodityService
+         * @var OwnerService $ownerService
+         */
+        $commodityService = app('CommodityService');
+        $ownerService = app('OwnerService');
+        if(count($orderHeaders) == 0)return ;
+        $order_nos = array_unique(data_get($orderHeaders,'*.orderno'));
+        $commodities_map = [];$owners_id_maps = [];
+        $owner_code_maps = (function()use(&$ownerService,&$orderHeaders,&$owners_id_maps){
+            $customer_ids= array_unique(data_get($orderHeaders,'*.customerid'));
+            $owners = $ownerService->getOwnerByCodes($customer_ids);
+            $owner_code_maps = [];
+            if(count($owners) == 0)return $owner_code_maps;
+            foreach ($owners as $owner) {
+                $owner_code_maps[$owner['code']]= $owner['id'];
+                $owners_id_maps[$owner['id']] =  $owner['code'];
+            }
+            return $owner_code_maps;
+        })();
+        // 重组OrderDetails
+        $orderDetails_map = (function()use(&$orderHeaders,&$owner_code_maps,&$commodities_map){
+            $map = [];
+            if(count($orderHeaders)==0)return $map;
+            foreach ($orderHeaders as $orderHeader) {
+                $Order_Details = $orderHeader->oracleDOCOrderDetails;
+                $Order_Details->each(function($item)use(&$map,&$owner_code_maps,&$commodities_map){
+                    if(!empty($item['customerid']) && !empty($item['sku'])){
+                        $key = "owner_code_{$item['customerid']}_sku_{$item['sku']}";
+                        $commodities_map[$key] =  ['owner_code'=>$item['customerid'],'sku'=>$item['sku']];
+                    }
+                    $key = "orderno_{$item['orderno']}_sku{$item['sku']}_each_{$item['qtyordered']}_location_{$item['location']}";
+                    if(empty($map[$key]))$map[$key]=[];
+                    $map[$key][] = [
+                        'code' => $item['orderno'],
+                        'sku' => $item['sku'],
+                        'owner_id'=>$owner_code_maps[$item['customerid']],
+                        'amount' => $item['qtyordered'],
+                        'location' => $item['location']
+                    ];
+                });
+            }
+            return $map;
+        })();
+        $commodities = $commodityService->getCommoditiesByMap($commodities_map);
+        $commodities_maps = (function()use($commodities,$owners_id_maps){
+            $map = [];
+            if(count($commodities) == 0)return $map;
+            foreach ($commodities as $commodity) {
+                $owner_code = $owners_id_maps[$commodity['owner_id']];
+                $key ="owner_code_{$owner_code}_sku_{$commodity['sku']}";
+                $map[$key] = $commodity;
+            }
+            return $map;
+        })();
+        $order_id_map = [];
+        $orders_map = (function()use($order_nos,&$order_id_map){
+            $map = [];
+            if(count($order_nos)==0)return $map;
+            $orders = Order::query()->whereIn('code',$order_nos)->get();
+            $orders->each(function($item)use(&$map,&$order_id_map){
+                $map[$item['code']] = ['id'=>  $item['id'], 'owner_id' =>  $item['owner_id']];
+                $order_id_map[$item['id']] = ['code'=>  $item['code'], 'owner_id' =>  $item['owner_id']];
+            });
+            return $map;
+        })();
+        $orderCommodities = OrderCommodity::query()->with('commodity','order')->whereHas('order',function($query)use($order_nos){
+            $query->whereIn('code',$order_nos);
+        })->get();
+
+        $orderCommodities_map = $this->regroupOrderCommodities($orderCommodities);              // 重组orderCommodities
+        $inner_params = $this->filterInnerParams($orderDetails_map,$orderCommodities_map);
+        $del_ids = $this->filterDeleteParams($orderDetails_map,$orderCommodities_map);
+        if(count($inner_params)>0){
+            $inner_arr = array_chunk($inner_params,4000);
+            foreach ($inner_arr as $item) {
+                $created_params = $this->createByInnerParams($item,$orders_map,$commodities_maps,$owners_id_maps);
+                $this->insert($created_params);
+            }
+        }
+        if(count($del_ids)>0){
+            $orderCommodities = OrderCommodity::query()->whereIn('id',$del_ids)->get();
+            $this->batchDelete($orderCommodities);
+        }
+    }
+
+    private function regroupOrderCommodities(&$orderCommodities)
+    {
+        $map = [];
+        if(count($orderCommodities)==0)return $map;
+        foreach ($orderCommodities as $orderCommodity) {
+            $key = "orderno_{$orderCommodity['order']['code']}_sku{$orderCommodity['commodity']['sku']}_each_{$orderCommodity['amount']}_location_{$orderCommodity['location']}";
+            if(empty($map[$key]))$map[$key] =[];
+            $map[$key][] = [
+                'id' =>$orderCommodity['id'],
+                'code' => $orderCommodity['order']['orderno'],
+                'sku' => $orderCommodity['commodity']['sku'],
+                'owner_id' => $orderCommodity['order']['owner_id'],
+                'amount' => $orderCommodity['amount'],
+                'location' => $orderCommodity['location']
+            ];
+        }
+        return $map;
+    }
+
+    private function filterInnerParams(&$orderDetails_map,&$orderCommodities_map)
+    {
+        $inner_params = [];
+        if(count($orderDetails_map) == 0)return $inner_params;
+        foreach ($orderDetails_map as $key=>&$map) {
+            if(empty($orderCommodities_map[$key])){
+                foreach ($map as &$item) {
+                    $inner_params[] = $item;
+                }
+            }elseif(count($map)>count($orderCommodities_map[$key])){
+                foreach ($map as &$obj) {
+                    if($orderCommodities_map[$key]>0)array_shift($orderCommodities_map[$key]);
+                    elseif($orderCommodities_map[$key]==0)$inner_params[] = $obj;
+                }
+            } elseif(count($map)==count($orderCommodities_map[$key]))continue;
+            unset($orderDetails_map[$key]);
+            $map = null;
+        }
+        return $inner_params;
+    }
+    private function filterDeleteParams(&$orderDetails_map,&$orderCommodities_map)
+    {
+        $del_ids = [];
+        if(count($orderDetails_map) == 0)return $del_ids;
+        foreach ($orderCommodities_map as $key=>$map) {
+            if(empty($orderDetails_map[$key])){
+                foreach ($map as &$item) {
+                    $del_ids[] = $item['id'];
+                }
+            }elseif(count($map)>count($orderDetails_map[$key])){
+                foreach ($map as $key1=>&$obj) {
+                    if(count($orderDetails_map[$key]) == 0){
+                        $del_ids [] = $obj['id'];
+                        unset($map[$key1]);
+                    } else{
+                        array_shift($orderDetails_map[$key]);
+                    }
+                }
+            }
+        }
+        return $del_ids;
+    }
+
+    private function createByInnerParams(&$inner_params,&$orders_map,&$commodities_maps,&$owner_id_maps)
+    {
+        $created_params = [];
+        if(count($inner_params) == 0)return $created_params;
+        $data = Carbon::now();
+        foreach ($inner_params as &$item) {
+            $order = $orders_map[$item['code']] ?? false;
+            if(!$order)continue;
+            $owner_code = $owner_id_maps[$item['owner_id']];
+            $key = "owner_code_{$owner_code}_sku_{$item['sku']}";
+            $commodity = $commodities_maps[$key];
+            $created_params[] = [
+                'order_id' =>$order['id'],
+                'commodity_id' =>$commodity['id'],
+                'amount' =>$item['amount'],
+                'location' =>$item['location'],
+                'created_at' =>$data,
+                'updated_at' => $data
+            ];
+        }
+        return $created_params;
+    }
+
+    public function batchDelete($orderCommodities)
+    {
+        if(count($orderCommodities) == 0)return true;
+        try {
+            $bool =  OrderCommodity::destroy(data_get($orderCommodities, '*.id'));
+            if($bool)app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities));
+            else app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities FAULT'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities).' || ');
+            return $bool;
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__,__FUNCTION__,'批量删除 OrderCommodities ERROR'.' || '.count($orderCommodities).' || '.json_encode($orderCommodities).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            return false;
+        }
+    }
+
+    public function insert($innerParams){
+        if(!$innerParams)return false;
+        if(count($innerParams)==0)return false;
+        try {
+            $bool = OrderCommodity::query()->insert($innerParams);
+            if ($bool) app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities SUCCESS' . ' || ' . count($innerParams) . ' || ' . json_encode($innerParams));
+            else app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities FAULT' . ' || ' . count($innerParams) . ' || ' . json_encode($innerParams));
+            return $bool;
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__, __FUNCTION__, '批量添加 OrderCommodities ERROR'. ' || ' . count($innerParams) . ' || ' . json_encode($innerParams).' || '.json_encode($e->getMessage()).' || '.json_encode($e->getTraceAsString()));
+            return false;
+        }
+    }
+}
+

+ 15 - 2
app/Services/OrderIssueService.php

@@ -219,6 +219,18 @@ class OrderIssueService
                 }
             });
         }
+        if(isset($condition['sendOrderClientCode'])){
+            $query->whereHas('secondOrder',function($query)use($condition){
+                $this->searchWay($query,$condition['sendOrderClientCode'],'client_code');
+            });
+            $query->orWhere('second_client_no',$condition['sendOrderClientCode']);
+        }
+        if(isset($condition['sendOrderLogisticNumber'])){
+            $query->whereHas('secondOrder.packages',function($query)use($condition){
+                $this->searchWay($query,$condition['sendOrderLogisticNumber'],'logistic_number');
+            });
+            $query->orWhere('second_logistic_number',$condition['sendOrderLogisticNumber']);
+        }
         return $query;
     }
 
@@ -333,7 +345,8 @@ class OrderIssueService
                 'imported_status' => $imported_status,
                 'custom_code' => $custom_code,
                 'hidden_tag' => $hiddenTag,
-                'updated_at' => $data
+                'updated_at' => $data,
+                'created_at' => $data
             ];
         }
         try {
@@ -517,7 +530,7 @@ class OrderIssueService
 
     public function createOrderIssue($logisticNumber, $type, $result_explain, $importedStatus = '正常', $custom_code = null,$hiddenTag = null)
     {
-        $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
+        $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode','orderType'])
             ->whereHas('actAllocationDetails', function ($query) use ($logisticNumber) {
                 $query->where('picktotraceid', $logisticNumber);
             })->get();

+ 46 - 33
app/Services/OrderPackageCommoditiesService.php

@@ -606,28 +606,48 @@ class OrderPackageCommoditiesService
          * @var DataHandlerService $dataHandService
          * @var CommodityService $commodityService
          * @var OrderPackageService $orderPackageService
+         * @var OwnerService $ownerService
          */
         $dataHandService = app('DataHandlerService');
         $commodityService = app('CommodityService');
         $orderPackageService  = app( 'OrderPackageService');
+        $ownerService  = app( 'OwnerService');
         if(!$orderHeaders)return ;
 
-        $commodityService->getByWmsOrders($orderHeaders);   // 预先处理     3s
+        $map = [];
+        foreach ($orderHeaders as $orderHeader) {
+            $Order_Details = $orderHeader->oracleDOCOrderDetails;
+            $Order_Details->each(function($item)use(&$map){
+                if(!empty($item['customerid']) && !empty($item['sku'])){
+                    $key = "owner_code_{$item['customerid']}_sku_{$item['sku']}";
+                    $map[$key] =  ['owner_code'=>$item['customerid'],'sku'=>$item['sku']];  // 货主编码 sku编码
+                }
+            });
+        }
+        $commodities = $commodityService->getCommoditiesByMap($map);   // 预先处理     3s
         $orderPackages = $orderPackageService->getByWmsOrders($orderHeaders);
         $orderCommodities = $this->getByWmsOrder($orderHeaders);
+        $owner_code_map = [];
+        $owner_id_map = (function()use(&$orderHeaders,&$ownerService,&$owner_code_map){
+            $owner_id_map = [];
+            $owners = $ownerService->getOwnerByCodes(array_unique(data_get($orderHeaders,'*.customerid')));
+            if(count($owners) == 0) return $owner_id_map;
+            foreach ($owners as $owner) {
+                $owner_id_map[$owner['id']] = $owner;
+                $owner_code_map[$owner['code']]  = $owner;
+            }
+            return $owner_id_map;
+        })();
 
         $package_map = $dataHandService->dataHeader(['logistic_number'],$orderPackages);
         $orderCommodities = $this->regroupOrderCommodities($orderCommodities);
-
         $orderAllocationDetails = $this->regroupWmsOrderAllocationDetails($orderHeaders);
         $del_orderCommodities  =[];
-
         $update_params =$this->filterUpdateParams($orderAllocationDetails,$orderCommodities,$del_orderCommodities);                  // 修改
-        $inner_params = $this->filterInnerParams($orderAllocationDetails,$orderCommodities);                              // 创建
+        $inner_params = $this->filterInnerParams($orderAllocationDetails,$orderCommodities);                                            // 创建
         $delete_params = $this->filterDeleteParams($orderAllocationDetails,$orderCommodities);                                           // 删除
-
         if(count($inner_params)>0)
-            $this->createOrderCommodities($inner_params,$package_map);  // 创建 3s
+            $this->createOrderCommodities($inner_params,$package_map,$commodities,$owner_id_map);  // 创建 3s
 
         if(count($update_params)>0)
             $this->updateOrderCommodities($update_params);              // 更新
@@ -750,26 +770,19 @@ class OrderPackageCommoditiesService
         return $del_params;
     }
     // TODO  根据数据创建
-    public function createOrderCommodities($inner_params,$package_map)
+    public function createOrderCommodities(&$inner_params,&$package_map,&$commodities,&$owner_id_map)
     {
         /** @var DataHandlerService $dataHandlerService */
         $dataHandlerService  = app('DataHandlerService');
-        $sku = [];$owners = [];
-        foreach ($inner_params as $inner_param) {
-            $sku_code = $inner_param['sku'];$owner_code = $inner_param['owner_code'];
-            if(!isset($sku[$sku_code]))
-                $sku[$sku_code] = $sku_code;
-            if(!isset($owner_code[$owner_code]))
-                $owners[$owner_code] = $owner_code;
-        }
-        $commodities = Commodity::query()->with('owner')->whereHas('owner',function ($query)use($owners){
-            $query->whereIn('code',$owners);
-        })->whereIn('sku',$sku)->get();
-        $commodity_map = [];
-        foreach ($commodities as $commodity) {
-            $key = ' owner='.$commodity->owner->code.' sku='.$commodity->sku;
-            $commodity_map[$key] = $commodity;
-        }
+        $commodity_map = (function()use(&$commodities,&$owner_id_map){
+            $map = [];
+            foreach ($commodities as $commodity) {
+                $owner = $owner_id_map[$commodity['owner_id']] ;
+                $key = ' owner='.$owner->code.' sku='.$commodity->sku;
+                $map[$key] = $commodity;
+            }
+            return $map;
+        })();
         $create_params =[];
         $date = Carbon::now();
         foreach ($inner_params as $inner_param) {
@@ -786,19 +799,19 @@ class OrderPackageCommoditiesService
             ];
         }
         if(count($create_params)>0){
-            try {
-                $inner_array = array_chunk($create_params,1000);
-                foreach ($inner_array as $item) {
+            $inner_array = array_chunk($create_params,5000);
+            foreach ($inner_array as $item) {
+                try {
                     $bool = $this->insert($item);
-                    LogService::log(__METHOD__,__FUNCTION__,'批量添加 orderCommodity --'. $bool ." || ".count($create_params).' || '.json_encode($create_params));
+                    LogService::log(__METHOD__, __FUNCTION__, '批量添加 orderCommodity ' . ($bool > 0 ? 'SUCCESS' : 'FAULT') . " || " . count($item) . ' || ' . json_encode($create_params));
+                } catch (\Exception $e) {
+                    LogService::log(__METHOD__,__FUNCTION__.'error','批量添加 orderCommodity ERROR'." || ".count($item).' || '.json_encode($item). ' || '.json_encode($e->getMessage()). ' || '.json_encode($e->getTraceAsString()));
                 }
-            } catch (\Exception $e) {
-                LogService::log(__METHOD__,__FUNCTION__.'error','批量添加 orderCommodity error'." || ".count($create_params).' || '.json_encode($create_params));
             }
         }
     }
     // TODO
-    public function updateOrderCommodities($orderCommodities)
+    public function updateOrderCommodities(&$orderCommodities)
     {
         if(!$orderCommodities)return ;
         $updated_at = Carbon::now();
@@ -816,17 +829,17 @@ class OrderPackageCommoditiesService
             $this->batchUpdate($update_params);
     }
     // TODO 删除
-    public function deleteOrderCommodities($orderCommodities){
+    public function deleteOrderCommodities(&$orderCommodities){
         if(!$orderCommodities)return;
         if(count($orderCommodities)==0)return;
         try {
             $ids = data_get($orderCommodities, '*.id');
             if(count($ids) >0){
                 $bool = OrderPackageCommodities::query()->whereIn('id', data_get($orderCommodities, '*.id'))->delete();
-                LogService::log(__METHOD__, __FUNCTION__, '批量删除 OrderCommodity -- ' . $bool . '||' .count($orderCommodities)  . ' || ' . json_encode($orderCommodities));
+                LogService::log(__METHOD__, __FUNCTION__, '批量删除 OrderCommodity '  . ($bool > 0 ? 'SUCCESS' : 'FAULT') .'||' .count($orderCommodities)  . ' || ' . json_encode($orderCommodities));
             }
         } catch (\Exception $e) {
-            LogService::log(__METHOD__, __FUNCTION__.' error', '批量删除 OrderCommodity Error-- ' . $e->getMessage() . '||' . $e->getTraceAsString() );
+            LogService::log(__METHOD__, __FUNCTION__.' error', '批量删除 OrderCommodity Error' . ' || ' . json_encode($e->getMessage()) . ' || ' . json_encode($e->getTraceAsString()));
         }
 
     }

+ 9 - 1
app/Services/OrderPackageService.php

@@ -392,7 +392,9 @@ class OrderPackageService
          * @var OrderPackageCommoditiesService $OrderPackageCommoditiesService
          */
         $OrderPackageCommoditiesService = app('OrderPackageCommoditiesService');
+
         $this->syncPackageByOrderHeaders($orderHeaders);
+
         $OrderPackageCommoditiesService->syncOrderPackageCommodities($orderHeaders);
     }
     // TODO
@@ -407,16 +409,22 @@ class OrderPackageService
         $orderPackageCommodityService= app('OrderPackageCommoditiesService');
         $orderTrackingService = app('OrderTrackingService');
         if(!$orderHeaders)return;
+
         $orders = $orderService->getByWmsOrders($orderHeaders);
+
         $packages = $this->getByOrderNos(data_get($orderHeaders,'*.orderno'));          // 已有
+
         $this->createOrderPackage($orderHeaders,$orders,$packages);                     // 创建package
 
         $del_ids = $this->deleteUnnecessaryPackage($orderHeaders,$packages);     // 删除package
+
         $orderPackageCommodityService->deleteUnnecessaryOrderCommodities($del_ids);     // 删除 orderCommodity
 
         $orderTracking = OrderTracking::query()->whereHas('commodities.package',function($query)use($del_ids){
             $query->whereIn('id',$del_ids);
         })->get();
+        if($orderTracking->count()==0)return;
+
         $orderTrackingService->deleteOrderTracings($orderTracking);                     // 删除追踪件
     }
     // TODO
@@ -439,7 +447,7 @@ class OrderPackageService
         }
         if(count($inner_params)>0){
             try {
-                $inner_array = array_chunk($inner_params,1000);
+                $inner_array = array_chunk($inner_params,5000);
                 foreach ($inner_array as $params) {
                     $bool = $this->insert($params);
                     $bool ? LogService::log(__METHOD__, __FUNCTION__, '批量添加 OrderPackage ' . count($inner_params) . ' || ' . json_encode($inner_params)) : null;

+ 147 - 38
app/Services/OrderService.php

@@ -9,6 +9,8 @@ use App\OracleDOCOrderHeader;
 use App\Order;
 use App\OrderIssue;
 use App\Owner;
+use App\OwnerPriceExpress;
+use App\OwnerPriceLogistic;
 use App\RejectedBill;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
@@ -16,6 +18,7 @@ use App\Shop;
 use App\ValueStore;
 use App\Warehouse;
 use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\Cache;
@@ -334,7 +337,7 @@ class OrderService
         $orderPackageService = app('OrderPackageService');
         $order = Order::query()->where('client_code', $clientCode)->first();
 
-        $orderHeader = OracleDOCOrderHeader::query()->where('SOReference1', $clientCode)->first();
+        $orderHeader = app('OracleDocOrderHeaderService')->first(['SOReference1'=> $clientCode]);
 
         if ($orderHeader == null) {
             return null;
@@ -678,7 +681,7 @@ class OrderService
     public function getByWmsOrders($orderHeaders){
         if(!$orderHeaders){return null;}
         $order_nos = data_get($orderHeaders,'*.orderno');
-        return Order::query()->whereIn('code',$order_nos)->get();
+        return Order::query()->with('packages.commodities')->whereIn('code',$order_nos)->get();
     }
 
     public function 返回有问题件的订单号($orders)
@@ -771,20 +774,25 @@ class OrderService
         return  $orders ? $orders->first() : null ;
     }
 
-    // TODO
     public function syncOrder(&$orderHeaders)
     {
         /**
          * @var OrderPackageService $packageService
+         * @var OrderCommodityService $orderCommodityService
          */
         $packageService = app("OrderPackageService");
+        $orderCommodityService = app("OrderCommodityService");
+
         $this->syncOrderByWMSOrderHeaders($orderHeaders);
+
+        $orderCommodityService->syncOrderCommodities($orderHeaders);
+
         $packageService->syncOrderPackage($orderHeaders);
     }
-    // TODO
+
     public function syncOrderByWMSOrderHeaders(&$orderHeaders)
     {
-        if($orderHeaders->isEmpty())return [];
+        if($orderHeaders->isEmpty())return;
         /**
          * @var OwnerService $ownerService
          * @var LogisticService $logisticService
@@ -795,33 +803,51 @@ class OrderService
         $logisticService = app("LogisticService");
         $shopService = app('ShopService');
         $warehouseService = app('WarehouseService');
+        $owner_codes = [];$logistic_codes = [];$warehouse_codes = [];$shop_names = [];
+        foreach ($orderHeaders as $orderHeader) {
+            if(!empty($orderHeader['customerid']))
+                $owner_codes[$orderHeader['customerid']] = $orderHeader['customerid'];
+            if(!empty($orderHeader['warehouseid']))
+                $warehouse_codes[$orderHeader['warehouseid']] = $orderHeader['warehouseid'];
+            if(!empty($orderHeader['userdefine1']))
+                $logistic_codes[$orderHeader['userdefine1']] = $orderHeader['userdefine1'];
+            if(!empty($orderHeader['issuepartyname']) && !empty($orderHeader['customerid'])){
+                $value = ['owner_code'=>$orderHeader['customerid'],'issuepartyname'=>$orderHeader['issuepartyname']];
+                $key = "owner_code_{$orderHeader['customerid']}_issuepartyname_{$orderHeader['issuepartyname']}";
+                $shop_names[$key] = $value;
+            }
+        }
+        $owners = $ownerService->getOwnerByCodes($owner_codes);
+        $logistics = $logisticService->getLogisticByCodes($logistic_codes);
+        $shops = $shopService->getShopByCodeMap($shop_names);
+        $warehouses = $warehouseService->getWareHouseByCodes($warehouse_codes);
 
-        $owners = $ownerService->getByWmsOrders($orderHeaders);
-        $logistics = $logisticService->getByWmsOrders($orderHeaders);
-        $shops = $shopService->getByWmsOrders($orderHeaders);
-        $warehouses = $warehouseService->getByWmsOrders($orderHeaders);
         $orders = $this->getByWmsOrders($orderHeaders);
+
         $created_params = $this->getCreateOrderModelsByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops); //3s
 
         $update_order = $this->getUpdateOrderModelByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops);
+
+
         // 转换插入 3s
         if(count($created_params) > 0){
-            collect($created_params)->chunk(4000)->each(function($inner_params){
+            collect($created_params)->chunk(3500)->each(function($inner_params){
                 $this->insert($inner_params->toArray());
             });
         }
         $update_params = [
-            ['id','code','warehouse_id','owner_id','shop_id','logistic_id','consignee_name','consignee_phone','province','city','district','address','client_code','wms_status','created_at','updated_at','wms_edittime']
+            ['id','code','warehouse_id','owner_id','shop_id','logistic_id','consignee_name','consignee_phone','province','city','district','address','client_code','wms_status','created_at','updated_at','wms_edittime','order_type']
         ];
-        $update_order->map(function ($item){
-            return $item->toArray();
-        })->each(function($item)use(&$update_params){
-            $update_params[] =$item;
+
+        $update_order->each(function($item)use(&$update_params){
+            $update_params[] = $item->toArray();
         });
+        if(count($update_order)==0)return;
+
         $this->batchUpdate($update_params);
     }
-    // TODO
-    public function getCreateOrderModelsByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops)
+
+    public function getCreateOrderModelsByWMSOrderHeaders(&$orderHeaders,&$orders,&$warehouses,&$owners,&$logistics,&$shops)
     {
         /** @var DataHandlerService $dataHandlerService */
         $dataHandlerService = app('DataHandlerService');
@@ -832,7 +858,6 @@ class OrderService
         $shop_map = $dataHandlerService->dataHeader(['name','owner_id'],$shops);
         $order_map = $dataHandlerService->dataHeader(['code'],$orders);
 
-//        $collect = collect();
         $inner_params  = [];
         $date = (string)Carbon::now();
         foreach ($orderHeaders as $orderHeader) {
@@ -841,12 +866,11 @@ class OrderService
             if(isset($order))continue;
             $order_model = $this->getCreateOrderModels($orderHeader,$warehouse_map,$owner_map,$logistic_map,$shop_map,$date);
             $inner_params[] = $order_model;
-//            $collect->push($order_model);
         }
         return $inner_params;
     }
-    // TODO
-    public function getUpdateOrderModelByWMSOrderHeaders($orderHeaders,$orders,$warehouses,$owners,$logistics,$shops)
+
+    public function getUpdateOrderModelByWMSOrderHeaders(&$orderHeaders,&$orders,&$warehouses,&$owners,&$logistics,&$shops)
     {
         /**
          * @var DataHandlerService $dataHandlerService
@@ -871,7 +895,7 @@ class OrderService
         }
         return $collect;
     }
-    // TODO
+
     public function getCreateOrderModels(&$orderHeader,&$warehouse_map,&$owner_map,&$logistic_map,&$shop_map,$date)
     {
         /** @var DataHandlerService $dataHandlerService */
@@ -898,6 +922,7 @@ class OrderService
             'client_code' => $orderHeader['soreference1'],
             'wms_edittime' => $orderHeader['edittime'],
             'wms_status' => $orderHeader->oracleBASCode->codename_c??'',
+            'order_type' => $orderHeader->orderType->codename_c??'',
             'updated_at' => $date,
             'created_at' => $orderHeader['addtime']
         ];
@@ -914,7 +939,7 @@ class OrderService
      * @param $updateParams
      * @return mixed
      */
-    public function UpdateOrderParamBy($shop, $logistic, $owner, $warehouse, $order, $orderHeader, string $updated_at, &$updateParams)
+    public function UpdateOrderParamBy(&$shop, &$logistic, &$owner, &$warehouse, &$order, &$orderHeader, string &$updated_at, &$updateParams)
     {
         $shop_id = $shop->id ?? null;
         $logistic_id = $logistic->id ?? null;
@@ -949,11 +974,11 @@ class OrderService
                 'updated_at' => $updated_at,
                 'created_at' => $orderHeader->addtime,
                 'wms_edittime' => $orderHeader->edittime,
+                'order_type' => $orderHeader->orderType->codename_c??'',
                 'warehouse_id' => $warehouse_id];
         }
     }
 
-    // TODO
     public function createOrFindOrder($orderHeader)
     {
         $order = Order::query()->where('code',$orderHeader->orderno)->first();
@@ -968,7 +993,7 @@ class OrderService
             return null;
         }
     }
-    // TODO
+
     public function createOrFindOrderInfo($orderHeader)
     {
         /**
@@ -981,7 +1006,7 @@ class OrderService
         $orderHeaders->push($orderHeader);
         try {
             $this->syncOrderByWMSOrderHeaders($orderHeaders);
-            $orderPackageService->syncOrderPackage($orderHeaders);
+            $orderPackageService->syncPackageByOrderHeaders($orderHeaders);
             $orderPackageCommoditiesService->syncOrderPackageCommodities($orderHeaders);
             return  Order::query()->with('packages.commodities')->where('code',$orderHeader->orderno)->first();
         } catch (\Exception $e) {
@@ -990,8 +1015,6 @@ class OrderService
         }
     }
 
-
-    // TODO
     public function setOrderSyncAt($key,$date,$bool=true){
         if($bool){
             ValueStore::query()->where('name',$key)->update(['value'=>Carbon::parse($date)->subSeconds(1)]);
@@ -999,7 +1022,7 @@ class OrderService
             ValueStore::query()->where('name',$key)->update(['value'=>$date]);
         }
     }
-    // TODO
+
     public function getOrderSyncAt($key,$type='newest'){
         $keyValue = ValueStore::query()->where('name',$key)->first();
         if($keyValue->value)return $keyValue->value;
@@ -1008,11 +1031,11 @@ class OrderService
         if($order)return $order->created_at;
         return Carbon::now()->subSeconds(65);
     }
-    // TODO
+
     public function pushOrderCache($orderHeaders,$prefixKey,$hasKey,$list_key){
         $list = [];
         try {
-            Redis::LLEN($list_key);
+            Cache::get($hasKey);
             collect($orderHeaders)->each(function($item)use(&$list,$prefixKey){
                 $list[] =$item->orderno;
                 Cache::put($prefixKey.$item->orderno,true);
@@ -1025,7 +1048,7 @@ class OrderService
 
         }
     }
-    // TODO
+
     public function filterOrderByCache($orderHeaders,$key)
     {
         /**
@@ -1034,7 +1057,7 @@ class OrderService
         if(!$orderHeaders)return $orderHeaders;
         if(!$key)return $orderHeaders;
         try {
-            Redis::LLEN($key);
+            Cache::get($key);
             return array_filter($orderHeaders,function($item)use($key){
                 $bool = Cache::get($key.$item->orderno);
                 return !$bool;
@@ -1043,10 +1066,11 @@ class OrderService
             return $orderHeaders;
         }
     }
-    // TODO
+
     public function cancelOrderCache($key,string $prefix)
     {
         try {
+            Cache::get($prefix);
             $list = Cache::get($key);
             collect($list)->each(function ($item)use($prefix) {
                 Cache::forget($prefix.$item);
@@ -1055,7 +1079,7 @@ class OrderService
         } catch (\Exception $e) {
         }
     }
-    // TODO
+
     public function syncCreatedOrder(){
         /**
          * @var OracleDOCOrderHeaderService $oracleDOCOrderHeaderService
@@ -1077,12 +1101,12 @@ class OrderService
 
         if(count($orderHeaders)>0 && count($orderHeaders) >0){
             $orderService->syncOrder($orderHeaders);                                                //  同步订单
-            $orderService->cancelOrderCache($newest_list);                                              //  清除缓存
+            $orderService->cancelOrderCache($newest_list,$prefixKey);                                   //  清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$newest_list);             //  添加缓存
             $orderService->setOrderSyncAt($newest,$last_order->addTime,count($orderHeaders)>0);   //  更新时间
         }
     }
-    // TODO
+
     public function syncUpdatedOrder(){
         /**
          * @var OracleDOCOrderHeaderService $oracleDOCOrderHeaderService
@@ -1104,9 +1128,94 @@ class OrderService
 
         if(count($renewal_orders)>0 && count($orderHeaders)>0){
             $orderService->syncOrder($orderHeaders);                                                    // 同步订单
-            $orderService->cancelOrderCache($renewal_list);                                                 // 清除缓存
+            $orderService->cancelOrderCache($renewal_list,$prefixKey);                                      // 清除缓存
             $orderService->pushOrderCache($renewal_orders,$prefixKey,$hasKey,$renewal_list);                // 添加缓存
             $orderService->setOrderSyncAt($renewal,$renewal_order->addTime,count($orderHeaders)>0);   // 更新时间
         }
     }
+
+    public function update(array $params, array $values)
+    {
+        $query = Order::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->update($values);
+    }
+
+    public function createInstantBill(Order $order):bool
+    {
+        //检查订单对象
+        if (!$order || $order->wms_status != "订单完成")return false;
+        $order->loadMissing(["logistic","packages.commodities.commodity"]);
+
+        /** @var OwnerPriceExpressService $service */
+        $service = app("OwnerPriceExpressService");
+        $logistic_fee = 0;
+        $commodities = [];
+        $amount = 0;
+        $volume = 0;
+        $weight = 0;
+        $logistic_bill = "";
+
+        if (!$order->logistic || $order->logistic->type != "快递")$logistic_fee = null;
+
+        foreach ($order->packages as &$package){
+            $logistic_bill .= $package->logistic_number.",";
+            $volume += $package->bulk;
+            $weight += $package->weight;
+
+            // 四维转二维
+            foreach($package->commodities as &$commodity){
+                $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
+                $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
+                $amount += $commodity->amount;
+            }
+            $commodities = array_merge($commodities,$package->commodities->toArray());
+
+            if ($logistic_fee!==null){
+                $provinceName = $order->province;
+                $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                    return app("ProvinceService")->first(["name"=>$provinceName]);
+                },60);
+                if (!$province)$logistic_fee = null;
+
+                $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+                if ($fee<0)$logistic_fee = null;
+
+                $logistic_fee += $fee;
+            }
+        }
+        if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
+
+        $object = ["commodities"=>$commodities,"logistic_name"=>($order->logistic ? $order->logistic->name : ''),"shop_name"=>($order->shop ? $order->shop->name : ''),"order_type"=>$order->order_type];
+        $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name","承运商"=>"logistic_name","店铺类型"=>"shop_name","订单类型"=>"order_type"];
+
+        /** @var OwnerPriceOperationService $service */
+        $service = app("OwnerPriceOperationService");
+        $work_fee = $service->matchRule($object,$mapping,$order->owner_id,"出库");
+        if ($work_fee < 0)$work_fee = null;
+
+       if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $order->owner_id,
+            "worked_at"         => $order->wms_edittime,
+            "type"              => "发货",
+            "shop_id"           => $order->shop_id,
+            "operation_bill"    => $order->code,
+            "consignee_name"    => $order->consignee_name,
+            "consignee_phone"   => $order->consignee_phone,
+            "commodity_amount"  => $amount,
+            "logistic_bill"     => rtrim($logistic_bill,","),
+            "volume"            => $volume,
+            "weight"            => $weight,
+            "logistic_id"       => $order->logistic_id,
+            "work_fee"          => $work_fee,
+            "logistic_fee"      => $logistic_fee,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $order->id,
+            "outer_table_name"  => "orders",
+        ]))return true;
+       return false;
+    }
 }

+ 22 - 35
app/Services/OrderTrackingService.php

@@ -77,6 +77,9 @@ class OrderTrackingService
         if ($params['client'] ?? false)  // 客户
             $query->where('client', 'like', $params['client']);
 
+        if(!empty($params['web_order_number']))
+            $query->where('web_order_number', 'like', $params['web_order_number'].'%');
+
         if ($params['sku'] ?? false) {
             $query->whereHas('commodities.commodity', function ($query) use ($params) {
                 $query->where('sku', $params['sku']);
@@ -210,7 +213,7 @@ class OrderTrackingService
             })->update($update);
             return['success'=> $bool > 0];
         } catch (\Exception $e) {
-            app('LogService')->log(__METHOD__,__FUNCTION__,'修改追踪件'.json_encode($orderId,$param,$value).$e->getMessage().$e->getTraceAsString());
+            app('LogService')->log(__METHOD__,__FUNCTION__,'修改追踪件'.json_encode($orderId,$param,$value).json_encode($e->getMessage()).json_encode($e->getTraceAsString()));
             return['success'=> false,'fail_info'=>$e->getMessage()];
         }
     }
@@ -255,16 +258,7 @@ class OrderTrackingService
             $order_header = $order_headers_map[$order->code];
             if(!$order_header){continue ;}
             if($order_header->sostatus == 90){continue;}
-            $client = null;
-            $order_remark = null;
-            if ($order_header['notes'] ?? false) {
-                $notes = $order_header->notes;
-                if (strpos($notes, '[')) {
-                    $arr= str_split($notes,strpos($notes,'['));
-                    $client = $arr[0] ?? '';
-                    $order_remark = str_replace(['[',']'],'', $arr[1] ?? '');
-                }
-            }
+
             $web_order_number = null;
             if(preg_match('/^O[\d]/',$order_header['soreference1'] ?? '') > 0){
                 $web_order_number = $order_header['soreference1'];
@@ -278,9 +272,10 @@ class OrderTrackingService
                 'order_package_commodity_id' => $item->id,
                 'owner_id' => $order->owner_id,
                 'order_client_code' =>$order->client_code,
-                'client' => $client,
+                'sale' => $param['sale'],
+                'client' => $param['client'],
                 'created_at' => $order->created_at,
-                'order_remark' => $order_remark,
+                'order_remark' => $param['order_remark'],
                 'pick_up_at' => $order_header->lastshipmenttime, // 提货时间,
                 'web_order_number' => $web_order_number,
                 'gross_weight'=> $gross_weight,
@@ -289,7 +284,6 @@ class OrderTrackingService
                 'planning_sent_at' => $param['planning_sent_at'] ?? ''
             ];
         }
-
         try {
             if (count($params) > 0) {
                 $this->insert($params);
@@ -306,12 +300,14 @@ class OrderTrackingService
         /** @var DataHandlerService $dataService */
         $dataService = app(DataHandlerService::class);
         $order_nos = data_get($orderHeaders,'*.orderno');
-        $order_package_commodities = OrderPackageCommodities::query()
-            ->with('package.order')
+
+        $order_package_commodities = OrderPackageCommodities::query()->with('package.order')
             ->whereHas('package.order',function($query) use ($order_nos){
                 $query->whereIn('code',$order_nos);
             })->get();
+
         $orderTrackings = OrderTracking::query()->whereIn('order_package_commodity_id',data_get($order_package_commodities,'*.id'))->get();
+
         $order_tracking_id_map = [];
         foreach ($orderTrackings as $orderTracking) {
             $order_tracking_id_map[$orderTracking->order_package_commodity_id] = $orderTracking;
@@ -382,12 +378,12 @@ class OrderTrackingService
                     $basSkU = $dataService->getKeyValue(['customerid'=>$orderHeader->customerid,'sku'=>$item->commodity->sku],$BasSKUs_code_sku_map);
                     $gross_weight = round($basSkU->grossweight * $item->amount, 2);
                     $bulk = round($basSkU->cube * $item->amount, 2);
-                    $pararm = $this->getParamsByOrderHeaderAndOrder($orderHeader,$order);
-                    $pararm['order_package_commodity_id'] =$item->id;
-                    $pararm['order_client_code'] = $order->client_code;
-                    $pararm['gross_weight'] = $gross_weight;
-                    $pararm['bulk'] = $bulk;
-                    $insert_params[] =$pararm;
+                    $param = $this->getParamsByOrderHeaderAndOrder($orderHeader,$order);
+                    $param['order_package_commodity_id'] =$item->id;
+                    $param['order_client_code'] = $order->client_code;
+                    $param['gross_weight'] = $gross_weight;
+                    $param['bulk'] = $bulk;
+                    $insert_params[] =$param;
                 }
             }
         }
@@ -411,16 +407,6 @@ class OrderTrackingService
     {
         $client = null;
         $order_remark = null;
-        if ($orderHeader['notes'] ?? false) {
-            $notes = $orderHeader->notes;
-            if (strpos($notes, '[')) {
-                $index = strpos($notes, '[');
-                $client = substr($notes,0,$index);
-                $order_remark = substr($notes,$index);
-                $order_remark = ltrim($order_remark,'[');
-                $order_remark = rtrim($order_remark,']');
-            }
-        }
         $web_order_number = null;
         if(preg_match('/^O[\d]/',$orderHeader['soreference1'] ?? '') > 0){
             $web_order_number = $orderHeader['soreference1'];
@@ -435,10 +421,11 @@ class OrderTrackingService
         }
         return [
             'owner_id' => $order->owner_id,
-            'client' => $client,
+            'client' => $orderHeader['c_contact'] ?? '',
+            'sale' => $orderHeader['issuepartyname'] ?? '',
             'created_at' => $order->created_at,
-            'order_remark' => $order_remark,
-            'pick_up_at' => $orderHeader->lastshipmenttime, // 提货时间
+            'order_remark' => $orderHeader['notes'] ?? '',
+            'pick_up_at' => $orderHeader['lastshipmenttime'] ?? '', // 提货时间
             'web_order_number' =>$web_order_number,
             'is_on_duty_shift'=>$planning_sent_at?'是':null,
             'planning_sent_at' => (string)$planning_sent_at

+ 20 - 0
app/Services/OwnerFeeDetailService.php

@@ -55,4 +55,24 @@ Class OwnerFeeDetailService
         return $query->sql();
     }
 
+    public function create(array $params)
+    {
+        return OwnerFeeDetail::query()->create($params);
+    }
+
+    public function first(array $params)
+    {
+        $query = OwnerFeeDetail::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->first();
+    }
+
+    public function updateFind(OwnerFeeDetail $detail, array $values)
+    {
+        return $detail->update($values);
+    }
+
 }

+ 16 - 11
app/Services/OwnerPriceExpressService.php

@@ -101,7 +101,7 @@ Class OwnerPriceExpressService
     }
 
     /**
-     * CODE: -1:未找到计费模型
+     * CODE: -1:未找到计费模型 -2:重量无效
      *
      * @param double $weight
      * @param integer $owner_id
@@ -111,16 +111,21 @@ Class OwnerPriceExpressService
      */
     public function matching($weight, $owner_id, $logistic_id, $province_id)
     {
-        $model = OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
-            /** @var Builder $query */
-            $query->where("province_id",$province_id);
-        }])->whereHas("owners",function ($query)use($owner_id){
-            /** @var Builder $query */
-           $query->where("id",$owner_id);
-        })->whereHas("logistics",function ($query)use($logistic_id){
-            /** @var Builder $query */
-            $query->where("id",$logistic_id);
-        })->first();
+        if (!$weight)return -2;
+
+        $key = "price_express_".$province_id."_".$logistic_id."_".$owner_id;
+        $model = app(CacheService::class)->getOrExecute($key,function ()use($owner_id, $logistic_id, $province_id){
+            return OwnerPriceExpress::query()->with(["details"=>function($query)use($province_id){
+                /** @var Builder $query */
+                $query->where("province_id",$province_id);
+            }])->whereHas("owners",function ($query)use($owner_id){
+                /** @var Builder $query */
+                $query->where("id",$owner_id);
+            })->whereHas("logistics",function ($query)use($logistic_id){
+                /** @var Builder $query */
+                $query->where("id",$logistic_id);
+            })->first();
+        });
         if (!$model || !$model->details)return -1;
         if ($weight < $model->initial_weight)$weight = $model->initial_weight;
         $initialMoney = $model->initial_weight*$model->details[0]->initial_weight_price;

+ 29 - 10
app/Services/OwnerPriceOperationService.php

@@ -104,11 +104,10 @@ Class OwnerPriceOperationService
      * @param array $columnMapping       key-val
      * @param string $owner_id
      * @param string $type
-     * @param string $sku
      * @return double
      * 错误代码: -1:无匹配对象 -2:无计费模型 -3:未知单位 -4:sku为空 -5:货主未找到 -6:无箱规 -7:未匹配到计费模型
      */
-    public function matchRule($matchObject, $columnMapping, $owner_id, $sku = null, $type = '出库')
+    public function matchRule($matchObject, $columnMapping, $owner_id, $type = '出库')
     {
         $unitModels = Unit::query()->whereIn("name",["件","箱","单"])->get();
         $units = [];
@@ -144,7 +143,12 @@ Class OwnerPriceOperationService
                     if ($bool === true){
                         if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                         if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $sum = $this->changeUnit($sum,$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
+                            }
+                            $sum = $sumTemp;
                             if ($sum<0)return $sum;
                         }
                         if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
@@ -153,7 +157,12 @@ Class OwnerPriceOperationService
                 }else{
                     if (!isset($units[$rule->ownerInStorageRule->unit_id])) return -3;
                     if ($units[$rule->ownerInStorageRule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                        $sum = $this->changeUnit($sum,$owner_id,$sku);
+                        $sumTemp = 0;
+                        $packageColumn = $columnMapping["packages"] ?? "packages";
+                        foreach ($matchObject[$packageColumn] as $commodity){
+                            $sumTemp += $this->changeUnit($sum,$owner_id,$commodity["sku"]);
+                        }
+                        $sum = $sumTemp;
                         if ($sum<0)return $sum;
                     }
                     if ($units[$rule->ownerInStorageRule->unit_id] == '单')$sum = 1; //为单时数量设为1;
@@ -168,11 +177,11 @@ Class OwnerPriceOperationService
             if ($rule->strategy == '特征'){
                 $bool = app("FeatureService")->matchFeature($rule->feature,$columnMapping,$matchObject);//匹配特征
                 if ($bool === true){
-                    $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                    $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id);
                     if ($money>0)return $money;
                 };
             }else{
-                $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id,$sku);
+                $money = $this->matchOutStorage($rule->ownerOutStorageRules,$columnMapping,$matchObject,$units,$owner_id);
                 if ($money>0)return $money;
             };
         }
@@ -186,7 +195,7 @@ Class OwnerPriceOperationService
         return ceil($amount/$pack);
     }
 
-    private function matchOutStorage($rules, $columnMapping, $matchObject, $units, $owner_id, $sku)
+    private function matchOutStorage($rules, $columnMapping, $matchObject, $units, $owner_id)
     {
         $amountColumn = $columnMapping["amount"] ?? "amount";
         $packageColumn = $columnMapping["packages"] ?? "packages";
@@ -200,7 +209,7 @@ Class OwnerPriceOperationService
                 case "特征":
                     foreach ($packages as &$package){
                         if ($package["price"] ?? false)continue;
-                        if (!app("FeatureService")->matchFeature($rule->feature,["商品名称"=>"commodity"],["commodity"=>$package[$commodityColumn] ?? ''])) continue;
+                        if (!app("FeatureService")->matchFeature($rule->feature,["商品名称"=>$commodityColumn],["commodity"=>$package[$commodityColumn] ?? ''])) continue;
 
                         if (!$unitName)$unitName = $units[$rule->unit_id];
                         else {
@@ -210,7 +219,12 @@ Class OwnerPriceOperationService
                         $package["price"] = $rule->unit_price;
                         if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($package[$amountColumn],$owner_id,$commodity["sku"]);
+                            }
+                            $amount = $sumTemp;
                             if ($amount<0)return $amount;
                             $package[$amountColumn] = $amount;
                         }
@@ -228,7 +242,12 @@ Class OwnerPriceOperationService
                         $package["price"] = $rule->unit_price;
                         if (!isset($units[$rule->unit_id]) || $units[$rule->unit_id] == '单')return -3;
                         if ($units[$rule->unit_id] == '箱'){ //为箱时同步商品寻找箱规
-                            $amount = $this->changeUnit($package[$amountColumn],$owner_id,$sku);
+                            $sumTemp = 0;
+                            $packageColumn = $columnMapping["packages"] ?? "packages";
+                            foreach ($matchObject[$packageColumn] as $commodity){
+                                $sumTemp += $this->changeUnit($package[$amountColumn],$owner_id,$commodity["sku"]);
+                            }
+                            $amount = $sumTemp;
                             if ($amount<0)return $amount;
                             $package[$amountColumn] = $amount;
                         }

+ 21 - 0
app/Services/OwnerService.php

@@ -9,6 +9,7 @@ use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
 
 Class OwnerService
 {
@@ -56,6 +57,7 @@ Class OwnerService
                     'name' => $basCustomer['descr_c'],
                     'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
                 ]);
+                continue;
             }
             if ($owner['name']!=$basCustomer['descr_c']){
                 $owner->update([
@@ -216,4 +218,23 @@ Class OwnerService
         return $builder;
     }
 
+    public function getOwnerByCodes($codes)
+    {
+        $collect = collect();
+        if(count($codes) == 0)return $collect;
+        foreach ($codes as $code) {
+            $collect->push($this->getOwnerByCode($code));
+        }
+        return $collect;
+    }
+
+    public function getOwnerByCode($code){
+        return Cache::remember("getOwnerByCode_{$code}", config('database.cache.expirations.owner'), function ()use($code){
+            $owner = Owner::query()->where('code',$code)->first();
+            if($owner) return $owner;
+            $basCustomer = app('OracleBasCustomerService')->first(['Customer_Type'=>'OW','CustomerID'=>$code]);
+            if(!$basCustomer)return null;
+            return Owner::query()->create(['name'=>$basCustomer['descr_c'],'code'=>$basCustomer['customerid']]);
+        });
+    }
 }

+ 20 - 0
app/Services/ProcessService.php

@@ -94,4 +94,24 @@ Class ProcessService
                 ->selectRaw('sign_commodity_barcode.mark sign_commodity_barcode_mark')
             ->sql();
     }
+
+    public function createInstantBill(Process $process)
+    {
+        if (!$process || $process->status!="交接完成")return false;
+        if (!$process->processStatistic)$process->load("processStatistic");
+
+        if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $process->owner_id,
+            "worked_at"         => $process->processStatistic ? $process->processStatistic->ended_at : '',
+            "type"              => "增值服务",
+            "operation_bill"    => $process->code,
+            "commodity_amount"  => $process->completed_amount,
+            "process_method_id" => $process->process_method_id,
+            "work_fee"          => $process->processStatistic ? $process->processStatistic->revenue : null,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $process->id,
+            "outer_table_name"  => "processes",
+        ]))return true;
+        return false;
+    }
 }

+ 9 - 0
app/Services/ProvinceService.php

@@ -29,4 +29,13 @@ Class ProvinceService
         }
         return null;
     }
+
+    public function first(array $params)
+    {
+        $query = Province::query();
+        foreach ($params as $column=>$param){
+            $query->where($column,$param);
+        }
+        return $query->first();
+    }
 }

+ 33 - 0
app/Services/ShopService.php

@@ -2,13 +2,21 @@
 
 namespace App\Services;
 
+use App\OracleBasCustomer;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
 use App\Shop;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 class ShopService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
+
     public function getSelection(array $column = ['id', 'name'])
     {
         return Shop::query()->select($column)->get();
@@ -86,5 +94,30 @@ class ShopService
         }
     }
 
+    public function getShopByCodeMap($map)
+    {
+        /** @var OwnerService $ownerService */
+        $ownerService = app('OwnerService');
+        $owner_codes = [];
+        foreach ($map as $item) {
+            $owner_codes[$item['owner_code']]= $item['owner_code'];
+        }
+        $owners = $ownerService->getOwnerByCodes($owner_codes);
+        $owner_map  = [];
+        $owners->each(function($owner)use(&$owner_map){
+            $owner_map[$owner['code']] = $owner;
+        });
+        $collect = collect();
+        if(count($map)==0)return $collect;
+        foreach ($map as $item) {
+            $collect->push(Cache::remember("getShopByCodeMap_{$item['owner_code']}_{$item['issuepartyname']}", null, function()use($item,$owner_map){
+                $owner = $owner_map[$item['owner_code']] ;
+                $shop = Shop::query()->where('owner_id',$owner['id'])->where('name',$item['issuepartyname'])->first();
+                if($shop)return $shop;
+                return Shop::query()->create(['owner_id'=>$owner['id'],'name'=>$item['issuepartyname']]);
+            }));
+        }
+        return $collect;
+    }
 
 }

+ 39 - 0
app/Services/StationService.php

@@ -0,0 +1,39 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Station;
+use App\StationType;
+use Exception;
+use Illuminate\Support\Facades\Cache;
+
+class StationService
+{
+    /**
+     * @param string $typeName
+     * @return Station
+     * @throws Exception
+     */
+    function getDefaultStation(string $typeName):Station{
+        $station= Cache::remember('StationType_default_name_'.$typeName,config('rarelyChange'), function ()use($typeName) {
+            $stationType= StationType::query()->where('name',$typeName)->orderBy('id')->get('id')->first();
+            if(!$stationType) throw new Exception('指定站类型获取不到');
+            return Station::query()->where('station_type_id',$stationType['id'])->first();
+        });
+        if(!$station)throw new Exception('默认站获取不到');
+        return $station;
+    }
+
+    function broadcast($station_id, $json_data){
+        //...
+        //event(new BroadcastToStation($station_id,$json_data))
+    }
+
+    function broadcastBinMonitor($station_id, ){
+        //...
+        //$this->broadcast($station_id, $json_data)
+    }
+
+}

+ 61 - 0
app/Services/StationTaskBatchService.php

@@ -0,0 +1,61 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Batch;
+use App\StationTaskBatch;
+use App\StationTaskBatchType;
+use Exception;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Cache;
+
+class StationTaskBatchService
+{
+    /** @var StationService $stationService */
+    private $stationService;
+    /** @var StationTaskBatchTypeService $stationTaskBatchTypeService */
+    private $stationTaskBatchTypeService;
+    /** @var BatchService $batchService */
+    private $batchService;
+    public function __construct(){
+        $this->stationService=null;
+        $this->stationTaskBatchTypeService=null;
+        $this->batchService=null;
+    }
+
+    /**
+     * @param $batches Batch[]
+     * @throws Exception
+     */
+    public function createByBatches(array $batches){
+        $this->stationService=app('StationService');
+        $this->stationTaskBatchTypeService=app('StationTaskBatchTypeService');
+        $this->batchService=app('BatchService');
+
+        $stationMissionBatches_toCreate=new Collection();
+        $station=$this->stationService->getDefaultStation('料箱出货口');
+        $id_stationMissionBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
+
+        $batches_handled=[];
+        foreach ($batches as $batch){
+            if ($batch['status']=='未处理'){
+                $stationMissionBatches_toCreate->push([
+                    'batch_id'=>$batch['id'],
+                    'station_id'=>$station['id'],
+                    'station_mission_batch_type_id'=> $id_stationMissionBatchType,
+                    'status'=>'待处理'
+                ]);
+                $batches_handled[]=$batch;
+            }
+        }
+        $this->batchService->updateWhereIn('id',data_get($batches_handled,'*.id'),['status'=>'处理中']);
+        $this->insert($stationMissionBatches_toCreate->toArray());
+        return $stationMissionBatches_toCreate;
+    }
+
+    public function insert(array $stationMissionBatches_inArray){
+        return StationTaskBatch::query()->insert($stationMissionBatches_inArray);
+    }
+}

+ 26 - 0
app/Services/StationTaskBatchTypeService.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Station;
+use App\StationTaskBatchType;
+use App\StationType;
+use Illuminate\Support\Facades\Cache;
+
+class StationTaskBatchTypeService
+{
+    /**
+     * @param string $key
+     * @param string $value
+     * @return Station
+     */
+    public function firstByWhere(string $key,string $value):Station{
+        return Cache::remember('station_mission_batch_type_id_by_'.$key.$value, config('rarelyChange'), function ()use($key,$value) {
+            $stationMissionBatchType =StationTaskBatchType::query()->where($key, $value)->first();
+            if(!$stationMissionBatchType)throw new \Exception("找不到 StationMissionBatchType,where $key = $value");
+            return $stationMissionBatchType;
+        });
+    }
+}

+ 28 - 0
app/Services/StoreService.php

@@ -183,4 +183,32 @@ Class StoreService
         $asn_nos = array_unique(data_get($asnHerders,'*.asnno'));
         return Store::query()->whereIn('asn_code',$asn_nos)->get();
     }
+
+    public function createInstantBill(Store $store):bool
+    {
+        if (!$store || $store->status!="已入库")return false;
+        if (!$store->storeItems)$store->load("storeItems");
+
+
+        /** @var OwnerPriceOperationService $service */
+        $service = app("OwnerPriceOperationService");
+
+        $mapping = ["packages"=>"storeItems","商品名称"=>"name","订单类型"=>"stored_method"];
+
+        $work_fee = $service->matchRule($store,$mapping,$store->owner_id,"入库");
+        if ($work_fee < 0)$work_fee = null;
+
+        if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $store->owner_id,
+            "worked_at"         => $store->created_at,
+            "type"              => "收货",
+            "operation_bill"    => $store->asn_code,
+            "commodity_amount"  => array_sum(array_column($store->storeItems->toArray(),"amount")),
+            "work_fee"          => $work_fee,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $store->id,
+            "outer_table_name"  => "stores",
+        ]))return true;
+        return false;
+    }
 }

+ 37 - 5
app/Services/WarehouseService.php

@@ -7,9 +7,15 @@ use App\Owner;
 use App\Warehouse;
 use Illuminate\Support\Collection;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 Class WarehouseService
 {
+    /** @var CacheService $cacheService */
+    private $cacheService;
+    function __construct(){
+        $this->cacheService=app('CacheService');
+    }
 
     public function firstOrCreate(array $params, array $values = null)
     {
@@ -45,11 +51,17 @@ Class WarehouseService
             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);
+            $params =[
+                'code' => $oracleBasCustomer->customerid,
+                'name' => $oracleBasCustomer->descr_c
+            ];
+            try {
+                $wereHouse = Warehouse::query()->create($params);
+                $collet->push($wereHouse);
+                app('LogService')->log(__METHOD__,__FUNCTION__,'创建 warehouse success'.json_encode($wereHouse));
+            } catch (\Exception $e) {
+                app('LogService')->log(__METHOD__,__FUNCTION__,'创建 warehouse error'.json_encode($params).json_encode($e->getMessage()));
+            }
         }
         return  $collet;
     }
@@ -93,4 +105,24 @@ Class WarehouseService
         return Warehouse::query()->insert($fillables);
     }
 
+    public function getWareHouseByCodes($codes)
+    {
+        $collect = collect();
+        if(count($codes)==0)return $collect;
+        foreach ($codes as $code) {
+            $collect->push($this->getWareHouseByCode($code));
+        }
+        return $collect;
+    }
+
+    public function getWareHouseByCode($code){
+        return Cache::remember("WareHouse_{$code}",config('database.cache.expirations.warehouse'),function()use($code){
+            $wareHouse =  Warehouse::query()->where('code',$code)->first();
+            if($wareHouse)return $wareHouse;
+            $bas_customer = app('OracleBasCustomerService')->first(['CustomerId'=>$code,'Customer_Type'=>'WH']);
+            if(!$bas_customer) return null;
+            return Warehouse::query()->create(['name'=>$bas_customer['descr_c'],'code'=>$bas_customer['customerid']]);
+        });
+    }
 }
+

+ 43 - 0
app/Services/WaybillService.php

@@ -143,4 +143,47 @@ Class WaybillService
             ->selectRaw('logistics.name carrier_name')
             ->sql();
     }
+
+    public function createInstantBill(Waybill $waybill) :bool
+    {
+        if (!$waybill || $waybill->status != "已完结" || !$waybill->wms_bill_number || !$waybill->logistic_id)return false;
+        $waybill->loadMissing("destinationCity");
+        if (!$waybill->destinationCity)return false;
+
+        $detail = app("OwnerFeeDetailService")->first([
+            "type" => "发货","owner_id" => $waybill->owner_id,"operation_bill"=>$waybill->wms_bill_number
+        ]);
+        if (!$detail || $detail->logistic_fee !== null)return false;
+
+        if ($waybill->type == "专线"){
+            /** @var OwnerPriceLogisticService $service */
+            $service = app("OwnerPriceLogisticService");
+            $fee = $service->matching($waybill->carrier_weight_other,$waybill->owner_id,$waybill->logistic_id,
+                $waybill->carrier_weight_unit_id_other,$waybill->destinationCity->province_id,
+                $waybill->destination_city_id);
+        }else{
+            /** @var OwnerPriceDirectLogisticService $service */
+            $service = app("OwnerPriceDirectLogisticService");
+            $fee = $service->matching($waybill->mileage,$waybill->owner_id,$waybill->carType_id);
+        }
+
+        if ($fee >= 0){
+            app("OwnerFeeDetailService")->updateFind($detail,[
+                "owner_id" => $waybill->owner_id,
+                "worked_at"=> $waybill->updated_at,
+                "type" => "发货",
+                "operation_bill" => $waybill->waybill_number,
+                "consignee_name" => $waybill->recipient,
+                "consignee_phone" => $waybill->recipient_mobile,
+                "commodity_amount" => $waybill->amount,
+                "logistic_bill" => $waybill->carrier_bill,
+                "volume" =>$waybill->carrier_weight ?? $waybill->warehouse_weight,
+                "weight" => $waybill->carrier_weight_other ?? $waybill->warehouse_weight_other,
+                "logistic_id" => $waybill->logistic_id,
+                "logistic_fee" => $fee,
+                "outer_id" => $waybill->id,
+                "outer_table_name" => "waybills",
+            ]);
+        }
+    }
 }

+ 17 - 0
app/Station.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Station extends Model
+{
+    protected $fillable=['name', 'code', 'station_type_id','sequence','parent_id'];
+
+    public function type(){
+        return $this->belongsTo(StationType::class,'station_type_id');
+    }
+    public function parent(){
+        return $this->belongsTo(Station::class,'parent_id','id');
+    }
+}

+ 10 - 0
app/StationRuleBatch.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationRuleBatch extends Model
+{
+    protected $fillable=['name','station_type_id','batch_type','owner_id'];
+}

+ 10 - 0
app/StationTask.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTask extends Model
+{
+    protected $fillable = ['station_id', 'station_type_id'];
+}

+ 10 - 0
app/StationTaskBatch.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskBatch extends Model
+{
+    protected $fillable=['batch_id','station_id','station_mission_batch_type_id','status'];
+}

+ 10 - 0
app/StationTaskBatchType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskBatchType extends Model
+{
+    protected $fillable=['name'];
+}

+ 10 - 0
app/StationTaskCommodity.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskCommodity extends Model
+{
+    protected $fillable= ['station_id','material_box_id','commodity_id','amount','order_id','status','station_id'];
+}

+ 10 - 0
app/StationTaskMaterialBox.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskMaterialBox extends Model
+{
+    protected $fillable=['station_id','material_box_id','status'];
+}

+ 10 - 0
app/StationTaskType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationTaskType extends Model
+{
+    //
+}

+ 10 - 0
app/StationType.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class StationType extends Model
+{
+    protected $fillable=['name'];
+}

+ 11 - 0
app/Utils/helpers.php

@@ -0,0 +1,11 @@
+<?php
+
+use Carbon\Carbon;
+
+function formatExcelDate(int $timestamp)
+{
+    $diff = intval($timestamp);
+    $today=new Carbon('1900-01-01');
+    $day = $today->addDays($diff-2);
+    return $day->toDateString();
+}

+ 3 - 0
composer.json

@@ -57,6 +57,9 @@
         "classmap": [
             "database/seeds",
             "database/factories"
+        ],
+        "files": [
+            "app/Utils/helpers.php"
         ]
     },
     "autoload-dev": {

+ 9 - 1
config/api.php

@@ -37,9 +37,17 @@ return [
         ],
     ],
 
+    /** 海柔
+     *  https://was.baoshi56.com/api/thirdPart/haiq/pickStation/processed  //标记料箱已处理
+     *  https://was.baoshi56.com/api/thirdPart/haiq/storage/taskUpdate  //任务状态更新
+     *  https://was.baoshi56.com/api/thirdPart/haiq/storage/exception  //异常通知
+     */
     'haiq'=>[
         'storage'=>[
-            'relocate' => "http://59.37.126.227:65448/api/haiqEss/gr/relocate",
+//            'relocate' => "http://59.37.126.227:65448/api/haiqEss/gr/relocate",
+            'moveBin' => "http://192.168.1.201:2011/api/haiqEss/gr/relocate",  //移动料箱
+            'lightOn' => "http://192.168.1.201:2011/api/ptl/curlPTL",  //亮灯
+            'lightOff' => "",  //灭灯
         ],
     ],
 

+ 7 - 5
config/cache.php

@@ -5,11 +5,13 @@ use Illuminate\Support\Str;
 return [
 
     'expirations'=>[
-        'default'=>10,
-        'oftenChange'=>5,
-        'rarelyChange'=>60,
-        'commonFrequent'=>20,
-        'owners'=>20,
+        'default'=>10,          //默认
+        'oftenChange'=>5,       //经常改
+        'rarelyChange'=>60,     //几乎不变
+        'commonFrequent'=>20,  //一般频率
+        'forever' =>null,       //永久
+
+        'owners'=>20,           //模型Owner
     ],
     /*
     |--------------------------------------------------------------------------

+ 1 - 0
config/sync.php

@@ -9,6 +9,7 @@ return [
         'start_at'=> '',    // 开始同步WMS的时间  时间格式: yyyy-MM-dd HH:mm:ss 如 2020-09-05 13:15:16
     ],
     'order_sync' => [
+        'enabled' => true,
         'interval' => 1,   // 时间以分为单位
         'start_at'=> '',    // 开始同步WMS的时间  时间格式: yyyy-MM-dd HH:mm:ss 如 2020-09-05 13:15:16
         'cache_prefix' => [

+ 12 - 0
database/factories/MaterialBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\MaterialBox;
+use Faker\Generator as Faker;
+
+$factory->define(MaterialBox::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 18 - 0
database/factories/OracleActAllocationDetailsFactory.php

@@ -0,0 +1,18 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleActAllocationDetails;
+use Faker\Generator as Faker;
+
+$factory->define(OracleActAllocationDetails::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => $faker->name,
+        'sku'=>$faker->name,
+        'qtyordered' => $faker->numberBetween(1,50),
+        'qty_each' => $faker->numberBetween(1,50),
+        'location' => $faker->md5,
+        'picktotraceid'  => $faker->uuid
+    ];
+});

+ 14 - 0
database/factories/OracleBasCodeFactory.php

@@ -0,0 +1,14 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasCode;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasCode::class, function (Faker $faker) {
+    return [
+        'codeid' => $faker->uuid,
+        'code' => $faker->uuid,
+        'codename_c' => $faker->name,
+    ];
+});

+ 14 - 0
database/factories/OracleBasCustomerFactory.php

@@ -0,0 +1,14 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasCustomer;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasCustomer::class, function (Faker $faker) {
+    return [
+        'customer_type'=> $faker->uuid,
+        'customerid'=> $faker->uuid,
+        'descr_c'=> $faker->name
+    ];
+});

+ 19 - 0
database/factories/OracleBasSKUFactory.php

@@ -0,0 +1,19 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleBasSKU;
+use Faker\Generator as Faker;
+
+$factory->define(OracleBasSKU::class, function (Faker $faker) {
+    return [
+        'customerid'=>$faker->name,
+        'sku' =>$faker->name,
+        'descr_c' =>$faker->title(20),
+        'packid'=>$faker->name,
+        'skulength' =>$faker->numberBetween(1,100),
+        'skuwidth'=>$faker->numberBetween(1,100),
+        'skuhigh'=>$faker->numberBetween(1,100),
+        'cube'=>$faker->numberBetween(1,100),
+    ];
+});

+ 16 - 0
database/factories/OracleDOCOrderDetailFactory.php

@@ -0,0 +1,16 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleDOCOrderDetail;
+use Faker\Generator as Faker;
+
+$factory->define(OracleDOCOrderDetail::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => $faker->name,
+        'sku'=>$faker->name,
+        'qtyordered' => $faker->numberBetween(1,50),
+        'location' => $faker->md5
+    ];
+});

+ 35 - 0
database/factories/OrcaleDOCOrderHeaderFactory.php

@@ -0,0 +1,35 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\OracleDOCOrderHeader;
+use Faker\Generator as Faker;
+
+$factory->define(OracleDOCOrderHeader::class, function (Faker $faker) {
+    return [
+        'orderno' => $faker->uuid,
+        'customerid' => '',
+        'ordertime' =>$faker->time(),
+        'soreference1' => $faker->uuid,
+        'consigneeid' => '',
+        'c_contact' =>$faker->title(10),
+        'consigneename' => $faker->title(11),
+        'c_address1' => $faker->address,
+        'c_city' =>$faker->city,
+        'c_province' =>$faker->city,
+        'addtime' => $faker->date(),
+        'edittime' => $faker->date(),
+        'notes' => $faker->text(15),
+        'carriername'  =>'',
+        'lastshipmenttime' => $faker->date(),
+        'edisendflag' => "Y",
+        'soreference5' => $faker->uuid,
+        'c_tel2' => $faker->phoneNumber,
+        'transportation' => $faker->phoneNumber,
+        'warehouseid' => '',
+        'sostatus' => '99',
+        'c_tel1' => $faker->phoneNumber,
+        'c_district' => $faker->city,
+        'issuepartyname'=> $faker->date(),
+    ];
+});

+ 1 - 1
database/factories/ShopFactory.php

@@ -8,6 +8,6 @@ use Faker\Generator as Faker;
 $factory->define(Shop::class, function (Faker $faker) {
     return [
         'name' => $faker->name,
-        'owner_id' => factory(\App\Owner::class),
+        'owner_id' => 1,
     ];
 });

+ 12 - 0
database/factories/StationFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\Station;
+use Faker\Generator as Faker;
+
+$factory->define(Station::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionBatchFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskBatch;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskBatch::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionBatchTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskBatchType;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskBatchType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionCommodityFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskCommodity;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskCommodity::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationMissionMaterialBoxFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskMaterialBox;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskMaterialBox::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationRuleBatchFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationRuleBatch;
+use Faker\Generator as Faker;
+
+$factory->define(StationRuleBatch::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTaskFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTask;
+use Faker\Generator as Faker;
+
+$factory->define(StationTask::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTaskTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationTaskType;
+use Faker\Generator as Faker;
+
+$factory->define(StationTaskType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/StationTypeFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\StationType;
+use Faker\Generator as Faker;
+
+$factory->define(StationType::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 2 - 4
database/factories/WarehouseFactory.php

@@ -1,15 +1,13 @@
 <?php
 
-/** @var Factory $factory */
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
 
 use App\Warehouse;
 use Faker\Generator as Faker;
-use Illuminate\Database\Eloquent\Factory;
 
 $factory->define(Warehouse::class, function (Faker $faker) {
     return [
-        //
         'name' => $faker->name,
-        'code' => $faker->city,
+        'code' => $faker->uuid
     ];
 });

+ 1 - 1
database/migrations/2020_01_02_172739_change_waybill_price_model_field.php

@@ -26,7 +26,7 @@ class ChangeWaybillPriceModelField extends Migration
     public function down()
     {
         Schema::table('waybill_price_models', function (Blueprint $table) {
-            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
+//            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
         });
     }
 }

+ 1 - 1
database/migrations/2020_03_09_153510_create_stores_table.php

@@ -19,7 +19,7 @@ class CreateStoresTable extends Migration
             $table->integer('warehouse_id')->nullable()->comment('仓库ID');
             $table->integer('owner_id')->index()->nullable()->comment('货主ID');
             $table->enum('stored_method',['正常','快速入库','采购入库','笕尚退货入库单','笕尚进仓入库单','笕尚移仓入库单','B2B入库','笕尚调整入库单','换货入库','初始化库存','虚拟入库','其他入库','退货入库','调拨入库'])->default('正常');
-            $table->enum('status',['待盘点','盘点中','复盘中','已完成','已审核'])->default(null)->nullable();
+            $table->enum('status',['无需入库','已入库','未入库','待推单','完全收货','部分收货','已码盘','订单创建','ASN关闭','等待释放','收货取消'])->default(null)->nullable();
             $table->string('remark')->nullable();
             $table->timestamp('deleted_at')->nullable()->index();
             $table->timestamp('updated_at')->nullable();

+ 2 - 1
database/migrations/2020_04_09_111540_change_tutorial_table.php

@@ -32,7 +32,8 @@ class ChangeTutorialTable extends Migration
             $table->longText('content')->after('name')->nullable()->comment('富文本内容');
         });
         Schema::table('users', function (Blueprint $table) {
-            $table->string('email')->unique()->change();
+//            $table->unique('email','users_email_unique');
+//            $table->string('email')->unique()->change();
         });
     }
 }

Некоторые файлы не были показаны из-за большого количества измененных файлов