Order.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\admin\controller\cms;
  3. use app\common\controller\Backend;
  4. /**
  5. * 订单管理
  6. *
  7. * @icon fa fa-cny
  8. */
  9. class Order extends Backend
  10. {
  11. /**
  12. * Order模型对象
  13. * @var \app\admin\model\cms\Order
  14. */
  15. protected $model = null;
  16. protected $searchFields = 'id,title';
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\cms\Order;
  21. $this->view->assign("statusList", $this->model->getStatusList());
  22. }
  23. /**
  24. * 查看
  25. */
  26. public function index()
  27. {
  28. //设置过滤方法
  29. $this->request->filter(['strip_tags']);
  30. if ($this->request->isAjax()) {
  31. $this->relationSearch = true;
  32. //如果发送的来源是Selectpage,则转发到Selectpage
  33. if ($this->request->request('keyField')) {
  34. return $this->selectpage();
  35. }
  36. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  37. $total = $this->model
  38. ->with(['user', 'archives'])
  39. ->where($where)
  40. ->order($sort, $order)
  41. ->count();
  42. $list = $this->model
  43. ->with(['user', 'archives'])
  44. ->where($where)
  45. ->order($sort, $order)
  46. ->limit($offset, $limit)
  47. ->select();
  48. foreach ($list as $item) {
  49. $item->user->visible(['id', 'username', 'nickname', 'avatar']);
  50. $item->archives->visible(['id', 'title', 'diyname']);
  51. }
  52. $result = array("total" => $total, "rows" => $list);
  53. return json($result);
  54. }
  55. return $this->view->fetch();
  56. }
  57. }