123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- namespace app\admin\controller\agent;
- use app\common\controller\Backend;
- use app\common\library\Auth;
- use Think\Db;
- /**
- * 主播管理
- *
- * @icon fa fa-user
- */
- class User extends Backend
- {
-
- protected $searchFields = 'id,username,nickname';
- protected $selectpageFields = 'id,username,nickname,mobile';
- /**
- * User模型对象
- * @var \app\admin\model\User
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->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();
- }
- }
|