12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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;
- //日报数据
- $date = input('date',date('Y-m-d'));
- $starttime = strtotime($date);
- $endtime = $starttime + 86399;
- //当日收益
- $log_type = [];
- 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'));//通话时长
- $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'));//通话时长
- //平均通话(分钟)
- //互动个人数
- $this->success('success',$wallet);
- }
- //金币日志
- 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;
- }
- }
|