SettlementBillStoreOutFeeDetailController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. $request = $this->buildRequest($request, $counting_month,$owner_id);
  36. return view('finance.settlementBills.storeOutFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request'));
  37. }
  38. public function export(Request $request)
  39. {
  40. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
  41. $query = $this->service->getSql($owner_id, $counting_month);
  42. if (!$request->exists('checkAllSign')) {
  43. $query->whereIn('id', explode(',', $request['data']));
  44. }
  45. $details = $query->get();
  46. $json = $this->service->buildExport($details);
  47. $row = ['作业时间', '作业名称', '上游单号', '订单号', '商家编码', '商品条码', '商品名称', '商品数量', '单价', '价格描述', '合计'];
  48. return Export::make($row, $json, "出库费明细");
  49. }
  50. }