Activepeople.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * 活动人员管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Activepeople extends Backend
  10. {
  11. /**
  12. * Activepeople模型对象
  13. * @var \app\admin\model\Activepeople
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\Activepeople;
  20. $this->view->assign("coupontypeList", $this->model->getCoupontypeList());
  21. $this->view->assign("isFreeList", $this->model->getIsFreeList());
  22. $this->view->assign("isSelfList", $this->model->getIsSelfList());
  23. $this->view->assign("statusList", $this->model->getStatusList());
  24. $this->view->assign("modifystatusList", $this->model->getModifystatusList());
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 查看
  33. */
  34. public function index()
  35. {
  36. $active_id = input('active_id', 0, 'intval'); //活动id
  37. if (!$active_id) {
  38. $active_id = input('ids', 0, 'intval'); //从活动列表第一次跳转过来
  39. }
  40. $this->assignconfig('active_id', $active_id);
  41. //当前是否为关联查询
  42. $this->relationSearch = true;
  43. //设置过滤方法
  44. $this->request->filter(['strip_tags', 'trim']);
  45. if ($this->request->isAjax()) {
  46. //如果发送的来源是Selectpage,则转发到Selectpage
  47. if ($this->request->request('keyField')) {
  48. return $this->selectpage();
  49. }
  50. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  51. $list = $this->model
  52. ->with(['active','activeorder','user'])
  53. ->where(['hu_active_people.active_id' => $active_id])
  54. ->where($where)
  55. ->order($sort, $order)
  56. ->paginate($limit);
  57. foreach ($list as $row) {
  58. $row->getRelation('active')->visible(['title','desc']);
  59. $row->getRelation('activeorder')->visible(['order_sn']);
  60. $row->getRelation('user')->visible(['nickname','mobile']);
  61. }
  62. $result = array("total" => $list->total(), "rows" => $list->items());
  63. return json($result);
  64. }
  65. return $this->view->fetch();
  66. }
  67. }