SettlementBillLogisticFeeController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Interfaces\SettlementBillControllerInterface;
  4. use App\Owner;
  5. use App\Services\OwnerBillReportArchiveService;
  6. use App\Services\OwnerWaybillSettlementBillService;
  7. use App\Traits\SettlementBillTrait;
  8. use Illuminate\Http\Request;
  9. use Oursdreams\Export\Export;
  10. class SettlementBillLogisticFeeController extends Controller implements SettlementBillControllerInterface
  11. {
  12. use SettlementBillTrait;
  13. /**
  14. * @var $service OwnerWaybillSettlementBillService
  15. */
  16. private $service;
  17. /**
  18. * @var $archiveService OwnerBillReportArchiveService
  19. */
  20. private $archiveService;
  21. //
  22. /**
  23. * SettlementBillLogisticFeeController constructor.
  24. */
  25. public function __construct()
  26. {
  27. $this->service = app('OwnerWaybillSettlementBillService');
  28. $this->archiveService = app('OwnerBillReportArchiveService');
  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. 'counting_month' => $counting_month,
  36. 'owner_id' => $owner_id,
  37. 'type' => $this->service::TYPE,
  38. ]);
  39. $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
  40. $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
  41. $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
  42. $request = $this->buildRequest($request, $counting_month);
  43. return view('finance.settlementBills.logisticFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived'));
  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 = $query->get();
  53. $json = $this->service->buildExport($details);
  54. $row = ['承运商', '订单号', '收件人姓名', '收件人电话', '重量/体积', '计数单位', '计数区间', '省份', '市', '单价', '送货费', '提货费', '燃油附加费', '信息费', '其它费用', '备注', '起始计费', '起始计数', '运费合计'];
  55. return Export::make($row, $json, "物流费");
  56. }
  57. }