| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use think\Db;
 
- //use app\common\model\wallet;
 
- /**
 
-  * 用户钱包
 
-  */
 
- class Userwallet extends Api
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = ['*'];
 
-     //我的钱包余额
 
-     public function my_wallet(){
 
-         $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'));
 
-         $starttime = strtotime($date);
 
-         $endtime = $starttime + 86399;
 
-         //当日收益
 
-         $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]],
 
-         ];
 
-         $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;
 
-         //平均通话(分钟)
 
-         $tonghua_times = $audio_times + $video_times;
 
-         if($tonghua_times == 0){
 
-             $pingjun_minutes = 0;
 
-         }else{
 
-             $pingjun_minutes = bcdiv($call_minutes,$tonghua_times,2);
 
-         }
 
-         //互动人数
 
-         $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);
 
-     }
 
-     //金币日志
 
-     public function my_gold_log(){
 
-         $money_type = input('money_type',0);
 
-         $map = [
 
-             'user_id' => $this->auth->id,
 
-         ];
 
-         if($money_type){
 
-             $map['money_type'] = $money_type;
 
-         }
 
-         $list = Db::name('user_gold_log')
 
-             ->field('id,log_type,money_type,before,change_value,remain,remark,createtime')
 
-             ->where($map)->order('id desc')->autopage()->select();
 
-         $list = $this->list_appen_logtext($list);
 
-         $this->success('success',$list);
 
-     }
 
-     //追加log_text
 
-     private function list_appen_logtext($list){
 
-         if(!empty($list)){
 
-             $conf = config('wallet.logtype');
 
-             foreach($list as $key => $val){
 
-                 $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
- }
 
 
  |