ANG YU пре 4 година
родитељ
комит
e66729cad4
23 измењених фајлова са 948 додато и 166 уклоњено
  1. 37 9
      app/Http/Controllers/OwnerLogisticFeeDetailController.php
  2. 34 10
      app/Http/Controllers/OwnerLogisticFeeReportController.php
  3. 11 5
      app/OwnerLogisticFeeDetail.php
  4. 8 1
      app/OwnerLogisticFeeReport.php
  5. 9 48
      app/Providers/AppServiceProvider.php
  6. 57 0
      app/Services/LogisticSyncRecordService.php
  7. 34 58
      app/Services/OwnerLogisticFeeDetailService.php
  8. 91 3
      app/Services/OwnerLogisticFeeReportService.php
  9. 17 14
      database/factories/OwnerFeeDetailFactory.php
  10. 13 5
      database/factories/OwnerLogisticFeeDetailFactory.php
  11. 14 1
      database/factories/OwnerLogisticFeeReportFactory.php
  12. 38 0
      database/migrations/2021_06_08_140312_add_logistic_id_to_owner_logistic_fee_details.php
  13. 60 0
      database/migrations/2021_06_08_144247_add_column_to_owner_logistic_fee_reports.php
  14. 54 1
      database/seeds/OwnerLogisticFeeDetailSeeder.php
  15. 1 1
      database/seeds/OwnerLogisticFeeReportSeeder.php
  16. 4 3
      resources/views/finance/menu.blade.php
  17. 160 0
      resources/views/finance/settlementBills/logisticFee/detail/index.blade.php
  18. 19 0
      resources/views/finance/settlementBills/logisticFee/menu.blade.php
  19. 173 0
      resources/views/finance/settlementBills/logisticFee/report/index.blade.php
  20. 9 2
      resources/views/finance/settlementBills/menu.blade.php
  21. 3 3
      resources/views/finance/settlementBills/ownerSundryFee/index.blade.php
  22. 6 2
      routes/web.php
  23. 96 0
      tests/Services/OwnerLogisticFeeReportService/RecordReportTest.php

+ 37 - 9
app/Http/Controllers/OwnerLogisticFeeDetailController.php

@@ -2,19 +2,47 @@
 
 namespace App\Http\Controllers;
 
+use App\Owner;
 use App\OwnerLogisticFeeDetail;
+use App\Services\OwnerLogisticFeeDetailService;
 use Illuminate\Http\Request;
 
 class OwnerLogisticFeeDetailController extends Controller
 {
+    /** @var $service OwnerLogisticFeeDetailService */
+    private $service;
+
     /**
      * Display a listing of the resource.
      *
-     * @return \Illuminate\Http\Response
      */
-    public function index()
+    public function index(Request $request)
     {
-        //
+        $paginateParams = $request->input();
+        $this->service = app('OwnerLogisticFeeDetailService');
+        $this->userService = app('UserService');
+        $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
+
+        if (is_null($request->owner_id)) {
+            $owner_id = $permittingOwnerIds[0];
+        } else {
+            $owner_id = $request->owner_id;
+        }
+        if (is_null($request->start)) {
+            $start = now()->subMonth()->startOfMonth()->toDateString();
+        } else {
+            $start = $request->start;
+        }
+
+        if (is_null($request->end)) {
+            $end = now()->subMonth()->endOfMonth()->toDateString();
+        } else {
+            $end = $request->end;
+        }
+        $details = $this->service->getDetails($owner_id, $start, $end, $paginateParams);
+        $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
+        $owner = Owner::query()->selectRaw("name")->find($owner_id);
+        return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners','owner'));
     }
 
     /**
@@ -30,7 +58,7 @@ class OwnerLogisticFeeDetailController extends Controller
     /**
      * Store a newly created resource in storage.
      *
-     * @param  \Illuminate\Http\Request  $request
+     * @param \Illuminate\Http\Request $request
      * @return \Illuminate\Http\Response
      */
     public function store(Request $request)
@@ -41,7 +69,7 @@ class OwnerLogisticFeeDetailController extends Controller
     /**
      * Display the specified resource.
      *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
+     * @param \App\OwnerLogisticFeeDetail $ownerLogisticFeeDetail
      * @return \Illuminate\Http\Response
      */
     public function show(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
@@ -52,7 +80,7 @@ class OwnerLogisticFeeDetailController extends Controller
     /**
      * Show the form for editing the specified resource.
      *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
+     * @param \App\OwnerLogisticFeeDetail $ownerLogisticFeeDetail
      * @return \Illuminate\Http\Response
      */
     public function edit(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
@@ -63,8 +91,8 @@ class OwnerLogisticFeeDetailController extends Controller
     /**
      * Update the specified resource in storage.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
+     * @param \Illuminate\Http\Request $request
+     * @param \App\OwnerLogisticFeeDetail $ownerLogisticFeeDetail
      * @return \Illuminate\Http\Response
      */
     public function update(Request $request, OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
@@ -75,7 +103,7 @@ class OwnerLogisticFeeDetailController extends Controller
     /**
      * Remove the specified resource from storage.
      *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
+     * @param \App\OwnerLogisticFeeDetail $ownerLogisticFeeDetail
      * @return \Illuminate\Http\Response
      */
     public function destroy(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)

+ 34 - 10
app/Http/Controllers/OwnerLogisticFeeReportController.php

@@ -2,19 +2,43 @@
 
 namespace App\Http\Controllers;
 
+use App\Owner;
 use App\OwnerLogisticFeeReport;
+use App\Services\OwnerLogisticFeeReportService;
+use App\Services\UserService;
 use Illuminate\Http\Request;
 
 class OwnerLogisticFeeReportController extends Controller
 {
+    /* @var OwnerLogisticFeeReportService $service */
+    private $service;
+    /* @var UserService $userService */
+    private $userService;
+
     /**
      * Display a listing of the resource.
-     *
-     * @return \Illuminate\Http\Response
      */
-    public function index()
+    public function index(Request $request)
     {
-        //
+        $paginateParams = $request->input();
+        $this->service = app('OwnerLogisticFeeReportService');
+        $this->userService = app('UserService');
+        $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
+        if (is_null($request->year) || is_null($request->month)) {
+            $date = now()->subMonth()->startOfMonth()->toDateString();
+        } else {
+            $date = $request->year . '-' . $request->month . '-' . '01';
+        }
+        if (is_null($request->owner_id)) {
+            $owner_id = $permittingOwnerIds[0];
+        }else{
+            $owner_id = $request->owner_id;
+        }
+        $reports = $this->service->getRecordPagination($owner_id, $date, $paginateParams);
+        $recordTotal = $this->service->getRecordTotal($owner_id, $date);
+        $owner = Owner::query()->selectRaw("name")->find($owner_id);
+        $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
+        return view('finance.settlementBills.logisticFee.report.index', compact('reports', 'recordTotal', 'paginateParams', 'owners','owner'));
     }
 
     /**
@@ -30,7 +54,7 @@ class OwnerLogisticFeeReportController extends Controller
     /**
      * Store a newly created resource in storage.
      *
-     * @param  \Illuminate\Http\Request  $request
+     * @param \Illuminate\Http\Request $request
      * @return \Illuminate\Http\Response
      */
     public function store(Request $request)
@@ -41,7 +65,7 @@ class OwnerLogisticFeeReportController extends Controller
     /**
      * Display the specified resource.
      *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
+     * @param \App\OwnerLogisticFeeReport $ownerLogisticFeeReport
      * @return \Illuminate\Http\Response
      */
     public function show(OwnerLogisticFeeReport $ownerLogisticFeeReport)
@@ -52,7 +76,7 @@ class OwnerLogisticFeeReportController extends Controller
     /**
      * Show the form for editing the specified resource.
      *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
+     * @param \App\OwnerLogisticFeeReport $ownerLogisticFeeReport
      * @return \Illuminate\Http\Response
      */
     public function edit(OwnerLogisticFeeReport $ownerLogisticFeeReport)
@@ -63,8 +87,8 @@ class OwnerLogisticFeeReportController extends Controller
     /**
      * Update the specified resource in storage.
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
+     * @param \Illuminate\Http\Request $request
+     * @param \App\OwnerLogisticFeeReport $ownerLogisticFeeReport
      * @return \Illuminate\Http\Response
      */
     public function update(Request $request, OwnerLogisticFeeReport $ownerLogisticFeeReport)
@@ -75,7 +99,7 @@ class OwnerLogisticFeeReportController extends Controller
     /**
      * Remove the specified resource from storage.
      *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
+     * @param \App\OwnerLogisticFeeReport $ownerLogisticFeeReport
      * @return \Illuminate\Http\Response
      */
     public function destroy(OwnerLogisticFeeReport $ownerLogisticFeeReport)

+ 11 - 5
app/OwnerLogisticFeeDetail.php

@@ -5,22 +5,28 @@ namespace App;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\HasOne;
 
 class OwnerLogisticFeeDetail extends Model
 {
     use ModelLogChanging;
 
-    public $fillable = ['owner_fee_detail_id', 'logistic_bill', 'initial_weight', 'initial_weight_price', 'additional_weight', 'additional_price'];
+    public $fillable = ['owner_fee_detail_id', 'logistic_bill', 'initial_weight', 'initial_weight_price', 'additional_weight', 'additional_price','logistic_id','owner_id','additional_weigh_weight'];
 
-    public function ownerFeeDetail(): HasOne
+    public function ownerFeeDetail(): BelongsTo
     {
-        return $this->hasOne(OwnerFeeDetail::class);
+        return $this->belongsTo(OwnerFeeDetail::class);
     }
 
 
-    public function ownerFeeDetailLogistic(): HasOne
+    public function ownerFeeDetailLogistic(): BelongsTo
     {
-        return $this->hasOne(OwnerFeeDetailLogistic::class,'logistic_bill', 'logistic_bill');
+        return $this->belongsTo(OwnerFeeDetailLogistic::class,'logistic_bill', 'logistic_bill');
+    }
+
+    public function logistic(): BelongsTo
+    {
+        return $this->belongsTo(Logistic::class);
     }
 }

+ 8 - 1
app/OwnerLogisticFeeReport.php

@@ -5,10 +5,17 @@ namespace App;
 use Illuminate\Database\Eloquent\Model;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 class OwnerLogisticFeeReport extends Model
 {
     use ModelLogChanging;
 
-    //
+    public $fillable = ['owner_logistic_sum_fee_report_id', 'logistic_id', 'province', 'counted_date', 'initial_weight', 'initial_weight_price', 'initial_amount', 'additional_weight', 'additional_price', 'additional_amount', 'fee','owner_id'];
+    public $timestamps = false;
+
+    public function logistic(): BelongsTo
+    {
+        return $this->belongsTo(Logistic::class);
+    }
 }

+ 9 - 48
app/Providers/AppServiceProvider.php

@@ -137,7 +137,7 @@ use App\Services\LogisticAliJiSuApiService;
 use App\Services\CommodityMaterialBoxModelService;
 use App\Services\OwnerLogisticFeeDetailService;
 use App\Services\OwnerLogisticFeeReportService;
-use App\Services\LaborCompanyService;
+use App\Services\LogisticSyncRecordService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -165,8 +165,10 @@ class AppServiceProvider extends ServiceProvider
             $payload = $event->job->payload();
             $displayName = $payload['displayName'];
             //快递信息同步失败计数
-            if ($this->isLogisticSyncJob($displayName)) {
-                $this->logisticSyncRecord($displayName, 'failed_count');
+            /** @var  $logisticSyncRecordService  LogisticSyncRecordService*/
+            $logisticSyncRecordService = app("LogisticSyncRecordService");
+            if ($logisticSyncRecordService->isLogisticSyncJob($displayName)) {
+                $logisticSyncRecordService->logisticSyncRecord($displayName, 'failed_count');
             }
         });
         //扩展身份证验证规则
@@ -193,8 +195,10 @@ class AppServiceProvider extends ServiceProvider
             //快递信息同步成功计数
             $payload = $event->job->payload();
             $displayName = $payload['displayName'];
-            if ($this->isLogisticSyncJob($displayName)) {
-                $this->logisticSyncRecord($displayName, 'succeed_count');
+            /** @var  $logisticSyncRecordService  LogisticSyncRecordService*/
+            $logisticSyncRecordService = app("LogisticSyncRecordService");
+            if ($logisticSyncRecordService->isLogisticSyncJob($displayName)) {
+                $logisticSyncRecordService->logisticSyncRecord($displayName, 'succeed_count');
             }
         });
     }
@@ -202,7 +206,6 @@ class AppServiceProvider extends ServiceProvider
     private function loadingService(){
         app()->singleton('AllInventoryService',AllInventoryService::class);
         app()->singleton('AuthorityService',AuthorityService::class);
-        app()->singleton('NewOrderCountingRecordService',NewOrderCountingRecordService::class);
         app()->singleton('BatchService',BatchService::class);
         app()->singleton('BatchUpdateService', BatchUpdateService::class);
         app()->singleton('CacheService',CacheService::class);
@@ -324,46 +327,4 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('HengLiWeightService',HengLiWeightService::class);
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
     }
-
-    /**
-     * 快递同步接口 同步情况统计
-     */
-    private function logisticSyncRecord($displayName, $column_name): void
-    {
-
-
-        /**
-         * @var OrderPackageReceivedSyncRecordService $orderPackageReceivedSyncRecordService
-         */
-        $orderPackageReceivedSyncRecordService = app('OrderPackageReceivedSyncRecordService');
-        switch ($displayName) {
-            case LogisticZopSync::class:
-                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('中通', now()->toDateString(), $column_name);
-                break;
-            case LogisticSFSync::class:
-                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('顺丰', now()->toDateString(), $column_name);
-                break;
-            case LogisticYDSync::class:
-                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('韵达', now()->toDateString(), $column_name);
-                break;
-            case LogisticYTOSync::class:
-                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('圆通', now()->toDateString(), $column_name);
-                break;
-            default:
-                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('其他', now()->toDateString(), $column_name);
-        }
-    }
-
-    /**
-     * 判断当前任务类型是否为快递信息同步
-     * @param $displayName
-     * @return bool
-     */
-    private function isLogisticSyncJob($displayName): bool
-    {
-        return ($displayName == LogisticZopSync::class)
-            || ($displayName == LogisticSFSync::class)
-            || ($displayName == LogisticYDSync::class)
-            || ($displayName == LogisticYTOSync::class);
-    }
 }

+ 57 - 0
app/Services/LogisticSyncRecordService.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace App\Services;
+
+use App\Jobs\LogisticSFSync;
+use App\Jobs\LogisticYDSync;
+use App\Jobs\LogisticYTOSync;
+use App\Jobs\LogisticZopSync;
+use App\Traits\ServiceAppAop;
+
+class LogisticSyncRecordService
+{
+    use ServiceAppAop;
+
+
+    /**
+     * 快递同步接口 同步情况统计
+     */
+    public function logisticSyncRecord($displayName, $column_name): void
+    {
+
+
+        /**
+         * @var OrderPackageReceivedSyncRecordService $orderPackageReceivedSyncRecordService
+         */
+        $orderPackageReceivedSyncRecordService = app('OrderPackageReceivedSyncRecordService');
+        switch ($displayName) {
+            case LogisticZopSync::class:
+                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('中通', now()->toDateString(), $column_name);
+                break;
+            case LogisticSFSync::class:
+                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('顺丰', now()->toDateString(), $column_name);
+                break;
+            case LogisticYDSync::class:
+                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('韵达', now()->toDateString(), $column_name);
+                break;
+            case LogisticYTOSync::class:
+                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('圆通', now()->toDateString(), $column_name);
+                break;
+            default:
+                $orderPackageReceivedSyncRecordService->createOrIncrementSucceededCount('其他', now()->toDateString(), $column_name);
+        }
+    }
+
+    /**
+     * 判断当前任务类型是否为快递信息同步
+     * @param $displayName
+     * @return bool
+     */
+    public function isLogisticSyncJob($displayName): bool
+    {
+        return ($displayName == LogisticZopSync::class)
+            || ($displayName == LogisticSFSync::class)
+            || ($displayName == LogisticYDSync::class)
+            || ($displayName == LogisticYTOSync::class);
+    }
+}

+ 34 - 58
app/Services/OwnerLogisticFeeDetailService.php

@@ -2,11 +2,13 @@
 
 namespace App\Services;
 
+use App\Logistic;
 use App\OwnerFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeDetail;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Pagination\LengthAwarePaginator;
 use Illuminate\Support\Collection;
 
 class OwnerLogisticFeeDetailService
@@ -25,71 +27,45 @@ class OwnerLogisticFeeDetailService
      * @param string $owner_id
      * @param string $start
      * @param string $end
-     * @return array
+     * @return LengthAwarePaginator
      */
-    public function getDetails(string $owner_id, string $start, string $end): array
+    public function getDetails(string $owner_id, string $start, string $end, $paginateParams): LengthAwarePaginator
     {
-        $ownerFeeDetailIds = OwnerFeeDetail::query()->selectRaw('id')
+        $logistic_ids = Logistic::query()->selectRaw('id')->where('type', '快递');
+        $ownerFeeDetailQuery = OwnerFeeDetail::query()->selectRaw('id')
             ->where('type', '发货')
             ->where('outer_table_name', 'orders')
-            ->whereHas('logistic', function (Builder $query) {
-                $query->where('type', '快递');
-            })
+            ->whereIn('logistic_id', $logistic_ids)
             ->where('owner_id', $owner_id)
             ->where('worked_at', '>=', Carbon::parse($start)->startOfDay())
-            ->where('worked_at', '<=', Carbon::parse($end)->endOfDay())->pluck('id');
-        $ownerLogisticFeeDetails = OwnerLogisticFeeDetail::query()->with(['ownerFeeDetail.logistic', 'ownerFeeDetailLogistic'])->whereIn('owner_fee_detail_id', $ownerFeeDetailIds)->paginate();
-        dd($ownerLogisticFeeDetails);
+            ->where('worked_at', '<=', Carbon::parse($end)->endOfDay());
 
-//         $ownerFeeDetails = OwnerFeeDetail::query()
-//            ->with(['ownerLogisticFeeDetail:id,logistic_bill,initial_weight_price,additional_price', 'items.logistic:id,name','items.ownerLogisticFeeDetail:id,logistic_bill,initial_weight_price,additional_price', 'logistic:id,name,type'])
-//            ->where('type', '发货')
-//            ->where('outer_table_name', 'orders')
-//            ->whereHas('logistic', function (Builder $query) {
-//                $query->where('type', '快递');
-//            })
-//            ->where('owner_id', $owner_id)
-//            ->where('worked_at', '>=', Carbon::parse($start)->startOfDay())
-//            ->where('worked_at', '<=', Carbon::parse($end)->endOfDay())
-//            ->get();
-//        $result = [];
-//        foreach ($ownerFeeDetails as $ownerFeeDetail) {
-//            if ($ownerFeeDetail->items->count()==0) {//只有一个包裹
-//                $result[] = [
-//                    'logistic_name' => $ownerFeeDetail->logistic->name ?? '',//快递公司
-//                    'province' => $ownerFeeDetail->province,//省份
-//                    'logistic_bill' => $ownerFeeDetail->logistic_bill ?? '',//快递单号
-//                    'weight' => $ownerFeeDetail->weight,//重量
-//                    'logistic_fee' => $ownerFeeDetail->logistic_fee,//快递费
-//                    'initial_weight_price' => $ownerFeeDetail->ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
-//                    'additional_price' => $ownerFeeDetail->ownerLogisticFeeDetail->additional_price ?? '',//续重价格
-//                ];
-//            } else {//多个包裹
-//                foreach ($ownerFeeDetail->items as $ownerFeeDetailLogistic) {
-//                    $result[] = [
-//                        'logistic_name' => $ownerFeeDetail->logistic->name ?? '',//快递公司
-//                        'province' => $ownerFeeDetail->province,//省份
-//                        'logistic_bill' => $ownerFeeDetailLogistic->logistic_bill,//快递单号
-//                        'weight' => $ownerFeeDetailLogistic->weight,//重量
-//                        'logistic_fee' => $ownerFeeDetailLogistic->logistic_fee,//快递费
-//                        'initial_weight_price' => $ownerFeeDetailLogistic->ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
-//                        'additional_price' => $ownerFeeDetailLogistic->ownerLogisticFeeDetail->additional_price ?? '',//续重价格
-//                    ];
-//                }
-//            }
-//        }
-        $result = [];
-        foreach ($ownerLogisticFeeDetails->items() as $ownerLogisticFeeDetail) {
-                $result[] = [
-                    'logistic_name' => $ownerLogisticFeeDetail->ownerFeeDetail->logistic->name ?? '',//快递公司
-                    'province' => $ownerLogisticFeeDetail->ownerFeeDetail->province,//省份
-                    'logistic_bill' => $ownerLogisticFeeDetail->logistic_bill ?? '',//快递单号
-                    'weight' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->weight,//重量
-                    'logistic_fee' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->logistic_fee,//快递费
-                    'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
-                    'additional_price' => $ownerLogisticFeeDetail->additional_price ?? '',//续重价格
-                ];
+        $ownerLogisticFeeDetails = OwnerLogisticFeeDetail::query()->with([
+            'ownerFeeDetail:id,province,weight,logistic_fee',
+            'ownerFeeDetailLogistic:id,weight,logistic_fee,logistic_bill',
+            'logistic:id,name'
+        ])
+            ->whereIn('owner_fee_detail_id', $ownerFeeDetailQuery)
+            ->orderBy('logistic_id')
+            ->paginate($paginateParams['paginate'] ?? 50);
+        $items = [];
+        foreach ($ownerLogisticFeeDetails as $ownerLogisticFeeDetail) {
+            $items[] = [
+                'logistic_name' => $ownerLogisticFeeDetail->logistic->name ?? '',//快递公司
+                'province' => $ownerLogisticFeeDetail->province,//省份
+                'logistic_bill' => $ownerLogisticFeeDetail->logistic_bill ?? '',//快递单号
+                'weight' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->weight ?? $ownerLogisticFeeDetail->ownerFeeDetail->weight ?? '0.00',//重量
+                'logistic_fee' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->logistic_fee ?? $ownerLogisticFeeDetail->ownerFeeDetail->logistic_fee ?? '0.00',//快递费
+                'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
+                'additional_price' => $ownerLogisticFeeDetail->additional_price ?? '',//续重价格
+            ];
         }
-        return $result;
+        return new LengthAwarePaginator(
+            $items,
+            $ownerLogisticFeeDetails->total(),
+            $ownerLogisticFeeDetails->perPage(),
+            $ownerLogisticFeeDetails->currentPage(),
+            ["path" => $ownerLogisticFeeDetails->path(), "pageName" => "page"]
+        );
     }
 }

+ 91 - 3
app/Services/OwnerLogisticFeeReportService.php

@@ -1,13 +1,101 @@
-<?php 
+<?php
 
 namespace App\Services;
 
+use App\OwnerLogisticFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeReport;
+use Carbon\Carbon;
+use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 
 class OwnerLogisticFeeReportService
 {
     use ServiceAppAop;
-    protected $modelClass=OwnerLogisticFeeReport::class;
 
-}
+    protected $modelClass = OwnerLogisticFeeReport::class;
+
+    private $reportDate;
+
+    /**
+     * 生成报表数据
+     * 如果参数$date为空 统计上一个月的
+     * 如果参数$date为2021-01-01 则统计2021-01-01 -- 2021-01-31之间的数据
+     * @param null $date 统计月份,默认统计上个月的 2021-05-01
+     */
+    public function recordReport($date = null)
+    {
+        if (is_null($date)) {
+            //默认统计上个月的数据
+            $date = now()->subMonth()->startOfMonth()->toDateTimeString();
+        }
+        $this->reportDate = $date;
+
+        $start = $this->reportDate;
+        $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateTimeString();
+
+
+        $ownerLogisticFeeDetails = OwnerLogisticFeeDetail::query()
+            ->selectRaw("logistic_id,province,DATE_FORMAT(created_at,'%Y-%m-%d') as counted_date,initial_weight,initial_weight_price,count(1) as initial_amount,additional_price,additional_weight,sum(additional_weigh_weight) as additional_amount,created_at,owner_id")
+            ->whereBetween('created_at', [$start, $end])
+            ->groupBy('initial_weight', 'initial_weight_price', 'additional_price', 'additional_weight', 'logistic_id', 'province', 'counted_date', 'owner_id')
+            ->get();
+        $ownerLogisticFeeReportArray = [];
+
+        foreach ($ownerLogisticFeeDetails as $ownerLogisticFeeDetail) {
+            $ownerLogisticFeeReportArray[] = [
+                'logistic_id' => $ownerLogisticFeeDetail->logistic_id,
+                'province' => $ownerLogisticFeeDetail->province,
+                'counted_date' => Carbon::parse($ownerLogisticFeeDetail->counted_date)->firstOfMonth()->toDateString(),
+                'initial_weight' => $ownerLogisticFeeDetail->initial_weight,
+                'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price,
+                'initial_amount' => $ownerLogisticFeeDetail->initial_amount,
+                'additional_weight' => $ownerLogisticFeeDetail->additional_weight,
+                'additional_price' => $ownerLogisticFeeDetail->additional_price,
+                'additional_amount' => $ownerLogisticFeeDetail->additional_amount,
+                'fee' => ($ownerLogisticFeeDetail['initial_weight_price'] * $ownerLogisticFeeDetail['initial_amount']) + ($ownerLogisticFeeDetail['additional_amount'] * $ownerLogisticFeeDetail['additional_price']),
+                'owner_id' => $ownerLogisticFeeDetail->owner_id,
+            ];
+        }
+        OwnerLogisticFeeReport::query()->insertOrIgnore($ownerLogisticFeeReportArray);
+    }
+
+    /**
+     * 订单统计分页查询
+     * @param $owner_id
+     * @param $date string 查询的年月 2021-05-01
+     * @param $paginateParams
+     * @return LengthAwarePaginator
+     */
+    public function getRecordPagination($owner_id, string $date,$paginateParams): LengthAwarePaginator
+    {
+        return OwnerLogisticFeeReport::query()
+            ->with('logistic:id,name')
+            ->where('owner_id', $owner_id)
+            ->where('counted_date', $date)
+            ->orderByDesc('logistic_id')
+            ->orderByDesc('province')
+            ->paginate($paginateParams['paginate']??50);
+    }
+
+    /**
+     * 订单总计查询
+     * @param $owner_id
+     * @param $date string 查询的年月 2021-05-01
+     * @return array
+     */
+    public function getRecordTotal($owner_id, string $date): array
+    {
+        $logistic_fee = OwnerLogisticFeeReport::query()
+            ->where('owner_id', $owner_id)
+            ->where('counted_date', $date)
+            ->sum('fee');
+        $order_count = (int)OwnerLogisticFeeReport::query()
+            ->where('owner_id', $owner_id)
+            ->where('counted_date', $date)
+            ->sum('initial_amount');
+        return [
+            'logistic_fee' => $logistic_fee,
+            'order_count' => $order_count,
+        ];
+    }
+}

+ 17 - 14
database/factories/OwnerFeeDetailFactory.php

@@ -6,20 +6,23 @@ use App\OwnerFeeDetail;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerFeeDetail::class, function (Faker $faker) {
-    $type = ["发货","收货","增值服务"];
+    $type = ["发货", "收货", "增值服务"];
+    $province = ['北京', '广东省', '湖北省', '广东省', '四川省', '上海', '山西省', '上海', '江西省', '贵州省', '湖南省', '广东省', '云南省', '山东省', '贵州省', '云南省', '新疆维吾尔自治区', '辽宁省', '福建省'];
+
     return [
-        "owner_id"          => factory(\App\Owner::class),         //货主ID
-        "worked_at"         => $faker->date(),//作业时间
-        "type"              => $type[array_rand($type)],//类型
-        "shop_id"           => factory(\App\Shop::class),//店铺ID
-        "operation_bill"    => \Illuminate\Support\Str::random(10),//发/收/退/提货单号
-        "consignee_name"    => $faker->name,   //收件人
-        "consignee_phone"   => $faker->phoneNumber,  //收件人电话
-        "commodity_amount"  => mt_rand(0,100), //商品数量
-        "logistic_bill"     => \Illuminate\Support\Str::random(12),    //快递单号
-        "volume"            => mt_rand(10,2600) / 88,//体积
-        "weight"            => mt_rand(10,2600) / 88,           //重量
-        "work_fee"          =>mt_rand(100,10000) / 10,         //作业费
-        "logistic_fee"      =>mt_rand(100,10000) / 10,     //物流费
+        "owner_id" => factory(\App\Owner::class),         //货主ID
+        "worked_at" => $faker->date(),//作业时间
+        "type" => $type[array_rand($type)],//类型
+        "shop_id" => factory(\App\Shop::class),//店铺ID
+        "operation_bill" => \Illuminate\Support\Str::random(10),//发/收/退/提货单号
+        "consignee_name" => $faker->name,   //收件人
+        "consignee_phone" => $faker->phoneNumber,  //收件人电话
+        "commodity_amount" => mt_rand(0, 100), //商品数量
+        "logistic_bill" => \Illuminate\Support\Str::random(12),    //快递单号
+        "volume" => mt_rand(10, 2600) / 88,//体积
+        "weight" => mt_rand(10, 2600) / 88,           //重量
+        "work_fee" => mt_rand(100, 10000) / 10,         //作业费
+        "logistic_fee" => mt_rand(100, 10000) / 10,     //物流费
+        "province" => $faker->randomElement($province),     //物流费
     ];
 });

+ 13 - 5
database/factories/OwnerLogisticFeeDetailFactory.php

@@ -6,12 +6,20 @@ use App\OwnerLogisticFeeDetail;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerLogisticFeeDetail::class, function (Faker $faker) {
+    $province = ['北京', '广东省', '湖北省', '广东省', '四川省', '上海', '山西省', '上海', '江西省', '贵州省', '湖南省', '广东省', '云南省', '山东省', '贵州省', '云南省', '新疆维吾尔自治区', '辽宁省', '福建省'];
+    $logistic_ids = \App\Logistic::query()->pluck('id')->toArray();
     return [
-        'owner_fee_detail_id'=>random_int(1,100),
-        'logistic_bill'=>$faker->uuid,
-        'initial_weight'=>random_int(1,100),
-        'initial_weight_price'=>random_int(1,100),
-        'additional_weight'=>random_int(1,100),
+        'owner_fee_detail_id' => random_int(1, 100),
+        'logistic_bill' => $faker->uuid,
+        'initial_weight' => random_int(1, 100),
+        'initial_weight_price' => random_int(1, 100),
+        'additional_weight' => random_int(1, 100),
         'additional_price' => random_int(1, 100),
+        'logistic_id' => $faker->randomElement($logistic_ids),
+        'province' => $faker->randomElement($province),
+        'owner_id' => 8,
+        'additional_weigh_weight' => random_int(1, 100),
+        'created_at' => now()->subMonth()->startOfMonth()->addDays(random_int(1, 28))->toDateTimeString(),
+        'updated_at' => now()->subMonth()->startOfMonth()->addDays(random_int(1, 28))->toDateTimeString(),
     ];
 });

+ 14 - 1
database/factories/OwnerLogisticFeeReportFactory.php

@@ -6,7 +6,20 @@ use App\OwnerLogisticFeeReport;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerLogisticFeeReport::class, function (Faker $faker) {
+    $province = ['北京', '广东省', '湖北省', '广东省', '四川省', '上海', '山西省', '上海', '江西省', '贵州省', '湖南省', '广东省', '云南省', '山东省', '贵州省', '云南省', '新疆维吾尔自治区', '辽宁省', '福建省'];
+    $logistic_ids = \App\Logistic::query()->pluck('id')->toArray();
     return [
-        //
+        'owner_logistic_sum_fee_report_id' => random_int(1, 100),
+        'logistic_id' => $faker->randomElement($logistic_ids),
+        'province' => $faker->randomElement($province),
+        'counted_date' => now()->subMonths(random_int(1,12))->startOfMonth()->toDateString(),
+        'initial_weight' => random_int(1, 100),
+        'initial_weight_price' => random_int(1, 100),
+        'initial_amount' => random_int(1, 100),
+        'additional_weight' => random_int(1, 100),
+        'additional_price' => random_int(1, 100),
+        'additional_amount' => random_int(1, 100),
+        'fee' => random_int(1, 100),
+        'owner_id' => 8,
     ];
 });

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

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddLogisticIdToOwnerLogisticFeeDetails extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_logistic_fee_details', function (Blueprint $table) {
+            $table->integer('logistic_id');
+            $table->integer('owner_id');
+            $table->string('province')->comment('省份');
+            $table->decimal('additional_weigh_weight')->comment('续重重量');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_logistic_fee_details', function (Blueprint $table) {
+            $table->dropColumn('logistic_id');
+            $table->dropColumn('province');
+            $table->dropColumn('owner_id');
+            $table->dropColumn('additional_weigh_weight');
+        });
+    }
+}

+ 60 - 0
database/migrations/2021_06_08_144247_add_column_to_owner_logistic_fee_reports.php

@@ -0,0 +1,60 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnToOwnerLogisticFeeReports extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owner_logistic_fee_reports', function (Blueprint $table) {
+            $table->integer('owner_logistic_sum_fee_report_id');
+            $table->integer('logistic_id');
+            $table->string('province');
+            $table->date('counted_date')->comment('统计年月');
+            $table->decimal('initial_weight')->comment('首重');
+            $table->decimal('initial_weight_price')->comment('首重价格');
+            $table->integer('initial_amount')->comment('首重计量');
+            $table->decimal('additional_weight')->comment('续重');
+            $table->decimal('additional_price')->comment('续重价格');
+            $table->decimal('additional_amount')->comment('续重计量');
+            $table->decimal('fee')->comment('费用');
+            $table->integer('owner_id')->comment('货主');
+
+            $table->dropColumn('created_at');
+            $table->dropColumn('updated_at');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owner_logistic_fee_reports', function (Blueprint $table) {
+            $table->dropColumn('owner_logistic_sum_fee_report_id');
+            $table->dropColumn('logistic_id');
+            $table->dropColumn('province');
+            $table->dropColumn('counted_date');
+            $table->dropColumn('initial_weight');
+            $table->dropColumn('initial_weight_price');
+            $table->dropColumn('initial_amount');
+            $table->dropColumn('additional_weight');
+            $table->dropColumn('additional_price');
+            $table->dropColumn('additional_amount');
+            $table->dropColumn('fee');
+            $table->dropColumn('owner_id');
+
+            $table->timestamp('created_at');
+            $table->timestamp('updated_at');
+        });
+    }
+}

+ 54 - 1
database/seeds/OwnerLogisticFeeDetailSeeder.php

@@ -1,5 +1,8 @@
 <?php
 
+use App\OwnerFeeDetail;
+use App\OwnerLogisticFeeDetail;
+use Carbon\Carbon;
 use Illuminate\Database\Seeder;
 
 class OwnerLogisticFeeDetailSeeder extends Seeder
@@ -11,6 +14,56 @@ class OwnerLogisticFeeDetailSeeder extends Seeder
      */
     public function run()
     {
-        //
+//        $ownerFeeDetails = OwnerFeeDetail::query()
+//            ->with('items')
+//            ->where('type', '发货')
+//            ->where('outer_table_name', 'orders')
+//            ->whereHas('logistic', function ($query) {
+//                $query->where('type', '快递');
+//            })
+//            ->where('owner_id', [12])
+//            ->where('worked_at', '>=', Carbon::parse('2021-05-30')->startOfDay())
+//            ->where('worked_at', '<=', Carbon::parse('2021-05-31')->endOfDay())
+//            ->get();
+//        foreach ($ownerFeeDetails as $ownerFeeDetail) {
+//            factory(\App\OwnerLogisticFeeDetail::class)->create([
+//                'owner_fee_detail_id' => $ownerFeeDetail->id,
+//                'logistic_bill' => $ownerFeeDetail->items->first()->logistic_bill??$ownerFeeDetail->logistic_bill,
+//                'logistic_id'=>$ownerFeeDetail->logistic_id,
+//                'province'=>$ownerFeeDetail->province
+//            ]);
+//        }
+//        factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
+//            [
+//                'created_at' =>now()->subMonth()->startOfMonth()->addDays(1),
+//                'updated_at' => now()->subMonth()->startOfMonth()->addDays(2)
+//            ]
+//        );
+//
+//        factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
+//            [
+//                'created_at' =>now()->subMonth()->startOfMonth()->addDays(2),
+//                'updated_at' => now()->subMonth()->startOfMonth()->addDays(3)
+//            ]
+//        );
+//
+//        factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
+//            [
+//                'created_at' =>now()->subMonth()->startOfMonth()->addDays(3),
+//                'updated_at' => now()->subMonth()->startOfMonth()->addDays(4)
+//            ]
+//        );
+
+        factory(OwnerLogisticFeeDetail::class)->times(200)->create();
+        $details = OwnerLogisticFeeDetail::all();
+        foreach ($details as $detail) {
+            factory(OwnerFeeDetail::class)->create([
+                'type' => '发货',
+                'outer_table_name'=>'orders',
+                'logistic_id'=>$detail->logistic_id,
+                'owner_id'=>$detail->owner_id,
+                'worked_at'=>now()->subMonth()->startOfMonth()->addDays(random_int(1,28)) ->toDateTimeString(),
+            ]);
+        }
     }
 }

+ 1 - 1
database/seeds/OwnerLogisticFeeReportSeeder.php

@@ -11,6 +11,6 @@ class OwnerLogisticFeeReportSeeder extends Seeder
      */
     public function run()
     {
-        //
+        factory(\App\OwnerLogisticFeeReport::class)->times(100)->create(['counted_date'=>'2021-05-01']);
     }
 }

+ 4 - 3
resources/views/finance/menu.blade.php

@@ -10,9 +10,10 @@
                 <a target="finance/billConfirmation" class="nav-link" href="{{url('finance/billConfirmation')}}" :class="{active:isActive('billConfirmation',2)}">账单确认</a>
             </li>@endcan
 {{--            @can('结算管理-结算账单')--}}
-{{--                <li class="nav-item">--}}
-{{--                    <a target="finance/settlementBills" class="nav-link" href="{{url('finance/settlementBills/ownerSundryFeeDetails')}}" :class="{active:isActive('settlementBills',2)}">结算账单</a>--}}
-{{--                </li>@endcan--}}
+                <li class="nav-item">
+                    <a target="finance/settlementBills" class="nav-link" href="{{url('finance/settlementBills/logisticFee/report')}}" :class="{active:isActive('settlementBills',2)}">结算账单</a>
+                </li>
+{{--                @endcan--}}
         </ul>
     </div>
 </div>

+ 160 - 0
resources/views/finance/settlementBills/logisticFee/detail/index.blade.php

@@ -0,0 +1,160 @@
+@extends('layouts.app')
+
+@section('content')
+    @component("finance.settlementBills.logisticFee.menu")@endcomponent
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="form-inline" id="btn"></div>
+            <div class="row">
+                <span class="fa fa-user fa-4x offset-md-3" style="color: #4c2584;opacity: 0.3"></span>
+                <span class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">{{ $owner->name }}</h5>
+                                <p class="text-muted">货主</p>
+                            </span>
+            </div>
+            <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
+                <tr v-for="(detail,i) in details"
+                    @click="selectTr===i+1?selectTr=0:selectTr=i+1"
+                    :class="selectTr===i+1?'focusing' : ''">
+                    <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
+                    <td>@{{ i+1 }}</td>
+                    <td v-if="i==0 || detail.logistic_name!== details[i-1].logistic_name"
+                        :rowspan="calRowspan(detail.logistic_name)" class="text-center pt-4">@{{ detail.logistic_name }}
+                    </td>
+                    <td>@{{ detail.province }}</td>
+                    <td>@{{ detail.logistic_bill }}</td>
+                    <td>@{{ detail.weight }}</td>
+                    <td>@{{ detail.initial_weight_price }}</td>
+                    <td>@{{ detail.additional_price }}</td>
+                    <td>@{{ detail.logistic_fee }}</td>
+                </tr>
+            </table>
+            <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>
+            {{$details->appends($paginateParams)->links()}}
+        </div>
+        <textarea id="clipboardDiv" style="opacity:0"></textarea>
+    </div>
+@endsection
+@section('lastScript')
+    <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
+    <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
+    <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
+    <script>
+        let vue = new Vue({
+            el: "#list",
+            data: {
+                details: [
+                        @foreach($details as $detail)
+                    {
+                        logistic_name: " {!! $detail['logistic_name'] !!}",
+                        province: " {!! $detail['province'] !!}",
+                        logistic_bill: "{!! $detail['logistic_bill'] !!}",
+                        weight: "{!! $detail['weight'] !!}",
+                        logistic_fee: "{!! $detail['logistic_fee'] !!}",
+                        initial_weight_price: "{!! $detail['initial_weight_price'] !!}",
+                        additional_price: "{!! $detail['additional_price'] !!}"
+                    },
+                    @endforeach
+                ],
+                owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                selectTr: 0,
+            },
+            created() {
+            },
+            mounted() {
+                $('#list').removeClass('d-none');
+                let _this = this;
+                $(".up").slideUp();
+                let data = [
+                    [
+                        {
+                            name: 'owner_id',
+                            type: 'select',
+                            tip: ['多货主权限选择查看指定货主,默认为权限下的第一个货主'],
+                            placeholder: ['货主'],
+                            data: _this.owners,
+                        },
+                        {
+                            name: 'year',
+                            type: 'select',
+                            tip: ['默认为时间上一个月所属年份'],
+                            placeholder: ['年'],
+                            data: [
+                                {name: 2021, value: 2021},
+                                {name: 2022, value: 2022},
+                                {name: 2023, value: 2023},
+                                {name: 2024, value: 2024},
+                                {name: 2025, value: 2025},
+                                {name: 2026, value: 2026},
+                                {name: 2027, value: 2027},
+                                {name: 2028, value: 2028},
+                                {name: 2029, value: 2029},
+                                {name: 2030, value: 2030},
+                                {name: 2031, value: 2031},
+                                {name: 2032, value: 2032},
+                                {name: 2033, value: 2033},
+                                {name: 2034, value: 2034},
+                                {name: 2035, value: 2035},
+                                {name: 2036, value: 2036},
+
+                            ],
+                        },
+                        {
+                            name: 'month',
+                            type: 'select',
+                            tip: ['默认为上一月'],
+                            placeholder: ['月'],
+                            data: [
+                                {name: 1, value: 1},
+                                {name: 2, value: 2},
+                                {name: 3, value: 3},
+                                {name: 4, value: 4},
+                                {name: 5, value: 5},
+                                {name: 6, value: 6},
+                                {name: 7, value: 7},
+                                {name: 8, value: 8},
+                                {name: 9, value: 9},
+                                {name: 10, value: 10},
+                                {name: 11, value: 11},
+                                {name: 12, value: 12},
+                            ],
+                        },
+                    ]
+                ];
+                _this.form = new query({
+                    el: '#form_div',
+                    condition: data,
+                });
+                _this.form.init();
+                let column = [
+                    {name: 'index', value: '序号', neglect: true},
+                    {name: 'logistic_name', value: '快递公司'},
+                    {name: 'province', value: '省份'},
+                    {name: 'logistic_bill', value: '快递单号'},
+                    {name: 'weight', value: '重量'},
+                    {name: 'initial_weight_price', value: '首重价格'},
+                    {name: 'additional_price', value: '续重价格'},
+                    {name: 'logistic_fee', value: '快递费'},
+                ];
+                new Header({
+                    el: "table",
+                    name: "detail",
+                    column: column,
+                    data: this.details,
+                    restorationColumn: 'addtime',
+                    fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
+                }).init();
+            },
+            methods: {
+                calRowspan(logistic_name) {
+                    return this.details.filter(item => item.logistic_name == logistic_name).length;
+
+                }
+            },
+            filters: {},
+        });
+    </script>
+@endsection

+ 19 - 0
resources/views/finance/settlementBills/logisticFee/menu.blade.php

@@ -0,0 +1,19 @@
+<div id="nav2">
+    @component('finance.settlementBills.menu')@endcomponent
+    <div class="container-fluid nav4">
+        <div class="card menu-third">
+            <ul class="nav nav-pills">
+                <li class="nav-item">
+                    <a target="finance/settlementBills/logisticFee/report" class="nav-link"
+                       href="{{url('finance/settlementBills/logisticFee/report')}}"
+                       :class="{active:isActive('report',4)}">合计</a>
+                </li>
+                <li class="nav-item">
+                    <a target="finance/settlementBills/logisticFee/detail" class="nav-link"
+                       href="{{url('finance/settlementBills/logisticFee/detail')}}"
+                       :class="{active:isActive('detail',4)}">详情</a>
+                </li>
+            </ul>
+        </div>
+    </div>
+</div>

+ 173 - 0
resources/views/finance/settlementBills/logisticFee/report/index.blade.php

@@ -0,0 +1,173 @@
+@extends('layouts.app')
+
+@section('content')
+    @component("finance.settlementBills.logisticFee.menu")@endcomponent
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="form-inline" id="btn"></div>
+            <div class="row">
+                <div class="col-4">
+                    <div class="row pt-2">
+                        <span class="fa fa-user fa-4x offset-md-3" style="color: #4c2584;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">{{ $owner->name }}</h5>
+                                <p class="text-muted">货主</p>
+                            </span>
+                    </div>
+                </div>
+                <div class="col-4">
+                    <div class="row pt-2">
+                        <span class="fa fa-cubes fa-4x offset-md-3" style="color: #9fcdff;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">{{ $recordTotal['order_count'] }}</h5>
+                                <p class="text-muted">订单量总计</p>
+                            </span>
+                    </div>
+                </div>
+                <div class="col-4">
+                    <div class="row pt-2">
+                        <span class="fa fa-jpy fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                        <h5 class="font-weight-bold">{{ $recordTotal['logistic_fee'] }}</h5>
+                        <p class="text-muted">快递金额总计</p>
+                        </span>
+                    </div>
+                </div>
+            </div>
+            <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
+                <tr v-for="(report,i) in reports"
+                    @click="selectTr===i+1?selectTr=0:selectTr=i+1"
+                    :class="selectTr===i+1?'focusing' : ''">
+                    <td><input class="checkItem" type="checkbox" :value="report.id"></td>
+                    <td>@{{ i+1 }}</td>
+                    <td v-if="i==0 || report.logistic.name!== reports[i-1].logistic.name"
+                        :rowspan="calRowspan(report.logistic.name)" class="text-center pt-4">@{{ report.logistic.name }}
+                    </td>
+                    <td>@{{ report.province }}</td>
+                    <td>@{{ report.initial_weight }}</td>
+                    <td>@{{ report.initial_amount }}</td>
+                    <td>@{{ report.additional_weight }}</td>
+                    <td>@{{ report.additional_amount }}</td>
+                    <td>@{{ report.fee }}</td>
+                </tr>
+            </table>
+            <div class="text-info h5 btn btn">{{$reports->count()}}/{{$reports->total()}}</div>
+            {{$reports->appends($paginateParams)->links()}}
+        </div>
+        <textarea id="clipboardDiv" style="opacity:0"></textarea>
+    </div>
+@endsection
+@section('lastScript')
+    <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
+    <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
+    <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
+    <script>
+        let vue = new Vue({
+            el: "#list",
+            data: {
+                reports: [
+                    @foreach($reports as $report)
+                        {!! $report !!},
+                    @endforeach
+                ],
+                owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                selectTr: 0,
+            },
+            created() {
+            },
+            mounted() {
+                $('#list').removeClass('d-none');
+                let _this = this;
+                $(".up").slideUp();
+                let data = [
+                    [
+                        {
+                            name: 'owner_id',
+                            type: 'select',
+                            tip: ['多货主权限选择查看指定货主,默认为权限下的第一个货主'],
+                            placeholder: ['货主'],
+                            data: _this.owners,
+                        },
+                        {
+                            name: 'year',
+                            type: 'select',
+                            tip: ['默认为时间上一个月所属年份'],
+                            placeholder: ['年'],
+                            data: [
+                                {name: 2021, value: 2021},
+                                {name: 2022, value: 2022},
+                                {name: 2023, value: 2023},
+                                {name: 2024, value: 2024},
+                                {name: 2025, value: 2025},
+                                {name: 2026, value: 2026},
+                                {name: 2027, value: 2027},
+                                {name: 2028, value: 2028},
+                                {name: 2029, value: 2029},
+                                {name: 2030, value: 2030},
+                                {name: 2031, value: 2031},
+                                {name: 2032, value: 2032},
+                                {name: 2033, value: 2033},
+                                {name: 2034, value: 2034},
+                                {name: 2035, value: 2035},
+                                {name: 2036, value: 2036},
+
+                            ],
+                        },
+                        {
+                            name: 'month',
+                            type: 'select',
+                            tip: ['默认为上一月'],
+                            placeholder: ['月'],
+                            data: [
+                                {name:1, value: 1},
+                                {name:2, value: 2},
+                                {name:3, value: 3},
+                                {name:4, value: 4},
+                                {name:5, value: 5},
+                                {name:6, value: 6},
+                                {name:7, value: 7},
+                                {name:8, value: 8},
+                                {name:9, value: 9},
+                                {name:10, value: 10},
+                                {name:11, value: 11},
+                                {name:12, value: 12},
+                            ],
+                        },
+                    ]
+                ];
+                _this.form = new query({
+                    el: '#form_div',
+                    condition: data,
+                });
+                _this.form.init();
+                let column = [
+                    {name: 'index', value: '序号', neglect: true},
+                    {name: 'logistic.name', value: '快递公司'},
+                    {name: 'province', value: '地区'},
+                    {name: 'initial_weight', value: '首重'},
+                    {name: 'initial_amount', value: '订单数'},
+                    {name: 'additional_weight', value: '续重'},
+                    {name: 'additional_amount', value: '续重合计'},
+                    {name: 'fee', value: '(省份)合计'},
+                ];
+                new Header({
+                    el: "table",
+                    name: "report",
+                    column: column,
+                    data: this.reports,
+                    restorationColumn: 'addtime',
+                    fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
+                }).init();
+            },
+            methods: {
+                calRowspan(logistic_name) {
+                    return this.reports.filter(item => item.logistic.name === logistic_name).length;
+                }
+            },
+            filters: {},
+        });
+    </script>
+@endsection

+ 9 - 2
resources/views/finance/settlementBills/menu.blade.php

@@ -4,10 +4,17 @@
         <div class="card menu-third">
             <ul class="nav nav-pills">
                 @can('结算管理-结算账单-杂项费')
-                    <li class="nav-item" >
-                        <a target="finance/settlementBills/ownerSundryFeeDetails" class="nav-link" href="{{url('finance/settlementBills/ownerSundryFeeDetails')}}" :class="{active:isActive('ownerSundryFeeDetails',3)}">杂项费</a>
+                    <li class="nav-item">
+                        <a target="finance/settlementBills/ownerSundryFeeDetails" class="nav-link"
+                           href="{{url('finance/settlementBills/ownerSundryFeeDetails')}}"
+                           :class="{active:isActive('ownerSundryFeeDetails',3)}">杂项费</a>
                     </li>
                 @endcan
+                <li class="nav-item">
+                    <a target="finance/settlementBills/logisticFee/report" class="nav-link"
+                       href="{{url('finance/settlementBills/logisticFee/report')}}"
+                       :class="{active:isActive('logisticFee',3)}">快递费</a>
+                </li>
             </ul>
         </div>
     </div>

+ 3 - 3
resources/views/finance/settlementBills/ownerSundryFee/index.blade.php

@@ -5,9 +5,9 @@
     @include('shared._messages')
     @include('shared._error')
     <div id="list" class="d-none">
-        <div class="container-fluid">
-            <div id="form_div"></div>
-            <div class="form-inline" id="btn"></div>
+                <div class="container-fluid">
+                    <div id="form_div"></div>
+                    <div class="form-inline" id="btn"></div>
             <table class="table table-striped table-sm text-nowrap table-hover" id="table">
                 <tr v-for="(owner_sundry_fee_detail,i) in owner_sundry_fee_details"
                     @click="selectTr===i+1?selectTr=0:selectTr=i+1"

+ 6 - 2
routes/web.php

@@ -753,9 +753,13 @@ Route::group(['prefix'=>'finance'],function(){
     Route::get('billConfirmation','CustomerController@financeBillConfirmation');
     Route::post('updateBillReport','CustomerController@updateBillReport');
     Route::post('billConfirm','CustomerController@billConfirm');
-//    Route::group(['prefix'=>'settlementBills'],function(){
+    Route::group(['prefix'=>'settlementBills'],function(){
 //        Route::resource('ownerSundryFeeDetails', 'OwnerSundryFeeDetailsController', ['only' => ['index', 'create', 'store', 'update', 'edit','destroy']]);
-//    });
+        Route::group(['prefix' => 'logisticFee'], function () {
+            Route::resource('detail', 'OwnerLogisticFeeDetailController', ['only' => ['index']]);
+            Route::resource('report', 'OwnerLogisticFeeReportController', ['only' => ['index']]);
+        });
+    });
 });
 
 /** 客户 */

+ 96 - 0
tests/Services/OwnerLogisticFeeReportService/RecordReportTest.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace Tests\Services\OwnerLogisticFeeReportService;
+
+use App\OwnerLogisticFeeDetail;
+use App\Services\OwnerLogisticFeeReportService;
+use Tests\TestCase;
+use App\OwnerLogisticFeeReport;
+use App\Traits\TestMockSubServices;
+
+class RecordReportTest extends TestCase
+{
+    use TestMockSubServices;
+
+    /** @var OwnerLogisticFeeReportService $service */
+    public $service;
+    private $data;
+    private $amount = 2;
+
+    function setUp(): void
+    {
+        parent::setUp();
+        $this->service = app('OwnerLogisticFeeReportService');
+
+//        $this->data['OwnerLogisticFeeDetail']
+//            = factory(\App\OwnerLogisticFeeDetail::class, $this->amount)
+//            ->create([
+//                'created_at' => now()->subMonth()->startOfMonth()->addDays(1),
+//                'province' => '北京',
+//                'initial_weight_price' => '20',
+//                'additional_price' => '20',
+//                'logistic_id' => '20',
+//            ]);
+    }
+
+    public function testReturned()
+    {
+        $this->assertTrue(true);
+    }
+
+    function tearDown(): void
+    {
+//        OwnerLogisticFeeDetail::query()
+//            ->whereIn('id', data_get($this->data['OwnerLogisticFeeDetail'], '*.id') ?? [])
+//            ->delete();
+        parent::tearDown();
+    }
+
+    /**
+     * @test
+     */
+    public function get_test()
+    {
+        OwnerLogisticFeeDetail::query()->truncate();
+        OwnerLogisticFeeReport::query()->truncate();
+        factory(OwnerLogisticFeeDetail::class)->create([
+            'created_at' => now()->subMonth(),
+            'updated_at' => now()->subMonth(),
+            'province' => '北京',
+            'initial_weight' => '10',
+            'initial_weight_price' => '10',
+            'additional_price' => '10',
+            'additional_weight' => '10',
+
+            'logistic_id' => '1',
+            'owner_id' => '1',
+            'additional_weigh_weight' => '1',
+        ]);
+        factory(OwnerLogisticFeeDetail::class)->create([
+            'created_at' => now()->subMonth(),
+            'updated_at' => now()->subMonth(),
+            'province' => '北京',
+            'initial_weight' => '10',
+            'initial_weight_price' => '10',
+            'additional_price' => '10',
+            'additional_weight' => '10',
+            'logistic_id' => '1',
+            'owner_id' => '1',
+            'additional_weigh_weight' => '1',
+        ]);
+        $this->service->recordReport();
+        $this->assertDatabaseHas('owner_logistic_fee_reports', [
+            'logistic_id' => '1',
+            'province' => '北京',
+            'counted_date' => now()->subMonth()->startOfMonth()->toDateString(),
+            'initial_weight' => '10',
+            'initial_weight_price' => '10',
+            'initial_amount' => '2',
+            'additional_weight' => '10',
+            'additional_price' => '10',
+            'additional_amount' => '2',
+            'fee' => '40',
+            'owner_id' => '1',
+        ]);
+    }
+}