Переглянути джерело

Merge branch 'mergeCarrier' of ssh://was.baoshi56.com:10022/var/git/bswas

LD 5 роки тому
батько
коміт
441d0189fe

+ 45 - 8
app/Http/Controllers/TestController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 
 use App\Authority;
+use App\Carrier;
 use App\Commodity;
 use App\CommodityBarcode;
 use App\Console\Commands\SyncWMSOrderTask;
@@ -11,7 +12,6 @@ use App\Events\CancelOrder;
 use App\Imports\OrderTrackingImport;
 use App\InventoryAccount;
 use App\LaborReport;
-use App\Feature;
 use App\Log;
 use App\Logistic;
 use App\OracleActAllocationDetails;
@@ -24,7 +24,6 @@ use App\OrderCommodity;
 use App\OrderIssue;
 use App\OrderPackage;
 use App\Owner;
-use App\OwnerAreaReport;
 use App\Package;
 use App\Process;
 use App\ProcessDaily;
@@ -34,8 +33,9 @@ use App\RejectedBillItem;
 use App\Services\CacheService;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
-use App\Services\FeatureService;
 use App\Services\InventoryCompareService;
+use App\Services\LogisticService;
+use App\Services\LogService;
 use App\Services\OracleDocAsnHerderService;
 use App\Services\OracleDOCOrderHeaderService;
 use App\Services\OrderPackageService;
@@ -46,17 +46,16 @@ use App\Services\OwnerService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
 use App\StoreCheckingReceiveItem;
-use App\Unit;
 use App\User;
 use App\Warehouse;
+use App\Waybill;
+use App\WaybillPriceModel;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Hash;
-use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Str;
 use Maatwebsite\Excel\Facades\Excel;
 use Ramsey\Collection\Collection;
@@ -96,8 +95,46 @@ class TestController extends Controller
             app(BatchUpdateService::class)->batchUpdate('inventory_accounts',$updateParams);
         }
     }
-    public function test4(){
-        dd($this->dd());
+    public function mergeCarrier(){
+        $carriers = Carrier::query()->get();
+        $logistics = [];
+        $map = [];
+        foreach ($carriers as $carrier){
+            $map[$carrier->name] = $carrier->id;
+            $lo = Logistic::query()->where("name",$carrier->name)->first();
+            if ($lo){
+                if ($lo->type == '快递'){
+                    $lo->update(["type"=>"全部"]);$lo->save();
+                }
+                continue;
+            };
+            $logistics[] = [
+                "name" => $carrier->name,
+                'mobile' => $carrier->mobile,
+                'delivery_fee'=> $carrier->delivery_fee,
+                'remark'=> $carrier->remark,
+                "type" => "logistic"
+            ];
+        }
+        Logistic::query()->insert($logistics);
+        $ls = Logistic::query()->where("type","logistic")->get();
+        $result = [];
+        foreach ($ls as $l)
+        {
+            if (isset($map[$l->name]))$result[$map[$l->name]] = $l->id;
+        }
+        LogService::log(__METHOD__,"同步承运商",json_encode($result));
+        foreach ($result as $tag => $val){
+            Waybill::query()->where("logistic_id",$tag)->update([
+                "logistic_id" => $val
+            ]);
+            WaybillPriceModel::query()->where("logistic_id",$tag)->update([
+                "logistic_id" => $val
+            ]);
+            DB::table("logistic_user")->where("logistic_id",$tag)->update([
+                "logistic_id" => $val
+            ]);
+        }
     }
 
     private function dd()

+ 2 - 2
app/Http/Controllers/UserController.php

@@ -49,7 +49,7 @@ class UserController extends Controller
     {
         if(!Gate::allows('用户-录入')){ return redirect(url('/'));  }
         $roles=Role::all();
-        $logistics=app('LogisticService')->getSelection(["id","name"],"logistic");
+        $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $userWorkgroups=UserWorkgroup::query()->get();
         return view('maintenance.user.create',['rolesAll'=>$roles,'logistics'=>$logistics,'userWorkgroups'=>$userWorkgroups]);
     }
@@ -80,7 +80,7 @@ class UserController extends Controller
         if(!Gate::allows('用户-编辑')){ return redirect(url('/'));  }
         $rolesAll=Role::all();
         $roles=$user->roles()->get();
-        $logistics=app('LogisticService')->getSelection(["id","name"],"logistic");
+        $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $logisticUser=$user->logistics()->get();
         $userWorkgroups=UserWorkgroup::query()->get();
         $userWorkgroup=$user->userWorkgroups()->first();

+ 2 - 2
app/Http/Controllers/WaybillController.php

@@ -55,7 +55,7 @@ class WaybillController extends Controller
         $waybills=app('waybillService')->paginate($request->input());
         return view('waybill.index', [
             'waybills' => $waybills,
-            'logistics' => $logisticService->getSelection(["id","name"],"logistic"),
+            'logistics' => $logisticService->getSelection(["id","name"],"物流"),
             'owners' => $ownerService->getSelection(),
             'paginateParams'=>$paginateParams,
             'uriType'=>$request->uriType??'']);
@@ -95,7 +95,7 @@ class WaybillController extends Controller
         $cities=$cityService->getSelection();
         $units=$unitService->getSelection();
         $carTypes=$carTypeService->getSelection();
-        return view('waybill/edit',['waybill'=>$waybill,'logistics'=>$logisticService->getSelection(["id","name"],"logistic"),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
+        return view('waybill/edit',['waybill'=>$waybill,'logistics'=>$logisticService->getSelection(["id","name"],"物流"),'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]);
     }
 
     public function update(Request $request, $id,WaybillPriceModelService $waybillPriceModelService,

+ 3 - 3
app/Http/Controllers/WaybillPriceModelsController.php

@@ -21,7 +21,7 @@ class WaybillPriceModelsController extends Controller
     public function index(Request $request)
     {
         if(!Gate::allows('计费模型-查询')){ return redirect(url('/'));  }
-        $logistics=app('LogisticService')->getSelection(["id","name"],"logistic");
+        $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $provinces=Province::query()->get();
         $data=$request->input();
         $waybillPriceModels= WaybillPriceModel::query()->orderBy('id', 'DESC');
@@ -44,7 +44,7 @@ class WaybillPriceModelsController extends Controller
     public function create()
     {
         if(!Gate::allows('计费模型-录入')){ return redirect(url('/'));  }
-        $logistics=app('LogisticService')->getSelection(["id","name"],"logistic");
+        $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $provinces=Province::get();
         $units=Unit::get();
         return view('maintenance.priceModel.waybillPriceModel.create',['logistics'=>$logistics,'provinces'=>$provinces,'units'=>$units]);
@@ -101,7 +101,7 @@ class WaybillPriceModelsController extends Controller
     {
         if(!Gate::allows('计费模型-编辑')){ return redirect(url('/'));  }
         $waybillPriceModel=WaybillPriceModel::find($id);
-        $logistics=app('LogisticService')->getSelection(["id","name"],"logistic");
+        $logistics=app('LogisticService')->getSelection(["id","name"],"物流");
         $provinces=Province::get();
         $cities=City::where('province_id',$waybillPriceModel->province_id)->get();
         $units=Unit::get();

+ 6 - 2
app/Services/LogisticService.php

@@ -5,6 +5,7 @@ namespace App\Services;
 use App\Logistic;
 use App\OracleBasCustomer;
 use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Str;
 
@@ -15,10 +16,13 @@ Class LogisticService
     function __construct(){
         $this->cacheService=app('CacheService');
     }
-    public function getSelection($column = ['id','name'], $type = 'express'){
+    public function getSelection($column = ['id','name'], $type = '快递'){
         return $this->cacheService->getOrExecute('LogisticAll_idName'.Str::studly($type),function()use($column,$type){
             $query = Logistic::query()->select($column);
-            if ($type)$query->where("type",$type);
+            if ($type)$query->where(function ($query)use($type){
+                /** @var Builder $query */
+                $query->where("type",$type)->orWhere("type","全部");
+            });
             return $query->get();
         },config('cache.expirations.persistent'));
     }

+ 38 - 0
database/migrations/2020_11_27_110032_change_column_type_table_logistics.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeColumnTypeTableLogistics extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->dropColumn("type");
+        });
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->enum("type",["物流","快递","全部"])->default("快递")->index()->comment("类型");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->dropColumn("type");
+        });
+        Schema::table('logistics', function (Blueprint $table) {
+            $table->enum("type",["logistic","express"])->default("express")->comment("类型");
+        });
+    }
+}

+ 1 - 0
resources/views/maintenance/logistic/create.blade.php

@@ -20,6 +20,7 @@
                             <select id="type" name="type" class="form-control @error('type') is-invalid @enderror" value="{{ old('type') }}" required>
                                 <option value="快递">快递</option>
                                 <option value="物流">物流</option>
+                                <option value="全部">全部</option>
                             </select>
                             @error('type')
                             <span class="invalid-feedback" role="alert">