SettlementBillUnloadFeeController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Owner;
  4. use App\Services\OwnerBillReportArchiveService;
  5. use App\Services\OwnerDischargeTaskSettlementBillService;
  6. use App\Traits\SettlementBillTrait;
  7. use Illuminate\Http\Request;
  8. use Oursdreams\Export\Export;
  9. class SettlementBillUnloadFeeController extends Controller implements \App\Interfaces\SettlementBillControllerInterface
  10. {
  11. use SettlementBillTrait;
  12. /** @var OwnerDischargeTaskSettlementBillService $service */
  13. private $service;
  14. /** @var OwnerBillReportArchiveService $archiveService */
  15. private $archiveService;
  16. /**
  17. * OwnerDischargeTaskSettlementBillController constructor.
  18. */
  19. public function __construct()
  20. {
  21. $this->service = app('OwnerDischargeTaskSettlementBillService');
  22. $this->archiveService = app('OwnerBillReportArchiveService');
  23. }
  24. public function index(Request $request)
  25. {
  26. $paginateParams = $request->input();
  27. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  28. list($details, $totalFee) = $this->service->get([
  29. 'counting_month' => $counting_month,
  30. 'owner_id' => $owner_id,
  31. 'paginateParams' => $paginateParams,
  32. ]);
  33. $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
  34. $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
  35. $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
  36. $request = $this->buildRequest($request, $counting_month,$owner_id);
  37. return view('finance.settlementBills.unloadFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'totalFee'));
  38. }
  39. public function export(Request $request)
  40. {
  41. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  42. $query = $this->service->getSql($owner_id, $counting_month);
  43. if (!$request->exists('checkAllSign')) {
  44. $query->whereIn('id', explode(',', $request['data']));
  45. }
  46. $details = $query->get();
  47. $json = $this->service->buildExport($details);
  48. $row = ['日期', '作业类型', '入库单号', '数量', '单位', '单价', '收费', '收入描述', '支出吗描述'];
  49. return Export::make($row, $json, "卸货费");
  50. }
  51. }