SettlementBillStoreOutFeeDetailController.php 2.5 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\Request;
  11. use Oursdreams\Export\Export;
  12. class SettlementBillStoreOutFeeDetailController extends Controller implements SettlementBillControllerInterface
  13. {
  14. use SettlementBillTrait;
  15. /** @var OwnerStoreOutFeeDetailService $service */
  16. private $service;
  17. /** @var OwnerBillReportArchiveService $archiveService */
  18. private $archiveService;
  19. public function __construct()
  20. {
  21. $this->service = app('OwnerStoreOutFeeDetailService');
  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. $details = $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);
  37. return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
  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. $this->service->buildPriceRemarks($details);
  48. $json = $this->service->buildExport($details);
  49. $row = ['作业时间', '作业名称', '上游单号', '订单号', '商品条码', '商品名称', '商品数量', '价格', '合计'];
  50. return Export::make($row, $json, "出库费明细");
  51. }
  52. }