Collect.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\controller\card;
  3. use app\common\controller\Backend;
  4. use app\common\model\CardDayCollect;
  5. use app\main\constants\ApiConstants;
  6. use app\main\service\ApiService;
  7. use think\Controller;
  8. use think\Request;
  9. /**
  10. * 抽奖统计管理
  11. *
  12. * @icon fa fa-circle-o
  13. */
  14. class Collect extends Backend
  15. {
  16. /**
  17. * @var CardDayCollect
  18. */
  19. protected $model = null;
  20. protected $noNeedRight = ['index'];
  21. public function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->model = model('CardDayCollect');
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. public function index()
  32. {
  33. $aid = $this->request->get('id');
  34. //设置过滤方法
  35. $this->request->filter(['strip_tags']);
  36. if ($this->request->isAjax())
  37. {
  38. //如果发送的来源是Selectpage,则转发到Selectpage
  39. if ($this->request->request('pkey_name')) {
  40. return $this->selectpage();
  41. }
  42. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  43. $channelId = $this->group < 3 ? 0 : $this->auth->id;
  44. $total = $this->model
  45. ->where('c_id', $aid)
  46. ->where('channel_id', $channelId)
  47. ->count();
  48. $list = $this->model
  49. ->where('c_id', $aid)
  50. ->where('channel_id', $channelId)
  51. ->order('createdate', 'desc')
  52. ->limit($offset, $limit)
  53. ->select();
  54. $result = array("total" => $total, "rows" => $list);
  55. return json($result);
  56. }
  57. $this->assignconfig('id', $aid);
  58. return $this->view->fetch();
  59. }
  60. }