ANG YU 4 лет назад
Родитель
Сommit
a7dc485f3d
44 измененных файлов с 1759 добавлено и 470 удалено
  1. 129 61
      app/Http/Controllers/OwnerFeeTotalController.php
  2. 1 1
      app/Http/Controllers/SettlementBillExpressFeeDetailController.php
  3. 2 23
      app/Http/Controllers/SettlementBillExpressFeeReportController.php
  4. 1 1
      app/Http/Controllers/SettlementBillLogisticFeeController.php
  5. 1 34
      app/Http/Controllers/SettlementBillPackingMaterialFeeController.php
  6. 1 1
      app/Http/Controllers/SettlementBillProcessFeeController.php
  7. 1 30
      app/Http/Controllers/SettlementBillStorageFeeController.php
  8. 1 1
      app/Http/Controllers/SettlementBillStoreFeeDetailController.php
  9. 12 39
      app/Http/Controllers/SettlementBillStoreFeeReportController.php
  10. 1 1
      app/Http/Controllers/SettlementBillStoreOutFeeDetailController.php
  11. 1 37
      app/Http/Controllers/SettlementBillStoreOutFeeReportController.php
  12. 1 1
      app/Http/Controllers/SettlementBillSundryFeeController.php
  13. 1 1
      app/Http/Controllers/SettlementBillUnloadFeeController.php
  14. 54 0
      app/Http/Controllers/SettlementIndemnityFeeController.php
  15. 18 0
      app/Http/Controllers/TestController.php
  16. 7 0
      app/Interfaces/SettlementBillReportInterface.php
  17. 10 11
      app/OwnerBillReportArchive.php
  18. 4 1
      app/OwnerFeeTotal.php
  19. 2 0
      app/Providers/AppServiceProvider.php
  20. 17 0
      app/Services/OwnerBillReportArchiveService.php
  21. 12 1
      app/Services/OwnerDischargeTaskSettlementBillService.php
  22. 349 104
      app/Services/OwnerFeeTotalService.php
  23. 45 3
      app/Services/OwnerLogisticFeeReportService.php
  24. 6 1
      app/Services/OwnerProcessSettlementBillService.php
  25. 44 5
      app/Services/OwnerProcurementSettlementBillService.php
  26. 46 5
      app/Services/OwnerStoreFeeReportService.php
  27. 34 0
      app/Services/OwnerStoreOutFeeReportService.php
  28. 19 3
      app/Services/OwnerSundryFeeDetailService.php
  29. 9 3
      app/Services/OwnerWaybillSettlementBillService.php
  30. 33 2
      app/Services/SettlementBillsAreaFeeService.php
  31. 54 0
      app/Services/SettlementIndemnityFeeService.php
  32. 47 2
      app/Traits/SettlementBillServiceTrait.php
  33. 4 17
      app/Traits/SettlementBillTrait.php
  34. 1 0
      database/factories/OwnerFeeDetailFactory.php
  35. 2 0
      database/factories/OwnerWayBillFeeDetailFactory.php
  36. 4 0
      database/migrations/2021_07_06_101511_create_owner_fee_totals_table.php
  37. 0 1
      database/seeds/SettlementBillSeeder.php
  38. 0 23
      resources/views/finance/settlementBills/expressFee/detail/index.blade.php
  39. 194 0
      resources/views/finance/settlementBills/indemnityFee/index.blade.php
  40. 1 1
      resources/views/finance/settlementBills/logisticFee/index.blade.php
  41. 0 26
      resources/views/finance/settlementBills/storeFee/detail/index.blade.php
  42. 0 23
      resources/views/finance/settlementBills/storeOutFee/detail/index.blade.php
  43. 570 0
      resources/views/finance/settlementBills/totalFee/index.blade.php
  44. 20 7
      routes/web.php

+ 129 - 61
app/Http/Controllers/OwnerFeeTotalController.php

@@ -2,84 +2,152 @@
 
 namespace App\Http\Controllers;
 
-use App\OwnerFeeTotal;
+use App\Owner;
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\OwnerDischargeTaskSettlementBillService;
+use App\Services\OwnerFeeTotalService;
+use App\Services\OwnerLogisticFeeReportService;
+use App\Services\OwnerProcessSettlementBillService;
+use App\Services\OwnerProcurementSettlementBillService;
+use App\Services\OwnerStoreFeeReportService;
+use App\Services\OwnerStoreOutFeeReportService;
+use App\Services\OwnerSundryFeeDetailService;
+use App\Services\OwnerWaybillSettlementBillService;
+use App\Services\SettlementBillsAreaFeeService;
+use App\Services\SettlementIndemnityFeeService;
 use Illuminate\Http\Request;
 
-class OwnerFeeTotalController extends Controller
+class OwnerFeeTotalController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
 {
-    /**
-     * Display a listing of the resource.
-     *
-     * @return \Illuminate\Http\Response
-     */
-    public function index()
-    {
-        //
-    }
+    use \App\Traits\SettlementBillTrait;
 
-    /**
-     * Show the form for creating a new resource.
-     *
-     * @return \Illuminate\Http\Response
-     */
-    public function create()
-    {
-        //
-    }
+    /** @var OwnerFeeTotalService $service */
+    private $service;
+
+    /** @var OwnerBillReportArchiveService $archiveService */
+    private $archiveService;
 
-    /**
-     * 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\OwnerFeeTotal  $ownerFeeTotal
-     * @return \Illuminate\Http\Response
+     * OwnerDischargeTaskSettlementBillController constructor.
      */
-    public function show(OwnerFeeTotal $ownerFeeTotal)
+    public function __construct()
     {
-        //
+        $this->service = app('OwnerFeeTotalService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
     }
 
-    /**
-     * Show the form for editing the specified resource.
-     *
-     * @param  \App\OwnerFeeTotal  $ownerFeeTotal
-     * @return \Illuminate\Http\Response
-     */
-    public function edit(OwnerFeeTotal $ownerFeeTotal)
+    public function index(Request $request)
     {
-        //
+        $paginateParams = $request->input();
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        $feeTotal = $this->service->get([
+            'counting_month' => $counting_month,
+            'owner_id' => $owner_id,
+            'paginateParams' => $paginateParams,
+        ]);
+        $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
+        $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
+        $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
+        $isArchivedItems = collect([
+            'expressFee' => $this->archiveService->isArchived($counting_month, $owner_id, '快递费-合计'),
+            'logisticFee' => $this->archiveService->isArchived($counting_month, $owner_id, '物流费'),
+            'packingMaterialFee' => $this->archiveService->isArchived($counting_month, $owner_id, '包材费'),
+            'processFee' => $this->archiveService->isArchived($counting_month, $owner_id, '加工费'),
+            'storageFee' => $this->archiveService->isArchived($counting_month, $owner_id, '仓储费'),
+            'storeFee' => $this->archiveService->isArchived($counting_month, $owner_id, '入库费-合计'),
+            'storeOutFee' => $this->archiveService->isArchived($counting_month, $owner_id, '出库费-合计'),
+            'sundryFee' => $this->archiveService->isArchived($counting_month, $owner_id, '杂项费'),
+            'unloadFee' => $this->archiveService->isArchived($counting_month, $owner_id, '卸货费'),
+            'indemnityFee' => $this->archiveService->isArchived($counting_month, $owner_id, '理赔费'),
+        ]);
+        return view('finance.settlementBills.totalFee.index', compact('feeTotal', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'isArchivedItems'));
     }
 
-    /**
-     * Update the specified resource in storage.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \App\OwnerFeeTotal  $ownerFeeTotal
-     * @return \Illuminate\Http\Response
-     */
-    public function update(Request $request, OwnerFeeTotal $ownerFeeTotal)
+
+    public function export(Request $request)
     {
-        //
+        // TODO: Implement export() method.
     }
 
-    /**
-     * Remove the specified resource from storage.
-     *
-     * @param  \App\OwnerFeeTotal  $ownerFeeTotal
-     * @return \Illuminate\Http\Response
-     */
-    public function destroy(OwnerFeeTotal $ownerFeeTotal)
+    public function confirmBill(Request $request): \Illuminate\Http\RedirectResponse
     {
-        //
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        $billReport = OwnerBillReport::query()
+            ->select('id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this->service::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [],
+        ]);
+
+        $unArchived = $this->archiveService->getUnAchieved($counting_month, $owner_id);
+        foreach ($unArchived as $type) {
+            switch ($type) {
+                case '仓储费':
+                    /**@var $storageFeeService  SettlementBillsAreaFeeService */
+                    $storageFeeService = app('SettlementBillsAreaFeeService');
+                    $storageFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '快递费-合计':
+                    /**@var $expressFeeService  OwnerLogisticFeeReportService */
+                    $expressFeeService = app('OwnerLogisticFeeReportService');
+                    $expressFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '入库费-合计':
+                    /**@var $storeFeeService  OwnerStoreFeeReportService */
+                    $storeFeeService = app('OwnerStoreFeeReportService');
+                    $storeFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '出库费-合计':
+                    /**@var $storeOutFeeService  OwnerStoreOutFeeReportService */
+                    $storeOutFeeService = app('OwnerStoreOutFeeReportService');
+                    $storeOutFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '物流费':
+                    /**@var $logisticFeeService  OwnerWaybillSettlementBillService */
+                    $logisticFeeService = app('OwnerWaybillSettlementBillService');
+                    $logisticFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '包材费':
+                    /**@var $packingMaterialFeeService  OwnerProcurementSettlementBillService */
+                    $packingMaterialFeeService = app('OwnerProcurementSettlementBillService');
+                    $packingMaterialFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '加工费':
+                    /**@var $processFeeService  OwnerProcessSettlementBillService */
+                    $processFeeService = app('OwnerProcessSettlementBillService');
+                    $processFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '杂项费':
+                    /**@var $sundryFeeService  OwnerSundryFeeDetailService */
+                    $sundryFeeService = app('OwnerSundryFeeDetailService');
+                    $sundryFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '卸货费':
+                    /**@var $unloadFeeService  OwnerDischargeTaskSettlementBillService */
+                    $unloadFeeService = app('OwnerDischargeTaskSettlementBillService');
+                    $unloadFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+                case '理赔费':
+                    /**@var $indemnityFeeService  SettlementIndemnityFeeService */
+                    $indemnityFeeService = app('SettlementIndemnityFeeService');
+                    $indemnityFeeService->confirmBill($counting_month, $owner_id);
+                    break;
+            }
+        }
+        return back()->with('success', '确认成功');
     }
 }

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

@@ -46,7 +46,7 @@ class SettlementBillExpressFeeDetailController extends Controller implements Set
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $this->archiveService = app('OwnerBillReportArchiveService');
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.expressFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 

+ 2 - 23
app/Http/Controllers/SettlementBillExpressFeeReportController.php

@@ -50,7 +50,7 @@ class SettlementBillExpressFeeReportController extends Controller
         $this->archiveService = app('OwnerBillReportArchiveService');
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-合计']);
 
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.expressFee.report.index', compact('reports', 'recordTotal', 'paginateParams', 'owners', 'owner', 'isArchived', 'request', 'reportPaginator'));
     }
 
@@ -121,29 +121,8 @@ class SettlementBillExpressFeeReportController extends Controller
     public function confirmBill(Request $request):RedirectResponse
     {
         $this->service = app('OwnerLogisticFeeReportService');
-        $this->archiveService = app('OwnerBillReportArchiveService');
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
-        $billReport = OwnerBillReport::query()
-            ->select('storage_fee', 'id')
-            ->where('owner_id', $owner_id)
-            ->where('counting_month', $counting_month)
-            ->firstOr(function () {
-                return new OwnerBillReport();
-            });
-        $reports = $this->service->getRecords($owner_id, $counting_month);
-        $recordTotal = $this->service->getRecordTotal($owner_id, $counting_month);
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [
-                'reports' => $reports,
-                'recordTotal' => $recordTotal,
-            ],
-        ]);
+        $this->service->confirmBill($counting_month, $owner_id);
         return back()->with('success', '确认成功');
     }
 }

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

@@ -46,7 +46,7 @@ class SettlementBillLogisticFeeController extends Controller implements Settleme
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.logisticFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 

+ 1 - 34
app/Http/Controllers/SettlementBillPackingMaterialFeeController.php

@@ -46,43 +46,10 @@ class SettlementBillPackingMaterialFeeController extends Controller implements S
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.packingMaterialFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'total_fee'));
     }
 
-    /**
-     * @param Request $request
-     * @return RedirectResponse
-     */
-    public function confirmBill(Request $request): RedirectResponse
-    {
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
-        $billReport = OwnerBillReport::query()
-            ->select('storage_fee', 'id')
-            ->where('owner_id', $owner_id)
-            ->where('counting_month', $counting_month)
-            ->firstOr(function () {
-                return new OwnerBillReport();
-            });
-        list($details, $total_fee) = $this->service->get([
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-        ]);
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [
-                'details' => $details,
-                'total_fee' => $total_fee,
-            ],
-        ]);
-        return back()->with('success', '确认成功');
-    }
 
     public function export(Request $request)
     {

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

@@ -44,7 +44,7 @@ class SettlementBillProcessFeeController extends Controller implements Settlemen
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $this->archiveService = app('OwnerBillReportArchiveService');
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.processFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'totalFee'));
     }
 

+ 1 - 30
app/Http/Controllers/SettlementBillStorageFeeController.php

@@ -47,39 +47,10 @@ class SettlementBillStorageFeeController extends Controller implements \App\Inte
         ]);
         $owners = Owner::query()->find($permittingOwnerIds);
         $owner = Owner::query()->find($owner_id);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.storageFee.index', compact('owner', 'owners', 'areaReports', 'billReport', 'request', 'isArchived'));
     }
 
-
-    /**
-     * 确认账单
-     * @param Request $request
-     * @return RedirectResponse
-     */
-    public function confirmBill(Request $request): RedirectResponse
-    {
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
-        list($areaReports, $billReport) = $this->service->get([
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-        ]);
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [
-                'areaReports' => $areaReports,
-                'billReport' => $billReport,
-            ],
-        ]);
-        return back()->with('success', '确认成功');
-    }
-
     public function export(Request $request)
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);

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

@@ -50,7 +50,7 @@ class SettlementBillStoreFeeDetailController extends Controller implements Settl
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $this->archiveService = app('OwnerBillReportArchiveService');
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.storeFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 

+ 12 - 39
app/Http/Controllers/SettlementBillStoreFeeReportController.php

@@ -23,12 +23,19 @@ class SettlementBillStoreFeeReportController extends Controller
     /** @var  $archiveService OwnerBillReportArchiveService */
     private $archiveService;
 
-
-    public function index(Request $request)
+    /**
+     * SettlementBillStoreFeeReportController constructor.
+     */
+    public function __construct()
     {
         $this->service = app('OwnerStoreFeeReportService');
         $this->archiveService = app('OwnerBillReportArchiveService');
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
+    }
+
+    public function index(Request $request)
+    {
+
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
         list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,
@@ -40,51 +47,17 @@ class SettlementBillStoreFeeReportController extends Controller
         $this->archiveService = app('OwnerBillReportArchiveService');
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
 
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
 
         return view('finance.settlementBills.storeFee.report.index',
             compact('owners', 'owner', 'isArchived', 'request', 'reports', 'totalAmount', 'totalFee', 'owner_price_operation_fees'));
     }
 
-    public function confirmBill(Request $request): RedirectResponse
-    {
-        $this->service = app('OwnerStoreFeeReportService');
-        $this->archiveService = app('OwnerBillReportArchiveService');
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
-        $billReport = OwnerBillReport::query()
-            ->select('storage_fee', 'id')
-            ->where('owner_id', $owner_id)
-            ->where('counting_month', $counting_month)
-            ->firstOr(function () {
-                return new OwnerBillReport();
-            });
-        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-        ]);
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [
-                'reports' => $reports,
-                'totalAmount' => $totalAmount,
-                'totalFee' => $totalFee,
-                'owner_price_operation_fees' => $owner_price_operation_fees
-            ],
-        ]);
-        return back()->with('success', '确认成功');
-    }
-
     public function export(Request $request)
     {
         $this->service = app('OwnerStoreFeeReportService');
         $this->archiveService = app('OwnerBillReportArchiveService');
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
         list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->service->get([
             'owner_id' => $owner_id,
             'counting_month' => $counting_month,

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

@@ -40,7 +40,7 @@ class SettlementBillStoreOutFeeDetailController extends Controller implements Se
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 

+ 1 - 37
app/Http/Controllers/SettlementBillStoreOutFeeReportController.php

@@ -4,13 +4,9 @@ namespace App\Http\Controllers;
 
 use App\Interfaces\SettlementBillControllerInterface;
 use App\Owner;
-use App\OwnerBillReport;
-use App\OwnerBillReportArchive;
-use App\OwnerStoreOutFeeReport;
 use App\Services\OwnerBillReportArchiveService;
 use App\Services\OwnerStoreOutFeeReportService;
 use App\Traits\SettlementBillTrait;
-use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Oursdreams\Export\Export;
 
@@ -19,7 +15,6 @@ class SettlementBillStoreOutFeeReportController extends Controller implements Se
 
     use SettlementBillTrait;
 
-    //TODO 缺少总计费用
     /* @var OwnerStoreOutFeeReportService $service */
     private $service;
 
@@ -48,43 +43,12 @@ class SettlementBillStoreOutFeeReportController extends Controller implements Se
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         $work_name_fee_total = collect($this->buildWorkNameFeeTotal($reports, $work_name_fee_total));
         return view('finance.settlementBills.storeOutFee.report.index',
             compact('owners', 'owner', 'isArchived', 'request', 'work_name_fee_total', 'fee_total'));
     }
 
-    public function confirmBill(Request $request): RedirectResponse
-    {
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
-        $billReport = OwnerBillReport::query()
-            ->select('storage_fee', 'id')
-            ->where('owner_id', $owner_id)
-            ->where('counting_month', $counting_month)
-            ->firstOr(function () {
-                return new OwnerBillReport();
-            });
-        list($reports, $work_name_fee_total, $fee_total) = $this->service->get([
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-        ]);
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [
-                'reports' => $reports,
-                'work_name_fee_total' => $work_name_fee_total,
-                'fee_total' => $fee_total,
-            ],
-        ]);
-        return back()->with('success', '确认成功');
-    }
-
     public function export(Request $request)
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);

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

@@ -45,7 +45,7 @@ class SettlementBillSundryFeeController extends Controller implements Settlement
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.sundryFee.index', compact('owner_sundry_fee_details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 

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

@@ -42,7 +42,7 @@ class SettlementBillUnloadFeeController extends Controller implements \App\Inter
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
-        $request = $this->buildRequest($request, $counting_month);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
         return view('finance.settlementBills.unloadFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'totalFee'));
 
     }

+ 54 - 0
app/Http/Controllers/SettlementIndemnityFeeController.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Owner;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\SettlementIndemnityFeeService;
+use Illuminate\Http\Request;
+
+class SettlementIndemnityFeeController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
+{
+
+    use \App\Traits\SettlementBillTrait;
+
+    /** @var SettlementIndemnityFeeService $service */
+    private $service;
+
+    /** @var OwnerBillReportArchiveService $archiveService */
+    private $archiveService;
+
+
+    /**
+     * OwnerDischargeTaskSettlementBillController constructor.
+     */
+    public function __construct()
+    {
+        $this->service = app('SettlementIndemnityFeeService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
+    }
+
+    //
+    public function index(Request $request)
+    {
+        $paginateParams = $request->input();
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        $details = $this->service->get([
+            'counting_month' => $counting_month,
+            'owner_id' => $owner_id,
+            'paginateParams' => $paginateParams,
+        ]);
+        $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
+        $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
+        $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
+        $request = $this->buildRequest($request, $counting_month,$owner_id);
+        return view('finance.settlementBills.indemnityFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
+    }
+
+    public function export(Request $request)
+    {
+
+    }
+
+
+}

+ 18 - 0
app/Http/Controllers/TestController.php

@@ -80,6 +80,7 @@ use App\Services\OrderPackageReceivedSyncService;
 use App\Services\OrderPackageService;
 use App\Services\OrderService;
 use App\Services\OrderTrackingService;
+use App\Services\OwnerBillReportArchiveService;
 use App\Services\OwnerBillTotalService;
 use App\Services\OwnerFeeTotalService;
 use App\Services\OwnerLogisticFeeDetailService;
@@ -1334,6 +1335,16 @@ TEXT;
         $service->record();
     }
 
+    public function test_bill_total_get()
+    {
+        /**@var $service OwnerFeeTotalService */
+        $service = app('OwnerFeeTotalService');
+        dd($service->get([
+            'owner_id' => 8,
+            'counting_month' => now()->subMonth()->startOfMonth(),
+        ])->toArray());
+    }
+
     public function OwnerWaybillSettlementBillServiceGet()
     {
         /**@var $service OwnerWaybillSettlementBillService */
@@ -1344,4 +1355,11 @@ TEXT;
         ]);
         dd($result->items()[0]->toArray());
     }
+
+    public function getUnAchieved()
+    {
+        /**@var $service OwnerBillReportArchiveService */
+        $service = app('OwnerBillReportArchiveService');
+        $service->getUnAchieved('2021-06-01',8);
+    }
 }

+ 7 - 0
app/Interfaces/SettlementBillReportInterface.php

@@ -31,4 +31,11 @@ interface SettlementBillReportInterface
 
     public function buildExport($details): array;
 
+    /**
+     * 确认账单
+     * @param $counting_month
+     * @param $owner_id
+     * @return mixed
+     */
+    public function confirmBill($counting_month, $owner_id);
 }

+ 10 - 11
app/OwnerBillReportArchive.php

@@ -27,17 +27,16 @@ class OwnerBillReportArchive extends Model
         'type' => [
             '' => 0,
             '仓储费' => 1,
-            '快递费-明细' => 2,
-            '快递费-合计' => 3,
-            '入库费-明细' => 4,
-            '入库费-合计' => 5,
-            '出库费-明细' => 6,
-            '出库费-合计' => 7,
-            '物流费' => 8,
-            '包材费' => 9,
-            '加工费' => 10,
-            '杂项费' => 11,
-            '卸货费' => 12,
+            '快递费-合计' => 2,
+            '入库费-合计' => 3,
+            '出库费-合计' => 4,
+            '物流费' => 5,
+            '包材费' => 6,
+            '加工费' => 7,
+            '杂项费' => 8,
+            '卸货费' => 9,
+            '总费用' => 10,
+            '理赔费' => 11,
         ],
     ];
 

+ 4 - 1
app/OwnerFeeTotal.php

@@ -27,7 +27,10 @@ class OwnerFeeTotal extends Model
         'system_fee',//系统使用费
         'system_tax_fee',//系统使用税费
         'sundry_information',//杂项费
-        'tax_rate'//税率
+        'tax_rate',//税率
+        'indemnity_fee',//理赔费
+        'packing_material_fee',//包材费
+        'unload_fee',//卸货费
     ];
 
     public $casts = [

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -155,6 +155,7 @@ use App\Services\OwnerProcessSettlementBillService;
 use App\Services\OwnerDischargeTaskSettlementBillService;
 use App\Services\OwnerFeeTotalService;
 use App\Services\OwnerWayBillFeeDetailService;
+use App\Services\SettlementIndemnityFeeService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -336,6 +337,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('RejectedService', RejectedService::class);
         app()->singleton('RoleService',RoleService::class);
         app()->singleton('SettlementBillsAreaFeeService',SettlementBillsAreaFeeService::class);
+        app()->singleton('SettlementIndemnityFeeService',SettlementIndemnityFeeService::class);
         app()->singleton('ShopService', ShopService::class);
         app()->singleton('StationCacheShelfGridService', StationCacheShelfGridService::class);
         app()->singleton('StationRuleBatchService', StationRuleBatchService::class);

+ 17 - 0
app/Services/OwnerBillReportArchiveService.php

@@ -58,4 +58,21 @@ class OwnerBillReportArchiveService
         }
         return $type;
     }
+
+    /**
+     *查询没有确认的账单
+     */
+    public function getUnAchieved($counting_month, $owner_id): array
+    {
+        //TODO   5 => "包材费"
+        //  8 => "卸货费"
+        //  9 => "理赔费"
+        //]
+        $archives = OwnerBillReportArchive::query()
+            ->where('counting_month', $counting_month)
+            ->where('owner_id', $owner_id)
+            ->pluck('type')->toArray();
+        $all = ['仓储费', '快递费-合计', '入库费-合计', '出库费-合计', '物流费', '包材费', '加工费', '杂项费', '卸货费', '理赔费',];
+        return array_diff($all, $archives);
+    }
 }

+ 12 - 1
app/Services/OwnerDischargeTaskSettlementBillService.php

@@ -6,7 +6,7 @@ use App\DischargeTask;
 use App\Traits\ServiceAppAop;
 use App\Traits\SettlementBillServiceTrait;
 
-class OwnerDischargeTaskSettlementBillService implements \App\Interfaces\SettlementBillDetailInterface
+class OwnerDischargeTaskSettlementBillService implements \App\Interfaces\SettlementBillReportInterface
 {
     use \App\Traits\SettlementBillServiceTrait;
     const TYPE = '卸货费';
@@ -58,6 +58,17 @@ class OwnerDischargeTaskSettlementBillService implements \App\Interfaces\Settlem
     {
         // TODO: Implement add() method.
     }
+
+    public function getTotalFee($owner_id, $counting_month)
+    {
+        return $this->getSql($owner_id, $counting_month)->sum('expenditure_total_cost');
+    }
+
+
+    public function recordReport($counting_month = null)
+    {
+        // TODO: Implement recordReport() method.
+    }
 }
 
 

+ 349 - 104
app/Services/OwnerFeeTotalService.php

@@ -2,17 +2,23 @@
 
 namespace App\Services;
 
+use App\OrderIssue;
 use App\Owner;
+use App\OwnerBillReport;
 use App\OwnerPriceOperation;
 use App\OwnerPriceOperationItem;
 use App\Traits\ServiceAppAop;
 use App\OwnerFeeTotal;
+use App\Traits\SettlementBillServiceTrait;
 use Illuminate\Database\Eloquent\Builder;
 
 class OwnerFeeTotalService
 {
+    const TYPE = '总费用';
     use ServiceAppAop;
 
+    use SettlementBillServiceTrait;
+
     protected $modelClass = OwnerFeeTotal::class;
 
     /**
@@ -52,90 +58,54 @@ class OwnerFeeTotalService
                     /** @var Builder $query */
                     $query->with(["items" => function ($query) {
                         /** @var Builder $query */
-                        $query->orderByRaw("CASE strategy  WHEN '起步' THEN 1 WHEN '默认' THEN 2 WHEN '特征' THEN 3 END");
+                        $query->with(['unit'])->orderByRaw("CASE strategy  WHEN '起步' THEN 1 WHEN '默认' THEN 2 WHEN '特征' THEN 3 END");
                     }]);
                 }])
             ->where('deleted_at', '>=', now()->subMonth()->startOfMonth())
             ->orWhereNull('deleted_at')->get();
         foreach ($owners as $owner) {
-            $features = app("FeatureService")->getMapArray();
-            OwnerPriceOperation::$features = $features;
-            OwnerPriceOperationItem::$features = $features;
-            foreach ($owner->ownerPriceOperations as &$operation) {
-                $operation["featureFormat"] = $operation->featureFormat;
-                $operation["isRejected"] = $operation->type_mark === 0 ? true : false;
-                foreach ($operation->items as &$item) {
-                    $item["featureFormat"] = $item->featureFormat;
-                    if ($item["strategy"] == "起步") $item["type"] = $item["amount"] ? 0 : 1;
-                }
-            }
-            $information = [
-                //仓储
-                'storageFee' => [],
-                //入库
-                'storeFee' => [],
-                //出库
-                'storeOutFee' => [],
-            ];
-            //仓储
-            foreach ($owner->ownerStoragePriceModels as $ownerStoragePriceModel) {
-                /**@var $areaFeeService SettlementBillsAreaFeeService */
-                $areaFeeService = app('SettlementBillsAreaFeeService');
-                $remark = "起租面积:{$ownerStoragePriceModel->minimum_area},{$ownerStoragePriceModel->price[0]}元/{$ownerStoragePriceModel->unit->name}/{$ownerStoragePriceModel->timeUnit->name}";
-                $information['storageFee'][] = [
-                    'name' => $ownerStoragePriceModel->name,
-                    'remark' => $remark,
-                    'id' => $ownerStoragePriceModel->id,
-                    'fee' => $areaFeeService->getTotalFee($owner->id, $counting_month)->storage_fee ?? 0,
-                    'tax_fee' => $areaFeeService->getTotalFee($owner->id, $counting_month)->storage_tax_fee ?? 0
-                ];
-            }
-
-            $ownerPriceOperationsGrouped = $owner->ownerPriceOperations->groupBy('operation_type');
-            /**@var $storeOutFeeDetailsService OwnerStoreOutFeeDetailService */
-            $storeOutFeeDetailsService = app('OwnerStoreOutFeeDetailService');
-            $workFeeTotalGrouped = $storeOutFeeDetailsService->getTotalFee($owner->id, $counting_month)->groupBy('owner_price_operation_id');
-            //入库
-            foreach ($ownerPriceOperationsGrouped['入库'] ?? [] as $ownerPriceOperationsGroupedItem) {
-                $information['storeFee'][] = [
-                    'name' => $ownerPriceOperationsGroupedItem->name,
-                    'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
-                    'id' => $ownerPriceOperationsGroupedItem->id,
-                    'fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0,
-                    'tax_fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0,
-                ];
-            }
-
-            //出库
-            foreach ($ownerPriceOperationsGrouped['出库'] ?? [] as $ownerPriceOperationsGroupedItem) {
-                $information['storeOutFee'][] = [
-                    'name' => $ownerPriceOperationsGroupedItem->name,
-                    'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
-                    'id' => $ownerPriceOperationsGroupedItem->id,
-                    'fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0,
-                    'tax_fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0,
-                ];
-            }
+            $information = $this->buildInformation($owner, $counting_month);
             $ownerFeeTotal = [];
             $ownerFeeTotal['information'] = $information;
             //快递费
-            /**@var $expressFeeService OwnerLogisticFeeReportService */
-            $expressFeeService = app('OwnerLogisticFeeReportService');
-            $expressFeeTotal = $expressFeeService->getTotalFee($owner->id, $counting_month);
-
-            $ownerFeeTotal ['logistic_fee'] = $expressFeeTotal->fee;
-            $ownerFeeTotal ['logistic_tax_fee'] = $expressFeeTotal->tax_fee;
-
-            //物流作业费
+            $ownerFeeTotal = $this->buildExpressFee($owner, $counting_month, $ownerFeeTotal);
+            //物流费
+            $ownerFeeTotal = $this->buildLogisticFee($owner, $counting_month, $ownerFeeTotal);
+            //加工
+            $ownerFeeTotal = $this->buildProcessFee($owner, $counting_month, $ownerFeeTotal);
+            //系统使用费
+            $ownerFeeTotal = $this->buildSystemFee($counting_month, $owner, $ownerFeeTotal);
+            //杂项费
+            $ownerFeeTotal = $this->buildSundryFee($owner, $counting_month, $ownerFeeTotal);
+            //理赔
+            $ownerFeeTotal = $this->buildIndemnityFee($counting_month, $owner, $ownerFeeTotal);
+            // 包材费
+            $ownerFeeTotal = $this->buildPackingMaterialFee($owner, $counting_month, $ownerFeeTotal);
+            // 卸货费
+            $ownerFeeTotal = $this->buildUnloadFee($owner, $counting_month, $ownerFeeTotal);
+            //总费用 和 总税费
+            list($totalFee, $totalTaxFee, $ownerFeeTotal) = $this->calTotalFeeAndTotalTaxFee($ownerFeeTotal);
+            //税率
+            $ownerFeeTotal = $this->calTaxRate($totalTaxFee, $totalFee, $ownerFeeTotal);
+            $insertData = $this->buildInsertData($owner, $counting_month, $ownerFeeTotal);
+            $this->createOrUpdate($owner, $counting_month, $insertData);
         }
     }
 
+    public function get(array $kvPairs)
+    {
+        return OwnerFeeTotal::query()
+            ->where('owner_id', $kvPairs['owner_id'])
+            ->where('counting_month', $kvPairs['counting_month'])
+            ->first();
+    }
+
     /**
      * 出库入库描述
      * @param $ownerPriceOperation
      * @return array
      */
-    public function buildPriceRemarks($ownerPriceOperation): array
+    private function buildPriceRemarks($ownerPriceOperation): array
     {
         //起步: 3 件 / 2.7000元  (满减单价: 0-19999 单(2.7元) , 20000-49999 单(2.5元) , 50000-99999 单(2元) , 100000+ 单(1.6元) )
         //默认续费: 1 件 / 0.5000元  (满减单价: 0-19999 单(0.5元) , 20000-49999 单(0.4元) , 50000-99999 单(0.3元) , 100000+ 单(0.2元) )
@@ -144,14 +114,15 @@ class OwnerFeeTotalService
         foreach ($ownerPriceOperation->items as $operationItem) {
             $discount_prices = explode(',', $operationItem->discount_price);
             $strategy = $operationItem->strategy == '起步' ? '起步' : '默认续费';
-            $priceRemark = "{$strategy}: {$operationItem->amount} {$operationItem->unit->name}/{$operationItem->unit_price}元";
+            $unit_name = $operationItem->unit->name ?? '个';
+            $priceRemark = "{$strategy}: {$operationItem->amount} {$unit_name}/{$operationItem->unit_price}元";
             if (!empty($discount_prices)) {
                 $priceRemark .= "(满减单价:";
                 for ($i = 0; $i < count($discount_counts) - 1; $i++) {
                     $next_discount_count = $discount_counts[$i + 1] ?? '+';
                     $discount_count = $discount_counts[$i] ?? '';
                     $discount_price = $discount_prices[$i] ?? '';
-                    $priceRemark .= "{$discount_count}-{$next_discount_count} {$operationItem->unit->name} {$discount_price}元,";
+                    $priceRemark .= "{$discount_count}-{$next_discount_count} {$unit_name} {$discount_price}元,";
                 }
                 $priceRemark .= ")";
             }
@@ -160,58 +131,332 @@ class OwnerFeeTotalService
         return $priceRemarks;
     }
 
+
     /**
-     * 重新统计
-     * @param $owner_id
+     * @param $owner
      * @param $counting_month
+     * @return array|array[]
+     */
+    private function buildInformation($owner, $counting_month): array
+    {
+        $features = app("FeatureService")->getMapArray();
+        OwnerPriceOperation::$features = $features;
+        OwnerPriceOperationItem::$features = $features;
+        foreach ($owner->ownerPriceOperations as &$operation) {
+            $operation["featureFormat"] = $operation->featureFormat;
+            $operation["isRejected"] = $operation->type_mark === 0;
+            foreach ($operation->items as &$item) {
+                $item["featureFormat"] = $item->featureFormat;
+                if ($item["strategy"] == "起步") $item["type"] = $item["amount"] ? 0 : 1;
+            }
+        }
+        $information = [
+            //仓储
+            'storageFee' => [],
+            //入库
+            'storeFee' => [],
+            //出库
+            'storeOutFee' => [],
+        ];
+        //仓储
+        foreach ($owner->ownerStoragePriceModels as $ownerStoragePriceModel) {
+            /**@var $areaFeeService SettlementBillsAreaFeeService */
+            $areaFeeService = app('SettlementBillsAreaFeeService');
+            $remark = "起租面积:{$ownerStoragePriceModel->minimum_area},{$ownerStoragePriceModel->price[0]}元/{$ownerStoragePriceModel->unit->name}/{$ownerStoragePriceModel->timeUnit->name}";
+            $information['storageFee'][] = [
+                'name' => $ownerStoragePriceModel->name,
+                'remark' => $remark,
+                'id' => $ownerStoragePriceModel->id,
+                'fee' => number_format($areaFeeService->getTotalFee($owner->id, $counting_month)->storage_fee ?? 0, 2),
+                'tax_fee' => $areaFeeService->getTotalFee($owner->id, $counting_month)->storage_tax_fee ?? 0
+            ];
+        }
+
+        $ownerPriceOperationsGrouped = $owner->ownerPriceOperations->groupBy('operation_type');
+        /**@var $storeOutFeeDetailsService OwnerStoreOutFeeDetailService */
+        $storeOutFeeDetailsService = app('OwnerStoreOutFeeDetailService');
+        $workFeeTotalGrouped = $storeOutFeeDetailsService->getTotalFee($owner->id, $counting_month)->groupBy('owner_price_operation_id');
+        //入库
+        foreach ($ownerPriceOperationsGrouped['入库'] ?? [] as $ownerPriceOperationsGroupedItem) {
+            $information['storeFee'][] = [
+                'name' => $ownerPriceOperationsGroupedItem->name,
+                'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
+                'id' => $ownerPriceOperationsGroupedItem->id,
+                'fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0, 2),
+                'tax_fee' => $workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0,
+            ];
+        }
+
+        //出库
+        foreach ($ownerPriceOperationsGrouped['出库'] ?? [] as $ownerPriceOperationsGroupedItem) {
+            $information['storeOutFee'][] = [
+                'name' => $ownerPriceOperationsGroupedItem->name,
+                'remark' => $this->buildPriceRemarks($ownerPriceOperationsGroupedItem),
+                'id' => $ownerPriceOperationsGroupedItem->id,
+                'fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_fee ?? 0, 2),
+                'tax_fee' => number_format($workFeeTotalGrouped[$ownerPriceOperationsGroupedItem->id][0]->work_tax_fee ?? 0, 2),
+            ];
+        }
+        return $information;
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildExpressFee($owner, ?string $counting_month, array $ownerFeeTotal): array
+    {
+        /**@var $expressFeeService OwnerLogisticFeeReportService */
+        $expressFeeService = app('OwnerLogisticFeeReportService');
+        $expressFeeTotal = $expressFeeService->getTotalFee($owner->id, $counting_month);
+        $ownerFeeTotal ['expressFee'] = [
+            'fee' => $expressFeeTotal->fee ?? 0,
+            'tax_fee' => $expressFeeTotal->tax_fee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildLogisticFee($owner, ?string $counting_month, array $ownerFeeTotal): array
+    {
+        /**@var $waybillSettlementBillService OwnerWaybillSettlementBillService */
+        $waybillSettlementBillService = app('OwnerWaybillSettlementBillService');
+        $logisticFeeTotal = $waybillSettlementBillService->getTotalFee($owner->id, $counting_month);
+        $ownerFeeTotal ['logisticFee'] = [
+            'fee' => $logisticFeeTotal->fee ?? 0,
+            'tax_fee' => $logisticFeeTotal->tax_fee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildProcessFee($owner, ?string $counting_month, array $ownerFeeTotal): array
+    {
+        /**@var $ownerProcessSettlementBillService OwnerProcessSettlementBillService */
+        $ownerProcessSettlementBillService = app('OwnerProcessSettlementBillService');
+        $processFeeTotal = $ownerProcessSettlementBillService->getTotalFee($owner->id, $counting_month);
+        $ownerFeeTotal ['processFee'] = [
+            'fee' => $processFeeTotal->fee ?? 0,
+            'tax_fee' => $processFeeTotal->tax_fee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param string|null $counting_month
+     * @param $owner
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildSystemFee(?string $counting_month, $owner, array $ownerFeeTotal): array
+    {
+        $ownerBillReport = OwnerBillReport::query()
+            ->where('counting_month', $counting_month)
+            ->where('owner_id', $owner->id)
+            ->first();
+        $ownerFeeTotal ['systemFee'] = [
+            'fee' => $ownerBillReport->other_fee ?? 0,
+            'tax_fee' => $ownerBillReport->other_tax_fee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildSundryFee($owner, ?string $counting_month, array $ownerFeeTotal): array
+    {
+        /**@var $ownerSundryFeeDetailService OwnerSundryFeeDetailService */
+        $ownerSundryFeeDetailService = app('OwnerSundryFeeDetailService');
+        $sundryFeeTotals = $ownerSundryFeeDetailService->getTotalFee($owner->id, $counting_month);
+        if (!$sundryFeeTotals->isEmpty()) {
+            foreach ($sundryFeeTotals as $sundryFeeTotal) {
+                $ownerFeeTotal ['sundryFee'][] = [
+                    'type' => $sundryFeeTotal->type,
+                    'fee' => $sundryFeeTotal->fee,
+                ];
+            }
+        } else {
+            $ownerFeeTotal ['sundryFee'] = [];
+        }
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param string|null $counting_month
+     * @param $owner
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildIndemnityFee(?string $counting_month, $owner, array $ownerFeeTotal): array
+    {
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        $indemnityFee = OrderIssue::query()
+            ->selectRaw("sum(baoshi_indemnity_money) as fee,owner_id,order_id")
+            ->leftJoin('orders', 'order_issues.order_id', '=', 'orders.id')
+            ->where('owner_id', $owner->id)
+            ->whereBetween('order_issues.created_at', [$start, $end])->first();
+        $ownerFeeTotal ['indemnityFee'] = [
+            'fee' => $indemnityFee->fee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
      */
-    public function restartRecord($owner_id, $counting_month)
+    private function buildPackingMaterialFee($owner, ?string $counting_month, array $ownerFeeTotal): array
     {
-//        OwnerBillTotal::query()
-//            ->where('owner_id', $owner_id)
-//            ->where('counting_month', $counting_month)
-//            ->updateOrInsert();
+        /**@var $packingMaterialFeeService OwnerProcurementSettlementBillService */
+        $packingMaterialFeeService = app('OwnerProcurementSettlementBillService');
+        $packingMaterialFee = $packingMaterialFeeService->getTotalFee($owner->id, $counting_month);
+        $ownerFeeTotal ['packingMaterialFee'] = [
+            'fee' => $packingMaterialFee ?? 0,
+        ];
+        return $ownerFeeTotal;
     }
 
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function buildUnloadFee($owner, ?string $counting_month, array $ownerFeeTotal): array
+    {
+        /**@var $unloadService OwnerDischargeTaskSettlementBillService */
+        $unloadService = app('OwnerDischargeTaskSettlementBillService');
+        $unloadFee = $unloadService->getTotalFee($owner->id, $counting_month);
+        $ownerFeeTotal ['unloadFee'] = [
+            'fee' => $unloadFee ?? 0,
+        ];
+        return $ownerFeeTotal;
+    }
 
-    public function getRecord(): array
+    /**
+     * @param array $ownerFeeTotal
+     * @return array
+     */
+    private function calTotalFeeAndTotalTaxFee(array $ownerFeeTotal): array
     {
-        $result = [];
+        $totalFee = 0;
+        $totalTaxFee = 0;
+        foreach ($ownerFeeTotal as $key => $ownerFeeTotalItem) {
+            if ($key == 'information') {
+                list($totalFee, $totalTaxFee) = $this->calInformationTotalFeeAndTotalTaxFee($ownerFeeTotalItem, $totalFee, $totalTaxFee);
+            } else if ($key == 'sundryFee') {
+                foreach ($ownerFeeTotalItem as $sundryFeeItem) {
+                    $totalFee += $sundryFeeItem['fee'] ?? 0;
+                }
+            } else {
+                $totalFee += $ownerFeeTotalItem['fee'] ?? 0;
+                $totalTaxFee += $ownerFeeTotalItem['tax_fee'] ?? 0;
+            }
+
+        }
+        $ownerFeeTotal['totalFee'] = $totalFee;
+        $ownerFeeTotal['totalTaxFee'] = $totalTaxFee;
+        return array($totalFee, $totalTaxFee, $ownerFeeTotal);
+    }
 
-        return $result;
+    /**
+     * @param $totalTaxFee
+     * @param $totalFee
+     * @param $ownerFeeTotal
+     * @return mixed
+     */
+    private function calTaxRate($totalTaxFee, $totalFee, $ownerFeeTotal)
+    {
+        try {
+            $taxRate = number_format(($totalTaxFee / $totalFee) * 100, 2) ?? 0;
+        } catch (\Exception $e) {
+            $taxRate = 0;
+        }
+        $ownerFeeTotal['taxRate'] = $taxRate;
+        return $ownerFeeTotal;
     }
 
     /**
-     * 仓储费
+     * @param $owner
      * @param string|null $counting_month
-     * @param $owner_id
+     * @param $ownerFeeTotal
      * @return array
      */
-    private function getStorageFeeForTotal(?string $counting_month, $owner_id): array
+    private function buildInsertData($owner, ?string $counting_month, $ownerFeeTotal): array
     {
-        /** @var  $service  SettlementBillsAreaFeeService */
-        $service = app('SettlementBillsAreaFeeService');
-        list($areaReports, $billReport) = $service->get([
+        return [
+            'owner_id' => $owner->id,
             'counting_month' => $counting_month,
-            'owner_id' => $owner_id,
-            'type' => $service::TYPE,
-        ]);
-        $storageFee = [
-            'data' => [],
-            'fee' => $billReport->storage_fee,
+            'information' => $ownerFeeTotal['information'],
+            'fee' => $ownerFeeTotal['totalFee'],
+            'logistic_fee' => $ownerFeeTotal['logisticFee']['fee'],
+            'logistic_tax_fee' => $ownerFeeTotal['logisticFee']['tax_fee'],
+            'express_fee' => $ownerFeeTotal['expressFee']['fee'],
+            'express_tax_fee' => $ownerFeeTotal['expressFee']['tax_fee'],
+            'process_fee' => $ownerFeeTotal['processFee']['fee'],
+            'process_tax_fee' => $ownerFeeTotal['processFee']['tax_fee'],
+            'system_fee' => $ownerFeeTotal['systemFee']['fee'],
+            'system_tax_fee' => $ownerFeeTotal['systemFee']['tax_fee'],
+            'sundry_information' => $ownerFeeTotal['sundryFee'],
+            'packing_material_fee' => $ownerFeeTotal['packingMaterialFee']['fee'],
+            'unload_fee' => $ownerFeeTotal['unloadFee']['fee'],
+            'tax_rate' => $ownerFeeTotal['taxRate'],
+            'indemnity_fee' => $ownerFeeTotal['indemnityFee']['fee'],
         ];
-        foreach ($areaReports as $areaReport) {
-            //起租面积:1.2元/m^3/天
-            $remark = '起租面积:'
-                . $areaReport->ownerStoragePriceModel->minimum_area . ','
-                . $areaReport->ownerStoragePriceModel->price . '/'
-                . $areaReport->ownerStoragePriceModel->unit->name .
-                '/' . $areaReport->ownerStoragePriceModel->timeUnit->name;
-            $storageFee['data'][] = [
-                'name' => $areaReport->ownerStoragePriceModel->name,
-                'remark' => $remark,
-            ];
+    }
+
+    /**
+     * @param $ownerFeeTotalItem
+     * @param $totalFee
+     * @param $totalTaxFee
+     * @return array|int[]
+     */
+    private function calInformationTotalFeeAndTotalTaxFee($ownerFeeTotalItem, $totalFee, $totalTaxFee): array
+    {
+        foreach ($ownerFeeTotalItem as $ownerFeeTotalItemOne) {
+            foreach ($ownerFeeTotalItemOne as $feeItem) {
+                $totalFee += $feeItem['fee'] ?? 0;
+                $totalTaxFee += $feeItem['tax_fee'] ?? 0;
+            }
+        }
+        return array($totalFee, $totalTaxFee);
+    }
+
+    /**
+     * @param $owner
+     * @param string|null $counting_month
+     * @param array $insertData
+     */
+    private function createOrUpdate($owner, ?string $counting_month, array $insertData): void
+    {
+        if (OwnerFeeTotal::query()->where('owner_id', $owner->id)->where('counting_month', $counting_month)->exists()) {
+            OwnerFeeTotal::query()
+                ->where('owner_id', $owner->id)
+                ->where('counting_month', $counting_month)
+                ->update($insertData);
+        } else {
+            OwnerFeeTotal::query()
+                ->where('owner_id', $owner->id)
+                ->where('counting_month', $counting_month)
+                ->create($insertData);
         }
-        return $storageFee;
     }
 }

+ 45 - 3
app/Services/OwnerLogisticFeeReportService.php

@@ -2,6 +2,8 @@
 
 namespace App\Services;
 
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
 use App\OwnerLogisticFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeReport;
@@ -10,10 +12,12 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
 
-class OwnerLogisticFeeReportService
+class OwnerLogisticFeeReportService implements \App\Interfaces\SettlementBillReportInterface
 {
     const TYPE = '快递费-合计';
+
     use ServiceAppAop;
+    use \App\Traits\SettlementBillServiceTrait;
 
     protected $modelClass = OwnerLogisticFeeReport::class;
 
@@ -21,6 +25,44 @@ class OwnerLogisticFeeReportService
     /** @var  $archiveService OwnerBillReportArchiveService */
     private $archiveService;
 
+
+    public function switchType($type)
+    {
+        // TODO: Implement switchType() method.
+    }
+
+    public function buildExport($details): array
+    {
+        // TODO: Implement buildExport() method.
+    }
+
+    public function confirmBill($counting_month, $owner_id)
+    {
+        $billReport = OwnerBillReport::query()
+            ->select('storage_fee', 'id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        $reports = $this->getRecords($owner_id, $counting_month);
+        $recordTotal = $this->getRecordTotal($owner_id, $counting_month);
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'reports' => $reports,
+                'recordTotal' => $recordTotal,
+            ],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+    }
+
+
     /**
      * 生成报表数据
      * 如果参数$counting_month为空 统计上一个月的
@@ -141,10 +183,10 @@ class OwnerLogisticFeeReportService
 
     /**
      * @param $owner_id
-     * @param string $counting_month
+     * @param  $counting_month
      * @return Builder
      */
-    public function getSql($owner_id, string $counting_month): Builder
+    public function getSql($owner_id, $counting_month): Builder
     {
         return OwnerLogisticFeeReport::query()
             ->with('logistic:id,name')

+ 6 - 1
app/Services/OwnerProcessSettlementBillService.php

@@ -61,7 +61,12 @@ class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
 
     public function getTotalFee($owner_id, $counting_month)
     {
-        // TODO: Implement getTotalFee() method.
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        return \Illuminate\Support\Facades\DB::table('owner_fee_details')
+            ->selectRaw("sum(work_fee) as fee,sum(work_tax_fee) as tax_fee")
+            ->where('owner_id', $owner_id)
+            ->whereBetween('created_at', [$start, $end])
+            ->first();
     }
 
 }

+ 44 - 5
app/Services/OwnerProcurementSettlementBillService.php

@@ -3,15 +3,17 @@
 namespace App\Services;
 
 use App\Interfaces\SettlementBillDetailInterface;
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
 use App\OwnerMaterial;
 use App\Procurement;
 use App\Traits\ServiceAppAop;
-use Carbon\Carbon;
-use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
 
 class OwnerProcurementSettlementBillService implements SettlementBillDetailInterface
 {
+
+
     const  TYPE = '包材费';
     use ServiceAppAop;
     use \App\Traits\SettlementBillServiceTrait;
@@ -30,6 +32,11 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
         $this->archiveService = app('OwnerBillReportArchiveService');
     }
 
+    public function getTotalFee($owner_id, $counting_month)
+    {
+        return $this->getSql($owner_id, $counting_month)->get()->sum('fee');
+    }
+
     /**
      *
      * @param array $kvPairs
@@ -40,9 +47,9 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
         if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) {
             $archived = $this->archiveService->get($kvPairs);
             $details = collect($archived['information']['details']);
-            $total_fee =$archived['information']['total_fee'];
+            $total_fee = $archived['information']['total_fee'];
         } else {
-            $details = $this->getSql($kvPairs['owner_id'],$kvPairs['counting_month'])->get();
+            $details = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->get();
             $total_fee = $details->sum('fee');
         }
         return array($details, $total_fee);
@@ -66,7 +73,7 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
 
     public function buildExport($details): array
     {
-        $result =  [];
+        $result = [];
         foreach ($details as $detail) {
             $result[] = [
                 $detail->created_at,
@@ -85,4 +92,36 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
     {
         // TODO: Implement add() method.
     }
+
+    public function confirmBill($counting_month, $owner_id)
+    {
+        $billReport = OwnerBillReport::query()
+            ->select('storage_fee', 'id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        list($details, $total_fee) = $this->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+        ]);
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'details' => $details,
+                'total_fee' => $total_fee,
+            ],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+
+    }
+
+
 }

+ 46 - 5
app/Services/OwnerStoreFeeReportService.php

@@ -3,21 +3,19 @@
 namespace App\Services;
 
 use App\OwnerBillReport;
-use App\OwnerStoreFeeDetail;
+use App\OwnerBillReportArchive;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreFeeReport;
-use App\Traits\SettlementBillTrait;
 use Carbon\Carbon;
-use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\DB;
 
-class OwnerStoreFeeReportService
+class OwnerStoreFeeReportService implements \App\Interfaces\SettlementBillReportInterface
 {
     const TYPE = '入库费-合计';
 
     use ServiceAppAop;
-    use SettlementBillTrait;
+    use \App\Traits\SettlementBillServiceTrait;
 
     protected $modelClass = OwnerStoreFeeReport::class;
 
@@ -120,4 +118,47 @@ class OwnerStoreFeeReportService
             ->where('owner_id', $owner_id)
             ->where('counting_month', $counting_month);
     }
+
+    public function switchType($type)
+    {
+        // TODO: Implement switchType() method.
+    }
+
+    public function buildExport($details): array
+    {
+        // TODO: Implement buildExport() method.
+    }
+
+    public function confirmBill($counting_month, $owner_id)
+    {
+        $billReport = OwnerBillReport::query()
+            ->select('storage_fee', 'id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        list($reports, $totalAmount, $totalFee, $owner_price_operation_fees) = $this->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+        ]);
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'reports' => $reports,
+                'totalAmount' => $totalAmount,
+                'totalFee' => $totalFee,
+                'owner_price_operation_fees' => $owner_price_operation_fees
+            ],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+    }
+
+
 }

+ 34 - 0
app/Services/OwnerStoreOutFeeReportService.php

@@ -4,6 +4,7 @@ namespace App\Services;
 
 use App\Interfaces\SettlementBillReportInterface;
 use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
 use App\OwnerStoreFeeReport;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreOutFeeReport;
@@ -17,6 +18,8 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
 
     use ServiceAppAop;
 
+    use \App\Traits\SettlementBillServiceTrait;
+
     protected $modelClass = OwnerStoreOutFeeReport::class;
     /** @var $detailService OwnerBillReportArchiveService */
     private $archiveService;
@@ -135,5 +138,36 @@ class OwnerStoreOutFeeReportService implements SettlementBillReportInterface
         return array($reports, $work_name_fee_total, $fee_total);
     }
 
+    public function confirmBill($counting_month, $owner_id)
+    {
+        $billReport = OwnerBillReport::query()
+            ->select('storage_fee', 'id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        list($reports, $work_name_fee_total, $fee_total) = $this->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+        ]);
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'reports' => $reports,
+                'work_name_fee_total' => $work_name_fee_total,
+                'fee_total' => $fee_total,
+            ],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+
+    }
+
 
 }

+ 19 - 3
app/Services/OwnerSundryFeeDetailService.php

@@ -4,11 +4,10 @@ namespace App\Services;
 
 use App\Traits\ServiceAppAop;
 use App\OwnerSundryFeeDetail;
-use Carbon\Carbon;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
 
-class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
+class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillReportInterface
 {
     use ServiceAppAop;
     use \App\Traits\SettlementBillServiceTrait;
@@ -26,7 +25,7 @@ class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetai
 
     public function getSql($owner_id, $counting_month): Builder
     {
-       list($start, $end) = $this->getStartAndEnd($counting_month);
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerSundryFeeDetail::query()
             ->with(['owner', 'logistic'])
             ->where('owner_id', $owner_id)
@@ -47,4 +46,21 @@ class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetai
     {
         // TODO: Implement add() method.
     }
+
+    public function getTotalFee($owner_id, $counting_month)
+    {
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        return OwnerSundryFeeDetail::query()
+            ->selectRaw("type,sum(fee) as fee")
+            ->where('owner_id', $owner_id)
+            ->whereBetween('created_at', [$start, $end])
+            ->groupBy('type')
+            ->get();
+    }
+
+    public function recordReport($counting_month = null)
+    {
+        // TODO: Implement recordReport() method.
+    }
+
 }

+ 9 - 3
app/Services/OwnerWaybillSettlementBillService.php

@@ -3,10 +3,10 @@
 namespace App\Services;
 
 use App\OwnerFeeDetail;
-use App\OwnerPriceLogisticDetail;
 use App\Traits\ServiceAppAop;
 use App\Waybill;
 use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Facades\DB;
 
 class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBillDetailInterface
 {
@@ -68,7 +68,7 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
                 $detail->dispatch_remark ?? '',
                 $detail->ownerWayBillFeeDetail->originate_fee ?? '',
                 $detail->ownerWayBillFeeDetail->originate_count ?? '',
-                $detail->fee ?? '',
+                $detail->ownerWayBillFeeDetail->ownerFeeDetail->logistic_fee ?? '',
             ];
         }
         return $results;
@@ -81,6 +81,12 @@ class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBil
 
     public function getTotalFee($owner_id, $counting_month)
     {
-        // TODO: Implement getTotalFee() method.
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        return DB::table('owner_way_bill_fee_details')
+            ->selectRaw("sum(owner_fee_details.logistic_fee) as fee,sum(owner_fee_details.logistic_tax_fee) as tax_fee")
+            ->leftJoin('owner_fee_details', 'owner_way_bill_fee_details.owner_fee_detail_id', '=', 'owner_fee_details.id')
+            ->whereBetween('owner_way_bill_fee_details.created_at', [$start, $end])
+            ->where('owner_fee_details.owner_id',$owner_id)
+            ->first();
     }
 }

+ 33 - 2
app/Services/SettlementBillsAreaFeeService.php

@@ -4,10 +4,10 @@ namespace App\Services;
 
 use App\OwnerAreaReport;
 use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
 use App\Traits\ServiceAppAop;
-use App\Traits\SettlementBillTrait;
 
-class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDetailInterface
+class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillReportInterface
 {
     /** @var $archiveService  OwnerBillReportArchiveService */
     private $archiveService;
@@ -15,6 +15,8 @@ class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDet
 
     use ServiceAppAop;
 
+    use \App\Traits\SettlementBillServiceTrait;
+
     /**
      * @param array $kvPairs
      * @return array
@@ -75,4 +77,33 @@ class SettlementBillsAreaFeeService implements \App\Interfaces\SettlementBillDet
     {
         // TODO: Implement add() method.
     }
+
+    public function recordReport($counting_month = null)
+    {
+        // TODO: Implement recordReport() method.
+    }
+
+    public function confirmBill($counting_month, $owner_id)
+    {
+        list($areaReports, $billReport) = $this->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+        ]);
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'areaReports' => $areaReports,
+                'billReport' => $billReport,
+            ],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+    }
+
+
 }

+ 54 - 0
app/Services/SettlementIndemnityFeeService.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Services;
+
+use App\Order;
+use App\OrderIssue;
+use App\Traits\ServiceAppAop;
+
+class SettlementIndemnityFeeService implements \App\Interfaces\SettlementBillDetailInterface
+
+{
+    const TYPE = '理赔费';
+    use ServiceAppAop;
+    use  \App\Traits\SettlementBillServiceTrait;
+
+    public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
+    {
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+        return OrderIssue::query()
+            ->with('order.shop')
+            ->whereIn('order_id', Order::query()
+                ->select('id')
+                ->where('owner_id', $owner_id)
+                ->whereBetween('created_at', [$start, $end]))
+            ->whereBetween('created_at', [$start, $end])
+            ->whereNotNull('baoshi_indemnity_money');
+    }
+
+    public function get(array $kvPairs)
+    {
+        return $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
+    }
+
+
+    public function switchType($type)
+    {
+        // TODO: Implement switchType() method.
+    }
+
+    public function buildExport($details): array
+    {
+        // TODO: Implement buildExport() method.
+    }
+
+    public function add(array $model)
+    {
+        // TODO: Implement add() method.
+    }
+
+    public function getTotalFee($owner_id, $counting_month)
+    {
+        // TODO: Implement getTotalFee() method.
+    }
+}

+ 47 - 2
app/Traits/SettlementBillServiceTrait.php

@@ -6,9 +6,9 @@ namespace App\Traits;
 
 use App\OwnerBillReport;
 use App\OwnerBillReportArchive;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\OwnerFeeTotalService;
 use Carbon\Carbon;
-use Illuminate\Http\Request;
-use Illuminate\Support\Collection;
 
 trait SettlementBillServiceTrait
 {
@@ -22,4 +22,49 @@ trait SettlementBillServiceTrait
         $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
         return array($start, $end);
     }
+
+    /**
+     * 确认账单
+     * @param $counting_month
+     * @param $owner_id
+     */
+    public function confirmBill($counting_month, $owner_id)
+    {
+        $billReport = OwnerBillReport::query()
+            ->select('id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $counting_month)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'type' => $this::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [],
+        ]);
+        $this->confirmBillFeeTotal($counting_month, $owner_id);
+    }
+
+    /**
+     * 确认总账单费用
+     * @param $counting_month
+     * @param $owner_id
+     */
+    public function confirmBillFeeTotal($counting_month, $owner_id): void
+    {
+        if ($this::TYPE !== '总费用') {
+            /**@var $archiveService  OwnerBillReportArchiveService */
+            $archiveService = app('OwnerBillReportArchiveService');
+            if (count($archiveService->getUnAchieved($counting_month, $owner_id)) == 0) {//全部子项已经确认完成
+                //确认总费用
+                /**@var $totalFeeService OwnerFeeTotalService */
+                $totalFeeService = app('OwnerFeeTotalService');
+                $totalFeeService->confirmBill($counting_month, $owner_id);
+            }
+        }
+    }
 }

+ 4 - 17
app/Traits/SettlementBillTrait.php

@@ -36,35 +36,22 @@ trait SettlementBillTrait
     /**
      * @param Request $request
      * @param $counting_month
+     * @param $owner_id
      * @return Collection|\Tightenco\Collect\Support\Collection
      */
-    public function buildRequest(Request $request, $counting_month)
+    public function buildRequest(Request $request, $counting_month,$owner_id)
     {
         $request = $request->all();
         $request['year'] = \Carbon\Carbon::parse($counting_month)->year;
         $request['month'] = \Carbon\Carbon::parse($counting_month)->month;
+        $request['owner_id'] = $owner_id;
         return collect($request);
     }
 
     public function confirmBill(Request $request): \Illuminate\Http\RedirectResponse
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
-        $billReport = OwnerBillReport::query()
-            ->select('id')
-            ->where('owner_id', $owner_id)
-            ->where('counting_month', $counting_month)
-            ->firstOr(function () {
-                return new OwnerBillReport();
-            });
-        OwnerBillReportArchive::query()->create([
-            'owner_bill_report_id' => $billReport->id ?? null,
-            'owner_id' => $owner_id,
-            'counting_month' => $counting_month,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [],
-        ]);
+        $this->service->confirmBill($counting_month, $owner_id);
         return back()->with('success', '确认成功');
     }
 }

+ 1 - 0
database/factories/OwnerFeeDetailFactory.php

@@ -23,6 +23,7 @@ $factory->define(OwnerFeeDetail::class, function (Faker $faker) {
         "weight" => mt_rand(10, 2600) / 88,           //重量
         "work_fee" => mt_rand(100, 10000) / 10,         //作业费
         "logistic_fee" => mt_rand(100, 10000) / 10,     //物流费
+        "logistic_tax_fee" => mt_rand(100, 10000) / 10,     //物流税费
         "province" => $faker->randomElement($province),     //物流费
         "logistic_id" => rand(1,100),     //物流费
     ];

+ 2 - 0
database/factories/OwnerWayBillFeeDetailFactory.php

@@ -18,5 +18,7 @@ $factory->define(OwnerWayBillFeeDetail::class, function (Faker $faker) {
         'originate_count' => rand(1, 100), //起始计数
         'price' => rand(1, 100),//起始计数
         'delivery_fee' => rand(1, 100),//送货费
+        'created_at' => now()->subMonth(),
+        'updated_at' => now()->subMonth(),
     ];
 });

+ 4 - 0
database/migrations/2021_07_06_101511_create_owner_fee_totals_table.php

@@ -20,6 +20,7 @@ class CreateOwnerFeeTotalsTable extends Migration
             $table->decimal('discount_fee')->comment('优惠费');
             $table->string('discount_remark')->comment('优惠备注');
             $table->longText('information')->comment('入库出库费');
+            $table->longText('sundry_information')->comment('入库出库费');
             $table->decimal('fee')->comment('总费用');
             $table->decimal('logistic_fee')->comment('物流费');
             $table->decimal('logistic_tax_fee')->comment('物流税费');
@@ -29,6 +30,9 @@ class CreateOwnerFeeTotalsTable extends Migration
             $table->decimal('process_tax_fee')->comment('加工税费');
             $table->decimal('system_fee')->comment('系统使用费');
             $table->decimal('system_tax_fee')->comment('系统使用税费');
+            $table->decimal('indemnity_fee')->comment('理赔费');
+            $table->decimal('packing_material_fee')->comment('包材费');
+            $table->decimal('unload_fee')->comment('卸货费');
             $table->decimal('tax_rate')->comment('税率');
             $table->timestamps();
         });

+ 0 - 1
database/seeds/SettlementBillSeeder.php

@@ -39,7 +39,6 @@ class SettlementBillSeeder extends Seeder
             //包材费
             SettlementBillPackingMaterialFeeSeeder::class,
 
-
             //杂项费
             OwnerSundryFeeDetailsTableSeeder::class,
 

+ 0 - 23
resources/views/finance/settlementBills/expressFee/detail/index.blade.php

@@ -25,29 +25,6 @@
                         <span class="ml-4 mt-2"><h5 class="font-weight-bold">{{ $owner->name }}</h5><p class="text-muted">货主</p></span>
                     </div>
                 </div>
-                <div  v-if="(isArchived===1)" class="col-3">
-                    <div class="row pt-2">
-                      <span  class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true" style="color: #4c2584;opacity: 0.3"></span>
-                      <span  class="ml-4 mt-2"><h5 class="font-weight-bold">已确认</h5></span>
-                    </div>
-                </div>
-                <div v-else class="col-3">
-                    <div class="row pt-2">
-                        <form action="{{ 'detail/confirmBill' }}" method="post" style="display: inline-block;"
-                              onsubmit="return confirm('您确定要确认金额吗?');">
-                            {{ csrf_field() }}
-                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
-                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
-                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
-                            <span class="ml-4 mt-2">
-                              <button type="submit" class="btn btn-success btn-lg">
-                                <i class="far fa-trash-alt"></i> 确认金额
-                            </button>
-                            </span>
-
-                        </form>
-                    </div>
-                </div>
             </div>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
                 <tr v-for="(detail,i) in details"

+ 194 - 0
resources/views/finance/settlementBills/indemnityFee/index.blade.php

@@ -0,0 +1,194 @@
+@extends('layouts.app')
+@section('title','理赔费用')
+@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">
+                <div class="col-3">
+                    <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 v-if="(isArchived===1)" class="col-3">
+                    <div class="row pt-2">
+                        <span class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true"
+                              style="color: #4c2584;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2"><h5 class="font-weight-bold">已确认</h5></span>
+                    </div>
+                </div>
+                <div v-else class="col-3">
+                    <div class="row pt-2">
+                        <form action="{{ 'indemnityFee/confirmBill' }}" method="post" style="display: inline-block;"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success btn-lg">
+                                <i class="far fa-trash-alt"></i> 确认金额
+                            </button>
+                            </span>
+                        </form>
+                    </div>
+                </div>
+            </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>@{{ detail.order.shop.name }}</td>
+                    <td>@{{ detail.order.client_code }}</td>
+                    <td>@{{ detail.baoshi_indemnity_money }}</td>
+                    <td>@{{ detail.order.province }}</td>
+                    <td>@{{ detail.order.city }}</td>
+                    <td>@{{ detail.order.district }}</td>
+                    <td>@{{ detail.result_explain }}</td>
+                </tr>
+            </table>
+            <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>
+            {{$details->appends($paginateParams)->links()}}
+        </div>
+        <textarea hidden 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: {
+                owner: {!! $owner !!},
+                details: [@foreach($details as $detail){!! $detail !!}, @endforeach],
+                owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                isArchived: {!! $isArchived !!},
+                request: {!! $request !!},
+                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: 'shop', value: '店铺'},
+                    {name: 'client_no', value: '客户订单号'},
+                    {name: 'fee', value: '赔付金额'},
+                    {name: 'province', value: '省'},
+                    {name: 'city', value: '市'},
+                    {name: 'district', value: '区'},
+                    {name: 'remark', value: '情况说明'},
+                ];
+                new Header({
+                    el: "table",
+                    name: "detail",
+                    column: column,
+                    data: this.details,
+                    restorationColumn: 'addtime',
+                    fixedTop: ($('#form_div').height()) + ($('#btn').height()) + 1,
+                }).init();
+            },
+            methods: {
+                detailExport(sign) {
+                    let url = '{{url('finance/settlementBills/indemnityFee/export')}}';
+                    let token = '{{ csrf_token() }}';
+                    if (sign) {
+                        excelExport(true, checkData, url, this.total, token);
+                    } else {
+                        excelExport(false, checkData, url, null, token, {
+                            owner_id: this.owner.id,
+                            year: this.request.year,
+                            month: this.request.month,
+                        });
+                    }
+                },
+            },
+            filters: {},
+        });
+    </script>
+@endsection

+ 1 - 1
resources/views/finance/settlementBills/logisticFee/index.blade.php

@@ -75,7 +75,7 @@
                     <td>@{{ detail.dispatch_remark }}</td>
                     <td>@{{ detail.owner_way_bill_fee_detail.originate_fee }}</td>
                     <td>@{{ detail.owner_way_bill_fee_detail.originate_count }}</td>
-                    <td>@{{ detail.fee }}</td>
+                    <td>@{{ detail.owner_way_bill_fee_detail.owner_fee_detail.logistic_fee }}</td>
                 </tr>
             </table>
             <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>

+ 0 - 26
resources/views/finance/settlementBills/storeFee/detail/index.blade.php

@@ -28,32 +28,6 @@
                             </span>
                     </div>
                 </div>
-                <div v-if="(isArchived===1)" class="col-3">
-                    <div class="row pt-2">
-                        <span class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true"
-                                      style="color: #4c2584;opacity: 0.3"></span>
-                        <span class="ml-4 mt-2">
-                                <h5 class="font-weight-bold">已确认</h5>
-                            </span>
-                    </div>
-                </div>
-                <div v-else class="col-3">
-                    <div class="row pt-2">
-                        <form action="{{ 'detail/confirmBill' }}" method="post" style="display: inline-block;"
-                              onsubmit="return confirm('您确定要确认金额吗?');">
-                            {{ csrf_field() }}
-                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
-                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
-                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
-                            <span class="ml-4 mt-2">
-                              <button type="submit" class="btn btn-success btn-lg">
-                                <i class="far fa-trash-alt"></i> 确认金额
-                            </button>
-                            </span>
-
-                        </form>
-                    </div>
-                </div>
             </div>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
                 <tr v-for="(detail,i) in details"

+ 0 - 23
resources/views/finance/settlementBills/storeOutFee/detail/index.blade.php

@@ -26,29 +26,6 @@
                         <span class="ml-4 mt-2"><h5 class="font-weight-bold">{{ $owner->name }}</h5><p class="text-muted">货主</p></span>
                     </div>
                 </div>
-                <div  v-if="(isArchived===1)" class="col-3">
-                    <div class="row pt-2">
-                        <span  class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true" style="color: #4c2584;opacity: 0.3"></span>
-                        <span  class="ml-4 mt-2"><h5 class="font-weight-bold">已确认</h5></span>
-                    </div>
-                </div>
-                <div v-else class="col-3">
-                    <div class="row pt-2">
-                        <form action="{{ 'detail/confirmBill' }}" method="post" style="display: inline-block;"
-                              onsubmit="return confirm('您确定要确认金额吗?');">
-                            {{ csrf_field() }}
-                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
-                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
-                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
-                            <span class="ml-4 mt-2">
-                              <button type="submit" class="btn btn-success btn-lg">
-                                <i class="far fa-trash-alt"></i> 确认金额
-                            </button>
-                            </span>
-
-                        </form>
-                    </div>
-                </div>
             </div>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
                 <tr v-for="(detail,i) in details"

+ 570 - 0
resources/views/finance/settlementBills/totalFee/index.blade.php

@@ -0,0 +1,570 @@
+@extends('layouts.app')
+@section('title','总账单')
+@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 target="_blank" class="dropdown-item" @click="detailExport(false)" href="javascript:">导出勾选内容</a>
+                            <a target="_blank" class="dropdown-item" @click="detailExport(true)" href="javascript:">导出所有页</a>
+                        </div>
+                    </span>
+            </div>
+            <div class="row">
+                <div class="col-3">
+                    <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-3">
+                    <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">@{{ feeTotal['fee'] }}</h5><p
+                                class="text-muted">总费用</p></span>
+                    </div>
+                </div>
+                <div v-if="(isArchived===1)" class="col-3">
+                    <div class="row pt-2">
+                        <span class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true"
+                              style="color: #4c2584;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2"><h5 class="font-weight-bold">已确认</h5></span>
+                    </div>
+                </div>
+                <div v-else class="col-3">
+                    <div class="row pt-2">
+                        <form action="{{ 'totalFee/confirmBill' }}" method="post" style="display: inline-block;"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success btn-lg">
+                                <i class="far fa-trash-alt"></i> 确认金额
+                            </button>
+                            </span>
+
+                        </form>
+                    </div>
+                </div>
+            </div>
+            <table class="table text-nowrap table-hover table-bordered table-striped">
+                <tr>
+                    <th>费用名称</th>
+                    <th>收费项目</th>
+                    <th>费用描述</th>
+                    <th>金额</th>
+                    <th>操作</th>
+                </tr>
+                <tr>
+                    <td>仓储费</td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storageFee']">
+                                <td>@{{ item.name }}<span v-if="item.tax_fee>0" class="badge badge-info">税</span></td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storageFee']">
+                                <td>@{{ item.remark }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storageFee']">
+                                <td>@{{ item.fee }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['storageFee']!==1" action="{{ 'storageFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+                    </td>
+                </tr>
+                <tr>
+                    <td>入库费</td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeFee']">
+                                <td>@{{ item.name }}<span v-if="item.tax_fee>0" class="badge badge-info">税</span></td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeFee']">
+                                <td class="m-0 p-0" >
+                                    <span v-for="itemInfo in item.remark">@{{ itemInfo }} </span>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeFee']">
+                                <td>@{{ item.fee }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['storeFee']!==1" action="{{ 'storeFee/report/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>出库费</td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeOutFee']">
+                                <td>@{{ item.name }}<span v-if="item.tax_fee>0" class="badge badge-info">税</span></td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeOutFee']">
+                                <td class="m-0 p-0" >
+                                    <span v-for="itemInfo in item.remark">@{{ itemInfo }} </span>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr v-for="item in feeTotal['information']['storeOutFee']">
+                                <td>@{{ item.fee }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['storeOutFee']!==1" action="{{ 'storeOutFee/report/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>配送费</td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr>
+                                <td>快递费<span v-if="feeTotal['express_tax_fee']>0" class="badge badge-info">税</span></td>
+                            </tr>
+                            <tr>
+                                <td>物流费<span v-if="feeTotal['logistic_tax_fee']>0" class="badge badge-info">税</span>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr>
+                                <td><a target="_blank"
+                                       href="{{ route('settlementBills.expressFee.report',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td><a target="_blank"
+                                       href="{{ route('settlementBills.logisticFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr>
+                                <td>@{{ feeTotal['express_fee'] }}</td>
+                            </tr>
+                            <tr>
+                                <td>@{{ feeTotal['logistic_fee'] }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0">
+                            <tr>
+                                <td class="m-0 p-0">
+                                    <form v-if="isArchivedItems['expressFee']!==1"
+                                          action="{{ 'expressFee/report/confirmBill' }}"
+                                          method="post"
+                                          onsubmit="return confirm('您确定要确认金额吗?');">
+                                        {{ csrf_field() }}
+                                        <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                                        <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                                        <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                                        <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                                    </form>
+                                    <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class="m-0 p-0">
+                                    <form v-if="isArchivedItems['logisticFee']!==1"
+                                          action="{{ 'logisticFee/confirmBill' }}"
+                                          method="post"
+                                          onsubmit="return confirm('您确定要确认金额吗?');">
+                                        {{ csrf_field() }}
+                                        <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                                        <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                                        <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                                        <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                                    </form>
+                                    <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                                </td>
+                            </tr>
+                        </table>
+
+                    </td>
+
+                </tr>
+                <tr>
+                    <td>库内加工</td>
+                    <td>加工作业<span v-if="feeTotal['process_tax_fee']>0" class="badge badge-info">税</span></td>
+                    <td><a target="_blank"
+                           href="{{ route('settlementBills.processFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
+                    </td>
+                    <td>@{{ feeTotal['process_fee'] }}</td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['processFee']!==1"
+                              action="{{ 'processFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>系统使用费</td>
+                    <td>系统使用费<span v-if="feeTotal['system_tax_fee']>0" class="badge badge-info">税</span></td>
+                    <td>-</td>
+                    <td>@{{ feeTotal['system_fee'] }}</td>
+                </tr>
+                <tr>
+                    <td>包材费</td>
+                    <td>包材费</td>
+                    <td><a target="_blank"
+                           href="{{ route('settlementBills.packingMaterialFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}"></a>
+                    </td>
+                    <td>@{{ feeTotal['packing_material_fee'] }}</td>
+                    <!--                   TODO -->
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['packingMaterialFee']!==1"
+                              action="{{ 'packingMaterialFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>卸货费</td>
+                    <td>卸货费</td>
+                    <td><a target="_blank"
+                           href="{{ route('settlementBills.unloadFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}"></a>
+                    </td>
+                    <td>@{{ feeTotal['unload_fee'] }}</td>
+                    <!--                   TODO -->
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['unloadFee']!==1"
+                              action="{{ 'unloadFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>杂项费</td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0"
+                               v-for="sundryFee in feeTotal['sundry_information']">
+                            <tr>
+                                <td>@{{ sundryFee.type }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table   m-0 p-0"
+                               v-for="sundryFee in feeTotal['sundry_information']">
+                            <tr>
+                                <td><a target="_blank"
+                                       href="{{ route('settlementBills.sundryFee', ['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <table class="table  m-0 p-0"
+                               v-for="sundryFee in feeTotal['sundry_information']">
+                            <tr>
+                                <td>@{{ sundryFee.fee }}</td>
+                            </tr>
+                        </table>
+                    </td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['sundryFee']!==1"
+                              action="{{ 'sundryFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>理赔</td>
+                    <td>责任理赔</td>
+                    <td><a target="_blank"
+                           href="{{ route('settlementBills.indemnityFee',['owner_id' => $request['owner_id'],'year' => $request['year'],'month' => $request['month']]) }}">查看明细</a>
+                    </td>
+                    <td>@{{ feeTotal['indemnity_fee'] }}</td>
+                    <td class="m-0 p-0">
+                        <form v-if="isArchivedItems['indemnityFee']!==1"
+                              action="{{ 'indemnityFee/confirmBill' }}"
+                              method="post"
+                              onsubmit="return confirm('您确定要确认金额吗?');">
+                            {{ csrf_field() }}
+                            <input type="hidden" name="owner_id" value="{{ $request['owner_id']??'' }}">
+                            <input type="hidden" name="year" value="{{ $request['year']??'' }}">
+                            <input type="hidden" name="month" value="{{ $request['month']??'' }}">
+                            <span class="ml-4 mt-2">
+                              <button type="submit" class="btn btn-success">
+                                 确认金额
+                            </button>
+                            </span>
+                        </form>
+                        <h5 v-else class="text-center pt-1 font-weight-bold">已确认</h5>
+
+                    </td>
+                </tr>
+                <tr>
+                    <td>优惠</td>
+                    <td>优惠政策</td>
+                    <td>@{{ feeTotal['discount_remark'] }}</td>
+                    <td>@{{ feeTotal['discount_fee'] }}</td>
+                </tr>
+                <tr>
+                    <td>税率</td>
+                    <td>@{{ feeTotal['tax_rate'] }}%</td>
+                </tr>
+                <tr>
+                    <td class="text-right font-weight-bolder" rowspan="3">
+                        公司名称:
+                        <br>
+                        开户银行:
+                        <br>
+                        公司账号:
+                    </td>
+                    <td class="font-weight-bolder" colspan="3">
+                        上海宝时供应链管理有限公司
+                        <br>
+                        中国工商银行股份有限公司上海市松江科技城支行
+                        <br>
+                        1001 7341 0900 0118 429
+                    </td>
+                </tr>
+            </table>
+        </div>
+    </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: {
+                owner: {!! $owner !!},
+                feeTotal: {!! $feeTotal !!},
+                owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                isArchived: {!! $isArchived !!},
+                request: {!! $request !!},
+                selectTr: 0,
+                isArchivedItems: {!! $isArchivedItems !!},
+            },
+            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();
+            },
+            methods: {
+                detailExport(sign) {
+                    let url = '{{url('finance/settlementBills/unloadFee/export')}}';
+                    let token = '{{ csrf_token() }}';
+                    if (sign) {
+                        excelExport(true, checkData, url, this.total, token);
+                    } else {
+                        excelExport(false, checkData, url, null, token, {
+                            owner_id: this.owner.id,
+                            year: this.request.year,
+                            month: this.request.month,
+                        });
+                    }
+                },
+            },
+            filters: {},
+        });
+    </script>
+@endsection

+ 20 - 7
routes/web.php

@@ -794,8 +794,8 @@ Route::group(['prefix'=>'finance'],function(){
             Route::post('report/confirmBill', 'SettlementBillExpressFeeReportController@confirmBill');
             Route::any('detail/export', 'SettlementBillExpressFeeDetailController@export');
             Route::any('report/export', 'SettlementBillExpressFeeReportController@export');
-            Route::resource('detail', 'SettlementBillExpressFeeDetailController', ['only' => ['index']]);
-            Route::resource('report', 'SettlementBillExpressFeeReportController', ['only' => ['index']]);
+            Route::get('detail', 'SettlementBillExpressFeeDetailController@index')->name('settlementBills.expressFee.detail');
+            Route::get('report', 'SettlementBillExpressFeeReportController@index')->name('settlementBills.expressFee.report');
         });
         //仓储费
         Route::group(['prefix' => 'storageFee'], function () {
@@ -823,34 +823,47 @@ Route::group(['prefix'=>'finance'],function(){
         });
         //杂项费
         Route::group(['prefix' => 'sundryFee'], function () {
-            Route::get('', 'SettlementBillSundryFeeController@index');
+            Route::get('', 'SettlementBillSundryFeeController@index')->name('settlementBills.sundryFee');
             Route::post('confirmBill', 'SettlementBillSundryFeeController@confirmBill');
             Route::post('export', 'SettlementBillSundryFeeController@export');
         });
         //包材费
         Route::group(['prefix' => 'packingMaterialFee'], function () {
-            Route::get('', 'SettlementBillPackingMaterialFeeController@index');
+            Route::get('', 'SettlementBillPackingMaterialFeeController@index')->name('settlementBills.packingMaterialFee');
             Route::post('confirmBill', 'SettlementBillPackingMaterialFeeController@confirmBill');
             Route::any('export', 'SettlementBillPackingMaterialFeeController@export');
         });
         //加工费
         Route::group(['prefix' => 'processFee'], function () {
-            Route::get('', 'SettlementBillProcessFeeController@index');
+            Route::get('', 'SettlementBillProcessFeeController@index')->name('settlementBills.processFee');
             Route::post('confirmBill', 'SettlementBillProcessFeeController@confirmBill');
             Route::any('export', 'SettlementBillProcessFeeController@export');
         });
         //卸货费
         Route::group(['prefix' => 'unloadFee'], function () {
-            Route::get('', 'SettlementBillUnloadFeeController@index');
+            Route::get('', 'SettlementBillUnloadFeeController@index')->name('settlementBills.unloadFee');
             Route::post('confirmBill', 'SettlementBillUnloadFeeController@confirmBill');
             Route::any('export', 'SettlementBillUnloadFeeController@export');
         });
         //物流费
         Route::group(['prefix' => 'logisticFee'], function () {
-            Route::get('', 'SettlementBillLogisticFeeController@index');
+            Route::get('', 'SettlementBillLogisticFeeController@index')->name('settlementBills.logisticFee');
             Route::post('confirmBill', 'SettlementBillLogisticFeeController@confirmBill');
             Route::any('export', 'SettlementBillLogisticFeeController@export');
         });
+        //总费用
+        Route::group(['prefix' => 'totalFee'], function () {
+            Route::get('', 'OwnerFeeTotalController@index');
+            Route::post('confirmBill', 'OwnerFeeTotalController@confirmBill');
+            Route::any('export', 'OwnerFeeTotalController@export');
+        });
+
+        //理赔费
+        Route::group(['prefix' => 'indemnityFee'], function () {
+            Route::get('', 'SettlementIndemnityFeeController@index')->name('settlementBills.indemnityFee');
+            Route::post('confirmBill', 'SettlementIndemnityFeeController@confirmBill');
+            Route::any('export', 'SettlementIndemnityFeeController@export');
+        });
     });
 });