SettlementBillExpressFeeDetailController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Interfaces\SettlementBillControllerInterface;
  4. use App\Owner;
  5. use App\OwnerBillReportArchive;
  6. use App\Services\OwnerBillReportArchiveService;
  7. use App\Services\OwnerLogisticFeeDetailService;
  8. use App\Traits\SettlementBillTrait;
  9. use Illuminate\Http\Request;
  10. use Oursdreams\Export\Export;
  11. class SettlementBillExpressFeeDetailController extends Controller implements SettlementBillControllerInterface
  12. {
  13. use SettlementBillTrait;
  14. /** @var $service OwnerLogisticFeeDetailService */
  15. private $service;
  16. /** @var $archiveService OwnerBillReportArchiveService */
  17. private $archiveService;
  18. /**
  19. * OwnerLogisticFeeDetailController constructor.
  20. */
  21. public function __construct()
  22. {
  23. $this->service = app('OwnerLogisticFeeDetailService');
  24. $this->archiveService = app('OwnerBillReportArchiveService');
  25. }
  26. /**
  27. * Display a listing of the resource.
  28. *
  29. */
  30. public function index(Request $request)
  31. {
  32. $paginateParams = $request->input();
  33. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month,$request->owner_id);
  34. $details = $this->service->get([
  35. 'owner_id' => $owner_id,
  36. 'counting_month' => $counting_month,
  37. 'paginateParams' => $paginateParams,
  38. ]);
  39. $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
  40. $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
  41. $this->archiveService = app('OwnerBillReportArchiveService');
  42. $request = $this->buildRequest($request, $counting_month,$owner_id);
  43. return view('finance.settlementBills.expressFee.detail.index', compact('details', 'paginateParams', 'owners', 'owner', 'request'));
  44. }
  45. public function export(Request $request)
  46. {
  47. list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month,$request->owner_id );
  48. $query = $this->service->getSql($owner_id, $counting_month);
  49. if (!$request->exists('checkAllSign')) {
  50. $query->whereIn('id', explode(',', $request['data']));
  51. }
  52. $details = $this->service->buildExport($query->get());
  53. $json = [];
  54. foreach ($details as $detail) {
  55. $json[] = array_values($detail);
  56. }
  57. $row = ['主键', '快递公司', '省份', '快递单号', '重量', '首重价格', '续重价格', '快递费',];
  58. return Export::make($row, $json, "快递费用详情");
  59. }
  60. }