Collect.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: lytian
  5. * Date: 2019/7/18
  6. * Time: 13:39
  7. */
  8. namespace app\admin\controller\booklistch;
  9. use app\common\controller\Backend;
  10. use app\common\model\BookList;
  11. use app\main\helper\StringHelper;
  12. use app\main\service\AdminService;
  13. use app\main\service\BookListChService;
  14. use app\main\service\VisitLimitService;
  15. /**
  16. * 数据统计
  17. *
  18. * @icon fa fa-circle-o
  19. */
  20. class Collect extends Backend
  21. {
  22. protected $noNeedRight = ['analysis'];
  23. /**
  24. * @var BookList
  25. */
  26. protected $model = null;
  27. protected $vipAdminBindModel = null;
  28. public function _initialize()
  29. {
  30. parent::_initialize();
  31. $this->model = model('BooklistCollect');
  32. }
  33. /**
  34. * 查看
  35. */
  36. public function index()
  37. {
  38. //设置过滤方法
  39. $this->request->filter(['strip_tags']);
  40. if ($this->request->isAjax())
  41. {
  42. //如果发送的来源是Selectpage,则转发到Selectpage
  43. if ($this->request->request('pkey_name'))
  44. {
  45. return $this->selectpage();
  46. }
  47. if (in_array($this->group, [7, 8])) {
  48. //VIP或VIP运营
  49. $maps['book_list_ch.admin_id'] = ['eq', $this->auth->id];
  50. } else {
  51. $maps['booklist_collect.admin_id'] = ['eq', $this->auth->id];
  52. }
  53. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  54. $total = $this->model
  55. ->join('book_list_ch', 'booklist_collect.booklist_id = book_list_ch.id')
  56. ->join('book', 'booklist_collect.idx = book.id')
  57. ->where($maps)
  58. ->where($where)
  59. ->order($sort, $order)
  60. ->count();
  61. $list = $this->model
  62. ->join('book_list_ch', 'booklist_collect.booklist_id = book_list_ch.id')
  63. ->join('book', 'booklist_collect.idx = book.id')
  64. ->where($maps)
  65. ->where($where)
  66. ->field("booklist_collect.*, book_list_ch.title, book.name")
  67. ->order($sort, $order)
  68. ->limit($offset, $limit)
  69. ->select();
  70. if ($list) {
  71. foreach ($list as $k=>$v) {
  72. $list[$k]['recharge_money'] = StringHelper::moneyFormat($v['recharge_money']);
  73. $list[$k]['booklist_collect'] = [
  74. 'idx' => $v['idx']
  75. ];
  76. $list[$k]['book_list_ch'] = [
  77. 'title' => $v['title']
  78. ];
  79. $list[$k]['book'] = [
  80. 'name' => $v['name']
  81. ];
  82. }
  83. }
  84. $result = array("total" => $total, "rows" => $list);
  85. return json($result);
  86. }
  87. return $this->view->fetch();
  88. }
  89. public function analysis()
  90. {
  91. //设置过滤方法
  92. $this->request->filter(['strip_tags']);
  93. if ($this->request->isAjax())
  94. {
  95. //如果发送的来源是Selectpage,则转发到Selectpage
  96. if ($this->request->request('pkey_name'))
  97. {
  98. return $this->selectpage();
  99. }
  100. $ids = $this->request->param('ids');
  101. $rowResult = BookListChService::instance()->getCollectList($ids, $this->auth->id)->data;
  102. return json(['rows'=>$rowResult]);
  103. }
  104. $this->assignconfig('ids', $this->request->param('ids'));
  105. return $this->view->fetch();
  106. }
  107. }