| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Http\Controllers;
- use App\OwnerAreaReport;
- use Illuminate\Http\Request;
- /**
- * 结算管理-结算账单-仓储费
- * Class SettlementBillOwnerAreaFeeController
- * @package App\Http\Controllers
- */
- class SettlementBillOwnerAreaFeeController extends Controller
- {
- /**
- * SettlementBillOwnerAreaFeeController constructor.
- */
- public function __construct()
- {
- $this->middleware('auth');
- }
- public function index(Request $request)
- {
- list($permittingOwnerIds, $date, $owner_id) = $this->getRequestParams($request);
- $owners = \App\Owner::query()->find($permittingOwnerIds);
- $owner = \App\Owner::query()->find($owner_id);
- $ownerAreas = OwnerAreaReport::query()
- ->with('ownerStoragePriceModel:id,using_type')
- ->where('owner_id', $owner_id)
- ->where('counting_month', $date)
- ->get();
- $ownerBillReport = \App\OwnerBillReport::query()
- ->selectRaw('storage_fee')
- ->where('owner_id', $owner_id)
- ->where('counting_month', $date)
- ->first();
- }
- /**
- * @param Request $request
- * @return array
- */
- 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)) {
- $date = now()->subMonth()->startOfMonth()->toDateString();
- } else {
- $date = $request->year . '-' . $request->month . '-' . '01';
- }
- if (is_null($request->owner_id)) {
- $owner_id = $permittingOwnerIds[0];
- } else {
- $owner_id = $request->owner_id;
- }
- return array($permittingOwnerIds, $date, $owner_id);
- }
- }
|