SettlementBillProcessFeeController.php 2.6 KB

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