Prize.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\admin\controller\lottery;
  3. use app\common\controller\Backend;
  4. /**
  5. * 抽奖商品列管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Prize extends Backend
  10. {
  11. /**
  12. * Prize模型对象
  13. * @var \app\admin\model\lottery\Prize
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\lottery\Prize;
  20. $this->view->assign("typeList", $this->model->getTypeList());
  21. }
  22. /**
  23. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  24. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  25. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  26. */
  27. public function index()
  28. {
  29. $this->relationSearch = true;
  30. $this->searchFields = "lottery.name,id";
  31. if ($this->request->isAjax())
  32. {
  33. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  34. $total = $this->model
  35. ->with(['lottery'])
  36. ->where($where)
  37. ->order($sort, $order)
  38. ->count();
  39. $list = $this->model
  40. ->with(['lottery'])
  41. ->where($where)
  42. ->order($sort, $order)
  43. ->limit($offset, $limit)
  44. ->select();
  45. $result = array("total" => $total, "rows" => $list, "extend" => ['money' => 1024, 'price' => 888]);
  46. return json($result);
  47. }
  48. return $this->view->fetch();
  49. }
  50. }