Browse Source

运输 逻辑补充

Zhouzhendong 5 years ago
parent
commit
4d13f136f0

+ 18 - 89
app/Http/Controllers/TestController.php

@@ -139,95 +139,24 @@ class TestController extends Controller
     public function zzd(){
         ini_set('max_execution_time',2500);
         ini_set('memory_limit','1526M');
-        $models = WaybillPriceModel::query()->get();
-        foreach ($models as $model){
-            if ($model->city_name == '汕头/汕尾'){
-                $region1 = Region::query()->where("name","汕头")->first();
-                $region2 = Region::query()->where("name","汕尾")->first();
-                $model->update([
-                    "province_id" =>$region1->parent_id,
-                    "city_id" =>$region1->id,
-                ]);
-                WaybillPriceModel::query()->create([
-                    'logistic_id'=> $model->logistic_id,
-                    'province_id' => $region2->parent_id,
-                    'city_id' => $region2->id,
-                    'unit_id' => $model->unit_id,
-                    'range_min' => $model->range_min,
-                    'range_max'=> $model->range_max,
-                    'unit_price'=> $model->unit_price,
-                    'base_fee'=> $model->base_fee,
-                    'initial_weight'=> $model->initial_weight
-                ]);
-                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
-                continue;
-            }
-            $obj = [];
-            if ($model->province_id){
-                $obj["province_id"] = app(RegionService::class)->getProvince($model->province_name);
-            }
-            if ($model->city_id){
-                $obj["city_id"] = app(RegionService::class)->getCity($model->city_name);;
-            }
-            if (count($obj)>0){
-                $model->update($obj);
-                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
-            }
-        }
-        dd("OK");
-    }
-
-    public function zzd1()
-    {
-        ini_set('max_execution_time',2500);
-        ini_set('memory_limit','1526M');
-        $models = Waybill::query()->whereNotNull("origination_city_id")
-            ->orWhereNotNull("destination_city_id")->get();
-        foreach ($models as $model){
-            $obj = [];
-            if ($model->origination_city_id){
-                $city = City::query()->find($model->origination_city_id)->name ?? null;
-                if ($city)$obj["origination_city_id"] = app(RegionService::class)->getCity($city);
-            }
-            if ($model->destination_city_id){
-                $city = City::query()->find($model->destination_city_id)->name ?? null;
-                if ($city)$obj["destination_city_id"] = app(RegionService::class)->getCity($city);
-            }
-            if (count($obj)>0){
-                $model->update($obj);
-                LogService::log(__CLASS__,"修改运输单",$model->toJson());
-            }
-        }
-        dd("OK");
-    }
-
-    public function zzd2(){
-        ini_set('max_execution_time',2500);
-        ini_set('memory_limit','1526M');
-        $models = DB::select(DB::raw("SELECT * FROM owner_fee_details where logistic_fee is not null and(weight is null or weight <= 0) and type = '发货'"));
-        foreach ($models as $model){
-            $packages = OrderPackage::query()->with("order")->where("order_id",$model->outer_id)->get();
-            $weight = 0;
-            $volume = 0;
-            foreach ($packages as $package){
-                $provinceName = mb_substr($package->order->province,0,2);
-                $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
-                    return Province::query()->where("name","like",$provinceName."%")->first();
-                },86400);
-                OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$model->id)
-                    ->where("logistic_bill",$package->logistic_number)->update([
-                        "volume" => $package->bulk,
-                        "weight" => $package->weight,
-                        "logistic_fee" => app("OwnerPriceExpressService")->matching($package->weight, $model->owner_id, $model->logistic_id, $province->id),
-                    ]);
-                $weight += $package->weight;
-                $volume += $package->bulk;
-            }
-            OwnerFeeDetail::query()->where("id",$model->id)->update([
-                "volume" => $volume,
-                "weight" => $weight,
-            ]);
-        }
+        $menus = [
+            "A管理"=>[
+                "A二级"=>[
+                    "A三级"
+                ]
+            ],
+            "B管理"=>[]
+        ];
+        $authorities = [
+            "A管理"=>[
+                "A二级"=>[
+                    "A三级"=>[
+                        "A四级"
+                    ]
+                ]
+            ]
+        ];
+        dd($authorities);
     }
 
     public function test1(){

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

@@ -206,11 +206,11 @@ class WaybillController extends Controller
             if ($waybillPriceModelRangeTwo)return $waybillPriceModelRangeTwo->id;
 
             //城市为空
-            $city=City::query()->where('id',$destination_city_id)->select('province_id')->first();
+            $city=Region::query()->where('id',$destination_city_id)->select('parent_id')->first();
             $waybillPriceModelProvinceOne=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
-                [$logistic_id,$city->province_id,$carrier_weight_unit_id[0],$carrier_weight[0],$carrier_weight[0]])->first();
+                [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[0],$carrier_weight[0],$carrier_weight[0]])->first();
             $waybillPriceModelProvinceTwo=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
-                [$logistic_id,$city->province_id,$carrier_weight_unit_id[1],$carrier_weight[1],$carrier_weight[1]])->first();
+                [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[1],$carrier_weight[1],$carrier_weight[1]])->first();
             if ($waybillPriceModelProvinceOne&&$waybillPriceModelProvinceTwo){
                 if ($waybillPriceModelProvinceOne->unit_price*$carrier_weight[0]>=$waybillPriceModelProvinceTwo->unit_price*$carrier_weight[1]){
                     return $waybillPriceModelProvinceOne->id;
@@ -223,9 +223,9 @@ class WaybillController extends Controller
 
             //城市价格区间都为空
             $waybillPriceModelProvinceRangeOne=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
-                [$logistic_id,$city->province_id,$carrier_weight_unit_id[0]])->first();
+                [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[0]])->first();
             $waybillPriceModelProvinceRangeTwo=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
-                [$logistic_id,$city->province_id,$carrier_weight_unit_id[1]])->first();
+                [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[1]])->first();
             if ($waybillPriceModelProvinceRangeOne&&$waybillPriceModelProvinceRangeTwo){
                 if ($waybillPriceModelProvinceRangeOne->unit_price*$carrier_weight[0]>=$waybillPriceModelProvinceRangeTwo->unit_price*$carrier_weight[1]){
                     return $waybillPriceModelProvinceRangeOne->id;
@@ -249,14 +249,14 @@ class WaybillController extends Controller
                 if ($waybillPriceModelRange){ return $waybillPriceModelRange->id;}
 
                 //城市为空
-                $city=City::where('id',$destination_city_id)->select('province_id')->first();
+                $city=Region::query()->where('id',$destination_city_id)->select('parent_id')->first();
                 $waybillPriceModelProvince=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max >= ? AND range_min < ? AND city_id IS NULL',
-                    [$logistic_id,$city->province_id,$carrier_weight_unit_id[$i],$carrier_weight[$i],$carrier_weight[$i]])->first();
+                    [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[$i],$carrier_weight[$i],$carrier_weight[$i]])->first();
                 if ($waybillPriceModelProvince){return $waybillPriceModelProvince->id;}
 
                 //城市价格区间都为空
                 $waybillPriceModelProvinceRange=WaybillPriceModel::query()->whereRaw('logistic_id = ? AND province_id = ? AND unit_id = ? AND range_max IS NULL AND city_id IS NULL',
-                    [$logistic_id,$city->province_id,$carrier_weight_unit_id[$i]])->first();
+                    [$logistic_id,$city->parent_id ?? 0,$carrier_weight_unit_id[$i]])->first();
                 if ($waybillPriceModelProvinceRange){return $waybillPriceModelProvinceRange->id;}
             }
         }

+ 1 - 1
resources/views/waybill/edit.blade.php

@@ -406,7 +406,7 @@
                     order_id:'{{$waybill->order_id}}',
                     owner_name:'{{$waybill->order->owner->name ?? $waybill->owner->name}}',
                     wms_bill_number:'{{$waybill->wms_bill_number}}',origination:'{{$waybill->origination}}',
-                    destination:'{{$waybill->order->address ?? $waybill->destination}}',
+                    destination:'{{$waybill->order->address ?? ($waybill->destinationCity->name ?? '').$waybill->destination}}',
                     recipient:'{{$waybill->order->consignee_name ?? $waybill->recipient}}',
                     recipient_mobile:'{{$waybill->order->consignee_phone ?? $waybill->recipient_mobile}}',ordering_remark:'{{$waybill->ordering_remark}}',
 

+ 1 - 1
resources/views/waybill/index.blade.php

@@ -296,7 +296,7 @@
                         owner:'{{$waybill->owner_name ?? ($waybill->owner->name ?? '')}}',
                         source_bill:'{{$waybill->source_bill}}',
                         wms_bill_number:'{{$waybill->wms_bill_number}}',
-                        is_cancel:'{{$waybill->order->wms_status ?? ''}}' === '订单取消' ? true : false,
+                        is_cancel:'{{$waybill->order->wms_status ?? ''}}' === '订单取消',
                         origination:'{{$waybill->origination}}',
                         destination:'{{$waybill->order_address ?? $waybill->destination}}',
                         recipient:'{{$waybill->order_consignee_name ?? $waybill->recipient}}',