OwnerStoreFeeDetailController.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\OwnerStoreFeeDetailService;
  9. use App\Traits\SettlementBillTrait;
  10. use Illuminate\Http\RedirectResponse;
  11. use Illuminate\Http\Request;
  12. use Oursdreams\Export\Export;
  13. class OwnerStoreFeeDetailController extends Controller implements SettlementBillControllerInterface
  14. {
  15. use SettlementBillTrait;
  16. /** @var $service OwnerStoreFeeDetailService */
  17. private $service;
  18. /** @var $archiveService OwnerBillReportArchiveService */
  19. private $archiveService;
  20. /**
  21. * Display a listing of the resource.
  22. *
  23. */
  24. public function index(Request $request)
  25. {
  26. $this->archiveService = app('OwnerBillReportArchiveService');
  27. $this->service = app('OwnerStoreFeeDetailService');
  28. $paginateParams = $request->input();
  29. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  30. $details = $this->service->get([
  31. 'counting_month' => $counting_month,
  32. 'owner_id' => $owner_id,
  33. 'type' => $this->service::TYPE,
  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);
  41. return view('finance.settlementBills.storeFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
  42. }
  43. public function export(Request $request)
  44. {
  45. $this->service = app('OwnerStoreFeeDetailService');
  46. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  47. $query = $this->service->getSql($counting_month, $owner_id);
  48. if (!$request->exists('checkAllSign')) {
  49. $query->whereIn('id', explode(',', $request['data']));
  50. }
  51. $details = $query->get();
  52. $json = $this->service->buildExport($details);
  53. $row = ['作业日期', '作业名称', '入库单号', '商品条码', '商品名称', '数量', '单价', '入库费'];
  54. return Export::make($row, $json, "入库费明细");
  55. }
  56. }