Export.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.thinkphp.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: thinkphp <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\model\order;
  13. use app\common\model\order\Export as ExportModel;
  14. use think\db\exception\DbException;
  15. /**
  16. * 订单导出Excel记录模型
  17. * Class Export
  18. * @package app\store\model\order
  19. */
  20. class Export extends ExportModel
  21. {
  22. /**
  23. * 获取导出记录
  24. * @return \think\Paginator
  25. * @throws DbException
  26. */
  27. public function getList(): \think\Paginator
  28. {
  29. // 获取列表记录
  30. $list = $this->order(['create_time' => 'desc'])->paginate(10);
  31. // 生成下载url
  32. foreach ($list as &$item) {
  33. $item['download_url'] = base_url() . $item['file_path'];
  34. }
  35. return $list;
  36. }
  37. /**
  38. * 新增数据
  39. * @param $data
  40. * @return bool
  41. */
  42. public function add($data): bool
  43. {
  44. return $this->save($data);
  45. }
  46. }