浏览代码

卸货费

ANG YU 4 年之前
父节点
当前提交
0eee9aa5e6

+ 4 - 1
app/DischargeTask.php

@@ -61,5 +61,8 @@ class DischargeTask extends Model
         return $this->belongsTo(Warehouse::class);
     }
 
-
+    public function getTypeAttribute($index)
+    {
+        return $this::types[$index];
+    }
 }

+ 62 - 0
app/Http/Controllers/OwnerDischargeTaskSettlementBillController.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Owner;
+use App\Services\OwnerBillReportArchiveService;
+use App\Services\OwnerDischargeTaskSettlementBillService;
+use App\Traits\SettlementBillTrait;
+use Illuminate\Http\Request;
+use Oursdreams\Export\Export;
+
+class OwnerDischargeTaskSettlementBillController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
+{
+    use SettlementBillTrait;
+
+
+    /** @var OwnerDischargeTaskSettlementBillService $service */
+    private $service;
+
+    /** @var OwnerBillReportArchiveService $archiveService */
+    private $archiveService;
+
+
+    /**
+     * OwnerDischargeTaskSettlementBillController constructor.
+     */
+    public function __construct()
+    {
+        $this->service = app('OwnerDischargeTaskSettlementBillService');
+        $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);
+        list($details, $totalFee) = $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);
+        return view('finance.settlementBills.dischargeTask.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'totalFee'));
+
+    }
+
+    public function export(Request $request)
+    {
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
+        $query = $this->service->getSql($owner_id, $counting_month);
+        if (!$request->exists('checkAllSign')) {
+            $query->whereIn('id', explode(',', $request['data']));
+        }
+        $details = $query->get();
+        $json = $this->service->buildExport($details);
+        $row = ['日期', '作业类型', '入库单号', '数量', '单位', '单价', '收费', '收入描述', '支出吗描述'];
+        return Export::make($row, $json, "卸货费");
+    }
+}

+ 20 - 63
app/Http/Controllers/OwnerLogisticFeeDetailController.php

@@ -2,18 +2,16 @@
 
 namespace App\Http\Controllers;
 
+use App\Interfaces\SettlementBillControllerInterface;
 use App\Owner;
-use App\OwnerBillReport;
 use App\OwnerBillReportArchive;
 use App\Services\OwnerBillReportArchiveService;
 use App\Services\OwnerLogisticFeeDetailService;
 use App\Traits\SettlementBillTrait;
-use Carbon\Carbon;
-use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Oursdreams\Export\Export;
 
-class OwnerLogisticFeeDetailController extends Controller
+class OwnerLogisticFeeDetailController extends Controller implements SettlementBillControllerInterface
 {
     use  SettlementBillTrait;
 
@@ -23,6 +21,14 @@ class OwnerLogisticFeeDetailController extends Controller
     /** @var  $archiveService OwnerBillReportArchiveService */
     private $archiveService;
 
+    /**
+     * OwnerLogisticFeeDetailController constructor.
+     */
+    public function __construct()
+    {
+        $this->service = app('OwnerLogisticFeeDetailService');
+        $this->archiveService = app('OwnerBillReportArchiveService');
+    }
     /**
      * Display a listing of the resource.
      *
@@ -30,20 +36,24 @@ class OwnerLogisticFeeDetailController extends Controller
     public function index(Request $request)
     {
         $paginateParams = $request->input();
-        list($permittingOwnerIds, $owner_id, $start, $end) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
-        $details = $this->service->getDetails($owner_id, $start, $end, $paginateParams);
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month,$request->owner_id);
+        $details = $this->service->get([
+            'owner_id' => $owner_id,
+            'counting_month' => $counting_month,
+            'paginateParams' => $paginateParams,
+        ]);
         $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
         $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
         $this->archiveService = app('OwnerBillReportArchiveService');
-        $isArchived = $this->archiveService->isArchived($start, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
-        $request = $this->buildRequest($request,$start);
+        $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
+        $request = $this->buildRequest($request, $counting_month);
         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->owner_id, $request->year, $request->month);
-        $query = $this->service->getSql($owner_id, $start, $end);
+        list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->owner_id, $request->year, $request->month);
+        $query = $this->service->getSql($owner_id, $counting_month);
         if (!$request->exists('checkAllSign')) {
             $query->whereIn('id', explode(',', $request['data']));
         }
@@ -55,57 +65,4 @@ class OwnerLogisticFeeDetailController extends Controller
         $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
         return Export::make($row, $json, "快递费用详情");
     }
-
-    /**
-     * @param $owner_id
-     * @param $year
-     * @param $month
-     * @return 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($owner_id)) {
-            $owner_id = $permittingOwnerIds[0];
-        }
-        if (is_null($year)) {
-            $year = now()->subMonth()->year;
-        }
-        if (is_null($month)) {
-            $month = now()->subMonth()->month;
-        }
-        $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_month' => $start,
-            'type' => $this->service::TYPE,
-            'archiver_id' => auth()->id(),
-            'archived_at' => now(),
-            'information' => [],
-        ]);
-        return back()->with('success', '确认成功');
-    }
 }

+ 0 - 22
app/Http/Controllers/OwnerProcessSettlementBillController.php

@@ -48,28 +48,6 @@ class OwnerProcessSettlementBillController extends Controller implements Settlem
         return view('finance.settlementBills.process.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'totalFee'));
     }
 
-    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('storage_fee', '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' => [],
-        ]);
-        return back()->with('success', '确认成功');
-    }
-
     public function export(Request $request)
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);

+ 2 - 31
app/Http/Controllers/OwnerStoreFeeDetailController.php

@@ -33,7 +33,7 @@ class OwnerStoreFeeDetailController extends Controller implements SettlementBill
         $this->archiveService = app('OwnerBillReportArchiveService');
         $this->service = app('OwnerStoreFeeDetailService');
         $paginateParams = $request->input();
-        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);
         $details = $this->service->get([
             'counting_month' => $counting_month,
             'owner_id' => $owner_id,
@@ -51,7 +51,7 @@ class OwnerStoreFeeDetailController extends Controller implements SettlementBill
     public function export(Request $request)
     {
         $this->service = app('OwnerStoreFeeDetailService');
-        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);
         $query = $this->service->getSql($counting_month, $owner_id);
         if (!$request->exists('checkAllSign')) {
             $query->whereIn('id', explode(',', $request['data']));
@@ -62,33 +62,4 @@ class OwnerStoreFeeDetailController extends Controller implements SettlementBill
         $row = ['作业日期', '作业名称', '入库单号', '商品条码', '商品名称', '数量', '单价', '入库费'];
         return Export::make($row, $json, "入库费明细");
     }
-
-    /**
-     * 确认账单
-     * @param Request $request
-     * @return RedirectResponse
-     */
-    public function confirmBill(Request $request): RedirectResponse
-    {
-        $this->service = app('OwnerStoreFeeDetailService');
-        $this->archiveService = app('OwnerBillReportArchiveService');
-        list($permittingOwnerIds, $counting_month, $owner_id) = $this->service->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' => [],
-        ]);
-        return back()->with('success', '确认成功');
-    }
 }

+ 0 - 23
app/Http/Controllers/OwnerStoreOutFeeDetailController.php

@@ -45,29 +45,6 @@ class OwnerStoreOutFeeDetailController extends Controller implements SettlementB
         return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
     }
 
-
-    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('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' => [],
-        ]);
-        return back()->with('success', '确认成功');
-    }
-
     public function export(Request $request)
     {
         list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);

+ 0 - 25
app/Http/Controllers/OwnerSundryFeeDetailSettlementBillController.php

@@ -49,31 +49,6 @@ class OwnerSundryFeeDetailSettlementBillController extends Controller implements
         return view('finance.settlementBills.ownerSundryFee.index', compact('owner_sundry_fee_details', 'paginateParams', 'owners', 'owner', '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);
-        $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' => [],
-        ]);
-        return back()->with('success', '确认成功');
-    }
 
     public function export(Request $request)
     {

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

@@ -1680,7 +1680,7 @@ TEXT;
          * @var $services OwnerLogisticFeeDetailService
          */
         $services = app('OwnerLogisticFeeDetailService');
-        $result = $services->getDetails('12', '2021-05-30', '2021-05-31', 50);
+        $result = $services->get('12', '2021-05-30', '2021-05-31', 50);
         dd($result);
     }
 

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -156,6 +156,7 @@ use App\Services\OwnerSundryFeeDetailService;
 use App\Services\OwnerProcurementSettlementBillService;
 use App\Services\OwnerWaybillSettlementBillService;
 use App\Services\OwnerProcessSettlementBillService;
+use App\Services\OwnerDischargeTaskSettlementBillService;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -294,6 +295,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OwnerAreaReportService', OwnerAreaReportService::class);
         app()->singleton('OwnerBillReportArchiveService',OwnerBillReportArchiveService::class);
         app()->singleton('OwnerBillReportService', OwnerBillReportService::class);
+        app()->singleton('OwnerDischargeTaskSettlementBillService',OwnerDischargeTaskSettlementBillService::class);
         app()->singleton('OwnerFeeDetailService', OwnerFeeDetailService::class);
         app()->singleton('OwnerLogisticFeeDetailService',OwnerLogisticFeeDetailService::class);
         app()->singleton('OwnerLogisticFeeReportService',OwnerLogisticFeeReportService::class);

+ 63 - 0
app/Services/OwnerDischargeTaskSettlementBillService.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Services;
+
+use App\DischargeTask;
+use App\Traits\ServiceAppAop;
+use App\Traits\SettlementBillServiceTrait;
+
+class OwnerDischargeTaskSettlementBillService implements \App\Interfaces\SettlementBillDetailInterface
+{
+    use \App\Traits\SettlementBillServiceTrait;
+    const TYPE = '卸货费';
+
+    use ServiceAppAop;
+
+    public function get(array $kvPairs): array
+    {
+        $details = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
+        $totalFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->sum('expenditure_total_cost');
+        return array($details, $totalFee);
+    }
+
+
+    public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
+    {
+        list($start, $end) = $this->getStartAndEnd($counting_month);
+
+        return DischargeTask::query()
+            ->where('owner_id', $owner_id)
+            ->whereBetween('income_at', [$start, $end]);
+    }
+
+    public function switchType($type)
+    {
+        // TODO: Implement switchType() method.
+    }
+
+    public function buildExport($details): array
+    {
+        $result = [];
+        foreach ($details as $detail) {
+            $result[] = [
+                $detail->income_at,
+                $detail->type,
+                $detail->numbers,
+                $detail->expenditure_amount,
+                $detail->expenditure_unit,
+                $detail->expenditure_unit_price,
+                $detail->expenditure_total_cost,
+                $detail->income_remark,
+                $detail->expenditure_remark,
+            ];
+        }
+        return $result;
+    }
+
+    public function add(array $model)
+    {
+        // TODO: Implement add() method.
+    }
+}
+
+

+ 23 - 13
app/Services/OwnerLogisticFeeDetailService.php

@@ -6,13 +6,14 @@ use App\Logistic;
 use App\OwnerFeeDetail;
 use App\Traits\ServiceAppAop;
 use App\OwnerLogisticFeeDetail;
+use App\Traits\SettlementBillServiceTrait;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Pagination\LengthAwarePaginator;
-use Illuminate\Support\Collection;
 
-class OwnerLogisticFeeDetailService
+class OwnerLogisticFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
 {
+    use SettlementBillServiceTrait;
     const TYPE = '快递费-明细';
 
     use ServiceAppAop;
@@ -26,16 +27,12 @@ class OwnerLogisticFeeDetailService
 
     /**
      * 根据货主查询 和时间段查询
-     * @param string $owner_id
-     * @param string $start
-     * @param string $end
-     * @param $paginateParams
+     * @param array $kvPairs
      * @return LengthAwarePaginator
      */
-    public function getDetails(string $owner_id, string $start, string $end, $paginateParams): LengthAwarePaginator
+    public function get(array $kvPairs): LengthAwarePaginator
     {
-        $ownerLogisticFeeDetails = $this->getSql($owner_id, $start, $end)
-            ->paginate($paginateParams['paginate'] ?? 50);
+        $ownerLogisticFeeDetails = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
         $items = $this->buildDetails($ownerLogisticFeeDetails);
         return new LengthAwarePaginator(
             $items,
@@ -65,13 +62,11 @@ class OwnerLogisticFeeDetailService
     }
 
     /**
-     * @param string $owner_id
-     * @param string $start
-     * @param string $end
      * @return Builder
      */
-    public function getSql(string $owner_id, string $start, string $end): Builder
+    public function getSql($owner_id, $counting_month): Builder
     {
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerLogisticFeeDetail::query()->with([
             'ownerFeeDetail:id,province,weight,logistic_fee',
             'ownerFeeDetailLogistic:id,weight,logistic_fee,logistic_bill',
@@ -102,4 +97,19 @@ class OwnerLogisticFeeDetailService
         }
         return $items;
     }
+
+    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.
+    }
 }

+ 2 - 3
app/Services/OwnerProcessSettlementBillService.php

@@ -5,11 +5,11 @@ namespace App\Services;
 use App\Interfaces\SettlementBillDetailInterface;
 use App\OwnerFeeDetail;
 use App\Traits\ServiceAppAop;
-use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 
 class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
 {
+    use \App\Traits\SettlementBillServiceTrait;
     const TYPE = '加工费';
     use ServiceAppAop;
 
@@ -23,8 +23,7 @@ class OwnerProcessSettlementBillService implements SettlementBillDetailInterface
 
     public function getSql($owner_id, $counting_month): Builder
     {
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerFeeDetail::query()
             ->with(['process.processMethod'])
             ->where('owner_id', $owner_id)

+ 2 - 2
app/Services/OwnerProcurementSettlementBillService.php

@@ -14,6 +14,7 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
 {
     const  TYPE = '包材费';
     use ServiceAppAop;
+    use \App\Traits\SettlementBillServiceTrait;
 
     protected $modelClass = Procurement::class;
     /**php
@@ -50,8 +51,7 @@ class OwnerProcurementSettlementBillService implements SettlementBillDetailInter
     public function getSql($owner_id, $counting_month): Builder
     {
         $ownerMaterialQuery = OwnerMaterial::query()->select('id')->where('owner_id', $owner_id);
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         return Procurement::query()
             ->selectRaw("id,owner_material_id,quantity,unit_price,ROUND(unit_price*quantity,2) as fee,created_at")
             ->with('ownerMaterial:id,size,special,specification')

+ 3 - 8
app/Services/OwnerStoreFeeDetailService.php

@@ -11,19 +11,15 @@ use Illuminate\Database\Eloquent\Builder;
 class OwnerStoreFeeDetailService
 {
     use ServiceAppAop;
-    use SettlementBillTrait;
+    use \App\Traits\SettlementBillServiceTrait;
 
     const TYPE = '入库费-明细';
 
     protected $modelClass = OwnerStoreFeeDetail::class;
 
-    /** @var  $archiveService OwnerBillReportArchiveService */
-    private $archiveService;
-
     public function get(array $kvPairs)
     {
-        return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'])
-            ->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
+        return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50);
 
     }
 
@@ -48,8 +44,7 @@ class OwnerStoreFeeDetailService
      */
     public function getSql($counting_month, $owner_id): Builder
     {
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerStoreFeeDetail::query()
             ->with(['ownerFeeDetail:id,work_fee,worked_at', 'storeItem' => function ($query) {
                 $query->selectRaw("id,asn_line_code,sku,commodity_id")->with('commodity:id,name');

+ 4 - 3
app/Services/OwnerStoreOutFeeDetailService.php

@@ -5,7 +5,7 @@ namespace App\Services;
 use App\Interfaces\SettlementBillDetailInterface;
 use App\Traits\ServiceAppAop;
 use App\OwnerStoreOutFeeDetail;
-use Carbon\Carbon;
+use App\Traits\SettlementBillServiceTrait;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
 use Illuminate\Database\Eloquent\Builder;
 
@@ -13,6 +13,8 @@ class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
 {
     const  TYPE = '出库费-明细';
     use ServiceAppAop;
+    use SettlementBillServiceTrait;
+
 
     protected $modelClass = OwnerStoreOutFeeDetail::class;
 
@@ -28,8 +30,7 @@ class OwnerStoreOutFeeDetailService implements SettlementBillDetailInterface
 
     public function getSql($owner_id, $counting_month): Builder
     {
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+       list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerStoreOutFeeDetail::query()
             ->with(['commodity:id,name,sku', 'ownerFeeDetail:id,worked_at,operation_bill,work_fee'])
             ->where('owner_id', $owner_id)

+ 3 - 2
app/Services/OwnerSundryFeeDetailService.php

@@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Builder;
 class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetailInterface
 {
     use ServiceAppAop;
+    use \App\Traits\SettlementBillServiceTrait;
+
 
     protected $modelClass = OwnerSundryFeeDetail::class;
     /** @var OwnerBillReportArchiveService $archiveService */
@@ -24,8 +26,7 @@ class OwnerSundryFeeDetailService implements \App\Interfaces\SettlementBillDetai
 
     public function getSql($owner_id, $counting_month): Builder
     {
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+       list($start, $end) = $this->getStartAndEnd($counting_month);
         return OwnerSundryFeeDetail::query()
             ->with(['owner', 'logistic'])
             ->where('owner_id', $owner_id)

+ 3 - 4
app/Services/OwnerWaybillSettlementBillService.php

@@ -3,17 +3,16 @@
 namespace App\Services;
 
 use App\Traits\ServiceAppAop;
-use App\OwnerWaybillSettlementBill;
-use Carbon\Carbon;
 
 class OwnerWaybillSettlementBillService implements \App\Interfaces\SettlementBillDetailInterface
 {
     use ServiceAppAop;
+    use \App\Traits\SettlementBillServiceTrait;
+
 
     public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder
     {
-        $start = Carbon::parse($counting_month)->startOfMonth()->startOfDay()->toDateTimeString();
-        $end = Carbon::parse($counting_month)->endOfMonth()->endOfDay()->toDateTimeString();
+        list($start, $end) = $this->getStartAndEnd($counting_month);
         \App\Waybill::query()
             ->select('id','created_at','wms_bill_number','recipient','recipient_mobile','warehouse_weight','warehouse_weight_unit_id','destination_city_id')
             ->with(['logistic:id,name','warehouseWeightUnit:id,name','destinationCity.parent'])

+ 24 - 0
app/Traits/SettlementBillServiceTrait.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace App\Traits;
+
+
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
+use Carbon\Carbon;
+use Illuminate\Http\Request;
+use Illuminate\Support\Collection;
+
+trait SettlementBillServiceTrait
+{
+    /**
+     * @param $counting_month
+     * @return array
+     */
+    public function getStartAndEnd($counting_month): array
+    {
+       list($start, $end) = $this->getStartAndEnd($counting_month);
+        return array($start, $end);
+    }
+}

+ 24 - 0
app/Traits/SettlementBillTrait.php

@@ -4,6 +4,8 @@
 namespace App\Traits;
 
 
+use App\OwnerBillReport;
+use App\OwnerBillReportArchive;
 use Illuminate\Http\Request;
 use Illuminate\Support\Collection;
 
@@ -43,4 +45,26 @@ trait SettlementBillTrait
         $request['month'] = \Carbon\Carbon::parse($counting_month)->month;
         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' => [],
+        ]);
+        return back()->with('success', '确认成功');
+    }
 }

+ 6 - 2
database/seeds/DischargeTaskSeeder.php

@@ -12,7 +12,11 @@ class DischargeTaskSeeder extends Seeder
      */
     public function run()
     {
-        $params = factory(DischargeTask::class)->times(100)->make()->toArray();
-        DischargeTask::query()->insert($params);
+//        $params = factory(DischargeTask::class)->times(100)->make()->toArray();
+//        DischargeTask::query()->insert($params);
+        factory(DischargeTask::class)->times(100)->create([
+            'owner_id' => 8,
+            'income_at' => now()->subMonth(),
+        ]);
     }
 }

+ 208 - 0
resources/views/finance/settlementBills/dischargeTask/index.blade.php

@@ -0,0 +1,208 @@
+@extends('layouts.app')
+
+@section('content')
+    @include('shared._messages')
+    @include('shared._error')
+    <div id="list" class="d-none">
+        <div class="container-fluid">
+            <div id="form_div"></div>
+            <div class="ml-3 form-inline" id="btn">
+                    <span class="dropdown">
+                        <button type="button"
+                                class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
+                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">导出Excel
+                        </button>
+                        <div class="dropdown-menu">
+                            <a class="dropdown-item" @click="detailExport(false)" href="javascript:">导出勾选内容</a>
+                            <a class="dropdown-item" @click="detailExport(true)" href="javascript:">导出所有页</a>
+                        </div>
+                    </span>
+            </div>
+            <div class="row">
+                <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-jpy fa-4x offset-md-3" style="color: #2ca02c;opacity: 0.3"></span>
+                        <span class="ml-4 mt-2">
+                        <h5 class="font-weight-bold">{{ $totalFee }}</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="{{ 'dischargeTask/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.income_at }}</td>
+                    <td>@{{ detail.type }}</td>
+                    <td>@{{ detail.numbers }}</td>
+                    <td>@{{ detail.expenditure_amount }}</td>
+                    <td>@{{ detail.expenditure_unit }}</td>
+                    <td>@{{ detail.expenditure_unit_price }}</td>
+                    <td>@{{ detail.expenditure_total_cost }}</td>
+                    <td>@{{ detail.income_remark }}</td>
+                    <td>@{{ detail.expenditure_remark }}</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: 'income_at', value: '日期'},
+                    {name: 'work_type', value: '作业类型'},
+                    {name: 'numbers', value: '入库单号'},
+                    {name: 'expenditure_amount', value: '数量'},
+                    {name: 'expenditure_unit', value: '单位'},
+                    {name: 'expenditure_unit_price', value: '单价'},
+                    {name: 'expenditure_total_cost', value: '收费'},
+                    {name: 'income_remark', value: '收入描述'},
+                    {name: 'expenditure_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/dischargeTask/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

+ 6 - 0
routes/web.php

@@ -829,6 +829,12 @@ Route::group(['prefix'=>'finance'],function(){
             Route::post('confirmBill', 'OwnerProcessSettlementBillController@confirmBill');
             Route::any('export', 'OwnerProcessSettlementBillController@export');
         });
+
+        Route::group(['prefix' => 'dischargeTask'], function () {
+            Route::get('', 'OwnerDischargeTaskSettlementBillController@index');
+            Route::post('confirmBill', 'OwnerDischargeTaskSettlementBillController@confirmBill');
+            Route::any('export', 'OwnerDischargeTaskSettlementBillController@export');
+        });
     });
 });