浏览代码

Merge branch 'master' into Haozi

# Conflicts:
#	app/User.php
haozi 5 年之前
父节点
当前提交
d5e1e2cfc1
共有 63 个文件被更改,包括 1150 次插入374 次删除
  1. 1 1
      app/Console/Commands/CreateOwnerBillReport.php
  2. 2 1
      app/Http/Controllers/CustomerBaseController.php
  3. 71 8
      app/Http/Controllers/CustomerController.php
  4. 12 0
      app/Http/Controllers/DeliveryAppointmentController.php
  5. 2 0
      app/Http/Controllers/ProcessController.php
  6. 5 0
      app/Http/Controllers/RegionController.php
  7. 1 1
      app/Http/Controllers/RejectedBillController.php
  8. 1 1
      app/Http/Controllers/StoreController.php
  9. 81 65
      app/Http/Controllers/TestController.php
  10. 68 49
      app/Http/Controllers/WaybillController.php
  11. 1 1
      app/Http/Controllers/api/thirdPart/flux/PackageController.php
  12. 1 1
      app/Http/Controllers/api/thirdPart/flux/ProcessController.php
  13. 1 1
      app/Http/Controllers/api/thirdPart/flux/ReceiveController.php
  14. 1 1
      app/Http/Controllers/api/thirdPart/flux/SortingController.php
  15. 1 1
      app/Http/Controllers/api/thirdPart/flux/StoreController.php
  16. 1 1
      app/Http/Controllers/api/thirdPart/flux/WaybillController.php
  17. 1 1
      app/Http/Controllers/api/thirdPart/goodscan/PackageController.php
  18. 3 3
      app/Http/Controllers/api/thirdPart/haochuang/SortingController.php
  19. 3 3
      app/Http/Controllers/api/thirdPart/weight/PackageController.php
  20. 1 1
      app/Http/Controllers/api/thirdPart/weixin/WxController.php
  21. 1 1
      app/Http/Controllers/api/thirdPart/weixin/WxLoginController.php
  22. 186 0
      app/Jobs/ResetInstantBill.php
  23. 1 1
      app/Listeners/InformWMSReceivedListener.php
  24. 1 1
      app/Listeners/ResetProcessStatisticStartDateListener.php
  25. 3 10
      app/Listeners/WaybillPriceModelListener.php
  26. 2 0
      app/OwnerFeeDetailLogistic.php
  27. 4 4
      app/Providers/RouteServiceProvider.php
  28. 2 0
      app/Services/FeatureService.php
  29. 33 18
      app/Services/OrderService.php
  30. 2 3
      app/Services/OwnerPriceExpressService.php
  31. 1 1
      app/Services/OwnerPriceOperationService.php
  32. 1 0
      app/Services/ProcessService.php
  33. 1 1
      app/Services/RegionService.php
  34. 1 0
      app/Services/StoreService.php
  35. 34 42
      app/Services/WaybillService.php
  36. 1 1
      app/User.php
  37. 1 3
      app/Waybill.php
  38. 35 35
      bootstrap/cache/packages.php
  39. 1 2
      composer.lock
  40. 63 0
      database/migrations/2021_02_26_093335_add_authority_data_money.php
  41. 38 0
      database/migrations/2021_02_26_152744_change_owner_fee_details_table_change_volume_column.php
  42. 45 0
      database/migrations/2021_03_02_133545_change_owner_bill_reports_table.php
  43. 15 15
      resources/js/queryForm/queryForm.js
  44. 37 0
      resources/sass/text.scss
  45. 1 0
      resources/views/customer/customer/index.blade.php
  46. 0 18
      resources/views/customer/finance/menu.blade.php
  47. 0 4
      resources/views/customer/menu.blade.php
  48. 1 0
      resources/views/customer/project/create.blade.php
  49. 9 5
      resources/views/customer/project/part/_operation.blade.php
  50. 28 0
      resources/views/finance/_resetBillConfirmation.blade.php
  51. 28 0
      resources/views/finance/_resetInstantBill.blade.php
  52. 30 10
      resources/views/finance/billConfirmation.blade.php
  53. 46 6
      resources/views/finance/instantBill.blade.php
  54. 15 0
      resources/views/finance/menu.blade.php
  55. 5 0
      resources/views/layouts/menu.blade.php
  56. 12 2
      resources/views/package/weigh/index.blade.php
  57. 123 0
      resources/views/store/checkingReceive/appointment.blade.php
  58. 5 1
      resources/views/store/checkingReceive/menu.blade.php
  59. 1 1
      resources/views/waybill/delivering.blade.php
  60. 52 34
      resources/views/waybill/edit.blade.php
  61. 6 2
      resources/views/waybill/index.blade.php
  62. 1 1
      resources/views/waybill/recycle.blade.php
  63. 20 12
      routes/web.php

+ 1 - 1
app/Console/Commands/CreateOwnerBillReport.php

@@ -46,7 +46,7 @@ class CreateOwnerBillReport extends Command
             $year--;
             $lastMonth = '12';
         }else $lastMonth = ($month-1) < 10 ? "0".($month-1) : ($month-1);
-        $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";
+        $sql = "SELECT owner_id,SUM(IFNULL(work_fee,0))+SUM(IFNULL(logistic_fee,0)) 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();

+ 2 - 1
app/Http/Controllers/CustomerBaseController.php

@@ -30,7 +30,8 @@ class CustomerBaseController extends Controller
         }]);
         $owners = app("OwnerService")->getIntersectPermitting(['id','name','customer_id']);
         $tags = CustomerTag::query()->orderByDesc('count')->get(["id","name"]);
-        return response()->view('customer.customer.index',compact("customers","owners","tags"));
+        $params = $request->input();
+        return response()->view('customer.customer.index',compact("customers","owners","tags","params"));
     }
 
     /**

+ 71 - 8
app/Http/Controllers/CustomerController.php

@@ -3,8 +3,11 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\Jobs\ResetInstantBill;
 use App\Owner;
 use App\OwnerAreaReport;
+use App\OwnerBillReport;
+use App\OwnerFeeDetail;
 use App\OwnerReport;
 use App\Services\LogService;
 use App\Services\OwnerAreaReportService;
@@ -295,18 +298,18 @@ class CustomerController extends Controller
 
     public function financeInstantBill(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-即时账单')){ return redirect('denied');  }
+        if(!Gate::allows('结算管理-即时账单')){ return redirect('denied');  }
         $params = $request->input();
         $shops = app('ShopService')->getSelection();
         $customers = app('CustomerService')->getSelection();
         $owners = app('OwnerService')->getIntersectPermitting();
         $details = app('OwnerFeeDetailService')->paginate($params,["owner.customer","shop","processMethod","logistic","items"]);
-        return response()->view('customer.finance.instantBill',compact("details","params","shops","customers","owners"));
+        return response()->view('finance.instantBill',compact("details","params","shops","customers","owners"));
     }
 
     public function financeInstantBillExport(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-即时账单')){ return redirect('denied');  }
+        if(!Gate::allows('结算管理-即时账单')){ return redirect('denied');  }
         $params = $request->input();
         if ($request->checkAllSign)unset($params['checkAllSign']);
         else $params = ["id"=>$request->data];
@@ -331,7 +334,7 @@ class CustomerController extends Controller
 
     public function financeBillConfirmation(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-账单确认')){ return redirect('denied');  }
+        if(!Gate::allows('结算管理-账单确认')){ return redirect('denied');  }
         $params = $request->input();
         $ownerGroups = app('UserOwnerGroupService')->getSelection();
         $customers = app('CustomerService')->getSelection();
@@ -340,12 +343,12 @@ class CustomerController extends Controller
             /** @var Builder $query */
             $query->with(["customer","userOwnerGroup"]);
         }]);
-        return response()->view('customer.finance.billConfirmation',compact("params","owners","ownerGroups","customers","bills"));
+        return response()->view('finance.billConfirmation',compact("params","owners","ownerGroups","customers","bills"));
     }
 
     public function financeBillConfirmationExport(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-账单确认')){ return redirect('denied');  }
+        if(!Gate::allows('结算管理-账单确认')){ return redirect('denied');  }
         $params = $request->input();
         if ($request->checkAllSign)unset($params['checkAllSign']);
         else $params = ["id"=>$request->data];
@@ -384,7 +387,7 @@ class CustomerController extends Controller
 
     public function updateBillReport(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-账单确认-编辑')){ return ["success"=>false,'data'=>"无权操作!"];  }
+        if(!Gate::allows('结算管理-账单确认-编辑')){ return ["success"=>false,'data'=>"无权操作!"];  }
         if (!$request->confirm_fee || !is_numeric($request->confirm_fee) || $request->confirm_fee<0)return ["success"=>false,"data"=>"非法金额参数"];
         $date = date('Y-m-d H:i:s');
         app('OwnerBillReportService')->update(["id"=>$request->id],["confirm_fee"=>$request->confirm_fee,"difference"=>DB::raw($request->confirm_fee.'- initial_fee'),"updated_at"=>$date]);
@@ -394,7 +397,7 @@ class CustomerController extends Controller
 
     public function billConfirm(Request $request)
     {
-        if(!Gate::allows('客户管理-财务-账单确认-完结')){ return ["success"=>false,'data'=>"无权操作!"];  }
+        if(!Gate::allows('结算管理-账单确认-完结')){ return ["success"=>false,'data'=>"无权操作!"];  }
         if (!($request->id ?? false))return["success"=>false,"data"=>"非法参数"];
         app('OwnerBillReportService')->update(["id"=>$request->id],["confirmed"=>"是"]);
         LogService::log(__METHOD__,"客户管理-确认账单",json_encode($request->input()));
@@ -513,4 +516,64 @@ class CustomerController extends Controller
         }
         $this->success($result);
     }
+
+    public function resetInstantBill()
+    {
+        $startData = request("startDate");
+        $endDate = request("endDate");
+        $owner = request("owner");
+        if (!$startData)$this->error("非法参数");
+        $details = OwnerFeeDetail::query()->where("worked_at",">=",$startData." 00:00:00");
+        if ($endDate)$details->where("worked_at","<=",$endDate." 23:59:59");
+        if (count($owner)>0)$details->whereIn("owner_id",$owner);
+        $details->get()->each(function ($detail){
+            $this->dispatch(new ResetInstantBill($detail));
+        });
+        $this->success();
+    }
+
+    public function resetBillConfirmation()
+    {
+        $month = request("month");
+        $owner = request("owner");
+        $sql = <<<sql
+SELECT owner_id,SUM(IFNULL(work_fee,0))+SUM(IFNULL(logistic_fee,0)) AS total 
+FROM owner_fee_details WHERE worked_at LIKE ? 
+sql;
+        if ($owner && count($owner)>0){
+            $sql.=" AND owner_id IN (''";
+            foreach ($owner as $o)$sql .=",'{$o}'";
+            $sql.=")";
+        }
+        $sql .= " 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),[$month."%"]);
+
+        $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel")->where("counting_month","like",$month."%")->get();
+        $map = [];
+        foreach($areas as $area){
+            if (isset($map[$area->owner_id."_".$area->counting_month])){
+                if (!$area->ownerStoragePriceModel)continue;
+                $map[$area->owner_id."_".$area->counting_month] += app('OwnerStoragePriceModelService')
+                    ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
+            }else{
+                if (!$area->ownerStoragePriceModel)continue;
+                $map[$area->owner_id."_".$area->counting_month] = app('OwnerStoragePriceModelService')
+                    ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
+            }
+        }
+
+        $chunks = array_chunk($billDetails,50);
+        foreach ($chunks as $bills){
+            foreach ($bills as $bill){
+                $key = $bill->owner_id."_".$month;
+                $total = $bill->total;
+                if (isset($map[$key]))$total += $map[$key];
+                OwnerBillReport::query()->where("owner_id",$bill->owner_id)
+                    ->where("counting_month",$month."-01")
+                    ->update(["initial_fee"=>$total]);
+            }
+        }
+        $this->success();
+    }
 }

+ 12 - 0
app/Http/Controllers/DeliveryAppointmentController.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Http\Controllers;
+
+class DeliveryAppointmentController extends Controller
+{
+    public function appointment()
+    {
+        $owners = app("OwnerService")->getIntersectPermitting();
+        return view("store.checkingReceive.appointment",compact("owners"));
+    }
+}

+ 2 - 0
app/Http/Controllers/ProcessController.php

@@ -14,6 +14,7 @@ use App\ProcessesContent;
 use App\ProcessMethod;
 use App\ProcessStatistic;
 use App\Services\OwnerService;
+use App\Services\ProcessService;
 use App\Sign;
 use App\Tutorial;
 use App\UserDetail;
@@ -204,6 +205,7 @@ class ProcessController extends Controller
         $process->createOperatorLog('交接完成');
         $processStatistic=$result['data'];
         app('LogService')->log(__METHOD__,"完成二次加工单_".__FUNCTION__,json_encode($process)." || ".json_encode($processStatistic),Auth::user()['id']);
+        app('ProcessService')->createInstantBill($process);
         return ['success'=>true,'data'=>'交接完成'];
     }
     private function statistic($process, $sign_end = false){

+ 5 - 0
app/Http/Controllers/RegionController.php

@@ -41,4 +41,9 @@ class RegionController extends Controller
             "parent_id" => $parent
         ]));
     }
+
+    public function getProvinces()
+    {
+        $this->success(app("RegionService")->getSelection(1));
+    }
 }

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

@@ -3,7 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Events\InformWMSReceivedEvent;
-use App\Http\Controllers\Api\thirdPart\flux\ReceiveController;
+use App\Http\Controllers\api\thirdPart\flux\ReceiveController;
 use App\Logistic;
 use App\OracleActAllocationDetails;
 use App\OracleBasSKU;

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

@@ -22,7 +22,7 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\View\View;
-use App\Http\Controllers\Api\thirdPart\flux\StoreController as FStoreController;
+use App\Http\Controllers\api\thirdPart\flux\StoreController as FStoreController;
 
 class StoreController extends Controller
 {

+ 81 - 65
app/Http/Controllers/TestController.php

@@ -24,6 +24,7 @@ use App\Http\Requests\ForeignHaiRobotic_taskUpdateRequest;
 use App\Http\Requests\TestAaRequest;
 use App\Imports\OrderTrackingImport;
 use App\InventoryAccount;
+use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
 use App\LaborReport;
 use App\Log;
@@ -49,6 +50,8 @@ use App\OrderPackageCommodities;
 use App\OrderPackageCountingRecord;
 use App\OrderTracking;
 use App\Owner;
+use App\OwnerFeeDetail;
+use App\OwnerFeeDetailLogistic;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
 use App\Package;
@@ -137,82 +140,95 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
-    public function zzd(){
+
+    public function bindOrder()
+    {
         ini_set('max_execution_time',2500);
         ini_set('memory_limit','1526M');
-        $models = WaybillPriceModel::query()->get();
+        $models = Waybill::query()->whereNotNull("wms_bill_number")->whereNotIn("status",['已完结','无模型'])->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());
-            }
+            $order = Order::query()->where("code",$model->wms_bill_number)->first();
+            if ($order)$model->update(["order_id"=>$order->id]);
         }
-        dd("OK");
     }
-
-    public function zzd1()
+    public function delRegion()
+    {
+        dd(Region::query()->where("id",">=",404)->where("id","<=",432)->delete());
+    }
+    public function restoreBill()
     {
         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());
+        OwnerFeeDetail::query()->where("logistic_fee",">",0)
+            ->whereNotNull("logistic_fee")
+            ->where("type","发货")->get()->each(function ($detail){
+                if (!$this->exe($detail)){
+                    dump($detail->id);
+                };
+            });
+    }
+    public function exe(OwnerFeeDetail $feeBill){
+        $order = Order::query()->where("id",$feeBill->outer_id)->first();
+        $order->loadMissing("packages","owner");//加载包裹
+        if (!$order->packages || !$order->owner)return false;
+        $order->owner->loadCount("ownerPriceExpresses");
+        if ($order->owner->owner_price_expresses_count < 1)return false; //不存在计费模型 跳出
+        foreach ($order->packages as $package)if (!$package->weight)return false; //包裹存在且全部存在数量
+
+        $logistic_fee = 0;
+        $volume = 0;
+        $weight = 0;
+        if (!$order->logistic || $order->logistic->type != "快递")$logistic_fee = null;
+        foreach ($order->packages as $package){
+            $volume += $package->bulk;
+            $weight += $package->weight;
+
+            $provinceName = mb_substr($order->province,0,2);
+            $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                return Province::query()->where("name","like",$provinceName."%")->first();
+            },86400);
+            if (!$province)$logistic_fee = null;
+
+            $fee = app("OwnerPriceExpressService")->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+            OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$feeBill->id)->where("logistic_bill",$package->logistic_number)->update([
+                "volume"=>$package->bulk,
+                "weight"=>$package->weight,
+                "logistic_fee" => $fee>0 ? $fee : null,
+            ]);
+            if ($logistic_fee!==null){
+                if ($fee<0)$logistic_fee = null;
+                else $logistic_fee += $fee;
             }
         }
-        dd("OK");
+        if ($logistic_fee===null || $logistic_fee<0)
+            LogService::log(__METHOD__,"ERROR-校正即时账单计算物流费错误","订单ID:".$order->id."  费用结果:".$logistic_fee);
+        else $feeBill->update(["logistic_fee"=>$logistic_fee,"volume"=>$volume,"weight"=>$weight]);
+        return true;
     }
-
-    public function test1(){
-        $cityIds = [2];
-        $parovince = "北京";
-        $waybills = Waybill::query()->where(function ($query)use($cityIds,$parovince){
-            /** @var Builder $query */
-            $query->whereIn('destination_city_id',$cityIds)->orWhereHas("order",function ($query)use($province){
-                /** @var Builder $query */
-                $query->where("province","like",$province."%");
-            });
-        })->get();
-        dd($waybills);
+    public function tt1(){
+        $order = Order::query()->find(2301382);
+        app("OrderService")->createInstantBill($order);
+    }
+    public function zzd(){
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
+        $menus = [
+            "A管理"=>[
+                "A二级"=>[
+                    "A三级"
+                ]
+            ],
+            "B管理"=>[]
+        ];
+        /*$authorities = [
+            "A管理"=>[
+                "A二级"=>[9
+                    "A三级"=>[
+                        "A四级"
+                    ]
+                ]
+            ]
+        ];*/
     }
 
     public function syncWeight()

+ 68 - 49
app/Http/Controllers/WaybillController.php

@@ -4,7 +4,9 @@ namespace App\Http\Controllers;
 
 
 use App\Components\AsyncResponse;
+use App\Region;
 use App\Services\CarTypeService;
+use App\Services\common\ExportService;
 use App\Services\LogisticService;
 use App\Services\OwnerService;
 use App\Services\UnitService;
@@ -15,7 +17,6 @@ use App\UploadFile;
 use App\WaybillAuditLog;
 use App\WaybillOnTop;
 use App\WaybillPriceModel;
-use App\City;
 use App\Unit;
 use App\Waybill;
 use App\WaybillPayoff;
@@ -137,7 +138,7 @@ class WaybillController extends Controller
             if ($waybillPriceModel_id){
                 $carrier_weight=$request->input('carrier_weight');
                 $waybillPriceModel=$waybillPriceModelService->find($waybillPriceModel_id);
-                $logistic=$logisticService->find($waybill->order->logistic_id ?? $waybill->logistic_id);
+                $logistic=$logisticService->find($waybill->logistic_id);
                 if ($carrier_weight<$waybillPriceModel->initial_weight){
                     $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$logistic->delivery_fee;
                 }else{
@@ -205,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;
@@ -222,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;
@@ -248,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;}
             }
         }
@@ -425,6 +426,7 @@ class WaybillController extends Controller
                     ]);
                 }
             }
+            app("waybillService")->createInstantBill($waybill);
             app('LogService')->log(__METHOD__,__FUNCTION__,$waybillPayoffJson,Auth::id());
             return ['success'=>$result,'status'=>$waybill->status,'waybillAuditLog'=>$waybillAuditLog];
         }
@@ -434,7 +436,7 @@ class WaybillController extends Controller
     //生成报表数据
     private function createReportData($waybill,$waybillPayoff){
         /** @var Waybill $waybill */
-        $waybill->loadMissing(["order.owner",'order.logistic']);
+        $waybill->loadMissing(["order.owner"]);
         return [
             "type"=>$waybill->type,
             "waybill_number"=>$waybill->waybill_number,
@@ -448,7 +450,7 @@ class WaybillController extends Controller
             "charge"=>$waybill->charge,
             "collect_fee"=>$waybill->collect_fee,
             "ordering_remark"=>$waybill->ordering_remark,
-            "carrier_name"=>$waybill->order->logistic->name ?? ($waybill->logistic->name ?? null),
+            "carrier_name"=>$waybill->logistic->name ?? null,
             "carrier_bill"=>$waybill->carrier_bill,
             "origination_city_name"=>$waybill->originationCity ? $waybill->originationCity->name : null,
             "destination_city_name"=>$waybill->order->city ?? ($waybill->destinationCity->name ?? null),
@@ -611,22 +613,53 @@ class WaybillController extends Controller
         return ['success'=>true];
     }
 
-    public function export(Request $request){
-        if(!Gate::allows('运输管理-查询')){ return '没有权限';  }
-        if ($request->checkAllSign){
-            $param = $request->input();
-            unset($param['checkAllSign']);
-            $sql = app('waybillService')->getSql($param);
-
-        }else $sql = app('waybillService')->getSql(['id'=>$request->data]);
-        $post = Http::post(config('go.export.url'),['type'=>'waybill','sql'=>$sql]);
-        if ($post->status() == 500){
-            throw new Exception($post->header("Msg"));
-        }
-        return response($post,200, [
-            "Content-type"=>"application/octet-stream",
-            "Content-Disposition"=>"attachment; filename=运单列表-".date('ymdHis').'.xlsx',
-        ]);
+    public function export(){
+        $this->gate('运输管理-查询');
+        if (request("checkAllSign")){
+            request()->offsetUnset("checkAllSign");
+            $waybills = app('waybillService')->get(request()->input());
+        }else $waybills = app('waybillService')->get(["id"=>request("id")]);
+        /** @var Collection $waybills */
+        $row = [
+            "运单类型", "货主", "上游单号", "wms订单号", "运单号", "运输收费",
+            "其他收费", "其他收费备注", "始发地", "目的地", "承运商", "承运商单号",
+            "仓库计抛", "承运商计抛", "仓库计重", "承运商计重", "车型", "车辆信息",
+            "计件", "里程数", "运费(元)", "提货费(元)", "其他费用(元)", "发货时间",
+            "调度备注", "创建时间"
+        ];
+        $list = [];
+        $waybills->each(function ($waybill)use(&$list){
+            $list[] = [
+                $waybill->type,
+                $waybill->order->owner->name ?? ($waybill->owner->name ?? ""),
+                $waybill->source_bill,
+                $waybill->wms_bill_number,
+                $waybill->waybill_number,
+                $waybill->waybill_number,
+                $waybill->charge,
+                $waybill->other_charge,
+                $waybill->other_charge_remark,
+                $waybill->origination,
+                $waybill->order->address ?? $waybill->destination,
+                $waybill->logistic->name ?? "",
+                $waybill->carrier_bill,
+                $waybill->warehouse_weight,
+                $waybill->carrier_weight,
+                $waybill->warehouse_weight_other,
+                $waybill->carrier_weight_other,
+                $waybill->car_type_name,
+                $waybill->car_owner_info,
+                $waybill->amount,
+                $waybill->mileage,
+                $waybill->fee,
+                $waybill->pick_up_fee,
+                $waybill->other_fee,
+                $waybill->deliver_at,
+                $waybill->dispatch_remark,
+                $waybill->created_at,
+            ];
+        });
+        return app(ExportService::class)->json($row,$list,"运输记录单");
     }
 
     public function deliveringExport(Request $request){
@@ -778,26 +811,12 @@ class WaybillController extends Controller
         ]);
         return $validator;
     }
-    public function addCounty(Request $request){
-        if ($request->destination_city =='undefined')$request->offsetUnset('destination_city');
-        $rule =[
-            'destination_city' => ['required', 'string','unique:cities,name'],
-        ];
-        $messages=[
-            'destination_city.required'=>'市/县不能为空',
-            'destination_city.string'=>'市/县必须是字符串',
-            'destination_city.unique'=>'市/县已存在',
-        ];
-        $validator = Validator::make($request->all(),$rule,$messages);
-        if ($validator->fails()) {
-            return $validator->errors();
-        }
-        $city=new City([
-            'name'=>$request->input('destination_city'),
-            'type'=>3,
-        ]);
-        $city->save();
-        return $city;
+    public function addCounty(){
+        $name = app("RegionService")->formatName(request("name"),2);
+        if (!$name)$this->error("非法参数");
+
+        $region = Region::query()->firstOrCreate(["name"=>$name,"type"=>2,"parent_id"=>request("province")]);
+        $this->success($region);
     }
 
     // 运单删除 软删除
@@ -813,7 +832,7 @@ class WaybillController extends Controller
         if(!Gate::allows('运输管理-删除')){return redirect('/');}
         $paginate = $request->input('paginate')??50;
         /** @var Collection $waybills */
-        $waybills = Waybill::query()->with(['owner','order.owner','order.logistic','logistic','amountUnit','warehouseWeightUnit','carrierWeightUnit',
+        $waybills = Waybill::query()->with(['owner','order.owner','logistic','amountUnit','warehouseWeightUnit','carrierWeightUnit',
             'warehouseWeightUnitOther','carrierWeightUnitOther','carType','waybillAuditLogs' => function ($query) {
             /** @var Builder $query */
             $query->with('user');

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/PackageController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 use App\Http\Controllers\Controller;
 use App\OracleDocOrderPackingSummary;

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/ProcessController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 
 use App\Commodity;

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/ReceiveController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 use App\Events\WmsReceiveNewEvent;
 use App\Http\Controllers\Controller;

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

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 use App\Batch;
 use App\Http\Controllers\Controller;

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/StoreController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 use App\Http\Controllers\Controller;
 use App\Store;

+ 1 - 1
app/Http/Controllers/api/thirdPart/flux/WaybillController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\flux;
+namespace App\Http\Controllers\api\thirdPart\flux;
 
 use App\City;
 use App\Http\Controllers\Controller;

+ 1 - 1
app/Http/Controllers/api/thirdPart/goodscan/PackageController.php

@@ -136,7 +136,7 @@ class PackageController
      */
     public function activityWaveNoProcessing(&$orderPackage) //处理活动波次
     {
-        $fluxController = new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
+        $fluxController = new \App\Http\Controllers\api\thirdPart\flux\PackageController();
         if($orderPackage->isActivityBatch()){
             app('LogService')->log(__METHOD__,__FUNCTION__,"依波次号同步所有包裹:".json_encode($orderPackage),null);
             $params = [

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

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\haochuang;
+namespace App\Http\Controllers\api\thirdPart\haochuang;
 
 use App\Batch;
 use App\CommodityBarcode;
@@ -117,7 +117,7 @@ class SortingController extends Controller
             $data['orders'][]=$orderData;
         });
 
-        $sendToWms=(new \App\Http\Controllers\Api\thirdPart\flux\SortingController())->informBinAssignment($batch);
+        $sendToWms=(new \App\Http\Controllers\api\thirdPart\flux\SortingController())->informBinAssignment($batch);
         if(!$sendToWms){
             app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, '播种位发送给WMS错误:'.json_encode($request->all()));
             return response()->json(['result'=>'failure','fail_info'=>'播种位发送给WMS错误,请联系管理员检查错误'])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
@@ -163,7 +163,7 @@ class SortingController extends Controller
             app('LogService')->log(__METHOD__,'alert_'.__FUNCTION__,$batch['code'].'重复发送,波次已处理');
             return ['result'=>'failure','fail_info'=>$batch['code'].'重复发送,波次已处理'];
         }
-        $sendToWms=(new \App\Http\Controllers\Api\thirdPart\flux\SortingController())->informBatchFinished($batch);
+        $sendToWms=(new \App\Http\Controllers\api\thirdPart\flux\SortingController())->informBatchFinished($batch);
         if(!$sendToWms){
             app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, '发送给WMS错误:'.json_encode($request->all()));
             return response()->json(['result'=>'failure','fail_info'=>'发送给WMS错误,请联系管理员检查错误'])->setEncodingOptions(JSON_UNESCAPED_UNICODE);

+ 3 - 3
app/Http/Controllers/api/thirdPart/weight/PackageController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\weight;
+namespace App\Http\Controllers\api\thirdPart\weight;
 
 use App\Events\WeighedEvent;
 use App\Http\Controllers\Controller;
@@ -67,7 +67,7 @@ class PackageController extends Controller
 //        }else{
 //            $max=0;$centre=0;$min=0;
 //        }
-//        $apiController=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
+//        $apiController=new \App\Http\Controllers\api\thirdPart\flux\PackageController();
 //        if ($package){
 //            $packageController=new \App\Http\Controllers\PackageController();
 //            $package->fetchPaperBox($max,$centre,$min,$package->owner_id);
@@ -188,7 +188,7 @@ class PackageController extends Controller
 
         $edges=[$request['length']??0,$request['width']??0,$request['height']??0];
         rsort($edges);
-        $fluxController=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
+        $fluxController=new \App\Http\Controllers\api\thirdPart\flux\PackageController();
         if ($package){
             $package['measuring_machine_id']=$measuringMachine->id;
             $package['weight']=$request['weight'];

+ 1 - 1
app/Http/Controllers/api/thirdPart/weixin/WxController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\weixin;
+namespace App\Http\Controllers\api\thirdPart\weixin;
 /**
  * 接口路径(微信线上)的需要修改,因为route文件和路径都改成了新的标准
  */

+ 1 - 1
app/Http/Controllers/api/thirdPart/weixin/WxLoginController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Http\Controllers\Api\thirdPart\weixin;
+namespace App\Http\Controllers\api\thirdPart\weixin;
 
 use App\User;
 use Illuminate\Http\Request;

+ 186 - 0
app/Jobs/ResetInstantBill.php

@@ -0,0 +1,186 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Order;
+use App\OwnerFeeDetail;
+use App\OwnerFeeDetailLogistic;
+use App\Process;
+use App\Province;
+use App\Services\CacheService;
+use App\Services\OwnerPriceDirectLogisticService;
+use App\Services\OwnerPriceExpressService;
+use App\Services\OwnerPriceLogisticService;
+use App\Services\OwnerPriceOperationService;
+use App\Store;
+use App\Waybill;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\Cache;
+
+class ResetInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    /** @var \stdClass $detail  */
+    private $detail;
+    /**
+     * Create a new job instance.
+     *
+     * @param OwnerFeeDetail $detail
+     *
+     * @return void
+     */
+    public function __construct(OwnerFeeDetail $detail)
+    {
+        $this->detail = $detail;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        switch ($this->detail->outer_table_name){
+            case "orders":
+                /** @var \stdClass $order */
+                $order = Order::query()->find($this->detail->outer_id);
+                $key = date("Y-m")."_".$order->owner_id;
+                if (Cache::has($key))Cache::increment($key);
+                else Cache::put($key,1,2678400);
+
+                $order->loadMissing(["logistic","shop","packages.commodities.commodity","batch"]);
+
+                /** @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;
+
+                $items = [];
+                foreach ($order->packages as &$package){
+                    $logistic_bill .= $package->logistic_number.",";
+                    $volume += $package->bulk;
+                    $weight += $package->weight;
+
+                    // 四维转二维
+                    $partAmount = 0;
+                    foreach($package->commodities as &$commodity){
+                        $commodity["commodity_name"] = $commodity->commodity ? $commodity->commodity->name : '';
+                        $commodity["sku"] = $commodity->commodity ? $commodity->commodity->sku : '';
+                        $partAmount += $commodity->amount;
+                    }
+                    $amount += $partAmount;
+                    $commodities = array_merge($commodities,$package->commodities->toArray());
+
+                    $provinceName = mb_substr($order->province,0,2);
+                    $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                        return Province::query()->where("name","like",$provinceName."%")->first();
+                    },86400);
+                    if ($province){
+                        $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+                    }else{
+                        $logistic_fee = null;
+                        $fee = null;
+                    }
+
+                    $items[] = [
+                        "amount" => $partAmount,
+                        "logistic_bill" => $package->logistic_number,
+                        "volume"=>$package->bulk,
+                        "weight"=>$package->weight,
+                        "logistic_fee" => $fee>0 ? $fee : null,
+                    ];
+                    if ($logistic_fee!==null){
+                        if ($fee<0)$logistic_fee = null;
+                        else $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,
+                    "batch_type" => $order->batch ? $order->batch->wms_type : '',
+                    "owner_id"=>$order->owner_id];
+                $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name",
+                    "承运商"=>"logistic_name","店铺类型"=>"shop_name","订单类型"=>"order_type",
+                    "波次类型"=>"batch_type"];
+
+                /** @var OwnerPriceOperationService $service */
+                $service = app("OwnerPriceOperationService");
+                $result = $service->matching($object,$mapping,$order->owner_id,"出库");
+
+
+                $detail = $this->detail->update([
+                    "work_fee"          => is_array($result) ? ($result["money"]>0 ? $result["money"] : null) : null,
+                    "logistic_fee"      => $logistic_fee,
+                ]);
+                if ($detail){
+                    foreach ($items as $item){
+                        OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$detail->id)
+                            ->where("logistic_bill",$item["logistic_bill"])
+                            ->update($item);
+                    }
+                }
+                break;
+            case "processes":
+                /** @var \stdClass $process */
+                $process = Process::query()->with("processStatistic")->find($this->detail->outer_id);
+                $this->detail->update([
+                    "work_fee"  => $process->processStatistic ? $process->processStatistic->revenue : null,
+                ]);
+                break;
+            case "waybills":
+                /** @var \stdClass $waybill */
+                $waybill = Waybill::query()->find($this->detail->outer_id);
+                $waybill->loadMissing(["destinationCity","order.owner"]);
+                if (!$waybill->destinationCity && !$waybill->order)break;
+
+                $owner_id = $waybill->order->owner_id ?? $waybill->owner_id;
+
+                if ($waybill->type == "专线"){
+                    /** @var OwnerPriceLogisticService $service */
+                    $service = app("OwnerPriceLogisticService");
+                    $fee = $service->matching($waybill->carrier_weight_other,$owner_id,$waybill->logistic_id,
+                        $waybill->carrier_weight_unit_id_other,$waybill->order ? app("RegionService")->getProvince($waybill->order->province) : $waybill->destinationCity->province_id,
+                        $waybill->destination_city_id);
+                }else{
+                    /** @var OwnerPriceDirectLogisticService $service */
+                    $service = app("OwnerPriceDirectLogisticService");
+                    $fee = $service->matching($waybill->mileage,$owner_id,$waybill->carType_id);
+                }
+                $this->detail->update([
+                    "logistic_fee" => $fee ?? null,
+                ]);
+                break;
+            case "stores":
+                /** @var \stdClass $store */
+                $store = Store::query()->find($this->detail->outer_id);
+                $store->loadMissing("storeItems");
+
+                /** @var OwnerPriceOperationService $service */
+                $service = app("OwnerPriceOperationService");
+
+                $mapping = ["packages" => "storeItems", "商品名称" => "name", "订单类型" => "stored_method", "订单数"=>"amount"];
+
+                $result = $service->matching($store, $mapping, $store->owner_id, "入库");
+
+                $this->detail->update([
+                    "work_fee" => is_array($result) ? ($result["money"]>0 ? $result["money"] : null) : null,
+                ]);
+                break;
+        }
+    }
+}

+ 1 - 1
app/Listeners/InformWMSReceivedListener.php

@@ -3,7 +3,7 @@
 namespace App\Listeners;
 
 use App\Events\InformWMSReceivedEvent;
-use App\Http\Controllers\Api\thirdPart\flux\ReceiveController;
+use App\Http\Controllers\api\thirdPart\flux\ReceiveController;
 use App\Http\Controllers\Controller;
 use App\RejectedBill;
 use App\RejectedBillItem;

+ 1 - 1
app/Listeners/ResetProcessStatisticStartDateListener.php

@@ -53,7 +53,7 @@ class ResetProcessStatisticStartDateListener
 
     private function comparisonReplace($statistic, $date)
     {
-        if ($statistic->started_at != $date){
+        if ($statistic && $statistic->started_at != $date){
             ProcessStatistic::query()->where("process_id",$statistic->process_id)->update(["started_at"=>$date]);
         }
     }

+ 3 - 10
app/Listeners/WaybillPriceModelListener.php

@@ -2,7 +2,6 @@
 
 namespace App\Listeners;
 
-use App\Logistic;
 use App\Events\WaybillPriceModelEvent;
 use App\Region;
 use App\Waybill;
@@ -16,19 +15,13 @@ class WaybillPriceModelListener
 {
     public function waybillPriceModel_check_waybill(WaybillPriceModel $waybillPriceModel){
 
-        $waybills=Waybill::query()->with(["logistic","order.logistic"])->where('type','专线')
+        $waybills=Waybill::query()->with(["logistic"])->where('type','专线')
             ->where('status','!=','已完结');
 
         //条件携带承运商
         /** @var \stdClass $waybillPriceModel */
         $logisticId = $waybillPriceModel->logistic_id;
-        $waybills->where(function ($query)use($logisticId){
-            /** @var Builder $query */
-            $query->where('logistic_id',$logisticId)->orWhereHas("order",function ($query)use($logisticId){
-                /** @var Builder $query */
-                $query->where("logistic_id",$logisticId);
-            });
-        });
+        $waybills->where('logistic_id',$logisticId);
         //市不存在
         if(!$waybillPriceModel->city_id){
             $cities=Region::query()->select('id')->where('parent_id',$waybillPriceModel['province_id'])->get();
@@ -98,7 +91,7 @@ class WaybillPriceModelListener
             foreach ($waybills as $waybill){
                 //修改运单表运费
                 /** @var \stdClass $carrier */
-                $carrier=$waybill->order->logistic ?? $waybill->logistic;
+                $carrier=$waybill->logistic;
                 if ($waybill->carrier_weight<$waybillPriceModel->initial_weight){
                     $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee;
                 }else{

+ 2 - 0
app/OwnerFeeDetailLogistic.php

@@ -14,6 +14,8 @@ class OwnerFeeDetailLogistic extends Model
       "owner_fee_detail_id","amount","logistic_bill","volume","weight","logistic_fee"
     ];
 
+    public $timestamps = false;
+
     public function logistic()
     {   //快递
         return $this->belongsTo(Logistic::class);

+ 4 - 4
app/Providers/RouteServiceProvider.php

@@ -78,14 +78,14 @@ class RouteServiceProvider extends ServiceProvider
 
         Route::prefix('api/thirdPart/flux')
             ->middleware('api')
-            ->namespace('App\Http\Controllers\Api\thirdPart\flux')
+            ->namespace('App\Http\Controllers\api\thirdPart\flux')
             ->group(base_path('routes/api/thirdPart/flux.php'));
         Route::prefix('api/thirdPart/weight')
             ->middleware('api')
-            ->namespace('App\Http\Controllers\Api\thirdPart\weight')
+            ->namespace('App\Http\Controllers\api\thirdPart\weight')
             ->group(base_path('routes/api/thirdPart/weight.php'));
         Route::prefix('api/thirdPart/weixin')
-            ->namespace('App\Http\Controllers\Api\thirdPart\weixin')
+            ->namespace('App\Http\Controllers\api\thirdPart\weixin')
             ->group(base_path('routes/api/thirdPart/weixin.php'));
         Route::prefix('api/thirdPart/haiq')
             ->namespace('App\Http\Controllers\api\thirdPart\haiq')
@@ -95,7 +95,7 @@ class RouteServiceProvider extends ServiceProvider
             ->group(base_path('routes/api/thirdPart/goodscan.php'));
         Route::prefix('api/thirdPart/haochuang')
             ->middleware('api')
-            ->namespace('App\Http\Controllers\Api\thirdPart\haochuang')
+            ->namespace('App\Http\Controllers\api\thirdPart\haochuang')
             ->group(base_path('routes/api/thirdPart/haochuang.php'));
     }
 }

+ 2 - 0
app/Services/FeatureService.php

@@ -212,6 +212,8 @@ class FeatureService
      */
     public function matchFeature($value, $columnMapping, $matchObject, $isMultiMatching = false) :bool
     {
+        if (!$value)return true;
+
         preg_match_all('/\d+|[\&\|\(\)]/',$value,$result);
         if (implode("",$result[0]) != $value)return false;
 

+ 33 - 18
app/Services/OrderService.php

@@ -1005,8 +1005,8 @@ class OrderService
     {
         /** @var \stdClass $order */
         //检查订单对象
-        if (!$order || $order->wms_status != "订单完成")return false;
-        if (OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first())return false;
+        if (!$order || $order->wms_status != "订单完成")return true;
+        if (OwnerFeeDetail::query()->where("outer_table_name","orders")->where("outer_id",$order->id)->first())return true;
 
         $key = date("Y-m")."_".$order->owner_id;
         if (Cache::has($key))Cache::increment($key);
@@ -1045,9 +1045,13 @@ class OrderService
             $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
                 return Province::query()->where("name","like",$provinceName."%")->first();
             },86400);
-            if (!$province)$logistic_fee = null;
+            if ($province){
+                $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+            }else{
+                $logistic_fee = null;
+                $fee = null;
+            }
 
-            $fee = $service->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
             $items[] = [
                 "amount" => $partAmount,
                 "logistic_bill" => $package->logistic_number,
@@ -1197,23 +1201,34 @@ class OrderService
         if ($order->owner->owner_price_expresses_count < 1)return false; //不存在计费模型 跳出
         foreach ($order->packages as $package)if (!$package->weight)return false; //包裹存在且全部存在数量
 
-        $logisticFee = 0;
+        $logistic_fee = 0;
+        $volume = 0;
+        $weight = 0;
+        if (!$order->logistic || $order->logistic->type != "快递")$logistic_fee = null;
         foreach ($order->packages as $package){
-            if ($logisticFee!==null){
-                $provinceName = mb_substr($order->province,0,2);
-                $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
-                    return Province::query()->where("name","like",$provinceName."%")->first();
-                },86400);
-                if (!$province)$logisticFee = null;
-
-                $fee = app("OwnerPriceExpressService")->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
-                if ($fee<0)$logisticFee = null;
-                else $logisticFee += $fee;
+            $volume += $package->bulk;
+            $weight += $package->weight;
+
+            $provinceName = mb_substr($order->province,0,2);
+            $province = app(CacheService::class)->getOrExecute("province_".$provinceName,function ()use($provinceName){
+                return Province::query()->where("name","like",$provinceName."%")->first();
+            },86400);
+            if (!$province)$logistic_fee = null;
+
+            $fee = app("OwnerPriceExpressService")->matching($package->weight, $order->owner_id, $order->logistic_id, $province->id);
+            OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$feeBill->id)->where("logistic_bill",$package->logistic_number)->update([
+                "volume"=>$package->bulk,
+                "weight"=>$package->weight,
+                "logistic_fee" => $fee>0 ? $fee : null,
+            ]);
+            if ($logistic_fee!==null){
+                if ($fee<0)$logistic_fee = null;
+                else $logistic_fee += $fee;
             }
         }
-        if ($logisticFee===null || $logisticFee<0)
-            LogService::log(__METHOD__,"ERROR-校正即时账单计算物流费错误","订单ID:".$order->id."  费用结果:".$logisticFee);
-        else $feeBill->update(["logistic_fee"=>$logisticFee]);
+        if ($logistic_fee===null || $logistic_fee<0)
+            LogService::log(__METHOD__,"ERROR-校正即时账单计算物流费错误","订单ID:".$order->id."  费用结果:".$logistic_fee);
+        else $feeBill->update(["logistic_fee"=>$logistic_fee,"volume"=>$volume,"weight"=>$weight]);
         return true;
     }
 

+ 2 - 3
app/Services/OwnerPriceExpressService.php

@@ -144,9 +144,8 @@ class OwnerPriceExpressService
             })->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;
+        if ($weight <= $model->initial_weight)return $model->details[0]->initial_weight_price;
         $weight -= $model->initial_weight;
-        return (ceil($weight/$model->additional_weight)*$model->details[0]->additional_weight_price)+$initialMoney;
+        return (ceil($weight/$model->additional_weight)*$model->details[0]->additional_weight_price)+$model->details[0]->initial_weight_price;
     }
 }

+ 1 - 1
app/Services/OwnerPriceOperationService.php

@@ -341,7 +341,7 @@ class OwnerPriceOperationService
             if ($package[$amountColumn] <= 0){
                 unset($packages[$i]);continue;
             }
-            if ($package["price"] > $maxPrice){
+            if ($package["price"] > $maxPrice || ($package["price"]==0 && $maxPrice==0)){
                 $maxPrice = $package["price"];
                 $index = $i;
             }

+ 1 - 0
app/Services/ProcessService.php

@@ -101,6 +101,7 @@ class ProcessService
 
     public function createInstantBill(Process $process)
     {
+        /** @var \stdClass $process */
         if (!$process || $process->status!="交接完成")return false;
         if (!$process->processStatistic)$process->load("processStatistic");
 

+ 1 - 1
app/Services/RegionService.php

@@ -51,7 +51,7 @@ class RegionService
             ->where("type",1)->first();
         if (!$region)$region = Region::query()->create([
             "name"      => $province,
-            "type"      => 2,
+            "type"      => 1,
         ]);
         return $region->id;
     }

+ 1 - 0
app/Services/StoreService.php

@@ -318,6 +318,7 @@ class StoreService
 
     public function createInstantBill(Store $store): bool
     {
+        /** @var \stdClass $store */
         if (!$store || $store->status != "已入库") return false;
         if (OwnerFeeDetail::query()->where("outer_table_name","stores")->where("outer_id",$store->id)->first())return false;
         $store->loadMissing("storeItems");

+ 34 - 42
app/Services/WaybillService.php

@@ -2,6 +2,7 @@
 
 namespace App\Services;
 
+use App\OwnerFeeDetail;
 use App\Services\common\QueryService;
 use App\Waybill;
 use Illuminate\Database\Eloquent\Builder;
@@ -33,7 +34,7 @@ class WaybillService
             $ownerIds = explode(",",$param["owner_id"]);
             $waybills->where(function ($query)use($ownerIds){
                 /** @var Builder $query */
-                $query->whereIn("owner_id",$ownerIds)->orWhereHas("order",function ($query)use($ownerIds){
+                $query->whereIn("waybills.owner_id",$ownerIds)->orWhereHas("order",function ($query)use($ownerIds){
                     /** @var Builder $query */
                     $query->whereIn("owner_id",$ownerIds);
                 });
@@ -44,7 +45,7 @@ class WaybillService
             $destination = $param["destination"];
             $waybills->where(function ($query)use($destination){
                 /** @var Builder $query */
-                $query->where("destination","like",$destination."%")->orWhereHas("order",function ($query)use($destination){
+                $query->where("waybills.destination","like",$destination."%")->orWhereHas("order",function ($query)use($destination){
                     /** @var Builder $query */
                     $query->where("address",'like',$destination."%");
                 });
@@ -55,7 +56,7 @@ class WaybillService
             $recipient = $param["recipient"];
             $waybills->where(function ($query)use($recipient){
                 /** @var Builder $query */
-                $query->where("recipient","like",$recipient."%")->orWhereHas("order",function ($query)use($recipient){
+                $query->where("waybills.recipient","like",$recipient."%")->orWhereHas("order",function ($query)use($recipient){
                     /** @var Builder $query */
                     $query->where("consignee_name",'like',$recipient."%");
                 });
@@ -66,24 +67,13 @@ class WaybillService
             $recipientMobile = $param["recipient_mobile"];
             $waybills->where(function ($query)use($recipientMobile){
                 /** @var Builder $query */
-                $query->where("recipient_mobile","like",$recipientMobile."%")->orWhereHas("order",function ($query)use($recipientMobile){
+                $query->where("waybills.recipient_mobile","like",$recipientMobile."%")->orWhereHas("order",function ($query)use($recipientMobile){
                     /** @var Builder $query */
                     $query->where("consignee_phone",'like',$recipientMobile."%");
                 });
             });
             unset($param["recipient_mobile"]);
         }
-        if ($param["logistic_id"] ?? false){
-            $logisticId = $param["logistic_id"];
-            $waybills->where(function ($query)use($logisticId){
-                /** @var Builder $query */
-                $query->where("logistic_id",$logisticId)->orWhereHas("order",function ($query)use($logisticId){
-                    /** @var Builder $query */
-                    $query->where("logistic_id",$logisticId);
-                });
-            });
-            unset($param["logistic_id"]);
-        }
         $columnQueryRules=[
             'waybill_number' => ['like' => ''],
             'carrier_bill' => ['like' => ''],
@@ -202,45 +192,47 @@ class WaybillService
 
     public function createInstantBill(Waybill $waybill) :bool
     {
+        /** @var \stdClass $waybill */
         if (!$waybill || $waybill->status != "已完结" || !$waybill->wms_bill_number || !$waybill->logistic_id)return false;
-        $waybill->loadMissing("destinationCity");
-        if (!$waybill->destinationCity)return false;
+        $waybill->loadMissing(["destinationCity","order.owner"]);
+        if (!$waybill->destinationCity && !$waybill->order)return false;
+
+        $owner_id = $waybill->order->owner_id ?? $waybill->owner_id;
+        $detail = OwnerFeeDetail::query()->where("type","发货")
+            ->where("owner_id",$owner_id)->whereIn("operation_bill",[$waybill->wms_bill_number,$waybill->waybill_number])->first();
 
-        $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 ($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,
+            $fee = $service->matching($waybill->carrier_weight_other,$owner_id,$waybill->logistic_id,
+                $waybill->carrier_weight_unit_id_other,$waybill->order ? app("RegionService")->getProvince($waybill->order->province) : $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);
+            $fee = $service->matching($waybill->mileage,$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",
-            ]);
-        }
+        $obj = [
+            "owner_id" => $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 ?? null,
+            "outer_id" => $waybill->id,
+            "outer_table_name" => "waybills",
+        ];
+        if ($detail)app("OwnerFeeDetailService")->updateFind($detail,$obj);
+        else OwnerFeeDetail::query()->create($obj);
         return true;
     }
 }

+ 1 - 1
app/User.php

@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Gate;
 use App\Traits\ModelTimeFormat;
 use Tymon\JWTAuth\Contracts\JWTSubject;
 
-class User extends Authenticatable /*implements JWTSubject*/
+class User extends Authenticatable
 {
     use ModelLogChanging;
     use ModelTimeFormat;

+ 1 - 3
app/Waybill.php

@@ -133,12 +133,10 @@ class Waybill extends Model
      */
     public static function filterAuthorities(){
         $ids=app('UserService')->getPermittingOwnerIds(auth()->user());
-        return (new static)->newQuery()->leftJoin("orders","waybills.wms_bill_number","orders.code")
+        return (new static)->newQuery()->leftJoin("orders","waybills.order_id","orders.id")
             ->leftJoin("owners","orders.owner_id","owners.id")
-            ->leftJoin("logistics","orders.logistic_id","logistics.id")
             ->selectRaw(<<<column
             owners.name as owner_name,
-            logistics.name as logistic_name,
             orders.consignee_name as order_consignee_name,
             orders.consignee_phone as order_consignee_phone,
             orders.province as order_province,

+ 35 - 35
bootstrap/cache/packages.php

@@ -1,125 +1,125 @@
 <?php return array (
-  'barryvdh/laravel-debugbar' => 
+  'barryvdh/laravel-debugbar' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Barryvdh\\Debugbar\\ServiceProvider',
     ),
-    'aliases' => 
+    'aliases' =>
     array (
       'Debugbar' => 'Barryvdh\\Debugbar\\Facade',
     ),
   ),
-  'beyondcode/laravel-dump-server' => 
+  'beyondcode/laravel-dump-server' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'BeyondCode\\DumpServer\\DumpServerServiceProvider',
     ),
   ),
-  'facade/ignition' => 
+  'facade/ignition' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Facade\\Ignition\\IgnitionServiceProvider',
     ),
-    'aliases' => 
+    'aliases' =>
     array (
       'Flare' => 'Facade\\Ignition\\Facades\\Flare',
     ),
   ),
-  'fideloper/proxy' => 
+  'fideloper/proxy' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider',
     ),
   ),
-  'intervention/image' => 
+  'intervention/image' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Intervention\\Image\\ImageServiceProvider',
     ),
-    'aliases' => 
+    'aliases' =>
     array (
       'Image' => 'Intervention\\Image\\Facades\\Image',
     ),
   ),
-  'laravel/tinker' => 
+  'laravel/tinker' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Laravel\\Tinker\\TinkerServiceProvider',
     ),
   ),
-  'laravel/ui' => 
+  'laravel/ui' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Laravel\\Ui\\UiServiceProvider',
     ),
   ),
-  'maatwebsite/excel' => 
+  'maatwebsite/excel' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
     ),
-    'aliases' => 
+    'aliases' =>
     array (
       'Excel' => 'Maatwebsite\\Excel\\Facades\\Excel',
     ),
   ),
-  'nesbot/carbon' => 
+  'nesbot/carbon' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Carbon\\Laravel\\ServiceProvider',
     ),
   ),
-  'nunomaduro/collision' => 
+  'nunomaduro/collision' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
     ),
   ),
-  'overtrue/laravel-pinyin' => 
+  'overtrue/laravel-pinyin' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Overtrue\\LaravelPinyin\\ServiceProvider',
     ),
-    'aliases' => 
+    'aliases' =>
     array (
       'Pinyin' => 'Overtrue\\LaravelPinyin\\Facades\\Pinyin',
     ),
   ),
-  'te7a-houdini/laravel-trix' => 
+  'te7a-houdini/laravel-trix' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Te7aHoudini\\LaravelTrix\\LaravelTrixServiceProvider',
     ),
   ),
-  'tymon/jwt-auth' => 
+  'tymon/jwt-auth' =>
   array (
-    'aliases' => 
+    'aliases' =>
     array (
       'JWTAuth' => 'Tymon\\JWTAuth\\Facades\\JWTAuth',
       'JWTFactory' => 'Tymon\\JWTAuth\\Facades\\JWTFactory',
     ),
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider',
     ),
   ),
-  'yajra/laravel-oci8' => 
+  'yajra/laravel-oci8' =>
   array (
-    'providers' => 
+    'providers' =>
     array (
       0 => 'Yajra\\Oci8\\Oci8ServiceProvider',
     ),
   ),
-);
+);

+ 1 - 2
composer.lock

@@ -10458,8 +10458,7 @@
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
-        "php": "^7.1.3",
-        "ext-bcmath": "*",
+        "php": "^7.2.34",
         "ext-json": "*",
         "ext-mbstring": "*",
         "ext-openssl": "*",

+ 63 - 0
database/migrations/2021_02_26_093335_add_authority_data_money.php

@@ -0,0 +1,63 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddAuthorityDataMoney extends Migration
+{
+     public $delAuthorities = [
+         '客户管理-财务-即时账单',
+         '客户管理-财务-账单确认',
+         '客户管理-财务-账单确认-编辑',
+         '客户管理-财务-账单确认-完结',
+     ];
+
+     public $addAuthorities = [
+         "结算管理",
+         "结算管理-即时账单",
+         "结算管理-账单确认",
+         "结算管理-账单确认-编辑",
+         "结算管理-账单确认-完结",
+     ];
+
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->delAuthorities as $authority){
+            \App\Authority::query()->where("name",$authority)->delete();
+        }
+        foreach ($this->addAuthorities as $authority){
+            \App\Authority::query()->firstOrCreate([
+                "name"=>$authority
+            ],[
+                "name"=>$authority,
+                "alias_name"=>$authority
+            ]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->addAuthorities as $authority){
+            \App\Authority::query()->where("name",$authority)->delete();
+        }
+        foreach ($this->delAuthorities as $authority){
+            \App\Authority::query()->firstOrCreate([
+                "name"=>$authority
+            ],[
+                "name"=>$authority,
+                "alias_name"=>$authority
+            ]);
+        }
+    }
+}

+ 38 - 0
database/migrations/2021_02_26_152744_change_owner_fee_details_table_change_volume_column.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOwnerFeeDetailsTableChangeVolumeColumn extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->decimal("volume",18,3)->nullable()->change();
+        });
+        Schema::table('owner_fee_detail_logistics', function (Blueprint $table) {
+            $table->decimal("volume",18,3)->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_fee_details', function (Blueprint $table) {
+            $table->decimal('volume',8,3)->nullable()->comment('体积');
+        });
+        Schema::table('owner_fee_detail_logistics', function (Blueprint $table) {
+            $table->decimal('volume',8,3)->nullable()->comment('体积');
+        });
+    }
+}

+ 45 - 0
database/migrations/2021_03_02_133545_change_owner_bill_reports_table.php

@@ -0,0 +1,45 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOwnerBillReportsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        \App\Authority::query()->firstOrCreate(["name"=>"结算管理-即时账单-重置即时账单"],[
+            "name"=>"结算管理-即时账单-重置即时账单",
+            "alias_name"=>"结算管理-即时账单-重置即时账单"
+        ]);
+        \App\Authority::query()->firstOrCreate(["name"=>"结算管理-账单确认-重置账单确认"],[
+            "name"=>"结算管理-账单确认-重置账单确认",
+            "alias_name"=>"结算管理-账单确认-重置账单确认"
+        ]);
+        Schema::table('owner_bill_reports', function (Blueprint $table) {
+            $table->decimal('initial_fee',11,3)->nullable()->comment('原始账单金额')->change();
+            $table->decimal('confirm_fee',11,3)->nullable()->comment('确认账单金额')->change();
+            $table->decimal('difference',11,3)->nullable()->comment('差额')->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        \App\Authority::query()->whereIn("name",["结算管理-账单确认-重置账单确认","结算管理-账单确认-重置账单确认"])->delete();
+        Schema::table('owner_bill_reports', function (Blueprint $table) {
+            $table->decimal('initial_fee',8,4)->nullable()->comment('原始账单金额')->change();
+            $table->decimal('confirm_fee',8,4)->nullable()->comment('确认账单金额')->change();
+            $table->decimal('difference',8,4)->nullable()->comment('差额')->change();
+        });
+    }
+}

+ 15 - 15
resources/js/queryForm/queryForm.js

@@ -652,7 +652,7 @@ const query = function getQueryForm(data) {
         ul_div.hide();
         ul_div.mouseleave(function () {
             if(_data[condition.name].value.length>0){
-                _this.onsubmit();
+                // _this.onsubmit();
                 ul_div.hide();
                 return;
             }
@@ -660,16 +660,16 @@ const query = function getQueryForm(data) {
                 ul_div.hide();
             }
         });
-        ul_div.mouseenter(function () {
-            if(_data[condition.name].value.length>0){
-                setTimeout(()=> {
-                    if (ul_div.is(':visible')){
-                        ul_div.attr("title","移出多选区域即可自动提交");
-                        ul_div.tooltip('show');
-                    }
-                },1000);
-            }
-        });
+        // ul_div.mouseenter(function () {
+        //     if(_data[condition.name].value.length>0){
+        //         setTimeout(()=> {
+        //             if (ul_div.is(':visible')){
+        //                 ul_div.attr("title","移出多选区域即可自动提交");
+        //                 ul_div.tooltip('show');
+        //             }
+        //         },1000);
+        //     }
+        // });
         return div;
     }
 
@@ -1106,16 +1106,16 @@ const query = function getQueryForm(data) {
         });
         $(_form).find("input[type='date']").change(function (e) {
             setTimeout(function () {
-                if (_this.keydownSearch)_this.onsubmit();
+                // if (_this.keydownSearch)_this.onsubmit();
                 if (controlJsType(_this.keydownfun, 'fun')) _this.keydownfun();
             },100);
         });
     }
 
     function selectChange() {
-        $(_form).find('select').change(function () {
-            _this.onsubmit();
-        })
+        // $(_form).find('select').change(function () {
+        //     _this.onsubmit();
+        // })
     }
 
     function redenerSearchFormOnData(key, value, mold) {

+ 37 - 0
resources/sass/text.scss

@@ -156,4 +156,41 @@
 //虚线边框-红色
 .border-dashed-red {
     border:2px dashed red;
+}
+
+//滑块
+.switch{
+    outline: none;
+    cursor: pointer;
+    appearance: none;
+    -webkit-appearance: none;
+    -moz-appearance: none;
+    position: relative;
+    width: 40px;
+    height: 20px;
+    background: #ccc;
+    border-radius: 10px;
+    transition: border-color .3s, background-color .3s;
+}
+.switch::after {
+    content: '';
+    display: inline-block;
+    width: 1rem;
+    height:1rem;
+    border-radius: 50%;
+    background: #fff;
+    box-shadow: 0 0 2px #999;
+    transition:.4s;
+    top: 2px;
+    position: absolute;
+    left: 2px;
+}
+.switch:checked {
+    background: rgb(19, 206, 102);
+}
+.switch:checked::after {
+    content: '';
+    position: absolute;
+    left: 55%;
+    top: 2px;
 }

+ 1 - 0
resources/views/customer/customer/index.blade.php

@@ -145,6 +145,7 @@
                     </td>
                 </tr>
             </table>
+            {{$customers->appends($params)->links()}}
         </div>
     </div>
 @stop

+ 0 - 18
resources/views/customer/finance/menu.blade.php

@@ -1,18 +0,0 @@
-<div id="nav2">
-    @component('customer.menu')
-    @endcomponent
-    <div class="container-fluid nav3">
-        <div class="card menu-third" >
-            <ul class="nav nav-pills">
-                @can('客户管理-财务-即时账单')
-                <li class="nav-item">
-                    <a target="customer/finance/instantBill" class="nav-link" href="{{url('customer/finance/instantBill')}}" :class="{active:isActive('instantBill',3)}">即时账单</a>
-                </li> @endcan
-                @can('客户管理-财务-账单确认')
-                <li class="nav-item">
-                    <a target="customer/finance/billConfirmation" class="nav-link" href="{{url('customer/finance/billConfirmation')}}" :class="{active:isActive('billConfirmation',3)}">账单确认</a>
-                </li> @endcan
-            </ul>
-        </div>
-    </div>
-</div>

+ 0 - 4
resources/views/customer/menu.blade.php

@@ -6,10 +6,6 @@
             <li class="nav-item">
                 <a target="customer/project/report" class="nav-link" href="{{url('customer/project/report')}}" :class="{active:isActive('project',2)}">项目</a>
             </li>@endcan
-            @can('客户管理-财务')
-            <li class="nav-item">
-                <a target="customer/finance/instantBill" class="nav-link" href="{{url('customer/finance/instantBill')}}" :class="{active:isActive('finance',2)}">财务</a>
-            </li>@endcan
             @can('客户管理-客户')
             <li class="nav-item">
                 <a target="customer/customer" class="nav-link" href="{{url('customer/customer')}}" :class="{active:isActive('customer',2)}">客户</a>

+ 1 - 0
resources/views/customer/project/create.blade.php

@@ -576,6 +576,7 @@
                     }
                 },
                 _verifyStorage(){
+                    let error = {};
                     if (!this.model.storage.counting_type)error["counting_type"] = ["未选择计费类型"];
                     if (!this.model.storage.name)error["name"] = ["未填写名称"];
                     if (!this.model.storage.using_type)error["using_type"] = ["未选择用仓类型"];

+ 9 - 5
resources/views/customer/project/part/_operation.blade.php

@@ -83,15 +83,19 @@
             </div>
         </div>
         <div class="card-body">
-            <div class="row" v-if="model.operation.items[0].type == 0">
+            <div class="row">
                 <label class="col-3">
                     <select class="form-control mt-1" v-model="model.operation.items[0].type">
                         <option value="0">起步数</option>
                         <option value="1">起步费</option>
                     </select>
                 </label>
-                <label class="col-6 mb-0"><input id="amount" type="number" :class="errors['items.0.amount'] ? 'is-invalid' : ''"
-                       v-model="model.operation.items[0].amount" class="form-control" step="1"></label>
+                <label class="col-6 mb-0">
+                    <input id="amount" type="number" :class="errors['items.0.amount'] ? 'is-invalid' : ''" v-if="model.operation.items[0].type == 0"
+                       v-model="model.operation.items[0].amount" class="form-control" step="1">
+                    <input v-else type="number" min="0" step="0.01" class="form-control" v-model="model.operation.items[0].unit_price"
+                           :class="errors['items.0.unit_price'] ? 'is-invalid' : ''">
+                </label>
             </div>
             <div class="row mt-0" v-if="errors['items.0.amount']">
                 <div class="offset-3"><small class="text-danger font-weight-bold ml-3">起步数为必填项</small></div>
@@ -105,8 +109,8 @@
             <div class="row mt-0" v-if="errors['items.0.unit_id']">
                 <div class="offset-3"><small class="text-danger font-weight-bold ml-3">单位为必选项</small></div>
             </div>
-            <div class="row mt-2">
-                <label class="col-3" v-if="model.operation.items[0].type == 0">起步费</label>
+            <div class="row mt-2" v-if="model.operation.items[0].type == 0">
+                <label class="col-3">起步费</label>
                 <label class="col-6 mb-0 input-group">
                     <input type="number" min="0" step="0.01" class="form-control" v-model="model.operation.items[0].unit_price"
                                                  :class="errors['items.0.unit_price'] ? 'is-invalid' : ''">

+ 28 - 0
resources/views/finance/_resetBillConfirmation.blade.php

@@ -0,0 +1,28 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="resetBillConfirmation">
+    <div class="modal-dialog modal-lg modal-dialog-centered">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <div class="row mt-2">
+                    <span class="col-2">结算月</span>
+                    <label class="col-8">
+                        <input type="month" class="form-control" v-model="reset.month">
+                    </label>
+                </div>
+                <div class="row mt-2">
+                    <span class="col-2">项目</span>
+                    <label class="col-8">
+                        <select class="form-control selectpicker" multiple data-live-search="true" title="项目" v-model="reset.owner">
+                            <option v-for="owner in owners" :value="owner.name">@{{ owner.value }}</option>
+                        </select>
+                    </label>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button"  class="btn btn-success pull-right" @click="resetBillConfirmation()">重置</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 28 - 0
resources/views/finance/_resetInstantBill.blade.php

@@ -0,0 +1,28 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="resetInstantBill">
+    <div class="modal-dialog modal-lg modal-dialog-centered">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <label class="row">
+                    <span class="col-2">日期</span>
+                    <input type="date" class="form-control col-4" v-model="reset.startDate">
+                    <span class="mt-1">&nbsp;━━━&nbsp;</span>
+                    <input type="date" class="form-control col-4" v-model="reset.endDate" :min="reset.startDate">
+                </label>
+                <div class="row mt-2">
+                    <span class="col-2">项目</span>
+                    <label class="col-8">
+                        <select class="form-control selectpicker" multiple data-live-search="true" title="项目" v-model="reset.owner">
+                            <option v-for="owner in owners" :value="owner.name">@{{ owner.value }}</option>
+                        </select>
+                    </label>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button"  class="btn btn-success pull-right" @click="resetInstantBill()">重置</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 30 - 10
resources/views/customer/finance/billConfirmation.blade.php → resources/views/finance/billConfirmation.blade.php

@@ -2,7 +2,7 @@
 @section('title')账单确认-客户管理@endsection
 
 @section('content')
-    @component('customer.finance.menu')@endcomponent
+    @component('finance.menu')@endcomponent
     <div class="container-fluid d-none" id="container">
         <div id="form_div"></div>
         <div class="mt-1">
@@ -14,6 +14,8 @@
                 <a class="dropdown-item" @click="billExport(false)" href="javascript:">导出勾选内容</a>
                 <a class="dropdown-item" @click="billExport(true)" href="javascript:">导出所有页</a>
             </div>
+            @include("finance._resetBillConfirmation")
+            @can("结算管理-账单确认-重置账单确认")<button data-toggle="modal" data-target="#resetBillConfirmation" class="btn btn-sm btn-outline-primary">重置账单确认</button>@endcan
         </div>
         <div>
             <label for="all" id="cloneCheckAll" class="d-none">
@@ -92,6 +94,9 @@
                 ],
                 thisIndex:"-1",
                 sum : Number("{{ $bills->total() }}"),
+                reset:{
+                    owner:[],
+                }
             },
             watch:{
                 checkData:{
@@ -129,11 +134,11 @@
                     {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
                         dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
                     {name:'index',value: '序号', neglect: true},
-                    {name:'workgroup',value: '项目小组'},
-                    {name:'customer',value: '客户'},
-                    {name:'owner',value: '子项目'},
-                    {name:'counting_month',value: '结算月'},
-                    {name:'created_at',value: '录入日期'},
+                    {name:'ownerGroupName',value: '项目小组'},
+                    {name:'customerName',value: '客户'},
+                    {name:'ownerName',value: '子项目'},
+                    {name:'countingMonth',value: '结算月'},
+                    {name:'updatedAt',value: '录入日期'},
                     {name:'initial_fee',value: '原始账单金额', neglect: true},
                     {name:'confirm_fee',value: '确认账单金额', neglect: true},
                     {name:'difference',value: '差额', neglect: true},
@@ -155,7 +160,7 @@
             },
             methods:{
                 billExport(isAll){
-                    let url = '{{url('customer/finance/billConfirmation/export')}}';
+                    let url = '{{url('finance/billConfirmation/export')}}';
                     let token='{{ csrf_token() }}';
                     excelExport(isAll,this.checkData,url,this.sum,token);
                 },
@@ -178,7 +183,7 @@
                         return;
                     }
                     window.tempTip.confirm("确定要更新账单确认金额为“"+confirm_fee+"”吗?",()=>{
-                        window.axios.post("{{url('customer/finance/updateBillReport')}}",{id:bill.id,confirm_fee:confirm_fee})
+                        window.axios.post("{{url('finance/updateBillReport')}}",{id:bill.id,confirm_fee:confirm_fee})
                             .then(res=>{
                                 if (res.data.success){
                                     bill.confirmFee = confirm_fee;
@@ -199,7 +204,7 @@
                 },
                 billConfirm(bill){
                     window.tempTip.confirm("确定要完结该账单吗?",()=>{
-                        window.axios.post("{{url('customer/finance/billConfirm')}}",{id:bill.id})
+                        window.axios.post("{{url('finance/billConfirm')}}",{id:bill.id})
                             .then(res=>{
                                 if (res.data.success){
                                     bill.confirmed = "是";
@@ -214,7 +219,22 @@
                             window.tempTip.show("网络错误:"+err);
                         })
                     });
-                }
+                },
+                resetBillConfirmation(){
+                    window.tempTip.setDuration(3000);
+                    window.tempTip.setIndex(1099);
+                    if (!this.reset.month){
+                        window.tempTip.show("未选择结算月");
+                        return;
+                    }
+                    window.tempTip.setDuration(999999);
+                    window.tempTip.waitingTip("加载中......");
+                    window.tempTip.postBasicRequest("{{url('customer/project/resetBillConfirmation')}}",this.reset,res=>{
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.cancelWaitingTip();
+                        return "重置成功";
+                    },true)
+                },
             },
         });
     </script>

+ 46 - 6
resources/views/customer/finance/instantBill.blade.php → resources/views/finance/instantBill.blade.php

@@ -2,8 +2,26 @@
 @section('title')即时账单-客户管理@endsection
 
 @section('content')
-    @component('customer.finance.menu')@endcomponent
+    @component('finance.menu')@endcomponent
     <div class="container-fluid d-none" id="container">
+        <div class="container-fluid nav3">
+            <div class="card menu-third">
+                <ul class="nav nav-pills">
+                    <li class="nav-item">
+                        <a target="customer/finance/instantBill" class="nav-link" href="{{url('finance/instantBill')}}" :class="!thisType ? 'active' : ''">全部</a>
+                    </li>
+                    <li class="nav-item">
+                        <a target="customer/finance/instantBill" class="nav-link" href="{{url('finance/instantBill?type=发货')}}" :class="thisType=='发货' ? 'active' : ''">发货</a>
+                    </li>
+                    <li class="nav-item">
+                        <a target="customer/finance/instantBill" class="nav-link" href="{{url('finance/instantBill?type=收货')}}" :class="thisType=='收货' ? 'active' : ''">收货</a>
+                    </li>
+                    <li class="nav-item">
+                        <a target="customer/finance/instantBill" class="nav-link" href="{{url('finance/instantBill?type=增值服务')}}" :class="thisType=='增值服务' ? 'active' : ''">增值服务</a>
+                    </li>
+                </ul>
+            </div>
+        </div>
         <div id="form_div"></div>
         <div class="mt-1">
             <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
@@ -14,6 +32,8 @@
                 <a class="dropdown-item" @click="billExport(false)" href="javascript:">导出勾选内容</a>
                 <a class="dropdown-item" @click="billExport(true)" href="javascript:">导出所有页</a>
             </div>
+            @include("finance._resetInstantBill")
+            @can("结算管理-即时账单-重置即时账单")<button data-toggle="modal" data-target="#resetInstantBill" class="btn btn-sm btn-outline-primary">重置即时账单</button>@endcan
         </div>
         <div>
             <label for="all" id="cloneCheckAll" class="d-none">
@@ -93,7 +113,7 @@
                         consigneePhone : "{{$detail->consignee_phone}}",
                         commodityAmount : "{{$detail->commodity_amount}}",
                         logisticBill : "{{$detail->logistic_bill}}",
-                        volume : "{{$detail->volume}}",
+                        volume : "{{$detail->volume ? floor($detail->volume/10)/100 : ''}}",
                         weight : "{{$detail->weight}}",
                         logisticName : "{{$detail->logistic ? $detail->logistic->name : ''}}",
                         methodName : "{{$detail->processMethod ? $detail->processMethod->name : ''}}",
@@ -125,6 +145,10 @@
                     {name:"发货",value:"发货"},{name:"收货",value:"收货"},{name:"增值服务",value:"增值服务"},
                 ],
                 sum : Number("{{ $details->total() }}"),
+                thisType : "",
+                reset:{
+                    owner:[],
+                },
             },
             mounted(){
                 $('#container').removeClass('d-none');
@@ -161,8 +185,8 @@
                     {name:'consigneePhone',value: '收件人电话', class: "bg-info"},
                     {name:'commodityAmount',value: '商品数量', class: "bg-info", neglect: true},
                     {name:'logisticBill',value: '物流/快递单号', class: "bg-khaki"},
-                    {name:'volume',value: '体积', class: "bg-khaki", neglect: true},
-                    {name:'weight',value: '重量', class: "bg-khaki", neglect: true},
+                    {name:'volume',value: '体积(cm³)', class: "bg-khaki", neglect: true},
+                    {name:'weight',value: '重量(kg)', class: "bg-khaki", neglect: true},
                     {name:'logisticName',value: '承运商', class: "bg-khaki"},
                     {name:'workFee',value: '操作费', class: "bg-cyanogen", neglect: true},
                     {name:'logisticFee',value: '物流费', class: "bg-cyanogen", neglect: true},
@@ -176,11 +200,12 @@
                         data: _this.bills,
                         restorationColumn: 'id',
                         fixedTop:($('#form_div').height())+2,
-                        offset:0.5,
+                        offset:7.5,
                         vue:vue
                     });
                     header.init();
                 },0);
+                this.thisType = document.getElementsByName("type")[0].value;
             },
             watch:{
                 checkData:{
@@ -198,7 +223,7 @@
             },
             methods:{
                 billExport(isAll){
-                    let url = '{{url('customer/finance/instantBill/export')}}';
+                    let url = '{{url('finance/instantBill/export')}}';
                     let token='{{ csrf_token() }}';
                     //excelExport 定义在 js/queryForm/export.js
                     excelExport(isAll,this.checkData,url,this.sum,token);
@@ -214,6 +239,21 @@
                         this.checkData = [];
                     }
                 },
+                resetInstantBill(){
+                    window.tempTip.setDuration(3000);
+                    window.tempTip.setIndex(1099);
+                    if (!this.reset.startDate){
+                        window.tempTip.show("未选择起始日期");
+                        return;
+                    }
+                    window.tempTip.setDuration(999999);
+                    window.tempTip.waitingTip("加载中......");
+                    window.tempTip.postBasicRequest("{{url('customer/project/resetInstantBill')}}",this.reset,res=>{
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.cancelWaitingTip();
+                        return "重置成功";
+                    },true)
+                },
             },
         });
     </script>

+ 15 - 0
resources/views/finance/menu.blade.php

@@ -0,0 +1,15 @@
+<div class="container-fluid nav2" id="nav2">
+    <div class="card">
+        <ul class="nav nav-pills">
+            @can('结算管理-即时账单')
+            <li class="nav-item">
+                <a target="finance/instantBill" class="nav-link" href="{{url('finance/instantBill')}}" :class="{active:isActive('instantBill',2)}">即时账单</a>
+            </li>@endcan
+            @can('结算管理-即时账单')
+            <li class="nav-item">
+                <a target="finance/billConfirmation" class="nav-link" href="{{url('finance/billConfirmation')}}" :class="{active:isActive('billConfirmation',2)}">账单确认</a>
+            </li>@endcan
+        </ul>
+    </div>
+</div>
+

+ 5 - 0
resources/views/layouts/menu.blade.php

@@ -42,6 +42,11 @@
                                     :class="{active:isActive('customer',1)}">
                     <span class="fa fa-address-book-o" style="color: #72441b"></span>
                     客户管理</a></li> @endcan
+        @can('结算管理')
+            <li class="nav-item"><a href="{{url("finance/instantBill")}}" class="nav-link" target="customer/project/report"
+                                    :class="{active:isActive('finance',1)}">
+                    <span class="fa fa-money" style="color: #72441b"></span>
+                    结算管理</a></li> @endcan
         @can('人事管理')
             <li class="nav-item"><a href="{{url("personnel/laborReport")}}" class="nav-link" target="personnel/laborReport"
                                     :class="{active:isActive('personnel',1)}">

+ 12 - 2
resources/views/package/weigh/index.blade.php

@@ -40,8 +40,8 @@
                         <td class="text-muted">@{{package.logisticName}}</td>
                         <td class="text-muted">@{{package.measuringMachineName}}</td>
                         <td>@{{package.weight}}</td>
-                        <td>@{{package.length}}<a v-if="package.length" class="text-primary">*</a>@{{package.width}}<a class="text-primary" v-if="package.width">*</a>@{{package.height}}</td>
-                        <td>@{{package.bulk}}</td>
+                        <td>@{{package.length|upDigit}}<a v-if="package.length" class="text-primary">*</a>@{{package.width|upDigit}}<a class="text-primary" v-if="package.width">*</a>@{{package.height|upDigit}}</td>
+                        <td>@{{package.bulk|upCubic}}</td>
                         <td>@{{package.paperBoxName}}</td>
                         <td :class="[package.uploaded_to_wms==='是'?'text-success':'']">@{{package.status}}</td>
                         <td class="text-muted">@{{package.batchRule}}</td>
@@ -182,6 +182,16 @@
                     excelExport(checkAllSign,this.checkData,url,this.sum,token);
                 },
             },
+            filters:{
+                upDigit(val){
+                    if(!val)return;
+                    return Math.round(Number(val)*10)/100;
+                },
+                upCubic(val){
+                    if(!val)return;
+                    return Math.round(Number(val)/10)/100;
+                }
+            }
         });
     </script>
 @endsection

+ 123 - 0
resources/views/store/checkingReceive/appointment.blade.php

@@ -0,0 +1,123 @@
+@extends('layouts.app')
+@section('title')任务-盘收一体@endsection
+
+@section('content')
+    <span id="nav2">
+    @component('store.menu')@endcomponent
+    @component('store.checkingReceive.menu')@endcomponent
+    </span>
+    <div class="container-fluid" id="container">
+        <div class="card">
+            <div class="card-body row">
+                <div class="offset-2 col-8">
+                    <div class="card">
+                        <div class="card-header">
+                            <div class="row">
+                                <label class="col-2 offset-2">车牌号</label>
+                                <label class="col-2">车型</label>
+                                <label class="col-2">司机姓名</label>
+                                <label class="col-3">司机电话</label>
+                                <label class="col-1">
+                                    <span class="fa fa-plus cursor-pointer text-primary">增加</span>
+                                </label>
+                            </div>
+                        </div>
+                        <div class="card-body">
+                            <div class="row" v-for="(car,i) in model.cars">
+                                <label class="col-2">车辆-@{{ i+1 }}</label>
+                                <label class="col-2">
+                                    <input type="text" class="form-control" v-model="car.number">
+                                </label>
+                                <label class="col-2">
+                                    <input type="text" class="form-control" v-model="car.id">
+                                </label>
+                                <label class="col-2">
+                                    <input type="text" class="form-control" v-model="car.name">
+                                </label>
+                                <label class="col-3">
+                                    <input type="text" class="form-control" v-model="car.phone">
+                                </label>
+                                <label class="col-1" v-if="i!==0">
+                                    <span class="h4 font-weight-bold cursor-pointer text-danger">&times;</span>
+                                </label>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row mt-4 ml-1">
+                        <label class="col-2" for="procurementNumber">采购单号</label>
+                        <input class="col-6 form-control" type="text" id="procurementNumber" v-model="model.procurement_number">
+                    </div>
+                    <div class="row mt-2 ml-1">
+                        <label class="col-2" for="asnNumber">ASN单号</label>
+                        <input class="col-6 form-control" type="text" id="asnNumber" v-model="model.asn_number">
+                    </div>
+                    <div class="row mt-2 ml-1">
+                        <label class="col-2" for="warehouse">仓库</label>
+                        <input class="col-6 form-control" type="text" id="warehouse" v-model="model.warehouse_id">
+                    </div>
+                    <div class="row mt-2 ml-1">
+                        <label class="col-2" for="tonne">吨</label>
+                        <input class="col-3 form-control" type="text" id="tonne" v-model="model.tonne">
+                        <label class="col-1 offset-2" for="cube">立方</label>
+                        <input class="col-3 form-control" type="text" id="cube" v-model="model.cube">
+                    </div>
+                    <div class="row mt-2 ml-1">
+                        <label class="col-2" for="isUpload">是否上传明细单</label>
+                        <input content="col-3" id="isUpload" type="checkbox" class="switch" v-model="model.is_upload">
+                        <button v-if="model.is_upload" type="button" class="col-2 offset-1 btn btn-info text-white" @click="openFile()">
+                            <span class="fa fa-cloud-upload"></span> 选择文件</button>
+                        <span v-if="model.is_upload" class="text-secondary mt-1">&nbsp;@{{ fileName }}</span>
+                        <label hidden><input type="file" id="file" accept=".csv, .xlsx, .xls" @change="selectedFile($event)"></label>
+                    </div>
+                    <div class="row mt-4 ml-1">
+                        <button type="button" class="btn btn-success col-8 offset-2">提 交 预 约</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+@stop
+
+@section("lastScript")
+    <script>
+        new Vue({
+            el:"#container",
+            data:{
+                cars:[],
+                model:{
+                    cars:[{number:"",id:"",name:"",phone:""}],
+                },
+                owners:JSON.parse("{{$owners->toJson() ?? '{}'}}"),
+                fileName:""
+            },
+            mounted(){
+
+            },
+            methods:{
+                openFile(){
+                    $('#file').click();
+                },
+                selectedFile(e){
+                    let file=e.target.files[0];
+                    this.fileName = file.name;
+                    if (!file){
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show("未选择文件");
+                        return;
+                    }
+                    let formData = new FormData();
+                    formData.append("file",file);
+                    window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
+                        'Content-Type':'multipart/form-data'
+                    }).then(res=>{
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show(res.data.data);
+                    }).catch(err=> {
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show("网络错误:"+err);
+                    })
+                },
+            },
+        });
+    </script>
+@stop

+ 5 - 1
resources/views/store/checkingReceive/menu.blade.php

@@ -4,9 +4,13 @@
             <ul class="nav nav-pills">
                 @can('入库管理-盘收一体-任务')
                     <li class="nav-item">
-                        <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('',4)}">任务</a>
+                        <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/mission')}}" :class="{active:isActive('mission',3)}">任务</a>
                     </li> @endcan
                 {{$slot}}
+                @can('入库管理-盘收一体-客户预约')
+                <li class="nav-item">
+                    <a target="store/checkingReceive/mission" class="nav-link" href="{{url('store/checkingReceive/appointment')}}" :class="{active:isActive('appointment',3)}">客户预约</a>
+                </li> @endcan
             </ul>
         </div>
     </div>

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

@@ -193,7 +193,7 @@
                     amount_unit_id:'{{$waybill->amount_unit_id}}',
                     amount_unit_name:'{{$waybill->amount_unit ? $waybill->amount_unit->name : ''}}',
                     inquire_tel:'{{$waybill->inquire_tel}}',
-                    carrier_name:'{{$waybill->logistic_name ?? ($waybill->logistic->name ?? '')}}',
+                    carrier_name:'{{$waybill->logistic->name ?? ''}}',
                     owner_name:'{{$waybill->owner_name ?? ($waybill->owner->name ?? '')}}',
                     warehouse_weight_unit_name:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',
                     carrier_weight_unit_name:'{{$waybill->carrier_weight_unit ? $waybill->carrier_weight_unit->name : ''}}',

+ 52 - 34
resources/views/waybill/edit.blade.php

@@ -9,6 +9,24 @@
         @endcomponent
     </div>
     <div class="container-fluid" id="list">
+        <div class="modal fade" tabindex="-1" role="dialog" id="selectedProvince">
+            <div class="modal-dialog modal-lg modal-dialog-centered">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <b>选择省份</b>
+                        <button type="button" class="close" data-dismiss="modal">&times;</button>
+                    </div>
+                    <div class="modal-body row">
+                        <label class="col-8 offset-2"><select class="form-control" v-model="waybill.province">
+                            <option v-for="province in provinces" :value="province.id">@{{ province.name }}</option>
+                        </select></label>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-success pull-right" @click="addCounty()">录入</button>
+                    </div>
+                </div>
+            </div>
+        </div>
         <div class="card">
             <div class="card-body">
                 <form method="POST" id="waybillForm" action='{{url("waybill/".$waybill->id)}}'>
@@ -127,8 +145,7 @@
                     <div class="form-group row" style="margin-bottom: 20px">
                         <label for="logistic_id" class="col-2 col-form-label text-right text-primary">承运商 *</label>
                         <div class="col-8" style="position: relative">
-                            <select class="form-control @error('logistic_id') is-invalid @enderror" id="logistic_id" style="width: 30%; "
-                                    :name="waybill.order_id ? '' : 'logistic_id'" :disabled="!!waybill.order_id"
+                            <select class="form-control @error('logistic_id') is-invalid @enderror" id="logistic_id" style="width: 30%; " name="logistic_id"
                                     :class="errors['logistic_id'] ? 'is-invalid' :''"  v-model="waybill.logistic_id">
                                 <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
                             </select>
@@ -172,9 +189,9 @@
                                         :class="errors['destination_city_id'] ? 'is-invalid' :''"  v-model="waybill.destination_city_id">
                                     <option v-for="city in cities" :value="city.id">@{{city.name}}</option>
                                 </select>
-                                <input type="text" class="form-control-sm  form-control tooltipTarget" style="vertical-align: middle"
+                                <input v-if="!waybill.order_id" type="text" class="form-control-sm  form-control tooltipTarget" style="vertical-align: middle"
                                        placeholder="输入关键字定位" @input="destination_city_id" v-model="waybill.destination_city" id="destination_city" title="若无法显示区/县级市,可点击后方按钮手动添加" >
-                                <button type="button" class="btn btn-outline-info btn-sm" @click="addCounty()" style="transform: scale(0.9)">添加市/县</button>
+                                <button v-if="!waybill.order_id" type="button" class="btn btn-outline-info btn-sm" @click="selectedProvince()" style="transform: scale(0.9)">添加城市</button>
                             </div>
                         </div>
                     </div>
@@ -395,7 +412,7 @@
         let vueList=new Vue({
             el:'#list',
             data:{
-                cities:[@foreach($cities as $city){id:'{{$city->id}}',name:'{{$city->name}}',type:'{{$city->type}}',},@endforeach],
+                cities:[@foreach($cities as $city){id:'{{$city->id}}',name:'{{$city->name}}'},@endforeach],
                 units:[@foreach($units as $unit){id:'{{$unit->id}}',name:'{{$unit->name}}',},@endforeach],
                 logistics:[@foreach($logistics as $logistic){id:'{{$logistic->id}}',name:'{{$logistic->name}}',},@endforeach],
                 carTypes:[@foreach($carTypes as $carType){!! $carType !!},@endforeach],
@@ -411,7 +428,7 @@
                     recipient_mobile:'{{$waybill->order->consignee_phone ?? $waybill->recipient_mobile}}',ordering_remark:'{{$waybill->ordering_remark}}',
 
                     charge:'{{ old("charge") ?? $waybill->charge}}',
-                    logistic_id:'{{ $waybill->order->logistic_id ?? (old("logistic_id") ?? $waybill->logistic_id)}}',
+                    logistic_id:'{{old("logistic_id") ?? $waybill->logistic_id}}',
                     carrier_bill:'{{ old("carrier_bill") ?? $waybill->carrier_bill}}',
                     type:'{{ old("type") ?? $waybill->type}}',
                     warehouse_weight_other:'{{ old("warehouse_weight_other") ?? $waybill->warehouse_weight_other}}',
@@ -435,9 +452,11 @@
                     carrier_weight_other:'{{$waybill->carrier_weight_other}}',
                     carrier_weight_unit_id_other:'{{$waybill->carrier_weight_unit_id_other}}',
                     pick_up_fee:'{{$waybill->pick_up_fee}}',
+                    province:"",
                 },
                 order:{!! $waybill->order ?? '{}' !!},
-                waybillTemp:{!! $waybill !!}
+                waybillTemp:{!! $waybill !!},
+                provinces : [],
             },
             mounted:function(){
                 let _this=this;
@@ -597,39 +616,38 @@
                         });
                 },
                 destination_city_id:function (e) {
-                    let _this=this;
-                    let $val=e.target.value;
-                    if($val==='')_this.waybill.destination_city_id='';
-                    else
-                        _this.cities.forEach(function (city) {
-                            if (city.name.includes($val)){
-                                _this.waybill.destination_city_id=city.id;
+                    if (this.waybill.order_id)return;
+                    let val=e.target.value;
+                    if (!val)this. waybill.destination_city_id='';
+                    else this.cities.some((city)=> {
+                            if (city.name.includes(val)){
+                                this.waybill.destination_city_id=city.id;
+                                return true;
                             }
                         });
                 },
-                addCounty:function () {
-                    let _this=this;
-                    if (!_this.waybill.destination_city) {
-                        tempTip.setDuration(2000);
-                        tempTip.show('您未输入市/县!');
+                selectedProvince(){
+                    if (this.waybill.order_id)return;
+                    if (!this.waybill.destination_city) {
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.show('您未输入市/县!');
                         return;
                     }
-                    tempTip.confirm("您确认添加该市/县?", function () {
-                        let url = '{{url('waybill/addCounty?destination_city=')}}' + _this.waybill.destination_city;
-                        axios.post(url)
-                            .then(function (response) {
-                                if (response.data && response.data.destination_city) {
-                                    tempTip.setDuration(3000);
-                                    tempTip.show(response.data.destination_city[0]);
-                                    return;
-                                }
-                                _this.cities.push(response.data);
-                                _this.waybill.destination_city_id = response.data.id;
-                            }).catch(function (err) {
-                            tempTip.setDuration(3000);
-                            tempTip.show("网络错误!" + err);
+                    window.tempTip.postBasicRequest("{{url('maintenance/region/getProvinces')}}",{},res=>{
+                       this.provinces = res;
+                        $("#selectedProvince").modal("show");
+                    });
+                },
+                addCounty:function () {
+                    window.tempTip.postBasicRequest("{{url('waybill/addCounty')}}",
+                        {name:this.waybill.destination_city,province:this.waybill.province},res=>{
+                        this.cities.push({
+                            id:res.id,
+                            name:res.name,
                         });
-                    })
+                        this.waybill.destination_city_id = res.id;
+                        $("#selectedProvince").modal("hide");
+                    });
                 }
             },
         });

+ 6 - 2
resources/views/waybill/index.blade.php

@@ -108,7 +108,10 @@
                     <td class="td-warm">@{{waybill.type}} <span class="badge badge-sm bg-warning" v-if="waybill.collect_fee">到付</span></td>
                     <td class="td-warm">@{{waybill.owner}}</td>
                     <td class="td-warm toptd" :title="waybill.remark? '置顶备注:'+waybill.remark :''">@{{waybill.source_bill}}</td>
-                    <td class="td-warm" >@{{waybill.wms_bill_number}}</td>
+                    <td class="td-warm">
+                        <span class="badge badge-pill badge-danger" v-if="waybill.is_cancel">取消</span>
+                        @{{waybill.wms_bill_number}}
+                    </td>
                     <td class="td-warm">@{{waybill.waybill_number}}</td>
                     @can('运输管理-运单编辑')
                     <td class="td-warm" >
@@ -293,13 +296,14 @@
                         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 ?? ''}}' === '订单取消',
                         origination:'{{$waybill->origination}}',
                         destination:'{{$waybill->order_address ?? $waybill->destination}}',
                         recipient:'{{$waybill->order_consignee_name ?? $waybill->recipient}}',
                         recipient_mobile:'{{$waybill->order_consignee_phone ?? $waybill->recipient_mobile}}',
                         charge:'{{$waybill->charge}}',
                         ordering_remark:'{{preg_replace("/[\n\s]/",' ',($waybill->ordering_remark??""))}}',
-                        carrier:'{{$waybill->logistic_name ?? ($waybill->logistic->name ?? '')}}',
+                        carrier:'{{$waybill->logistic->name ?? ''}}',
                         carrier_bill:'{{$waybill->carrier_bill}}',
                         warehouse_weight:'{{$waybill->warehouse_weight}}',
                         warehouse_weight_unit:'{{$waybill->warehouse_weight_unit ? $waybill->warehouse_weight_unit->name : ''}}',

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

@@ -147,7 +147,7 @@
                         recipient_mobile:'{{$waybill->order->consignee_phone ?? $waybill->recipient_mobile}}',
                         charge:'{{$waybill->charge}}',
                         ordering_remark:'{{preg_replace("/[\n\s]/",' ',($waybill->ordering_remark??""))}}',
-                        carrier:'{{$waybill->order->logistic->name ?? ($waybill->logistic->name ?? '')}}',
+                        carrier:'{{$waybill->logistic->name ?? ''}}',
                         carrier_bill:'{{$waybill->carrier_bill}}',
                         origination_city:'{{$waybill->origination_city ? $waybill->origination_city->name : ''}}',
                         destination_city:'{{$waybill->order->city ?? ($waybill->destination_city->name ?? '')}}',

+ 20 - 12
routes/web.php

@@ -198,6 +198,7 @@ Route::group(['prefix'=>'maintenance'],function(){
     Route::group(['prefix'=>"region"],function (){
         Route::post("get",'RegionController@get');
         Route::post("store",'RegionController@store');
+        Route::post("getProvinces",'RegionController@getProvinces');
     });
     /** 耗材 */
     Route::get('material','MaterialController@index');;
@@ -405,6 +406,7 @@ Route::group(['prefix'=>'store'],function(){
         Route::post('insertItem','StoreCheckingReceiveController@insertItem');
         Route::get('mission','StoreCheckingReceiveController@mission');
         Route::post('destroyItem','StoreCheckingReceiveController@destroyItem');
+        Route::get('appointment','DeliveryAppointmentController@appointment');
     });
 });
 
@@ -639,6 +641,20 @@ Route::group(['prefix'=>'order'],function(){
     Route::post('isRejectedBillExist','OrderController@isRejectedBillExist');
 });
 
+/** 结算 */
+Route::group(['prefix'=>'finance'],function(){
+    Route::group(['prefix'=>'instantBill'],function(){
+        Route::match(['GET','POST'],'export','CustomerController@financeInstantBillExport');
+    });
+    Route::get('instantBill','CustomerController@financeInstantBill');
+    Route::group(['prefix'=>'billConfirmation'],function(){
+        Route::match(['GET','POST'],'export','CustomerController@financeBillConfirmationExport');
+    });
+    Route::get('billConfirmation','CustomerController@financeBillConfirmation');
+    Route::post('updateBillReport','CustomerController@updateBillReport');
+    Route::post('billConfirm','CustomerController@billConfirm');
+});
+
 /** 客户 */
 Route::group(['prefix'=>'customer'],function(){
     /** 项目 */
@@ -668,18 +684,10 @@ Route::group(['prefix'=>'customer'],function(){
         //手动生成账单
         Route::post("createReport","CustomerController@createReport");
         Route::post("createAreaReport","CustomerController@createAreaReport");
-    });
-    Route::group(['prefix'=>'finance'],function(){
-        Route::group(['prefix'=>'instantBill'],function(){
-            Route::match(['GET','POST'],'export','CustomerController@financeInstantBillExport');
-        });
-        Route::get('instantBill','CustomerController@financeInstantBill');
-        Route::group(['prefix'=>'billConfirmation'],function(){
-            Route::match(['GET','POST'],'export','CustomerController@financeBillConfirmationExport');
-        });
-        Route::get('billConfirmation','CustomerController@financeBillConfirmation');
-        Route::post('updateBillReport','CustomerController@updateBillReport');
-        Route::post('billConfirm','CustomerController@billConfirm');
+        //手动重置账单数据
+        Route::post("resetInstantBill","CustomerController@resetInstantBill");
+        Route::post("resetBillConfirmation","CustomerController@resetBillConfirmation");
+
     });
     Route::get('relating',function (){return view('customer.relating');});
     Route::group(['prefix' => 'customer'], function () {