Order.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\cms\Order;
  20. $this->view->assign("statusList", $this->model->getStatusList());
  21. }
  22. /**
  23. * 查看
  24. */
  25. public function index()
  26. {
  27. //设置过滤方法
  28. $this->request->filter(['strip_tags']);
  29. if ($this->request->isAjax()) {
  30. $this->relationSearch = true;
  31. //如果发送的来源是Selectpage,则转发到Selectpage
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  36. $total = $this->model
  37. ->with(['user', 'archives'])
  38. ->where($where)
  39. ->order($sort, $order)
  40. ->count();
  41. $list = $this->model
  42. ->with(['user', 'archives'])
  43. ->where($where)
  44. ->order($sort, $order)
  45. ->limit($offset, $limit)
  46. ->select();
  47. foreach ($list as $item) {
  48. $item->user->visible(['id', 'username', 'nickname', 'avatar']);
  49. $item->archives->visible(['id', 'title', 'diyname']);
  50. }
  51. $result = array("total" => $total, "rows" => $list);
  52. return json($result);
  53. }
  54. return $this->view->fetch();
  55. }
  56. }