SettlementBillStoreFeeDetailController.php 2.6 KB

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