123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * Created by PhpStorm.
- * User: lytian
- * Date: 2019/7/18
- * Time: 13:39
- */
- namespace app\admin\controller\booklistch;
- use app\common\controller\Backend;
- use app\common\model\BookList;
- use app\main\helper\StringHelper;
- use app\main\service\AdminService;
- use app\main\service\BookListChService;
- use app\main\service\VisitLimitService;
- /**
- * 数据统计
- *
- * @icon fa fa-circle-o
- */
- class Collect extends Backend
- {
- protected $noNeedRight = ['analysis'];
- /**
- * @var BookList
- */
- protected $model = null;
- protected $vipAdminBindModel = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = model('BooklistCollect');
- }
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax())
- {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('pkey_name'))
- {
- return $this->selectpage();
- }
- if (in_array($this->group, [7, 8])) {
- //VIP或VIP运营
- $maps['book_list_ch.admin_id'] = ['eq', $this->auth->id];
- } else {
- $maps['booklist_collect.admin_id'] = ['eq', $this->auth->id];
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->join('book_list_ch', 'booklist_collect.booklist_id = book_list_ch.id')
- ->join('book', 'booklist_collect.idx = book.id')
- ->where($maps)
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->join('book_list_ch', 'booklist_collect.booklist_id = book_list_ch.id')
- ->join('book', 'booklist_collect.idx = book.id')
- ->where($maps)
- ->where($where)
- ->field("booklist_collect.*, book_list_ch.title, book.name")
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- if ($list) {
- foreach ($list as $k=>$v) {
- $list[$k]['recharge_money'] = StringHelper::moneyFormat($v['recharge_money']);
- $list[$k]['booklist_collect'] = [
- 'idx' => $v['idx']
- ];
- $list[$k]['book_list_ch'] = [
- 'title' => $v['title']
- ];
- $list[$k]['book'] = [
- 'name' => $v['name']
- ];
- }
- }
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- public function analysis()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax())
- {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('pkey_name'))
- {
- return $this->selectpage();
- }
- $ids = $this->request->param('ids');
- $rowResult = BookListChService::instance()->getCollectList($ids, $this->auth->id)->data;
- return json(['rows'=>$rowResult]);
- }
- $this->assignconfig('ids', $this->request->param('ids'));
- return $this->view->fetch();
- }
- }
|