Browse Source

钱包日报

lizhen_gitee 1 year ago
parent
commit
45db538a8e
3 changed files with 55 additions and 20 deletions
  1. 24 6
      application/api/controller/Userwallet.php
  2. 21 0
      application/common.php
  3. 10 14
      application/extra/wallet.php

+ 24 - 6
application/api/controller/Userwallet.php

@@ -18,6 +18,9 @@ class Userwallet extends Api
         $wallet = model('wallet')->getwallet($this->auth->id);
         $wallet['is_vip'] = $wallet['vip_endtime'] > time() ? 1 : 0;
 
+        $this->success('success',$wallet);
+    }
+    public function ribao(){
 
         //日报数据
         $date = input('date',date('Y-m-d'));
@@ -25,15 +28,15 @@ class Userwallet extends Api
         $endtime = $starttime + 86399;
 
         //当日收益
-        $log_type = [];
-        Db::name('user_gold_log')
+        $log_type = [21,22,23,54,41,61,63];
+        $change_value = Db::name('user_gold_log')
             ->where('createtime','IN',[$starttime,$endtime])
             ->where('user_id',$this->auth->id)
             ->where('money_type','jewel')
             ->where('log_type','IN',$log_type)
             ->sum('change_value');
 
-        //通话时长
+        //通话
         $where = [
             'to_user_id' => $this->auth->id,
             'createtime' => ['BETWEEN',[$starttime,$endtime]],
@@ -41,17 +44,32 @@ class Userwallet extends Api
         $audio_log = Db::name('user_match_audio_log')->where($where)->select();
         $audio_times = count($audio_log);//次数
         $audio_call_minutes = array_sum(array_column($audio_log,'call_minutes'));//通话时长
-
+        $audio_userid = array_column($audio_log,'user_id');
 
 
         $video_log = Db::name('user_match_video_log')->where($where)->select();
         $video_times = count($video_log);//次数
         $video_call_minutes = array_sum(array_column($video_log,'call_minutes'));//通话时长
+        $video_userid = array_column($video_log,'user_id');
+
+        //通话时长
+        $call_minutes = $audio_call_minutes + $video_call_minutes;
 
         //平均通话(分钟)
-        //互动个人数
+        $pingjun_minutes = bcdiv($call_minutes,($audio_times + $video_times),2);
 
-        $this->success('success',$wallet);
+        //互动人数
+        $call_usernum = count(array_flip(array_flip(array_merge($audio_userid,$video_userid))));
+
+        $result = [
+            'change_value' => $change_value,
+            'call_minutes' => Minute2Time($call_minutes),
+            'pingjun_minutes' => $pingjun_minutes,
+            'call_usernum' => $call_usernum,
+            'online_times' => '00:02:47',
+        ];
+
+        $this->success('success',$result);
     }
 
 

+ 21 - 0
application/common.php

@@ -579,6 +579,27 @@ function Sec2Time($time){
         return '0天';
     }
 }
+
+//秒 转换 日月分
+function Minute2Time($time){
+    if(is_numeric($time)){
+        $value = array(
+            'years' => 0, 'days' => 0, 'hours' => 0,
+            'minutes' => 0, 'seconds' => 0,
+        );
+
+        if($time >= 60){
+            $value['hours'] = floor($time/60);
+            $time = ($time%60);
+        }
+        $value['minutes'] = floor($time) > 10 ? floor($time) : '0'.floor($time);
+        $t = $value['hours'] .':'. $value['minutes'] .':00';
+        return $t;
+
+    }else{
+        return '00:00:00';
+    }
+}
 //生日转年龄
 function birthtime_to_age($birthtime){
 //    $birthtime = strtotime('1990-11-06');

+ 10 - 14
application/extra/wallet.php

@@ -11,26 +11,22 @@ return [
         11 => '视频通话',//-
         12 => '语音通话',//-
         13 => '聊天',//-
-        14 => '金币首充赠送',
-
-        15 => '提现',      //money-
-        16 => '提现拒绝返回',  //money+
-
-        21 => '视频通话',//+
-        22 => '语音通话',//+
-        23 => '聊天',//+
+//        14 => '金币首充赠送',
+        53 => '聊天赠送礼物',//gold -
 
 
-        31 => '购买装扮消费', //gold -
-        41 => '签到赠送金币',//jewel +
 
+        15 => '提现',      //jewel-
+        16 => '提现拒绝返回',  //jewel+
 
-        53 => '聊天赠送礼物',//gold -
+        21 => '视频通话',//jewel+
+        22 => '语音通话',//jewel+
+        23 => '聊天',//jewel+
         54 => '聊天获得礼物',//jewel +
 
-
-        61 => '完成个人任务',//gold +
-        63 => '邀请注册奖励',//money +
+        41 => '签到赠送',//jewel +
+        61 => '完成个人任务',//jewel +
+        63 => '邀请注册奖励',//jewel +
 
     ],
     'moneyname' => [