Kaynağa Gözat

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

 Conflicts:
	app/Services/OrderPackageReceivedSyncService.php
LD 4 yıl önce
ebeveyn
işleme
ead0cbbe9d
23 değiştirilmiş dosya ile 663 ekleme ve 228 silme
  1. 55 21
      app/Http/Controllers/OwnerLogisticFeeDetailController.php
  2. 98 29
      app/Http/Controllers/OwnerLogisticFeeReportController.php
  3. 68 81
      app/Http/Controllers/SettlementBillOwnerAreaFeeController.php
  4. 17 16
      app/OwnerBillReportArchive.php
  5. 2 0
      app/Providers/AppServiceProvider.php
  6. 1 1
      app/Services/LogisticYDService.php
  7. 44 21
      app/Services/OrderPackageReceivedSyncService.php
  8. 54 3
      app/Services/OwnerBillReportArchiveService.php
  9. 2 0
      app/Services/OwnerLogisticFeeDetailService.php
  10. 46 18
      app/Services/OwnerLogisticFeeReportService.php
  11. 78 0
      app/Services/SettlementBillsAreaFeeService.php
  12. 5 2
      database/factories/OwnerBillReportFactory.php
  13. 1 1
      database/migrations/2021_06_15_110826_add_logistic_number_and_logistic_id_and_amount_and_price_to_owner_sundry_fee_details.php
  14. 37 0
      database/migrations/2021_06_16_153322_create_owner_bill_report_archives_table.php
  15. 27 0
      database/seeds/OwnerAreaReportTableSeeder.php
  16. 24 0
      database/seeds/OwnerBillReportTableSeeder.php
  17. 2 1
      database/seeds/OwnerLogisticFeeDetailSeeder.php
  18. 1 1
      database/seeds/OwnerStoragePriceModelSeeder.php
  19. 1 1
      resources/js/queryForm/export.js
  20. 13 11
      resources/views/finance/settlementBills/areaFee/index.blade.php
  21. 35 7
      resources/views/finance/settlementBills/logisticFee/detail/index.blade.php
  22. 49 14
      resources/views/finance/settlementBills/logisticFee/report/index.blade.php
  23. 3 0
      routes/web.php

+ 55 - 21
app/Http/Controllers/OwnerLogisticFeeDetailController.php

@@ -3,8 +3,12 @@
 namespace App\Http\Controllers;
 
 use App\Owner;
-use App\OwnerLogisticFeeDetail;
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
+use App\Services\OwnerBillReportArchiveService;
 use App\Services\OwnerLogisticFeeDetailService;
+use Carbon\Carbon;
+use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Oursdreams\Export\Export;
 
@@ -13,6 +17,9 @@ class OwnerLogisticFeeDetailController extends Controller
     /** @var $service OwnerLogisticFeeDetailService */
     private $service;
 
+    /** @var  $archiveService OwnerBillReportArchiveService */
+    private $archiveService;
+
     /**
      * Display a listing of the resource.
      *
@@ -20,16 +27,19 @@ class OwnerLogisticFeeDetailController extends Controller
     public function index(Request $request)
     {
         $paginateParams = $request->input();
-        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request);
+        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
         $details = $this->service->getDetails($owner_id, $start, $end, $paginateParams);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
-        $owner = Owner::query()->selectRaw("name")->find($owner_id);
-        return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner'));
+        $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        $isArchived =  $this->archiveService->isArchived($start, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
+        $request = collect($request->all());
+        return view('finance.settlementBills.logisticFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request','isArchived'));
     }
 
     public function export(Request $request)
     {
-        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request);
+        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
         $query = $this->service->getSql($owner_id, $start, $end);
         if (!$request->exists('checkAllSign')) {
             $query->whereIn('id', explode(',', $request['data']));
@@ -44,31 +54,55 @@ class OwnerLogisticFeeDetailController extends Controller
     }
 
     /**
-     * @param Request $request
+     * @param $owner_id
+     * @param $year
+     * @param $month
      * @return array
      */
-    private function getRequestParams(Request $request): array
+    private function getRequestParams($owner_id, $year, $month): array
     {
         $this->service = app('OwnerLogisticFeeDetailService');
         $this->userService = app('UserService');
         $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
-
-        if (is_null($request->owner_id)) {
+        if (is_null($owner_id)) {
             $owner_id = $permittingOwnerIds[0];
-        } else {
-            $owner_id = $request->owner_id;
         }
-        if (is_null($request->start)) {
-            $start = now()->subMonth()->startOfMonth()->toDateString();
-        } else {
-            $start = $request->start;
+        if (is_null($year)) {
+            $year = now()->subMonth()->year;
         }
-
-        if (is_null($request->end)) {
-            $end = now()->subMonth()->endOfMonth()->toDateString();
-        } else {
-            $end = $request->end;
+        if (is_null($month)) {
+            $month = now()->subMonth()->month;
         }
-        return array($permittingOwnerIds, $owner_id, $start, $end);
+        $day = Carbon::parse($year . '-' . $month . '-01');
+        return array($permittingOwnerIds, $owner_id, $day->startOfMonth()->toDateString(), $day->endOfMonth()->toDateString());
+    }
+
+    /**
+     * 确认账单
+     * @param Request $request
+     * @return RedirectResponse
+     */
+    public function confirmBill(Request $request)
+    {
+        $this->service = app('OwnerLogisticFeeDetailService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
+        $billReport = OwnerBillReport::query()
+            ->select('storage_fee', 'id')
+            ->where('owner_id', $owner_id)
+            ->where('counting_month', $start)
+            ->firstOr(function () {
+                return new OwnerBillReport();
+            });
+        OwnerBillReportArchive::query()->create([
+            'owner_bill_report_id' => $billReport->id ?? null,
+            'owner_id' => $owner_id,
+            'counting_mouth' => $start,
+            'type' => $this->service::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [],
+        ]);
+        return back()->with('success', '确认成功');
     }
 }

+ 98 - 29
app/Http/Controllers/OwnerLogisticFeeReportController.php

@@ -3,11 +3,14 @@
 namespace App\Http\Controllers;
 
 use App\Owner;
-use App\OwnerLogisticFeeReport;
-use App\Services\common\ExportService;
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
+use App\Services\OwnerBillReportArchiveService;
 use App\Services\OwnerLogisticFeeReportService;
 use App\Services\UserService;
+use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
+use Illuminate\Pagination\LengthAwarePaginator;
 use Oursdreams\Export\Export;
 
 class OwnerLogisticFeeReportController extends Controller
@@ -17,6 +20,9 @@ class OwnerLogisticFeeReportController extends Controller
     /* @var UserService $userService */
     private $userService;
 
+    /** @var  $archiveService OwnerBillReportArchiveService */
+    private $archiveService;
+
     /**
      * OwnerLogisticFeeReportController constructor.
      */
@@ -32,32 +38,59 @@ class OwnerLogisticFeeReportController extends Controller
     public function index(Request $request)
     {
         $paginateParams = $request->input();
-        list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
-        $reports = $this->service->getRecordPagination($owner_id, $date, $paginateParams);
-        $recordTotal = $this->service->getRecordTotal($owner_id, $date);
-        $owner = Owner::query()->selectRaw("name")->find($owner_id);
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        list($reports, $recordTotal) = $this->service->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'paginateParams' => $paginateParams,
+            'type' => $this->service::TYPE,
+        ]);
+        $reportPaginator = null;
+        if ($reports instanceof LengthAwarePaginator) {
+            $reportPaginator = $reports;
+            $reports = collect($reportPaginator->items());
+        }
+        $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
-        return view('finance.settlementBills.logisticFee.report.index', compact('reports', 'recordTotal', 'paginateParams', 'owners', 'owner'));
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-合计']);
+
+        $request = $request->all();
+        $request['year'] = \Carbon\Carbon::parse($counting_month)->year;
+        $request['month'] = \Carbon\Carbon::parse($counting_month)->month;
+        $request = collect($request);
+        return view('finance.settlementBills.logisticFee.report.index', compact('reports', 'recordTotal', 'paginateParams', 'owners', 'owner', 'isArchived', 'request', 'reportPaginator'));
     }
 
     public function export(Request $request)
     {
-        list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
-        $query = $this->service->getSql($owner_id, $date);
-        if (!$request->exists('checkAllSign')) {
-            $query->whereIn('id', explode(',', $request['data']));
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        if ($this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE) == 1) {
+            //已确认账单导出
+            list($reports, $recordTotal) = $this->service->get([
+                'owner_id' => $owner_id,
+                'counting_month' => $counting_month,
+                'type' => $this->service::TYPE,
+            ]);
+        } else {
+            //未确认账单导出
+            $query = $this->service->getSql($owner_id, $counting_month);
+            if (!$request->exists('checkAllSign')) {
+                $query->whereIn('id', explode(',', $request['data']));
+            }
+            $reports = $query->get();
         }
-        $reports = $query->get();
         $json = [];
         foreach ($reports as $report) {
             $json[] = [
-                $report->logistic->name ?? '',
-                $report->province,
-                $report->initial_weight,
-                $report->initial_amount,
-                $report->additional_weight,
-                $report->additional_amount,
-                $report->fee,
+                $report['logistic']['name'] ?? '',
+                $report['province'],
+                $report['initial_weight'],
+                $report['initial_amount'],
+                $report['additional_weight'],
+                $report['additional_amount'],
+                $report['fee'],
             ];
         }
         $row = ['快递公司', '地区', '首重', '订单数', '续重', '续重合计', '(省份)合计'];
@@ -65,24 +98,60 @@ class OwnerLogisticFeeReportController extends Controller
     }
 
     /**
-     * @param Request $request
+     * @param $year
+     * @param $month
+     * @param $owner_id
      * @return array
      */
-    private function getRequestParams(Request $request): array
+    private function getRequestParams($year, $month, $owner_id): array
     {
         $this->service = app('OwnerLogisticFeeReportService');
         $this->userService = app('UserService');
         $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
-        if (is_null($request->year) || is_null($request->month)) {
-            $date = now()->subMonth()->startOfMonth()->toDateString();
-        } else {
-            $date = $request->year . '-' . $request->month . '-' . '01';
+        if (is_null($year)) {
+            $year = now()->subMonth() ->year;
         }
-        if (is_null($request->owner_id)) {
+        if (is_null($month)) {
+            $month = now()->subMonth()->month;
+        }
+        $counting_month = $year . '-' . $month . '-' . '01';
+        if (is_null($owner_id)) {
             $owner_id = $permittingOwnerIds[0];
-        } else {
-            $owner_id = $request->owner_id;
         }
-        return array($permittingOwnerIds, $date, $owner_id);
+        return array($permittingOwnerIds, $counting_month, $owner_id);
+    }
+
+    /**
+     * 确认账单
+     * @param Request $request
+     * @return RedirectResponse
+     */
+    public function confirmBill(Request $request)
+    {
+        $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_mouth' => $counting_month,
+            'type' => $this->service::TYPE,
+            'archiver_id' => auth()->id(),
+            'archived_at' => now(),
+            'information' => [
+                'reports' => $reports,
+                'recordTotal' => $recordTotal,
+            ],
+        ]);
+        return back()->with('success', '确认成功');
     }
 }

+ 68 - 81
app/Http/Controllers/SettlementBillOwnerAreaFeeController.php

@@ -3,10 +3,13 @@
 namespace App\Http\Controllers;
 
 use App\Owner;
-use App\OwnerAreaReport;
-use App\OwnerBillReport;
 use App\OwnerBillReportArchive;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\SettlementBillsAreaFeeService;
+use Carbon\Carbon;
+use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
+use Oursdreams\Export\Export;
 
 /**
  * 结算管理-结算账单-仓储费
@@ -15,6 +18,11 @@ use Illuminate\Http\Request;
  */
 class SettlementBillOwnerAreaFeeController extends Controller
 {
+    /* @var $service SettlementBillsAreaFeeService */
+    private $service;
+    /** @var  $archiveService OwnerBillReportArchiveService */
+    private $archiveService;
+
     /**
      * SettlementBillOwnerAreaFeeController constructor.
      */
@@ -25,103 +33,82 @@ class SettlementBillOwnerAreaFeeController extends Controller
 
     public function index(Request $request)
     {
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request);
-        $isArchived = $this->ownerBillReportArchiveQuery($counting_month, $owner_id)->exists();
-        $isArchived =  $isArchived ? 1 : 2;
-        list($areaReports, $billReport, $price) = $this->get($owner_id, $counting_month);
+        $this->service = app('SettlementBillsAreaFeeService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
+
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
+        $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['仓储费']);
+        list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month);
         $owners = Owner::query()->find($permittingOwnerIds);
         $owner = Owner::query()->find($owner_id);
+        $request = $request->all();
+        $request['year'] = Carbon::parse($counting_month)->year;
+        $request['month'] = Carbon::parse($counting_month)->month;
+        $request = collect($request);
         return view('finance.settlementBills.areaFee.index', compact('owner', 'owners', 'areaReports', 'billReport', 'price', 'request', 'isArchived'));
     }
 
+
     /**
-     * @param Request $request year month owner_id
-     * @return array
+     * 确认账单
+     * @param Request $request
+     * @return RedirectResponse
      */
-    private function getRequestParams(Request $request): array
-    {
-        $this->service = app('OwnerLogisticFeeReportService');
-        $this->userService = app('UserService');
-        $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
-        if (is_null($request->year) || is_null($request->month)) {
-            $counting_month = now()->subMonth()->startOfMonth()->toDateString();
-        } else {
-            $counting_month = $request->year . '-' . $request->month . '-' . '01';
-        }
-        if (is_null($request->owner_id)) {
-            $owner_id = $permittingOwnerIds[0];
-        } else {
-            $owner_id = $request->owner_id;
-        }
-        return array($permittingOwnerIds, $counting_month, $owner_id);
-    }
-
     public function confirmBill(Request $request)
     {
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request);
-        list($areaReports, $billReport, $price) = $this->get($owner_id, $counting_month);
-        $information = [
-            'areaReports' => $areaReports,
-            'billReport' => $billReport,
-            'price' => $price,
-        ];
+        $this->service = app('SettlementBillsAreaFeeService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
+        list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month);
         OwnerBillReportArchive::query()->create([
             'owner_bill_report_id' => $billReport->id ?? null,
             'owner_id' => $owner_id,
-            'counting_mouth' => $counting_month,
-            'type' => '仓储费',
+            'counting_month' => $counting_month,
+            'type' => $this->service::TYPE,
             'archiver_id' => auth()->id(),
             'archived_at' => now(),
-            'information' => $information,
+            'information' => [
+                'areaReports' => $areaReports,
+                'billReport' => $billReport,
+                'price' => $price,
+            ],
         ]);
-        return back();
+        return back()->with('success', '确认成功');
     }
 
-    /**
-     * @param $owner_id
-     * @param $counting_month
-     * @return array
-     */
-    private function get($owner_id, $counting_month): array
+    public function export(Request $request)
     {
-        $archived = $this->ownerBillReportArchiveQuery($counting_month, $owner_id)->first();
-        if ($archived ?? false) {
-            $areaReports = collect($archived->information['areaReports']);
-            $billReport = collect($archived->information['billReport']);
-            $price = $archived->information['price'];
-        } else {
-            $areaReports = OwnerAreaReport::query()
-                ->with('ownerStoragePriceModel:id,using_type,price')
-                ->where('owner_id', $owner_id)
-                ->where('counting_month', $counting_month)
-                ->get();
-            $billReport = OwnerBillReport::query()
-                ->selectRaw('storage_fee')
-                ->where('owner_id', $owner_id)
-                ->where('counting_month', $counting_month)
-                ->firstOr(function () {
-                    return new OwnerBillReport();
-                });
-            $totalArea = $areaReports->reduce(function ($carry, $areaReport) {
-                return $carry + $areaReport->accounting_area;
-            }, 0);
-            try {
-                $price = $billReport->storage_fee ?? 0 / $totalArea;
-            } catch (\Exception $e) {
-                $price = 0;
-            }
+        $this->service = app('SettlementBillsAreaFeeService');
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->getRequestParams($request->year, $request->month, $request->owner_id);
+        list($areaReports, $billReport, $price) = $this->service->get($owner_id, $counting_month);
+        $json = [];
+        foreach ($areaReports as $areaReport) {
+            $json[] = [
+                $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'],
+                '平面区',
+                $areaReport['area_on_flat'],
+                $areaReport['accounting_area'],
+                $price,
+                $billReport['storage_fee'],
+            ];
+            $json[] = [
+                $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'],
+                '整托存储',
+                $areaReport['area_on_tray'],
+                $areaReport['accounting_area'],
+                $price,
+                $billReport['storage_fee'],
+            ];
+            $json[] = [
+                $areaReport['owner_storage_price_model']['using_type']??$areaReport['ownerStoragePriceModel']['using_type'],
+                '半托存储',
+                $areaReport['area_on_half_tray'],
+                $areaReport['accounting_area'],
+                $price,
+                $billReport['storage_fee'],
+            ];
         }
-        return array($areaReports, $billReport, $price);
-    }
-
-    /**
-     * @param $counting_month
-     * @param $owner_id
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    private function ownerBillReportArchiveQuery($counting_month, $owner_id): \Illuminate\Database\Eloquent\Builder
-    {
-        return OwnerBillReportArchive::query()->where('counting_mouth', $counting_month)
-            ->where('owner_id', $owner_id)->where('type', '仓储费');
+        $row = ['仓库类型', '使用区域', '数量', '合计面积', '单价', '金额',];
+        return Export::make($row, $json, "仓储费");
     }
 }

+ 17 - 16
app/OwnerBillReportArchive.php

@@ -11,11 +11,11 @@ class OwnerBillReportArchive extends Model
 {
     use ModelLogChanging;
 
-    public $fillable = ['owner_bill_report_id', 'owner_id', 'counting_mouth', 'type', 'archiver_id', 'archived_at', 'information'];
+    public $fillable = ['owner_bill_report_id', 'owner_id', 'counting_month', 'type', 'archiver_id', 'archived_at', 'information'];
 
     public $dates = [
         'archived_at',
-        'counting_mouth'
+        'counting_month'
     ];
 
     public $casts = [
@@ -24,38 +24,39 @@ class OwnerBillReportArchive extends Model
 
     public $timestamps = false;
     static public $enums = [
-        'types' => [
+        'type' => [
             '' => 0,
             '仓储费' => 1,
-            '快递费' => 2,
-            '入库费' => 3,
-            '出库费' => 4,
-            '物流费' => 5,
-            '包材费' => 6,
-            '加工费' => 7,
-            '杂项' => 8,
-            '卸货费' => 9,
+            '快递费-明细' => 2,
+            '快递费-合计' => 3,
+            '入库费' => 4,
+            '出库费' => 5,
+            '物流费' => 6,
+            '包材费' => 7,
+            '加工费' => 8,
+            '杂项' => 9,
+            '卸货费' => 10,
         ],
     ];
 
     function __construct(array $attributes = [])
     {
         foreach (self::$enums as &$enum) {
-            $enum = $enum + array_flip($enum);
+            $enum=$enum+array_flip($enum);
         }
         parent::__construct($attributes);
     }
 
-    public function getTypesAttribute($value)
+    public function getTypeAttribute($value)
     {
         if (!$value) return '';
-        return self::$enums['types'][$value];
+        return self::$enums['type'][$value];
     }
 
-    public function setTypesAttribute($value): int
+    public function setTypeAttribute($value)
     {
         if (!$value) return 0;
-        $this->attributes['types'] = self::$enums['types'][$value];
+        $this->attributes['type'] = self::$enums['type'][$value];
     }
 
     public function ownerBillReport(): BelongsTo

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -143,6 +143,7 @@ use App\Services\OwnerLogisticFeeDetailService;
 use App\Services\OwnerLogisticFeeReportService;
 use App\Services\LogisticSyncRecordService;
 use App\Services\OwnerBillReportArchiveService;
+use App\Services\SettlementBillsAreaFeeService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -312,6 +313,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('RejectedBillService', RejectedBillService::class);
         app()->singleton('RejectedService', RejectedService::class);
         app()->singleton('RoleService',RoleService::class);
+        app()->singleton('SettlementBillsAreaFeeService',SettlementBillsAreaFeeService::class);
         app()->singleton('ShopService', ShopService::class);
         app()->singleton('StationCacheShelfGridService', StationCacheShelfGridService::class);
         app()->singleton('StationRuleBatchService', StationRuleBatchService::class);

+ 1 - 1
app/Services/LogisticYDService.php

@@ -51,7 +51,7 @@ class LogisticYDService
                     "county" => $order->district,
                     "name" => $order->consignee_name,
                     "phone" => $order->consignee_phone,
-                    "province" => $order->province
+                    "province" => $order->province ?? $order->city,
                 ],
                 "sender" => $sender
             ];

+ 44 - 21
app/Services/OrderPackageReceivedSyncService.php

@@ -25,15 +25,15 @@ class OrderPackageReceivedSyncService
      * 2 如果当前时间小于等于初始化时间,执行初始化脚本,将数据库中全部小于等于初始化时间的数据更新
      * @throws Exception
      */
-    public function syncLogisticRoute($is_to_init=false)
+    public function syncLogisticRoute($is_to_init = false)
     {
         ini_set('max_execution_time', 2 * 60 * 60);
         ini_set('memory_limit', '1024M');
         LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法", '');
         $query = OrderPackage::query()
-            ->select(['logistic_number', 'order_id','id'])
+            ->select(['logistic_number', 'order_id', 'id'])
             ->with(['order' => function ($query) {
-                return $query->select(['id','logistic_id'])->with('logistic:id,name,code');
+                return $query->select(['id', 'logistic_id'])->with('logistic:id,name,code');
             }]);
         if ($is_to_init) {//当前时间小于等于初始化时间
             $initDate = Carbon::parse(config('api_logistic.init_date'));
@@ -45,7 +45,7 @@ class OrderPackageReceivedSyncService
                 ->whereNull('received_at');
         }
         $query->chunkById(1000, function ($orderPackages) {
-            LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法", json_encode(data_get($orderPackages,'*.logistic_number')));
+            LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法", json_encode(data_get($orderPackages, '*.logistic_number')));
             $logisticNumbers = $this->buildData($orderPackages);
             //sf
             if (array_key_exists('SF', $logisticNumbers)) {
@@ -89,40 +89,63 @@ class OrderPackageReceivedSyncService
     {
         ini_set('max_execution_time', 2 * 60 * 60);
         $query = OrderPackage::query()
-            ->select(['logistic_number', 'order_id','id'])
-            ->whereIn('order_id',function ($query){
-                $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
-                    $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->whereNotIn('belong_company',['顺丰','中通','韵达','圆通','京东']);
+            ->select(['logistic_number', 'order_id'])
+            ->whereIn('order_id', function ($query) {
+                $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
+                    $builder->from('logistics')->selectRaw('id')->where('type', '!=', '物流')->whereNotIn('belong_company', ['顺丰', '中通', '韵达', '圆通', '京东']);
                 });
             });
         $query = $query->where('sent_at', '>=', now()->subDays(config('api_logistic.querying_days')))
             ->whereNull('received_at');
         $query->chunkById(200, function ($orderPackages) {
             LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-阿里公用接口", json_encode($orderPackages));
-            foreach ($orderPackages as $orderPackage){
-                if ($orderPackage && $orderPackage->logistic_number)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
+            foreach ($orderPackages as $orderPackage) {
+                if ($orderPackage && $orderPackage->logistic_number) LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
             }
         });
         $this->syncLogisticRouteJD();
     }
-    public function syncLogisticRouteJD(){
+
+    public function syncLogisticRouteJD()
+    {
         ini_set('max_execution_time', 60);
         $query = OrderPackage::query()
-            ->select(['logistic_number', 'order_id','id'])
-            ->whereIn('order_id',function ($query){
-                $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
-                    $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->where('belong_company','京东');
+            ->select(['logistic_number', 'order_id'])
+            ->whereIn('order_id', function ($query) {
+                $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
+                    $builder->from('logistics')->selectRaw('id')->where('type', '!=', '物流')->where('belong_company', '京东');
                 });
             });
-        $query = $query->where('created_at', '>=', now()->subDays(config('api_logistic.querying_days')))
-            ->whereNull('received_at')->where('logistic_number','like','JD%');
-        $query->chunkById(200, function ($orderPackages) {
+        $query = $query->where('created_at', '>=', now()->subDays(20))
+            ->whereNull('received_at')->where('logistic_number', 'like', 'JD%');
+        $query->chunk(200, function ($orderPackages) {
             LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-JD", json_encode($orderPackages));
-            foreach ($orderPackages as $orderPackage){
-                if ($orderPackage && $orderPackage->logistic_number)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
+            foreach ($orderPackages as $orderPackage) {
+                if ($orderPackage && $orderPackage->logistic_number) LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
             }
         });
     }
+
+    public function syncLogisticRouteYTO()
+    {
+        ini_set('max_execution_time', 120);
+        $query = OrderPackage::query()
+            ->select(['logistic_number', 'order_id'])
+            ->whereIn('order_id', function ($query) {
+                $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
+                    $builder->from('logistics')->selectRaw('id')->where('type', '!=', '物流')->where('belong_company', '圆通');
+                });
+            });
+        $query = $query->where('sent_at', '>=', now()->subDays(20))
+            ->whereNull('received_at');
+        $query->chunk(1000, function ($orderPackages) {
+            LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", json_encode($orderPackages));
+            foreach ($orderPackages as $orderPackage) {
+                if ($orderPackage && $orderPackage->logistic_number) LogisticYTOSync::dispatch($orderPackage->logistic_number);
+            }
+        });
+    }
+
     /**
      * 根据传递的承运商与快递单号更新快递信息
      * @param array $logisticNumbers 快递单号
@@ -213,7 +236,7 @@ class OrderPackageReceivedSyncService
             try {
                 $logisticCode = $orderPackage->order->logistic->code;
             } catch (Exception $e) {
-                LogService::log(OrderPackageReceivedSyncService::class, "快递同步按照承运商分组异常", json_encode($orderPackage??[]));
+                LogService::log(OrderPackageReceivedSyncService::class, "快递同步按照承运商分组异常", json_encode($orderPackage ?? []));
                 continue;
             }
             $key = config('api_logistic.logistic.' . $logisticCode);

+ 54 - 3
app/Services/OwnerBillReportArchiveService.php

@@ -1,13 +1,64 @@
-<?php 
+<?php
 
 namespace App\Services;
 
+use App\OwnerAreaReport;
+use App\OwnerBillReport;
 use App\Traits\ServiceAppAop;
 use App\OwnerBillReportArchive;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Model;
 
 class OwnerBillReportArchiveService
 {
     use ServiceAppAop;
-    protected $modelClass=OwnerBillReportArchive::class;
 
-}
+    protected $modelClass = OwnerBillReportArchive::class;
+
+    /**
+     * @param $counting_month
+     * @param $owner_id
+     * @param $type
+     * @return Builder
+     */
+    public function getSql($counting_month, $owner_id, $type): Builder
+    {
+        return OwnerBillReportArchive::query()->where('counting_month', $counting_month)
+            ->where('owner_id', $owner_id)->where('type', $type);
+    }
+
+    /**
+     * @param $counting_month
+     * @param $owner_id
+     * @param $type
+     * @return int
+     */
+    public function isArchived($counting_month, $owner_id, $type): int
+    {
+        $type = $this->switchType($type);
+        return $this->getSql($counting_month, $owner_id, $type)->exists() ? 1 : 2;
+    }
+
+    /**
+     * 获取确认账单数据
+     * @param array $kvPairs
+     * @return Builder|Model|object|null
+     */
+    public function get(array $kvPairs)
+    {
+        return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'], $this->switchType($kvPairs['type']))->first();
+    }
+
+    /**
+     * @param $type
+     * @return int|mixed
+     */
+    private function switchType($type)
+    {
+//枚举转换
+        if (is_string($type)) {
+            $type = OwnerBillReportArchive::$enums['type'][$type];
+        }
+        return $type;
+    }
+}

+ 2 - 0
app/Services/OwnerLogisticFeeDetailService.php

@@ -13,6 +13,8 @@ use Illuminate\Support\Collection;
 
 class OwnerLogisticFeeDetailService
 {
+    const TYPE = '快递费-明细';
+
     use ServiceAppAop;
 
     /**

+ 46 - 18
app/Services/OwnerLogisticFeeReportService.php

@@ -12,25 +12,28 @@ use Illuminate\Database\Eloquent\Collection;
 
 class OwnerLogisticFeeReportService
 {
+    const TYPE = '快递费-合计';
     use ServiceAppAop;
 
     protected $modelClass = OwnerLogisticFeeReport::class;
 
     private $reportDate;
+    /** @var  $archiveService OwnerBillReportArchiveService */
+    private $archiveService;
 
     /**
      * 生成报表数据
-     * 如果参数$date为空 统计上一个月的
-     * 如果参数$date为2021-01-01 则统计2021-01-01 -- 2021-01-31之间的数据
-     * @param null $date 统计月份,默认统计上个月的 2021-05-01
+     * 如果参数$counting_month为空 统计上一个月的
+     * 如果参数$counting_month为2021-01-01 则统计2021-01-01 -- 2021-01-31之间的数据
+     * @param null $counting_month 统计月份,默认统计上个月的 2021-05-01
      */
-    public function recordReport($date = null)
+    public function recordReport($counting_month = null)
     {
-        if (is_null($date)) {
+        if (is_null($counting_month)) {
             //默认统计上个月的数据
-            $date = now()->subMonth()->startOfMonth()->toDateTimeString();
+            $counting_month = now()->subMonth()->startOfMonth()->toDateTimeString();
         }
-        $this->reportDate = $date;
+        $this->reportDate = $counting_month;
 
         $start = $this->reportDate;
         $end = Carbon::parse($this->reportDate)->endOfMonth()->toDateTimeString();
@@ -64,31 +67,56 @@ class OwnerLogisticFeeReportService
     /**
      * 订单统计分页查询
      * @param $owner_id
-     * @param $date string 查询的年月 2021-05-01
+     * @param $counting_month string 查询的年月 2021-05-01
      * @param $paginateParams
      * @return LengthAwarePaginator
      */
-    public function getRecordPagination($owner_id, string $date,$paginateParams): LengthAwarePaginator
+    private function getRecordPagination($owner_id, string $counting_month, $paginateParams): LengthAwarePaginator
     {
-        return $this->getSql($owner_id, $date)
-            ->paginate($paginateParams['paginate']??50);
+        return $this->getSql($owner_id, $counting_month)
+            ->paginate($paginateParams['paginate'] ?? 50);
+    }
+
+    public function get(array $kvPairs): array
+    {
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        if ($this->archiveService->isArchived($kvPairs['counting_month'], $kvPairs['owner_id'], $kvPairs['type']) == 1) {
+            $archived = $this->archiveService->get($kvPairs);
+            $reports =collect($archived->information['reports']);
+            $recordTotal = $archived->information['recordTotal'];
+        } else {
+            $recordTotal = $this->getRecordTotal($kvPairs['owner_id'], $kvPairs['counting_month']);
+            $reports = $this->getRecordPagination($kvPairs['owner_id'], $kvPairs['counting_month'], $kvPairs['paginateParams']);
+        }
+        return array($reports, $recordTotal);
+    }
+
+    /**
+     * 订单统计查询
+     * @param $owner_id
+     * @param $counting_month string 查询的年月 2021-05-01
+     * @return Builder[]|Collection
+     */
+    public function getRecords($owner_id, string $counting_month)
+    {
+        return $this->getSql($owner_id, $counting_month)->get();
     }
 
     /**
      * 订单总计查询
      * @param $owner_id
-     * @param $date string 查询的年月 2021-05-01
+     * @param $counting_month string 查询的年月 2021-05-01
      * @return array
      */
-    public function getRecordTotal($owner_id, string $date): array
+    public function getRecordTotal($owner_id, string $counting_month): array
     {
         $logistic_fee = OwnerLogisticFeeReport::query()
             ->where('owner_id', $owner_id)
-            ->where('counted_date', $date)
+            ->where('counted_date', $counting_month)
             ->sum('fee');
         $order_count = (int)OwnerLogisticFeeReport::query()
             ->where('owner_id', $owner_id)
-            ->where('counted_date', $date)
+            ->where('counted_date', $counting_month)
             ->sum('initial_amount');
         return [
             'logistic_fee' => $logistic_fee,
@@ -98,15 +126,15 @@ class OwnerLogisticFeeReportService
 
     /**
      * @param $owner_id
-     * @param string $date
+     * @param string $counting_month
      * @return Builder
      */
-    public function getSql($owner_id, string $date): Builder
+    public function getSql($owner_id, string $counting_month): Builder
     {
         return OwnerLogisticFeeReport::query()
             ->with('logistic:id,name')
             ->where('owner_id', $owner_id)
-            ->where('counted_date', $date)
+            ->where('counted_date', $counting_month)
             ->orderByDesc('logistic_id')
             ->orderByDesc('province');
     }

+ 78 - 0
app/Services/SettlementBillsAreaFeeService.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace App\Services;
+
+use App\OwnerAreaReport;
+use App\OwnerBillReport;
+use App\Traits\ServiceAppAop;
+
+class SettlementBillsAreaFeeService
+{
+    /** @var $archiveService  OwnerBillReportArchiveService */
+    private $archiveService;
+    const TYPE = '仓储费';
+
+    use ServiceAppAop;
+
+    /**
+     * @param $year
+     * @param $month
+     * @param $owner_id
+     * @return array
+     */
+    public function getRequestParams($year, $month, $owner_id): array
+    {
+        $this->service = app('OwnerLogisticFeeReportService');
+        $this->userService = app('UserService');
+        $permittingOwnerIds = $this->userService->getPermittingOwnerIds(auth()->user());
+        if (is_null($year)) {
+            $year = now()->subMonth()->year;
+        }
+        if (is_null($month)) {
+            $month = now()->subMonth()->month;
+        }
+        $counting_month = $year . '-' . $month . '-' . '01';
+        if (is_null($owner_id)) {
+            $owner_id = $permittingOwnerIds[0];
+        }
+        return array($permittingOwnerIds, $counting_month, $owner_id);
+    }
+
+    /**
+     * @param $owner_id
+     * @param $counting_month
+     * @return array
+     */
+    public function get($owner_id, $counting_month): array
+    {
+        $this->archiveService = app('OwnerBillReportArchiveService');
+        $archived = $this->archiveService->getSql(\Carbon\Carbon::parse($counting_month)->toDateString(), $owner_id, \App\OwnerBillReportArchive::$enums['type']['仓储费'])->first();
+        if ($archived ?? false) {
+            $areaReports = collect($archived->information['areaReports']);
+            $billReport = collect($archived->information['billReport']);
+            $price = $archived->information['price'];
+        } else {
+            $areaReports = OwnerAreaReport::query()
+                ->with('ownerStoragePriceModel:id,using_type,price')
+                ->where('owner_id', $owner_id)
+                ->where('counting_month', $counting_month)
+                ->get();
+            $billReport = OwnerBillReport::query()
+                ->select(['storage_fee', 'id'])
+                ->where('owner_id', $owner_id)
+                ->where('counting_month', $counting_month)
+                ->firstOr(function () {
+                    return new OwnerBillReport();
+                });
+            $totalArea = $areaReports->reduce(function ($carry, $areaReport) {
+                return $carry + $areaReport->accounting_area;
+            }, 0);
+            try {
+                $price = number_format(($billReport->storage_fee ?? 0) / $totalArea, 3);
+            } catch (\Exception $e) {
+                $price = 0;
+            }
+        }
+        return array($areaReports, $billReport, $price);
+    }
+}

+ 5 - 2
database/factories/OwnerBillReportFactory.php

@@ -6,8 +6,8 @@ use App\OwnerBillReport;
 use Faker\Generator as Faker;
 
 $factory->define(OwnerBillReport::class, function (Faker $faker) {
-    $initial_fee = mt_rand(0,50000) / 10;
-    $confirm_fee = mt_rand(0,50000) / 10;
+    $initial_fee = mt_rand(0, 50000) / 10;
+    $confirm_fee = mt_rand(0, 50000) / 10;
     return [
 //        "owner_id" => factory(\App\Owner::class),       //项目ID
         "counting_month" => $faker->date(), //结算月
@@ -15,5 +15,8 @@ $factory->define(OwnerBillReport::class, function (Faker $faker) {
         "confirm_fee" => $confirm_fee,    //确认账单金额
         "difference" => $confirm_fee - $initial_fee,     //差额
         "confirmed" => "否",      //确认状态
+        "work_fee" => mt_rand(10, 100),      //操作费
+        "logistic_fee" => mt_rand(10, 100),   //物流费
+        "storage_fee" => mt_rand(10, 100),    //仓储费
     ];
 });

+ 1 - 1
database/migrations/2021_06_15_110826_add_logistic_number_and_logistic_id_and_amount_and_price_to_owner_sundry_fee_details.php

@@ -32,7 +32,7 @@ class AddLogisticNumberAndLogisticIdAndAmountAndPriceToOwnerSundryFeeDetails ext
             $table->dropColumn('logistic_number');
             $table->dropColumn('logistic_id');
             $table->dropColumn('amount');
-            $table->dropColumn('price;');
+            $table->dropColumn('price');
         });
     }
 }

+ 37 - 0
database/migrations/2021_06_16_153322_create_owner_bill_report_archives_table.php

@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateOwnerBillReportArchivesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('owner_bill_report_archives', function (Blueprint $table) {
+            $table->id();
+            $table->integer('owner_bill_report_id')->nullable();
+            $table->integer('owner_id');
+            $table->date('counting_month')->comment('结算月');
+            $table->integer('type')->comment('归档类型');
+            $table->integer('archiver_id')->comment('归档人');
+            $table->timestamp('archived_at')->comment('归档时间');
+            $table->text('information')->comment('归档信息json数组');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('owner_bill_report_archives');
+    }
+}

+ 27 - 0
database/seeds/OwnerAreaReportTableSeeder.php

@@ -0,0 +1,27 @@
+<?php
+
+use App\OwnerAreaReport;
+use App\OwnerStoragePriceModel;
+use Illuminate\Database\Seeder;
+
+class OwnerAreaReportTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        OwnerAreaReport::query()->truncate();
+        OwnerStoragePriceModel::query()->truncate();
+        $owners = \App\Owner::query()->get();
+        foreach ($owners as $owner) {
+            factory(OwnerAreaReport::class)->create([
+                'user_owner_group_id' => random_int(1, 100),
+                'owner_id' => $owner->id,
+                'counting_month' =>'2021-05-01'
+            ]);
+        }
+    }
+}

+ 24 - 0
database/seeds/OwnerBillReportTableSeeder.php

@@ -0,0 +1,24 @@
+<?php
+
+use App\OwnerBillReport;
+use Illuminate\Database\Seeder;
+
+class OwnerBillReportTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        OwnerBillReport::query()->truncate();
+        $owners = \App\Owner::query()->get();
+        foreach ($owners as $owner) {
+            factory(OwnerBillReport::class)->create([
+                'owner_id' => $owner->id,
+                'counting_month' =>'2021-05-01'
+            ]);
+        }
+    }
+}

+ 2 - 1
database/seeds/OwnerLogisticFeeDetailSeeder.php

@@ -53,7 +53,8 @@ class OwnerLogisticFeeDetailSeeder extends Seeder
 //                'updated_at' => now()->subMonth()->startOfMonth()->addDays(4)
 //            ]
 //        );
-
+        OwnerLogisticFeeDetail::query()->truncate();
+        OwnerFeeDetail::query()->truncate();
         factory(OwnerLogisticFeeDetail::class)->times(200)->create();
         $details = OwnerLogisticFeeDetail::all();
         foreach ($details as $detail) {

+ 1 - 1
database/seeds/OwnerStoragePriceModelSeeder.php

@@ -11,6 +11,6 @@ class OwnerStoragePriceModelSeeder extends Seeder
      */
     public function run()
     {
-        factory(\App\OwnerStoragePriceModel::class,3)->create();
+        factory(\App\OwnerStoragePriceModel::class,100)->create();
     }
 }

+ 1 - 1
resources/js/queryForm/export.js

@@ -38,4 +38,4 @@ function excelExport(checkAllSign,checkData,url,sum,token,reservation = null) {
             form.submit();
         }
     }
-}
+}

+ 13 - 11
resources/views/finance/settlementBills/areaFee/index.blade.php

@@ -13,8 +13,7 @@
                                 data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
                         </button>
                         <div class="dropdown-menu">
-{{--                            <a class="dropdown-item" @click="ownerFeeExport(false)" href="javascript:">导出勾选内容</a>--}}
-                            <a class="dropdown-item" @click="ownerFeeExport(true)" href="javascript:">导出所有页</a>
+                            <a class="dropdown-item" @click="areaFeeExport(true)" href="javascript:">导出所有页</a>
                         </div>
                     </span>
             </div>
@@ -47,8 +46,7 @@
                     <td>@{{ areaReport.area_on_flat?areaReport.area_on_flat:0 }}</td>
                     <td rowspan="3" class="text-center pt-4 bg-light">@{{ areaReport.accounting_area }}</td>
                     <td :rowspan="areaReports.length*3" class="text-center pt-4 bg-light">@{{ price }}</td>
-                    <td :rowspan="areaReports.length*3" class="text-center pt-4 bg-light">@{{ billReport.storage_fee
-                        }}
+                    <td :rowspan="areaReports.length*3" class="text-center pt-4 bg-light">@{{ billReport.storage_fee }}
                     </td>
                 </tr>
                 <tr v-for="(areaReport,i) in areaReports">
@@ -68,9 +66,9 @@
                     <form action="{{ 'areaFee/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 }}">
+                        <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']??''}}">
                         <button type="submit" class="btn btn-outline-success btn-sm">
                             <i class="far fa-trash-alt"></i> 确认金额
                         </button>
@@ -78,7 +76,6 @@
                 </div>
             </div>
         </div>
-        {{--        <textarea id="clipboardDiv" style="opacity:0"></textarea>--}}
     </div>
 @endsection
 @section('lastScript')
@@ -95,6 +92,7 @@
                 owner: {!! $owner !!},
                 price: {!! $price !!},
                 isArchived: {!! $isArchived !!},
+                request: {!! $request !!},
                 selectTr: 0,
             },
             created() {
@@ -167,13 +165,17 @@
                 _this.form.init();
             },
             methods: {
-                ownerFeeExport(sign) {
-                    let url = '{{url('finance/settlementBills/logisticFee/ownerFee/export')}}';
+                areaFeeExport(sign) {
+                    let url = '{{url('finance/settlementBills/areaFee/confirmBill/export')}}';
                     let token = '{{ csrf_token() }}';
                     if (sign) {
                         excelExport(true, checkData, url, this.total, token);
                     } else {
-                        excelExport(false, checkData, url, null, token);
+                        excelExport(false, checkData, url, null, token, {
+                            owner_id: this.owner.id,
+                            year: this.request.year,
+                            month: this.request.month,
+                        });
                     }
                 },
             },

+ 35 - 7
resources/views/finance/settlementBills/logisticFee/detail/index.blade.php

@@ -24,6 +24,11 @@
                                 <h5 class="font-weight-bold">{{ $owner->name }}</h5>
                                 <p class="text-muted">货主</p>
                             </span>
+                <span v-if="(isArchived===1)" class="fa fa-check-circle  fa-4x offset-md-3" aria-hidden="true"
+                      style="color: #4c2584;opacity: 0.3"></span>
+                <span v-if="(isArchived===1)" class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">已确认</h5>
+                            </span>
             </div>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
                 <tr v-for="(detail,i) in details"
@@ -32,7 +37,8 @@
                     <td><input class="checkItem" type="checkbox" :value="detail.id"></td>
                     <td>@{{ i+1 }}</td>
                     <td v-if="i==0 || detail.logistic_name!== details[i-1].logistic_name"
-                        :rowspan="calRowspan(detail.logistic_name)" class="text-center pt-4 bg-light">@{{ detail.logistic_name }}
+                        :rowspan="calRowspan(detail.logistic_name)" class="text-center pt-4 bg-light">@{{
+                        detail.logistic_name }}
                     </td>
                     <td>@{{ detail.province }}</td>
                     <td>@{{ detail.logistic_bill }}</td>
@@ -42,6 +48,23 @@
                     <td>@{{ detail.logistic_fee }}</td>
                 </tr>
             </table>
+            <div class="container" v-if="!(isArchived===1) && details.length>0">
+                <div class="row">
+                    <div class="col-10"></div>
+                    <div class="col-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']??''}}">
+                            <button type="submit" class="btn btn-outline-success btn-sm">
+                                <i class="far fa-trash-alt"></i> 确认金额
+                            </button>
+                        </form>
+                    </div>
+                </div>
+            </div>
             <div class="text-info h5 btn btn">{{$details->count()}}/{{$details->total()}}</div>
             {{$details->appends($paginateParams)->links()}}
         </div>
@@ -56,9 +79,9 @@
         let vue = new Vue({
             el: "#list",
             data: {
+                owner: {!! $owner !!},
                 details: [
-                        @foreach($details as $detail)
-                    {
+                        @foreach($details as $detail){
                         id: " {!! $detail['id'] !!}",
                         logistic_name: " {!! $detail['logistic_name'] !!}",
                         province: " {!! $detail['province'] !!}",
@@ -66,11 +89,12 @@
                         weight: "{!! $detail['weight'] !!}",
                         logistic_fee: "{!! $detail['logistic_fee'] !!}",
                         initial_weight_price: "{!! $detail['initial_weight_price'] !!}",
-                        additional_price: "{!! $detail['additional_price'] !!}"
-                    },
+                        additional_price: "{!! $detail['additional_price'] !!}",},
                     @endforeach
                 ],
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                isArchived: {!! $isArchived !!},
+                request: {!! $request !!},
                 selectTr: 0,
             },
             created() {
@@ -138,7 +162,7 @@
                 _this.form = new query({
                     el: '#form_div',
                     condition: data,
-                    appendDom : "btn",
+                    appendDom: "btn",
                 });
                 _this.form.init();
                 let column = [
@@ -170,7 +194,11 @@
                     if (sign) {
                         excelExport(true, checkData, url, this.total, token);
                     } else {
-                        excelExport(false, checkData, url, null, token);
+                        excelExport(false, checkData, url, null, token,{
+                            owner_id:this.owner.id,
+                            year:this.request.year,
+                            month:this.request.month,
+                        });
                     }
                 },
             },

+ 49 - 14
resources/views/finance/settlementBills/logisticFee/report/index.blade.php

@@ -13,22 +13,24 @@
                                 data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
                         </button>
                         <div class="dropdown-menu">
-                            <a class="dropdown-item" @click="reportExport(false)" href="javascript:">导出勾选内容</a>
+                             @if($isArchived===2 )
+                                <a class="dropdown-item" @click="reportExport(false)" href="javascript:">导出勾选内容</a>
+                            @endif
                             <a class="dropdown-item" @click="reportExport(true)" href="javascript:">导出所有页</a>
                         </div>
                     </span>
             </div>
             <div class="row">
-                <div class="col-4">
+                <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>
+                                <h5 class="font-weight-bold">@{{ owner.name }}</h5>
                                 <p class="text-muted">货主</p>
                             </span>
                     </div>
                 </div>
-                <div class="col-4">
+                <div class="col-3">
                     <div class="row pt-2">
                         <span class="fa fa-cubes fa-4x offset-md-3" style="color: #9fcdff;opacity: 0.3"></span>
                         <span class="ml-4 mt-2">
@@ -37,7 +39,7 @@
                             </span>
                     </div>
                 </div>
-                <div class="col-4">
+                <div class="col-3">
                     <div class="row pt-2">
                         <span class="fa fa-jpy fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
                         <span class="ml-4 mt-2">
@@ -46,6 +48,15 @@
                         </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>
             <table class="table table-striped table-sm text-nowrap table-hover table-bordered" id="table">
                 <tr v-for="(report,i) in reports"
@@ -54,7 +65,8 @@
                     <td><input class="checkItem" type="checkbox" :value="report.id"></td>
                     <td>@{{ i+1 }}</td>
                     <td v-if="i==0 || report.logistic.name!== reports[i-1].logistic.name"
-                        :rowspan="calRowspan(report.logistic.name)" class="text-center pt-4 bg-light">@{{ report.logistic.name }}
+                        :rowspan="calRowspan(report.logistic.name)" class="text-center pt-4 bg-light">@{{
+                        report.logistic.name }}
                     </td>
                     <td>@{{ report.province }}</td>
                     <td>@{{ report.initial_weight }}</td>
@@ -64,8 +76,28 @@
                     <td>@{{ report.fee }}</td>
                 </tr>
             </table>
-            <div class="text-info h5 btn btn">{{$reports->count()}}/{{$reports->total()}}</div>
-            {{$reports->appends($paginateParams)->links()}}
+            <div class="container" v-if="!(isArchived===1) && reports.length>0">
+                <div class="row">
+                    <div class="col-10"></div>
+                    <div class="col-2">
+                        <form action="{{ 'report/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']??'' }}">
+                            <button type="submit" class="btn btn-outline-success btn-sm">
+                                <i class="far fa-trash-alt"></i> 确认金额
+                            </button>
+                        </form>
+                    </div>
+                </div>
+            </div>
+            @if($isArchived===2 )
+                <div class="text-info h5 btn btn">{{$reportPaginator->count()??''}}
+                    /{{$reportPaginator->total()??''}}</div>
+                <span>{{$reportPaginator->appends($paginateParams)->links()??''}}</span>
+            @endif
         </div>
         <textarea id="clipboardDiv" style="opacity:0"></textarea>
     </div>
@@ -78,12 +110,11 @@
         let vue = new Vue({
             el: "#list",
             data: {
-                reports: [
-                    @foreach($reports as $report)
-                        {!! $report !!},
-                    @endforeach
-                ],
+                owner: {!! $owner !!},
+                reports: {!! $reports !!},
                 owners: [@foreach($owners as $owner){name: '{{ $owner->id }}', value: '{{ $owner->name}}'},@endforeach],
+                isArchived: {!! $isArchived !!},
+                request: {!! $request !!},
                 selectTr: 0,
             },
             created() {
@@ -183,7 +214,11 @@
                     if (sign) {
                         excelExport(true, checkData, url, this.total, token);
                     } else {
-                        excelExport(false, checkData, url, null, token);
+                        excelExport(false, checkData, url, null, token, {
+                            owner_id: this.owner.id,
+                            year: this.request.year,
+                            month: this.request.month,
+                        });
                     }
                 },
             },

+ 3 - 0
routes/web.php

@@ -783,6 +783,8 @@ Route::group(['prefix'=>'finance'],function(){
     Route::group(['prefix'=>'settlementBills'],function(){
 //        Route::resource('ownerSundryFeeDetails', 'OwnerSundryFeeDetailsController', ['only' => ['index', 'create', 'store', 'update', 'edit','destroy']]);
         Route::group(['prefix' => 'logisticFee'], function () {
+            Route::post('detail/confirmBill', 'OwnerLogisticFeeDetailController@confirmBill');
+            Route::post('report/confirmBill', 'OwnerLogisticFeeReportController@confirmBill');
             Route::any('detail/export', 'OwnerLogisticFeeDetailController@export');
             Route::any('report/export', 'OwnerLogisticFeeReportController@export');
             Route::resource('detail', 'OwnerLogisticFeeDetailController', ['only' => ['index']]);
@@ -790,6 +792,7 @@ Route::group(['prefix'=>'finance'],function(){
         });
         Route::get('areaFee','SettlementBillOwnerAreaFeeController@index');
         Route::post('areaFee/confirmBill','SettlementBillOwnerAreaFeeController@confirmBill');
+        Route::any('areaFee/confirmBill/export','SettlementBillOwnerAreaFeeController@export');
     });
 });