OwnerStoreOutFeeDetailController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\OwnerStoreOutFeeDetailService;
  9. use App\Traits\SettlementBillTrait;
  10. use Illuminate\Http\RedirectResponse;
  11. use Illuminate\Http\Request;
  12. use Oursdreams\Export\Export;
  13. class OwnerStoreOutFeeDetailController extends Controller implements SettlementBillControllerInterface
  14. {
  15. use SettlementBillTrait;
  16. /** @var OwnerStoreOutFeeDetailService $service */
  17. private $service;
  18. /** @var OwnerBillReportArchiveService $archiveService */
  19. private $archiveService;
  20. public function __construct()
  21. {
  22. $this->service = app('OwnerStoreOutFeeDetailService');
  23. $this->archiveService = app('OwnerBillReportArchiveService');
  24. }
  25. public function index(Request $request)
  26. {
  27. $paginateParams = $request->input();
  28. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  29. $details = $this->service->get([
  30. 'counting_month' => $counting_month,
  31. 'owner_id' => $owner_id,
  32. 'paginateParams' => $paginateParams,
  33. ]);
  34. $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
  35. $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
  36. $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
  37. $request = $this->buildRequest($request, $counting_month);
  38. return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
  39. }
  40. public function export(Request $request)
  41. {
  42. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  43. $query = $this->service->getSql($owner_id, $counting_month);
  44. if (!$request->exists('checkAllSign')) {
  45. $query->whereIn('id', explode(',', $request['data']));
  46. }
  47. $details = $query->get();
  48. $json = $this->service->buildExport($details);
  49. $row = ['作业时间', '作业名称', '上游单号', '订单号', '商品条码', '商品名称', '商品数量', '价格', '合计'];
  50. return Export::make($row, $json, "出库费明细");
  51. }
  52. }