| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace App\Http\Controllers;
- use App\Owner;
- 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;
- /**
- * 结算管理-结算账单-仓储费
- * Class SettlementBillOwnerAreaFeeController
- * @package App\Http\Controllers
- */
- class SettlementBillOwnerAreaFeeController extends Controller
- {
- /* @var $service SettlementBillsAreaFeeService */
- private $service;
- /** @var $archiveService OwnerBillReportArchiveService */
- private $archiveService;
- /**
- * SettlementBillOwnerAreaFeeController constructor.
- */
- public function __construct()
- {
- $this->middleware('auth');
- }
- public function index(Request $request)
- {
- $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
- * @return RedirectResponse
- */
- public function confirmBill(Request $request)
- {
- $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_month' => $counting_month,
- 'type' => $this->service::TYPE,
- 'archiver_id' => auth()->id(),
- 'archived_at' => now(),
- 'information' => [
- 'areaReports' => $areaReports,
- 'billReport' => $billReport,
- 'price' => $price,
- ],
- ]);
- return back()->with('success', '确认成功');
- }
- public function export(Request $request)
- {
- $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'],
- ];
- }
- $row = ['仓库类型', '使用区域', '数量', '合计面积', '单价', '金额',];
- return Export::make($row, $json, "仓储费");
- }
- }
|