model = new \app\admin\model\User; $this->view->assign("realStatusList", $this->model->getRealStatusList()); $this->view->assign("genderList", $this->model->getGenderList()); $this->view->assign("idcardStatusList", $this->model->getIdcardStatusList()); $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("isKefuList", $this->model->getIsKefuList()); $this->view->assign("openMatchVideoList", $this->model->getOpenMatchVideoList()); $this->view->assign("openMatchAudioList", $this->model->getOpenMatchAudioList()); $this->view->assign("openMatchTypingList", $this->model->getOpenMatchTypingList()); $this->view->assign("freeVideoList", $this->model->getFreeVideoList()); $this->view->assign("freeAudioList", $this->model->getFreeAudioList()); $this->view->assign("freeTypingList", $this->model->getFreeTypingList()); } public function import() { parent::import(); } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ /** * 查看 */ public function index() { //当前是否为关联查询 $this->relationSearch = true; //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $map = []; if ($this->auth->id != 1 && $this->auth->id != 11) { if ($this->auth->user_id > 0) { $map['intro_uid'] = $this->auth->user_id; } else { $map['intro_uid'] = -100; } } $list = $this->model ->with([/*'gonghui',*/ 'userwallet']) ->where($where) ->where($map) ->order($sort, $order) ->paginate($limit); $mt_admin = Db::name('admin'); if ($this->auth->id == 1 || $this->auth->id == 11) { $is_show = 1; } else { $is_show = 0; } foreach ($list as &$row) { // $row->getRelation('gonghui')->visible(['id','name']); $row->getRelation('userwallet')->visible(['money', 'pay_money', 'get_money']); $row['sharing_ratio'] = $mt_admin->where(['user_id' => $row['intro_uid']])->value('sharing_ratio'); $row['sharing_ratio'] = $row['sharing_ratio'] ? : 0; $row['is_show'] = $is_show; } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } $this->assignConfig('sharing_ratio', $this->auth->sharing_ratio); return $this->view->fetch(); } /** * 统计详情 * @return void */ public function detail() { $ids = $this->request->param('ids',''); $result = []; if (!empty($ids)) { //21='视频通话收益',22='语音通话收益',23='文字聊天收益',52='语聊间获得礼物',54='聊天获得礼物',56='直播获得礼物',58='打招呼获得礼物' //60='动态获得礼物',65='邀请人充值奖励',67='女性完成个人任务',68='邀请人收益奖励',82='被守护收益',91='额外提成奖励' //总收益:今天、昨天、上周、近30天、总收益(收益+充值奖励) $revenueWhere['user_id'] = $ids; //$revenueWhere['log_type'] = ['in',[60,65,67,91]]; $revenueWhere['log_type'] = ['in',[21,22,23,52,54,56,58,60,67,82,91]]; /*$revenueWhereOr['other_user_id'] = $ids; $revenueWhereOr['log_type'] = ['in',[21,22,23,52,54,56,58,68,82]];*///other_user_id $today = day_now(); $yesterday = day_yesterday(); $nowweek = week_now(); $lastweek = last_week(); $month = now_month(); //今日总收益 $revenueWhereToday['createtime'] = [['egt',$today[0]],['lt',$today[1]+1],'and']; $revenueToday = Db::name('user_money_log')->where($revenueWhere)->where($revenueWhereToday)->sum('change_value'); //昨日总收益 $revenueWhereYesterday['createtime'] = [['egt',$yesterday[0]],['lt',$yesterday[1]+1],'and']; $revenueYesterday = Db::name('user_money_log')->where($revenueWhere)->where($revenueWhereYesterday)->sum('change_value'); //上周总收益 $revenueWhereLastweek['createtime'] = [['egt',$lastweek[0]],['lt',$lastweek[1]+1],'and']; $revenueLastweek = Db::name('user_money_log')->where($revenueWhere)->where($revenueWhereLastweek)->sum('change_value'); //本周总收益 $revenueWhereNowweek['createtime'] = [['egt',$nowweek[0]],['lt',$nowweek[1]+1],'and']; $revenueNowweek = Db::name('user_money_log')->where($revenueWhere)->where($revenueWhereNowweek)->sum('change_value'); //近30天总收益 $revenueWhereMonth['createtime'] = [['egt',$month[0]],['lt',$month[1]+1],'and']; $revenueMonth = Db::name('user_money_log')->where($revenueWhere)->where($revenueWhereMonth)->sum('change_value'); //总收益 $revenueTotal = Db::name('user_money_log')->where($revenueWhere)->sum('change_value'); $result['revenue_today'] = !empty($revenueToday) ? $revenueToday : 0; $result['revenue_yesterday'] = !empty($revenueYesterday) ? $revenueYesterday : 0; $result['revenue_now_week'] = !empty($revenueNowweek) ? $revenueNowweek : 0; $result['revenue_last_week'] = !empty($revenueLastweek) ? $revenueLastweek : 0; $result['revenue_month'] = !empty($revenueMonth) ? $revenueMonth : 0; $result['revenue_taotal'] = !empty($revenueTotal) ? $revenueTotal : 0; //邀请充值奖励:本周、上周 $inviteRechargeWhere['user_id'] = $ids; $inviteRechargeWhere['log_type'] = 65; //本周 $inviteWhereNowweek['createtime'] = [['egt',$nowweek[0]],['lt',$nowweek[1]+1],'and']; $inviteNowweek = Db::name('user_money_log')->where($inviteRechargeWhere)->where($inviteWhereNowweek)->sum('change_value'); //上周 $inviteWhereLastweek['createtime'] = [['egt',$lastweek[0]],['lt',$lastweek[1]+1],'and']; $inviteLastweek = Db::name('user_money_log')->where($inviteRechargeWhere)->where($inviteWhereLastweek)->sum('change_value'); $result['invite_recharge_week'] = $inviteNowweek; $result['invite_recharge_last_week'] = $inviteLastweek; //邀请奖励:今日、昨日 $inviteWhere['user_id'] = $ids; $inviteWhere['log_type'] = ['in',[65,68]]; //今日 $inviteWhereToday['createtime'] = [['egt',$today[0]],['lt',$today[1]+1],'and']; $inviteToday = Db::name('user_money_log')->where($inviteWhere)->where($inviteWhereToday)->sum('change_value'); //昨日 $inviteWhereYesterday['createtime'] = [['egt',$yesterday[0]],['lt',$yesterday[1]+1],'and']; $inviteLastweek = Db::name('user_money_log')->where($inviteWhere)->where($inviteWhereYesterday)->sum('change_value'); $result['invite_today'] = $inviteToday; $result['invite_yesterday'] = $inviteLastweek; } $res['row'] = $result; $user = $this->model->find($ids); $res['user'] = [ 'id' => $user['id'], 'nickname' => $user['nickname'], ]; $this->view->assign($res); return $this->view->fetch(); } }