Procházet zdrojové kódy

运输管理-同时编辑互不覆盖

Zhouzhendong před 5 roky
rodič
revize
bc24dcd4e1
1 změnil soubory, kde provedl 24 přidání a 2 odebrání
  1. 24 2
      app/Http/Controllers/WaybillsController.php

+ 24 - 2
app/Http/Controllers/WaybillsController.php

@@ -236,8 +236,8 @@ class WaybillsController extends Controller
         }
         sign:
         $total_receivable=0;
-        $waybill->fill($data);
-        if ($waybill->save()){
+        $waybill=$this->executeUpdate($waybill,$data);
+        if ($waybill){
             if ($waybill->type=="直发车"){
                 if ($waybill->charge)$total_receivable=($waybill->charge);
                 elseif ($waybill->collect_fee)$total_receivable=($waybill->collect_fee);
@@ -290,6 +290,28 @@ class WaybillsController extends Controller
         }
     }
 
+    private function executeUpdate(Waybill $waybill,array $data){
+        if ($waybill->type != $data['type']) $waybill->type=$data['type'];
+        if ($waybill->charge != $data['charge']) $waybill->charge=$data['charge'];
+        if ($waybill->carrier_id != $data['carrier_id']) $waybill->carrier_id=$data['carrier_id'];
+        if ($waybill->carrier_bill != $data['carrier_bill']) $waybill->carrier_bill=$data['carrier_bill'];
+        if ($waybill->warehouse_weight_other != $data['warehouse_weight_other']) $waybill->warehouse_weight_other=$data['warehouse_weight_other'];
+        if ($waybill->warehouse_weight_unit_id_other != $data['warehouse_weight_unit_id_other']) $waybill->warehouse_weight_unit_id_other=$data['warehouse_weight_unit_id_other'];
+        if ($waybill->amount != $data['amount']) $waybill->amount=$data['amount'];
+        if ($waybill->amount_unit_id != $data['amount_unit_id']) $waybill->amount_unit_id=$data['amount_unit_id'];
+        if ($waybill->mileage != $data['mileage']) $waybill->mileage=$data['mileage'];
+        if ($waybill->car_owner_info != $data['car_owner_info']) $waybill->car_owner_info=$data['car_owner_info'];
+        if ($waybill->fee != $data['fee']) $waybill->fee=$data['fee'];
+        if ($waybill->other_fee != $data['other_fee']) $waybill->other_fee=$data['other_fee'];
+        if ($waybill->other_charge != $data['other_charge']) $waybill->other_charge=$data['other_charge'];
+        if ($waybill->other_charge_remark != $data['other_charge_remark']) $waybill->other_charge_remark=$data['other_charge_remark'];
+        if ($waybill->dispatch_remark != $data['dispatch_remark']) $waybill->dispatch_remark=$data['dispatch_remark'];
+        if ($waybill->waybillPriceModel != $data['waybillPriceModel']) $waybill->waybillPriceModel=$data['waybillPriceModel'];
+        if ($waybill->destination != $data['destination']) $waybill->destination=$data['destination'];
+        $waybill->update();
+        return $waybill;
+    }
+
     public function checkWaybillPriceModel($carrier_id,$destination_city_id,$carrier_weight,$carrier_weight_unit_id){
         //确保承运商计数与计数单位为一个数组且长度2
         if(!$carrier_id)return false;