request = $request; $this->orderService = $orderService; } /** * 列表. * * @return \Illuminate\Http\Response */ public function index() { $conditions = $this->request->all(); $res = $this->orderService->index($conditions); return res($res, '订单统计', 201); } /** * 导出. * * @return \Illuminate\Http\Response */ public function export() { $conditions = $this->request->except(['page', 'limit']); $conditions['limit'] = 0; try { $export = new OrderExport($conditions); $url = ExportService::store($export, $this->disk); } catch (\Exception $e) { throw $e; } return res($url, '导出成功', 201); } /** * 统计明细. * * @return \Illuminate\Http\Response */ public function detail() { $conditions = $this->request->all(); $res = $this->orderService->detail($conditions); return res($res, '统计明细', 201); } /** * 统计明细导出. * * @return \Illuminate\Http\Response */ public function detailExport() { $conditions = $this->request->except(['page', 'limit']); $conditions['order_id'] = $this->request->ids('order_id'); if (!$class = OrderService::$classes[$conditions['type']]) { throw new NotAllowedException('统计类型不存在'); } $repository = app($class); $total = $repository->withConditions($conditions)->applyConditions()->getCountForPagination(); try { $export = new OrderDetailExport($conditions); $queue = $total > 6000; $url = ExportService::store($export, $this->disk, $queue); } catch (\Exception $e) { throw $e; } return res($url, '导出成功', 201); } }