OrderController.php 869 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Modules\Mini\Controllers;
  3. use App\Base\BaseController;
  4. use App\Exports\AdminOrderExport;
  5. use App\Exports\UserOrderExport;
  6. use App\Modules\Mini\Services\OrderService;
  7. use Illuminate\Support\Facades\Auth;
  8. use Maatwebsite\Excel\Facades\Excel;
  9. class OrderController extends BaseController
  10. {
  11. public function paginate()
  12. {
  13. $params = $this->valid([
  14. "page_size" => "",
  15. ]);
  16. $paginate = app(OrderService::class)->paginate(Auth::id(), $params);
  17. return $this->ok($paginate);
  18. }
  19. public function export()
  20. {
  21. $name = sprintf('用户订单导出%s.xls', date("YmdHis"));
  22. Excel::store(new UserOrderExport([
  23. "user_id" => Auth::id(),
  24. ]), $name, "public");
  25. return $this->ok([
  26. "url" => config("app.url") . "/storage/" . $name,
  27. ]);
  28. }
  29. }