| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Http\Controllers;
- use App\Interfaces\SettlementBillControllerInterface;
- use App\Owner;
- use App\OwnerBillReportArchive;
- use App\Services\OwnerBillReportArchiveService;
- use App\Services\OwnerLogisticFeeDetailService;
- use App\Traits\SettlementBillTrait;
- use Illuminate\Http\Request;
- use Oursdreams\Export\Export;
- class SettlementBillExpressFeeDetailController extends Controller implements SettlementBillControllerInterface
- {
- use SettlementBillTrait;
- /** @var $service OwnerLogisticFeeDetailService */
- private $service;
- /** @var $archiveService OwnerBillReportArchiveService */
- private $archiveService;
- /**
- * OwnerLogisticFeeDetailController constructor.
- */
- public function __construct()
- {
- $this->service = app('OwnerLogisticFeeDetailService');
- $this->archiveService = app('OwnerBillReportArchiveService');
- }
- /**
- * Display a listing of the resource.
- *
- */
- public function index(Request $request)
- {
- $paginateParams = $request->input();
- 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($counting_month, $owner_id, OwnerBillReportArchive::$enums['type']['快递费-明细']);
- $request = $this->buildRequest($request, $counting_month,$owner_id);
- return view('finance.settlementBills.expressFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
- }
- public function export(Request $request)
- {
- 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']));
- }
- $details = $this->service->buildDetails($query->get());
- $json = [];
- foreach ($details as $detail) {
- $json[] = array_values($detail);
- }
- $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
- return Export::make($row, $json, "快递费用详情");
- }
- }
|