Export.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 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 app\store\controller\Controller;
  14. use app\store\model\order\Export as ExportModel;
  15. use app\store\service\order\Export as ExportService;
  16. use app\common\exception\BaseException;
  17. /**
  18. * 订单导出记录控制器
  19. * Class Export
  20. * @package app\store\controller\order
  21. */
  22. class Export extends Controller
  23. {
  24. /**
  25. * 执行订单导出excel
  26. * @return array|\think\response\Json
  27. * @throws BaseException
  28. */
  29. public function exportOrder()
  30. {
  31. $model = new ExportService;
  32. if (!$model->exportOrder($this->request->param())) {
  33. $this->renderError($model->getError() ?: '导出失败');
  34. }
  35. return $this->renderSuccess('导出Excel文件成功,请在导出记录中下载');
  36. }
  37. /**
  38. * 订单导出记录
  39. * @return array|\think\response\Json
  40. * @throws \think\db\exception\DbException
  41. */
  42. public function list()
  43. {
  44. $model = new ExportModel;
  45. $list = $model->getList();
  46. return $this->renderSuccess(compact('list'));
  47. }
  48. }