Browse Source

邀请中心接口,成员收入

lizhen_gitee 11 months ago
parent
commit
35c2edd861
1 changed files with 67 additions and 7 deletions
  1. 67 7
      application/api/controller/Userintro.php

+ 67 - 7
application/api/controller/Userintro.php

@@ -89,7 +89,6 @@ class Userintro extends Api
 
     //日报
     public function ribao(){
-        $authid = $this->auth->id;
         $result = [];
 
         //日期
@@ -118,7 +117,7 @@ class Userintro extends Api
         }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');//其下直推+其下代理+代理下直推
+            $downall_uid = Db::name('user')->where('intro_uid','IN',$down_uid)->column('id');//其下直推B0+代理下直推C1 或 C1
         }
         //dump($downall_uid);
 
@@ -205,7 +204,7 @@ class Userintro extends Api
         $down_all_id = input('down_all_id',0);
 
         //传入用户id
-        $get_user_id = input('get_user_id',0);
+        $get_username = input('get_username',0);
 
         //一级代理  下拉  可选二级代理
         $down_all = $this->select_agent();
@@ -215,16 +214,16 @@ class Userintro extends Api
         //确定收益统计范围
         if(!empty($down_all_id)){
             $where = ['intro_uid' => $down_all_id];
-            if($get_user_id){
-                $where['id']= $get_user_id;
+            if($get_username){
+                $where['username']= $get_username;
             }
             $downall_uid = Db::name('user')->where($where)->field('id,username,avatar,nickname,is_active,intro_uid,yaoqingtime')->order('yaoqingtime desc')->autopage()->select();//其下直推,A1下B0 或 B1下C1
             //$downall_uid[] = $down_all_id;
         }else{
             $down_uid = array_column($down_all,'id');
             $where = ['intro_uid' => ['IN',$down_uid]];
-            if($get_user_id){
-                $where['id']= $get_user_id;
+            if($get_username){
+                $where['username']= $get_username;
             }
             //dump($down_uid);
             $downall_uid = Db::name('user')->where($where)->field('id,username,avatar,nickname,is_active,intro_uid,yaoqingtime')->order('yaoqingtime desc')->autopage()->select();//其下直推B0+代理下直推C1 或 C1
@@ -256,7 +255,68 @@ class Userintro extends Api
     }
     //成员收入
     public function user_shouyi(){
+        $result = [];
+
+        //日期
+        $today = date('Y-m-d');
+        $startday  = input('startday',$today);
+        $starttime = strtotime($startday);
+        $endtime   = $starttime + 86399;
+
+        //传入代理
+        $down_all_id = input('down_all_id',0);
+
+        //传入用户id
+        $get_username = input('get_username',0);
+
+        $result['startday']    = $startday;
+
+        //一级代理  下拉  可选二级代理
+        $down_all = $this->select_agent();
+        $result['down_all'] = $down_all;
+        //dump($down_all);
+
+        //确定收益统计范围
+        if(!empty($down_all_id)){
+            $where = ['intro_uid' => $down_all_id];
+            if($get_username){
+                $where['username']= $get_username;
+            }
+            $downall_uid = Db::name('user')->where($where)->field('id,username,avatar,nickname,intro_uid')->order('yaoqingtime desc')->autopage()->select();//其下直推,A1下B0 或 B1下C1
+            //$downall_uid[] = $down_all_id;
+        }else{
+            $down_uid = array_column($down_all,'id');
+            $where = ['intro_uid' => ['IN',$down_uid]];
+            if($get_username){
+                $where['username']= $get_username;
+            }
+            //dump($down_uid);
+            $downall_uid = Db::name('user')->where($where)->field('id,username,avatar,nickname,intro_uid')->order('yaoqingtime desc')->autopage()->select();//其下直推B0+代理下直推C1 或 C1
+        }
+        //dump($downall_uid);
+        foreach($downall_uid as $key => &$user){
+            $user['agentname'] = Db::name('user')->where('id',$user['intro_uid'])->value('agentname');
+            //邀请奖励收益
+            $recharge_sum = Db::name('user_agentjewel_log')->where('user_id',$user['id'])->where('log_type',51)->where('createtime','BETWEEN',[$starttime,$endtime])->sum('change_value');
+//            $user['recharge_sum'] = $recharge_sum;
+            //视频收益
+            $video_sum = Db::name('user_match_video_log')->where('to_user_id',$user['id'])->where('updatetime','BETWEEN',[$starttime,$endtime])->sum('money');
+//            $user['video_sum'] = $video_sum;
+            //语音收益
+            $audio_sum = Db::name('user_match_audio_log')->where('to_user_id',$user['id'])->where('updatetime','BETWEEN',[$starttime,$endtime])->sum('money');
+//            $user['audio_sum'] = $audio_sum;
+            //私信收益
+            $typing_sum= Db::name('user_match_typing_log')->where('to_user_id',$user['id'])->where('createtime','BETWEEN',[$starttime,$endtime])->sum('money');
+//            $user['typing_sum'] = $typing_sum;
+            //礼物收益
+            $gift_sum  = Db::name('gift_user_typing')->where('user_to_id',$user['id'])->where('createtime','BETWEEN',[$starttime,$endtime])->sum('getvalue');
+//            $user['gift_sum'] = $gift_sum;
+            //总收益
+            $user['total'] = $recharge_sum + $video_sum + $audio_sum + $typing_sum + $gift_sum;
 
+        }
+
+        $this->success(1,$downall_uid);
     }
 
     //成员详情