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(); } }