Export.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\controller\order;
  13. use think\response\Json;
  14. use app\store\controller\Controller;
  15. use app\store\model\order\Export as ExportModel;
  16. use app\store\service\order\Export as ExportService;
  17. use cores\exception\BaseException;
  18. /**
  19. * 订单导出记录控制器
  20. * Class Export
  21. * @package app\store\controller\order
  22. */
  23. class Export extends Controller
  24. {
  25. /**
  26. * 执行订单导出excel
  27. * @return Json
  28. * @throws BaseException
  29. */
  30. public function exportOrder(): Json
  31. {
  32. $model = new ExportService;
  33. if (!$model->exportOrder($this->request->param())) {
  34. $this->renderError($model->getError() ?: '导出失败');
  35. }
  36. return $this->renderSuccess('导出Excel文件成功,请在导出记录中下载');
  37. }
  38. /**
  39. * 订单导出记录
  40. * @return Json
  41. * @throws \think\db\exception\DbException
  42. */
  43. public function list(): Json
  44. {
  45. $model = new ExportModel;
  46. $list = $model->getList();
  47. return $this->renderSuccess(compact('list'));
  48. }
  49. }