123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace app\admin\controller\user;
- use app\common\controller\Backend;
- use app\common\model\UserCollect;
- use app\main\constants\AdminConstants;
- use app\main\constants\ApiConstants;
- use app\main\service\ApiService;
- use app\main\service\UserCollectService;
- use app\main\service\UserService;
- use app\main\service\VisitLimitService;
- /**
- * 数据统计-用户统计
- *
- * @icon fa fa-circle-o
- */
- class Collect extends Backend
- {
- /**
- * @var UserCollect
- */
- protected $model = null;
- protected $groupId;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = model('UserCollect');
- $group = model('AuthGroupAccess')->where('uid',$this->auth->id)->find();
- $this->groupId = $group->group_id;
- $this->assign('groupId',$this->groupId);
- $this->assignconfig('groupId',$this->groupId);
- }
-
- /**
- * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
- * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
- * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
- */
- /**
- * 查看
- */
- public function index()
- {
- if(isset($_GET['ids']) && !empty($_GET['ids'])){
- $admin_id = $_GET['ids'];
- }else{
- $admin_id = $this->auth->id;
- }
- $this->assignconfig('ids', $admin_id);
- if ($this->request->isAjax())
- {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $result = UserCollectService::instance()->getUserCollectDateListData($admin_id, $where, $sort, $order, $offset, $limit, $this->group);
- return json($result->data);
- }
- if (VisitLimitService::instance()->checkMigratedV2()) {
- $data = UserCollectService::instance()->getMigrateCollectData($admin_id, $this->group)->data;
- } else {
- $data = UserCollectService::instance()->getCollectData($this->auth->id)->data;
- }
- $this->assign($data);
- return $this->view->fetch();
- }
- public function ajaxToday(){
- if (VisitLimitService::instance()->checkMigratedV2()) {
- if ($this->group == AdminConstants::ADMIN_GROUP_ID_SUPER_ADMIN) {
- $admin_id = 0;
- } else {
- $admin_id = $this->auth->id;
- }
- $todayData = UserCollectService::instance()->getMigrateTodayData($admin_id);
- } else {
- $todayData = UserCollectService::instance()->getUserCollectToday($this->auth->id);
- }
- return json($todayData->data);
- }
- public function recharge_new()
- {
- $data = [];
- $filter = $this->request->get('filter');
- $where = [
- ];
- if ($filter) {
- $filter = json_decode($filter, TRUE);
- if (array_key_exists('reg_date', $filter)) {
- $range = explode(' - ', $filter['reg_date']);
- $data['begin_date'] = $range[0];
- $data['end_date'] = $range[1];
- $range[0] = str_replace('-', '', $range[0]);
- $range[1] = str_replace('-', '', $range[1]);
- $where['reg_date'] = ['between', [$range[0], $range[1]]];
- }
- }
- list(, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = model('recharge_new_analysis')
- ->where('channel_id', $this->auth->id)
- ->field('id,channel_id,reg_date,new,cost,day1,day2,day3,day5,day7,day15,day30')
- ->order('reg_date', 'desc')
- ->where($where)
- ->limit($offset, $limit)
- ->select();
- $count = model('recharge_new_analysis')
- ->where('channel_id', $this->auth->id)
- ->order('reg_date', 'desc')
- ->where($where)
- ->count();
- $data['total'] = $count;
- $data['rows'] = $list;
- return json($data);
- }
- public function recharge_cost($cost, $id)
- {
- model('recharge_new_analysis')->update(['cost' => $cost], ['id' => $id]);
- $this->success();
- }
- }
|