Browse Source

邀请中心接口,日报

lizhen_gitee 11 months ago
parent
commit
8cd25176f3
1 changed files with 131 additions and 0 deletions
  1. 131 0
      application/api/controller/Userintro.php

+ 131 - 0
application/api/controller/Userintro.php

@@ -12,6 +12,14 @@ class Userintro extends Api
     protected $noNeedLogin = [];
     protected $noNeedRight = ['*'];
 
+    /*public function __construct(){
+        parent::__construct();
+
+        if($this->auth->group_id == 1){
+            $this->error('无权进入');
+        }
+    }*/
+
 
     //生成我的视频海报
     //生成邀请码二维码图片
@@ -76,6 +84,129 @@ class Userintro extends Api
         $this->success('', $imgurl);
     }
 
+    //申请绑定
+    //申请绑定记录
+
+    //日报
+    public function ribao(){
+        $authid = $this->auth->id;
+        $result = [];
+
+        //日期
+        $today = date('Y-m-d');
+        $startday  = input('startday',$today);
+        $starttime = strtotime($startday);
+        $endtime   = $starttime + 86399;
+
+        //传入代理
+        $down_all_id = input('down_all_id',0);
+
+        //代理名
+        $result['agentname']   = $this->auth->agentname ?: $this->auth->nickname;
+        $result['yaoqingtime'] = $this->auth->yaoqingtime;
+        $result['startday']    = $startday;
+
+        //一级代理  下拉  可选二级代理
+        $down_all = $this->select_agent();
+        $result['down_all'] = $down_all;
+        //dump($down_all);
+
+        //确定收益统计范围
+        if(!empty($down_all_id)){
+            $downall_uid = Db::name('user')->where('intro_uid',$down_all_id)->column('id');//其下直推,A1下B0 或 B1下C1
+            //$downall_uid[] = $down_all_id;
+        }else{
+            $down_uid = array_column($down_all,'id');
+            //dump($down_uid);
+            $downall_uid = Db::name('user')->where('intro_uid|agent_id','IN',$down_uid)->column('id');//其下直推+其下代理+代理下直推
+        }
+        //dump($downall_uid);
+
+        //邀请奖励收益
+        $recharge_sum = Db::name('user_agentjewel_log')->where('user_id','IN',$downall_uid)->where('log_type',51)->where('createtime','BETWEEN',[$starttime,$endtime])->sum('change_value');
+        $result['recharge_sum'] = $recharge_sum;
+        //视频收益
+        $video_sum = Db::name('user_match_video_log')->where('to_user_id','IN',$downall_uid)->where('updatetime','BETWEEN',[$starttime,$endtime])->sum('money');
+        $result['video_sum'] = $video_sum;
+        //语音收益
+        $audio_sum = Db::name('user_match_audio_log')->where('to_user_id','IN',$downall_uid)->where('updatetime','BETWEEN',[$starttime,$endtime])->sum('money');
+        $result['audio_sum'] = $audio_sum;
+        //私信收益
+        $typing_sum= Db::name('user_match_typing_log')->where('to_user_id','IN',$downall_uid)->where('createtime','BETWEEN',[$starttime,$endtime])->sum('money');
+        $result['typing_sum'] = $typing_sum;
+        //礼物收益
+        $gift_sum  = Db::name('gift_user_typing')->where('user_to_id','IN',$downall_uid)->where('createtime','BETWEEN',[$starttime,$endtime])->sum('getvalue');
+        $result['gift_sum'] = $gift_sum;
+        //总收益
+        $result['total'] = $recharge_sum + $video_sum + $audio_sum + $typing_sum + $gift_sum;
+        //在线用户
+        $active_num = Db::name('user_active')->where('user_id','IN',$downall_uid)->where('requesttime','BETWEEN',[$starttime,$endtime])->count();
+        $result['active_num'] = $active_num;
+        //收益用户
+        $a = Db::name('user_agentjewel_log')->where('user_id','IN',$downall_uid)->where('log_type',51)->where('createtime','BETWEEN',[$starttime,$endtime])->distinct(true)->field('user_id')->select();
+        $a1 = array_column($a,'user_id');
+
+        $b = Db::name('user_match_video_log')->where('to_user_id','IN',$downall_uid)->where('updatetime','BETWEEN',[$starttime,$endtime])->distinct(true)->field('to_user_id')->select();
+        $b1 = array_column($b,'to_user_id');
+
+        $c = Db::name('user_match_audio_log')->where('to_user_id','IN',$downall_uid)->where('updatetime','BETWEEN',[$starttime,$endtime])->distinct(true)->field('to_user_id')->select();
+        $c1 = array_column($c,'to_user_id');
+
+        $d = Db::name('user_match_typing_log')->where('to_user_id','IN',$downall_uid)->where('createtime','BETWEEN',[$starttime,$endtime])->distinct(true)->field('to_user_id')->select();
+        $d1 = array_column($d,'to_user_id');
+
+        $e = Db::name('gift_user_typing')->where('user_to_id','IN',$downall_uid)->where('createtime','BETWEEN',[$starttime,$endtime])->distinct(true)->field('user_to_id')->select();
+        $e1 = array_column($e,'user_to_id');
+//        dump($a);
+//        dump($a1);
+//        dump($b);
+//        dump($b1);
+//        dump($c);
+//        dump($c1);
+//        dump($d);
+//        dump($d1);
+//        dump($e);
+//        dump($e1);
+
+        $abcde = array_merge(array_merge($a1,$b1,$c1),$d1,$e1);
+        $shouyi_user = array_flip(array_flip($abcde));
+        $result['shouyi_num'] = count($shouyi_user);
+
+        $this->success(1,$result);
+    }
+
+    //下拉选择代理
+    private function select_agent(){
+        //一级代理下的二级代理
+        $down_agent_users = [];
+        if($this->auth->group_id == 3){
+            $down_agent_users = Db::name('user')->field('id,nickname,agentname')->where('agent_id',$this->auth->id)->select();
+        }
+
+        //追加自己。二级代理的,就只有自己
+        $self_agent = [['id'=>$this->auth->id,'nickname'=>$this->auth->nickname,'agentname'=>$this->auth->agentname]];
+
+        $down_all = array_merge($self_agent,$down_agent_users);
+
+        //没有代理名的用昵称
+        foreach($down_all as $key => $val){
+            $val['agentname'] = $val['agentname'] ?: $val['nickname'];
+            unset($val['nickname']);
+            $down_all[$key] = $val;
+        }
+
+        return $down_all;
+    }
+    //成员管理
+    //成员收入
+    //成员详情
+    //邀请页
+    //账户中心
+    //账户明细
+    //提现
+    //提现记录
+
+
 
     //我邀请的人列表
     public function myintro_list(){