| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?php
- namespace App\Http\Controllers;
- use App\Owner;
- use App\OwnerBillReport;
- use App\OwnerBillReportArchive;
- use App\Services\OwnerBillReportArchiveService;
- use App\Services\OwnerDischargeTaskSettlementBillService;
- use App\Services\OwnerFeeTotalService;
- use App\Services\OwnerLogisticFeeReportService;
- use App\Services\OwnerProcessSettlementBillService;
- use App\Services\OwnerProcurementSettlementBillService;
- use App\Services\OwnerStoreFeeReportService;
- use App\Services\OwnerStoreOutFeeReportService;
- use App\Services\OwnerSundryFeeDetailService;
- use App\Services\OwnerWaybillSettlementBillService;
- use App\Services\SettlementBillsAreaFeeService;
- use App\Services\SettlementIndemnityFeeService;
- use Illuminate\Http\Request;
- class OwnerFeeTotalController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
- {
- use \App\Traits\SettlementBillTrait;
- /** @var OwnerFeeTotalService $service */
- private $service;
- /** @var OwnerBillReportArchiveService $archiveService */
- private $archiveService;
- /**
- * OwnerDischargeTaskSettlementBillController constructor.
- */
- public function __construct()
- {
- $this->service = app('OwnerFeeTotalService');
- $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);
- $feeTotal = $this->service->get([
- 'counting_month' => $counting_month,
- 'owner_id' => $owner_id,
- 'paginateParams' => $paginateParams,
- ]);
- $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
- $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
- $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
- $request = $this->buildRequest($request, $counting_month,$owner_id);
- $isArchivedItems = collect([
- 'expressFee' => $this->archiveService->isArchived($counting_month, $owner_id, '快递费-合计'),
- 'logisticFee' => $this->archiveService->isArchived($counting_month, $owner_id, '物流费'),
- 'packingMaterialFee' => $this->archiveService->isArchived($counting_month, $owner_id, '包材费'),
- 'processFee' => $this->archiveService->isArchived($counting_month, $owner_id, '加工费'),
- 'storageFee' => $this->archiveService->isArchived($counting_month, $owner_id, '仓储费'),
- 'storeFee' => $this->archiveService->isArchived($counting_month, $owner_id, '入库费-合计'),
- 'storeOutFee' => $this->archiveService->isArchived($counting_month, $owner_id, '出库费-合计'),
- 'sundryFee' => $this->archiveService->isArchived($counting_month, $owner_id, '杂项费'),
- 'unloadFee' => $this->archiveService->isArchived($counting_month, $owner_id, '卸货费'),
- 'indemnityFee' => $this->archiveService->isArchived($counting_month, $owner_id, '理赔费'),
- ]);
- return view('finance.settlementBills.totalFee.index', compact('feeTotal', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'isArchivedItems'));
- }
- public function export(Request $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' => [],
- ]);
- $unArchived = $this->archiveService->getUnAchieved($counting_month, $owner_id);
- foreach ($unArchived as $type) {
- switch ($type) {
- case '仓储费':
- /**@var $storageFeeService SettlementBillsAreaFeeService */
- $storageFeeService = app('SettlementBillsAreaFeeService');
- $storageFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '快递费-合计':
- /**@var $expressFeeService OwnerLogisticFeeReportService */
- $expressFeeService = app('OwnerLogisticFeeReportService');
- $expressFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '入库费-合计':
- /**@var $storeFeeService OwnerStoreFeeReportService */
- $storeFeeService = app('OwnerStoreFeeReportService');
- $storeFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '出库费-合计':
- /**@var $storeOutFeeService OwnerStoreOutFeeReportService */
- $storeOutFeeService = app('OwnerStoreOutFeeReportService');
- $storeOutFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '物流费':
- /**@var $logisticFeeService OwnerWaybillSettlementBillService */
- $logisticFeeService = app('OwnerWaybillSettlementBillService');
- $logisticFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '包材费':
- /**@var $packingMaterialFeeService OwnerProcurementSettlementBillService */
- $packingMaterialFeeService = app('OwnerProcurementSettlementBillService');
- $packingMaterialFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '加工费':
- /**@var $processFeeService OwnerProcessSettlementBillService */
- $processFeeService = app('OwnerProcessSettlementBillService');
- $processFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '杂项费':
- /**@var $sundryFeeService OwnerSundryFeeDetailService */
- $sundryFeeService = app('OwnerSundryFeeDetailService');
- $sundryFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '卸货费':
- /**@var $unloadFeeService OwnerDischargeTaskSettlementBillService */
- $unloadFeeService = app('OwnerDischargeTaskSettlementBillService');
- $unloadFeeService->confirmBill($counting_month, $owner_id);
- break;
- case '理赔费':
- /**@var $indemnityFeeService SettlementIndemnityFeeService */
- $indemnityFeeService = app('SettlementIndemnityFeeService');
- $indemnityFeeService->confirmBill($counting_month, $owner_id);
- break;
- }
- }
- return back()->with('success', '确认成功');
- }
- }
|