Zhouzhendong 5 gadi atpakaļ
vecāks
revīzija
b5531f36ea

+ 25 - 1
app/Http/Controllers/TestController.php

@@ -141,7 +141,6 @@ class TestController extends Controller
         $models = WaybillPriceModel::query()->get();
         foreach ($models as $model){
             if ($model->city_name == '汕头/汕尾'){
-                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
                 $region1 = Region::query()->where("name","汕头")->first();
                 $region2 = Region::query()->where("name","汕尾")->first();
                 $model->update([
@@ -159,6 +158,7 @@ class TestController extends Controller
                     'base_fee'=> $model->base_fee,
                     'initial_weight'=> $model->initial_weight
                 ]);
+                LogService::log(__CLASS__,"修改运输计费",$model->toJson());
                 continue;
             }
             $obj = [];
@@ -169,8 +169,32 @@ class TestController extends Controller
                 $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");

+ 1 - 1
app/Services/WaybillService.php

@@ -21,7 +21,7 @@ class WaybillService
      * @return Builder
      */
     private function conditionQuery(array $param){
-        $waybills = Waybill::filterAuthorities()->with(['owner','logistic','originationCity','destinationCity.province',
+        $waybills = Waybill::filterAuthorities()->with(['owner','logistic','originationCity','destinationCity.parent',
             'uploadFile','amountUnit','warehouseWeightUnit','carrierWeightUnit','district',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','uploadFile','waybillAuditLogs.user'])
             ->selectRaw('waybills.* ,waybill_on_tops.id top_id ,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')

+ 6 - 4
app/Waybill.php

@@ -71,11 +71,13 @@ class Waybill extends Model
     public function logistic(){
         return $this->hasOne('App\Logistic','id','logistic_id');
     }
-    public function originationCity(){
-        return $this->hasOne('App\City','id','origination_city_id');
+    public function originationCity()
+    {   //始发市
+        return $this->hasOne(Region::class,'id','origination_city_id');
     }
-    public function destinationCity(){
-        return $this->hasOne('App\City','id','destination_city_id');
+    public function destinationCity()
+    {   //目的市
+        return $this->hasOne(Region::class,'id','destination_city_id');
     }
     public function wmsCommodities(){
         return $this->hasMany('App\WMSWaybillOrder','OrderNo','wms_bill_number');

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

@@ -324,7 +324,7 @@
                         waybillAuditLogs:{!! $waybill->waybillAuditLogs !!},
                         btn_refresh_weight:'zoomIn',
                         remark:'{{$waybill->remark ?? ''}}',
-                        province:'{{$waybill->order_province ?? ($waybill->destinationCity->province->name ?? '')}}',
+                        province:'{{$waybill->order_province ?? ($waybill->destinationCity->parent->name ?? '')}}',
                         city:'{{$waybill->order_city ?? ($waybill->destinationCity->name ?? '')}}',
                         district:'{{$waybill->order_district ?? ($waybill->district->name ?? '')}}',
                     },