Kaynağa Gözat

Merge branch 'yang' of ssh://was.baoshi56.com:10022/var/git/bswas

 Conflicts:
	app/Services/OrderPackageReceivedSyncService.php
LD 4 yıl önce
ebeveyn
işleme
cd2ed320c2
26 değiştirilmiş dosya ile 1368 ekleme ve 739 silme
  1. 48 59
      app/Http/Controllers/OwnerLogisticFeeDetailController.php
  2. 59 56
      app/Http/Controllers/OwnerLogisticFeeReportController.php
  3. 63 0
      app/Http/Controllers/SettlementBillOwnerAreaFeeController.php
  4. 11 5
      app/OwnerLogisticFeeDetail.php
  5. 8 1
      app/OwnerLogisticFeeReport.php
  6. 10 45
      app/Providers/AppServiceProvider.php
  7. 57 0
      app/Services/LogisticSyncRecordService.php
  8. 4 0
      app/Services/OrderPackageReceivedSyncService.php
  9. 66 58
      app/Services/OwnerLogisticFeeDetailService.php
  10. 103 3
      app/Services/OwnerLogisticFeeReportService.php
  11. 66 484
      composer.lock
  12. 17 14
      database/factories/OwnerFeeDetailFactory.php
  13. 13 5
      database/factories/OwnerLogisticFeeDetailFactory.php
  14. 14 1
      database/factories/OwnerLogisticFeeReportFactory.php
  15. 38 0
      database/migrations/2021_06_08_140312_add_logistic_id_to_owner_logistic_fee_details.php
  16. 60 0
      database/migrations/2021_06_08_144247_add_column_to_owner_logistic_fee_reports.php
  17. 54 1
      database/seeds/OwnerLogisticFeeDetailSeeder.php
  18. 1 1
      database/seeds/OwnerLogisticFeeReportSeeder.php
  19. 20 0
      resources/views/finance/menu.blade.php
  20. 171 0
      resources/views/finance/settlementBills/areaFee/index.blade.php
  21. 180 0
      resources/views/finance/settlementBills/logisticFee/detail/index.blade.php
  22. 193 0
      resources/views/finance/settlementBills/logisticFee/report/index.blade.php
  23. 3 3
      resources/views/finance/settlementBills/ownerSundryFee/index.blade.php
  24. 8 3
      routes/web.php
  25. 96 0
      tests/Services/OwnerLogisticFeeReportService/RecordReportTest.php
  26. 5 0
      yarn.lock

+ 48 - 59
app/Http/Controllers/OwnerLogisticFeeDetailController.php

@@ -2,84 +2,73 @@
 
 namespace App\Http\Controllers;
 
+use App\Owner;
 use App\OwnerLogisticFeeDetail;
+use App\Services\OwnerLogisticFeeDetailService;
 use Illuminate\Http\Request;
+use Oursdreams\Export\Export;
 
 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();
+        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request);
+        $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'));
     }
 
-    /**
-     * Show the form for creating a new resource.
-     *
-     * @return \Illuminate\Http\Response
-     */
-    public function create()
+    public function export(Request $request)
     {
-        //
+        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request);
+        $query = $this->service->getSql($owner_id, $start, $end);
+        if (!$request->exists('checkAllSign')) {
+            $query->whereIn('id', explode(',', $request['data']));
+        }
+        $details = $this->service->buildDetails($query->get());
+        $json = [];
+        foreach ($details as $detail) {
+            $json[] = array_values($detail);
+        }
+        $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
+        return Export::make($row, $json, "快递费用详情");
     }
 
     /**
-     * Store a newly created resource in storage.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @return \Illuminate\Http\Response
+     * @param Request $request
+     * @return array
      */
-    public function store(Request $request)
+    private function getRequestParams(Request $request): array
     {
-        //
-    }
+        $this->service = app('OwnerLogisticFeeDetailService');
+        $this->userService = app('UserService');
+        $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
 
-    /**
-     * Display the specified resource.
-     *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
-     * @return \Illuminate\Http\Response
-     */
-    public function show(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
-    {
-        //
-    }
+        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;
+        }
 
-    /**
-     * Show the form for editing the specified resource.
-     *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
-     * @return \Illuminate\Http\Response
-     */
-    public function edit(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
-    {
-        //
-    }
-
-    /**
-     * Update the specified resource in storage.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
-     * @return \Illuminate\Http\Response
-     */
-    public function update(Request $request, OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
-    {
-        //
-    }
-
-    /**
-     * Remove the specified resource from storage.
-     *
-     * @param  \App\OwnerLogisticFeeDetail  $ownerLogisticFeeDetail
-     * @return \Illuminate\Http\Response
-     */
-    public function destroy(OwnerLogisticFeeDetail $ownerLogisticFeeDetail)
-    {
-        //
+        if (is_null($request->end)) {
+            $end = now()->subMonth()->endOfMonth()->toDateString();
+        } else {
+            $end = $request->end;
+        }
+        return array($permittingOwnerIds, $owner_id, $start, $end);
     }
 }

+ 59 - 56
app/Http/Controllers/OwnerLogisticFeeReportController.php

@@ -2,84 +2,87 @@
 
 namespace App\Http\Controllers;
 
+use App\Owner;
 use App\OwnerLogisticFeeReport;
+use App\Services\common\ExportService;
+use App\Services\OwnerLogisticFeeReportService;
+use App\Services\UserService;
 use Illuminate\Http\Request;
+use Oursdreams\Export\Export;
 
 class OwnerLogisticFeeReportController extends Controller
 {
-    /**
-     * Display a listing of the resource.
-     *
-     * @return \Illuminate\Http\Response
-     */
-    public function index()
-    {
-        //
-    }
+    /* @var OwnerLogisticFeeReportService $service */
+    private $service;
+    /* @var UserService $userService */
+    private $userService;
 
     /**
-     * Show the form for creating a new resource.
-     *
-     * @return \Illuminate\Http\Response
+     * OwnerLogisticFeeReportController constructor.
      */
-    public function create()
+    public function __construct()
     {
-        //
+        $this->middleware('auth');
     }
 
-    /**
-     * Store a newly created resource in storage.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @return \Illuminate\Http\Response
-     */
-    public function store(Request $request)
-    {
-        //
-    }
 
     /**
-     * Display the specified resource.
-     *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
-     * @return \Illuminate\Http\Response
-     */
-    public function show(OwnerLogisticFeeReport $ownerLogisticFeeReport)
-    {
-        //
-    }
-
-    /**
-     * Show the form for editing the specified resource.
-     *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
-     * @return \Illuminate\Http\Response
+     * Display a listing of the resource.
      */
-    public function edit(OwnerLogisticFeeReport $ownerLogisticFeeReport)
+    public function index(Request $request)
     {
-        //
+        $paginateParams = $request->input();
+        list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
+        $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'));
     }
 
-    /**
-     * Update the specified resource in storage.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
-     * @return \Illuminate\Http\Response
-     */
-    public function update(Request $request, OwnerLogisticFeeReport $ownerLogisticFeeReport)
+    public function export(Request $request)
     {
-        //
+        list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
+        $query = $this->service->getSql($owner_id, $date);
+        if (!$request->exists('checkAllSign')) {
+            $query->whereIn('id', explode(',', $request['data']));
+        }
+        $reports = $query->get();
+        $json = [];
+        foreach ($reports as $report) {
+            $json[] = [
+                $report->logistic->name ?? '',
+                $report->province,
+                $report->initial_weight,
+                $report->initial_amount,
+                $report->additional_weight,
+                $report->additional_amount,
+                $report->fee,
+            ];
+        }
+        $row = ['快递公司', '地区', '首重', '订单数', '续重', '续重合计', '(省份)合计'];
+        return Export::make($row, $json, "快递费用合计");
     }
 
     /**
-     * Remove the specified resource from storage.
-     *
-     * @param  \App\OwnerLogisticFeeReport  $ownerLogisticFeeReport
-     * @return \Illuminate\Http\Response
+     * @param Request $request
+     * @return array
      */
-    public function destroy(OwnerLogisticFeeReport $ownerLogisticFeeReport)
+    private function getRequestParams(Request $request): array
     {
-        //
+        $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;
+        }
+        return array($permittingOwnerIds, $date, $owner_id);
     }
 }

+ 63 - 0
app/Http/Controllers/SettlementBillOwnerAreaFeeController.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\OwnerAreaReport;
+use Illuminate\Http\Request;
+
+/**
+ * 结算管理-结算账单-仓储费
+ * Class SettlementBillOwnerAreaFeeController
+ * @package App\Http\Controllers
+ */
+class SettlementBillOwnerAreaFeeController extends Controller
+{
+    /**
+     * SettlementBillOwnerAreaFeeController constructor.
+     */
+    public function __construct()
+    {
+        $this->middleware('auth');
+    }
+
+    public function index(Request $request)
+    {
+        list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
+        $owners = \App\Owner::query()->find($permittingOwnerIds);
+        $owner = \App\Owner::query()->find($owner_id);
+        $ownerAreas = OwnerAreaReport::query()
+            ->with('ownerStoragePriceModel:id,using_type')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $date)
+            ->get();
+
+        $ownerBillReport = \App\OwnerBillReport::query()
+            ->selectRaw('storage_fee')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $date)
+            ->first();
+
+    }
+
+    /**
+     * @param Request $request
+     * @return array
+     */
+    private function getRequestParams(Request $request): array
+    {
+        $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;
+        }
+        return array($permittingOwnerIds, $date, $owner_id);
+    }
+}

+ 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);
+    }
 }

+ 10 - 45
app/Providers/AppServiceProvider.php

@@ -141,6 +141,7 @@ use App\Services\LogisticAliJiSuApiService;
 use App\Services\CommodityMaterialBoxModelService;
 use App\Services\OwnerLogisticFeeDetailService;
 use App\Services\OwnerLogisticFeeReportService;
+use App\Services\LogisticSyncRecordService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -169,8 +170,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');
             }
         });
         //扩展身份证验证规则
@@ -197,8 +200,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');
             }
         });
     }
@@ -206,7 +211,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);
@@ -233,6 +237,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('LogisticZopService', LogisticZopService::class);
         app()->singleton('InventoryCompareService', InventoryCompareService::class);
         app()->singleton('InventoryDailyLogService', InventoryDailyLogService::class);
+        app()->singleton('LaborCompanyService',LaborCompanyService::class);
         app()->singleton('LaborReportsCountingRecordService', LaborReportsCountingRecordService::class);
         app()->singleton('LogService', LogService::class);
         app()->singleton('LogisticAliJiSuApiService',LogisticAliJiSuApiService::class);
@@ -335,44 +340,4 @@ class AppServiceProvider extends ServiceProvider
         Owner::observe(OwnerObserver::class);
         UserWorkgroup::observe(UserWorkGroupObserver::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);
+    }
+}

+ 4 - 0
app/Services/OrderPackageReceivedSyncService.php

@@ -227,6 +227,10 @@ class OrderPackageReceivedSyncService
      */
     public function setExceptionType(array $data, $lastRouteDate): array
     {
+        //设置默认异常为否
+
+        $data['exception_type'] = '无';
+        $data['exception'] = '否';
         $logistic_number = $data['logistic_number'];
         /** @var OrderPackage $orderPackage */
         $orderPackage = OrderPackage::query()->with('order')->where('logistic_number', $logistic_number)->first();

+ 66 - 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,77 @@ class OwnerLogisticFeeDetailService
      * @param string $owner_id
      * @param string $start
      * @param string $end
-     * @return array
+     * @param $paginateParams
+     * @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')
+        $ownerLogisticFeeDetails = $this->getSql($owner_id, $start, $end)
+            ->paginate($paginateParams['paginate'] ?? 50);
+        $items = $this->buildDetails($ownerLogisticFeeDetails);
+        return new LengthAwarePaginator(
+            $items,
+            $ownerLogisticFeeDetails->total(),
+            $ownerLogisticFeeDetails->perPage(),
+            $ownerLogisticFeeDetails->currentPage(),
+            ["path" => $ownerLogisticFeeDetails->path(), "pageName" => "page"]
+        );
+    }
+
+    /**
+     * @param Builder $logistic_ids
+     * @param string $owner_id
+     * @param string $start
+     * @param string $end
+     * @return Builder
+     */
+    private function getOwnerFeeDetailQuery(Builder $logistic_ids, string $owner_id, string $start, string $end): Builder
+    {
+        return 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());
+    }
+
+    /**
+     * @param string $owner_id
+     * @param string $start
+     * @param string $end
+     * @return Builder
+     */
+    public function getSql(string $owner_id, string $start, string $end): Builder
+    {
+        return OwnerLogisticFeeDetail::query()->with([
+            'ownerFeeDetail:id,province,weight,logistic_fee',
+            'ownerFeeDetailLogistic:id,weight,logistic_fee,logistic_bill',
+            'logistic:id,name'
+        ])
+            ->whereIn('owner_fee_detail_id', $this->getOwnerFeeDetailQuery(Logistic::query()->selectRaw('id')->where('type', '快递'), $owner_id, $start, $end))
+            ->orderBy('logistic_id');
+    }
 
-//         $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 ?? '',//续重价格
-                ];
+    /**
+     * @param  $ownerLogisticFeeDetails
+     * @return array
+     */
+    public function buildDetails($ownerLogisticFeeDetails): array
+    {
+        $items = [];
+        foreach ($ownerLogisticFeeDetails as $ownerLogisticFeeDetail) {
+            $items[] = [
+                'id' => $ownerLogisticFeeDetail->id,
+                'logistic_name' => $ownerLogisticFeeDetail->logistic->name ?? '',//快递公司
+                'province' => $ownerLogisticFeeDetail->province,//省份
+                'logistic_bill' => $ownerLogisticFeeDetail->logistic_bill ?? '',//快递单号
+                'weight' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->weight ?? $ownerLogisticFeeDetail->ownerFeeDetail->weight ?? '0.00',//重量
+                'initial_weight_price' => $ownerLogisticFeeDetail->initial_weight_price ?? '',//首重价格
+                'additional_price' => $ownerLogisticFeeDetail->additional_price ?? '',//续重价格
+                'logistic_fee' => $ownerLogisticFeeDetail->ownerFeeDetailLogistic->logistic_fee ?? $ownerLogisticFeeDetail->ownerFeeDetail->logistic_fee ?? '0.00',//快递费
+            ];
         }
-        return $result;
+        return $items;
     }
 }

+ 103 - 3
app/Services/OwnerLogisticFeeReportService.php

@@ -1,13 +1,113 @@
-<?php 
+<?php
 
 namespace App\Services;
 
+use App\OwnerLogisticFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeReport;
+use Carbon\Carbon;
+use Illuminate\Contracts\Pagination\LengthAwarePaginator;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Collection;
 
 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 $this->getSql($owner_id, $date)
+            ->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,
+        ];
+    }
+
+    /**
+     * @param $owner_id
+     * @param string $date
+     * @return Builder
+     */
+    public function getSql($owner_id, string $date): Builder
+    {
+        return OwnerLogisticFeeReport::query()
+            ->with('logistic:id,name')
+            ->where('owner_id', $owner_id)
+            ->where('counted_date', $date)
+            ->orderByDesc('logistic_id')
+            ->orderByDesc('province');
+    }
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 66 - 484
composer.lock


+ 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']);
     }
 }

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

@@ -0,0 +1,20 @@
+<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
+{{--            @can('结算管理-结算账单')--}}
+                <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>
+

+ 171 - 0
resources/views/finance/settlementBills/areaFee/index.blade.php

@@ -0,0 +1,171 @@
+@extends('layouts.app')
+
+@section('content')
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="ml-3 form-inline" id="btn">
+                    <span class="dropdown">
+                        <button type="button"
+                                class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
+                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
+                        </button>
+                        <div class="dropdown-menu">
+                            <a class="dropdown-item" @click="ownerFeeExport(false)" href="javascript:">导出勾选内容</a>
+                            <a class="dropdown-item" @click="ownerFeeExport(true)" href="javascript:">导出所有页</a>
+                        </div>
+                    </span>
+            </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="(ownerFee,i) in ownerFees"
+                    @click="selectTr===i+1?selectTr=0:selectTr=i+1"
+                    :class="selectTr===i+1?'focusing' : ''">
+                    <td><input class="checkItem" type="checkbox" :value="ownerFee.id"></td>
+                    <td>@{{ i+1 }}</td>
+                    <td v-if="i==0 || ownerFee.logistic_name!== ownerFees[i-1].logistic_name"
+                        :rowspan="calRowspan(ownerFee.logistic_name)" class="text-center pt-4 bg-light">@{{
+                        ownerFee.logistic_name }}
+                    </td>
+                    <td>@{{ ownerFee.province }}</td>
+                    <td>@{{ ownerFee.logistic_bill }}</td>
+                    <td>@{{ ownerFee.weight }}</td>
+                    <td>@{{ ownerFee.initial_weight_price }}</td>
+                    <td>@{{ ownerFee.additional_price }}</td>
+                    <td>@{{ ownerFee.logistic_fee }}</td>
+                </tr>
+            </table>
+            <div class="text-info h5 btn btn">{{$ownerFees->count()}}/{{$ownerFees->total()}}</div>
+            {{$ownerFees->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: {
+                ownerFees: [
+                    @foreach($ownerFees as $ownerFee)
+                        {!! $ownerFee !!}
+                    @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,
+                    appendDom: "btn",
+                });
+                _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: '金额'},
+                ];
+                new Header({
+                    el: "table",
+                    name: "ownerFee",
+                    column: column,
+                    data: this.ownerFees,
+                    restorationColumn: 'addtime',
+                    fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
+                }).init();
+            },
+            methods: {
+                calRowspan(logistic_name) {
+                    return this.ownerFees.filter(item => item.logistic_name === logistic_name).length;
+                },
+                ownerFeeExport(sign) {
+                    let url = '{{url('finance/settlementBills/logisticFee/ownerFee/export')}}';
+                    let token = '{{ csrf_token() }}';
+                    if (sign) {
+                        excelExport(true, checkData, url, this.total, token);
+                    } else {
+                        excelExport(false, checkData, url, null, token);
+                    }
+                },
+            },
+            filters: {},
+        });
+    </script>
+@endsection

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

@@ -0,0 +1,180 @@
+@extends('layouts.app')
+
+@section('content')
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="ml-3 form-inline" id="btn">
+                    <span class="dropdown">
+                        <button type="button"
+                                class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
+                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
+                        </button>
+                        <div class="dropdown-menu">
+                            <a class="dropdown-item" @click="detailExport(false)" href="javascript:">导出勾选内容</a>
+                            <a class="dropdown-item" @click="detailExport(true)" href="javascript:">导出所有页</a>
+                        </div>
+                    </span>
+            </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 bg-light">@{{ 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)
+                    {
+                        id: " {!! $detail['id'] !!}",
+                        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,
+                    appendDom : "btn",
+                });
+                _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;
+                },
+                detailExport(sign) {
+                    let url = '{{url('finance/settlementBills/logisticFee/detail/export')}}';
+                    let token = '{{ csrf_token() }}';
+                    if (sign) {
+                        excelExport(true, checkData, url, this.total, token);
+                    } else {
+                        excelExport(false, checkData, url, null, token);
+                    }
+                },
+            },
+            filters: {},
+        });
+    </script>
+@endsection

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

@@ -0,0 +1,193 @@
+@extends('layouts.app')
+
+@section('content')
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="ml-3 form-inline" id="btn">
+                    <span class="dropdown">
+                        <button type="button"
+                                class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
+                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
+                        </button>
+                        <div class="dropdown-menu">
+                            <a class="dropdown-item" @click="reportExport(false)" href="javascript:">导出勾选内容</a>
+                            <a class="dropdown-item" @click="reportExport(true)" href="javascript:">导出所有页</a>
+                        </div>
+                    </span>
+            </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 bg-light">@{{ 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,
+                    appendDom: 'btn'
+                });
+                _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;
+                },
+                reportExport(sign) {
+                    let url = '{{url('finance/settlementBills/logisticFee/report/export')}}';
+                    let token = '{{ csrf_token() }}';
+                    if (sign) {
+                        excelExport(true, checkData, url, this.total, token);
+                    } else {
+                        excelExport(false, checkData, url, null, token);
+                    }
+                },
+            },
+            filters: {},
+        });
+    </script>
+@endsection

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

@@ -4,9 +4,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"

+ 8 - 3
routes/web.php

@@ -779,9 +779,15 @@ 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::any('detail/export', 'OwnerLogisticFeeDetailController@export');
+            Route::any('report/export', 'OwnerLogisticFeeReportController@export');
+            Route::resource('detail', 'OwnerLogisticFeeDetailController', ['only' => ['index']]);
+            Route::resource('report', 'OwnerLogisticFeeReportController', ['only' => ['index']]);
+        });
+    });
 });
 
 /** 客户 */
@@ -904,4 +910,3 @@ Route::group(['prefix'=>'procurement'],function () {
 Route::group(['prefix'=>'demand'],function (){
     Route::get('/','DemandController@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',
+        ]);
+    }
+}

+ 5 - 0
yarn.lock

@@ -3514,6 +3514,11 @@ http-proxy@^1.17.0:
     follow-redirects "^1.0.0"
     requires-port "^1.0.0"
 
+http-vue-loader@^1.4.2:
+  version "1.4.2"
+  resolved "https://registry.npm.taobao.org/http-vue-loader/download/http-vue-loader-1.4.2.tgz#98e8c3304f5c1351858eaca60c5d80bf6a244196"
+  integrity sha1-mOjDME9cE1GFjqymDF2Av2okQZY=
+
 https-browserify@^1.0.0:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor