From 07672be58b9519bc149dbefbaf1b082ddd71481e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Mon, 19 Jan 2026 19:43:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E8=A1=A5=E8=B4=B4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/adminapi/controller/Guild.php | 62 ++++++++++++++++-- application/adminapi/model/Room.php | 43 ++++++++++-- application/guildadmin/controller/Room.php | 76 +++++++++++++++++----- 3 files changed, 157 insertions(+), 24 deletions(-) diff --git a/application/adminapi/controller/Guild.php b/application/adminapi/controller/Guild.php index 04b8992c..e9c63fe4 100644 --- a/application/adminapi/controller/Guild.php +++ b/application/adminapi/controller/Guild.php @@ -3,6 +3,7 @@ namespace app\adminapi\controller; use app\common\controller\adminApi; +use app\common\library\GiftTableManager; use think\Controller; use think\Db; use think\Session; @@ -479,8 +480,16 @@ class Guild extends adminApi $page = input('page', 1); $page_limit = input('page_limit', 30); $guild_id = input('guild_id', 0); - $search_stime_str = input('search_stime',''); - $search_etime_str = input('search_etime',''); + $firstDay = date('Y-m-01'); + $lastDay = date('Y-m-t 23:59:59'); + $search_stime_str = input('search_stime',$firstDay); + $search_etime_str = input('search_etime',$lastDay); + if(empty($search_stime_str)){ + $search_stime_str = $firstDay; + } + if(empty($search_etime_str)){ + $search_etime_str = $lastDay; + } $room_id = input('room_id', 0); $where=['a.status'=>1]; $where=['a.room_id'=>['>',0]]; @@ -498,6 +507,7 @@ class Guild extends adminApi ->join('vs_room b', 'a.room_id = b.id', 'left') ->where(['a.guild_id'=>$guild_id])->where($where)->count(); $list = db::name($this->table_guild_user)->alias('a') + ->field('a.*,b.room_name,b.room_number') ->join('vs_room b', 'a.room_id = b.id', 'left') ->where(['a.guild_id'=>$guild_id])->where($where) // ->page($page, $page_limit) @@ -507,6 +517,49 @@ class Guild extends adminApi } $rum_lists = []; //总流水 + $tables = GiftTableManager::getTablesByTimeRange( + strtotime($search_stime_str), + strtotime($search_etime_str) + ); + + $room_consumption =[]; + if($tables){ + foreach ($list as $vs) { + $search_stime = $search_stime_str; + $search_etime = $search_etime_str; + if($search_stime!=""){ + if($vs['apply_time'] && strtotime($search_stime) < $vs['apply_time']) { + $search_stime = date('Y-m-d H:i:s',$vs['apply_time']); + } + }else{ + $search_stime = date('Y-m-d H:i:s',$vs['apply_time']); + } + if($search_etime!=""){ + if($vs['quit_time'] && (strtotime($search_etime) > $vs['quit_time'])){ + $search_etime = date('Y-m-d H:i:s',$vs['quit_time']); + } + }else{ + if($vs['quit_time']){ + $search_etime = date('Y-m-d H:i:s',$vs['quit_time']); + }else{ + $search_etime = date('Y-m-d H:i:s',time()); + } + } + $all_total_price =0; + $total_price = 0; + foreach ($tables as $table_name) { + //表前缀 + $table_prefix = config('database.prefix'); + $table_name = str_replace($table_prefix, '', $table_name); + $total_price = db::name($table_name) + ->where(['from_id' => $vs['room_id'], 'from' => 2]) + ->where(['createtime' => ['between',[strtotime($search_stime),strtotime($search_etime)]]]) + ->sum('total_price'); + $all_total_price += $total_price; + $room_consumption[$vs['id']] = $all_total_price; + } + } + } $total_consumption = 0; foreach ($list as $k=>$v){ $search_stime = $search_stime_str; @@ -539,8 +592,9 @@ class Guild extends adminApi $rum_lists[$k]['room_name']=$room_info['room_name']?? ''; $rum_lists[$k]['room_cover']=$room_info['room_cover']?? ''; //房间流水 - $rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime); - $rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']); +// $rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime); + $rum_lists[$k]['consumption']= $room_consumption[$v['id']]??0; + $rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['apply_time']); $total_consumption += $rum_lists[$k]['consumption']; //幸运币统计 $where_lucky = []; diff --git a/application/adminapi/model/Room.php b/application/adminapi/model/Room.php index 713d0fe5..ff40dcb1 100644 --- a/application/adminapi/model/Room.php +++ b/application/adminapi/model/Room.php @@ -2,6 +2,7 @@ namespace app\adminapi\model; +use app\common\library\GiftTableManager; use think\Model; use think\Session; use think\Db; @@ -70,11 +71,30 @@ class Room extends Model /* * 查询房间流水 */ +// public function getRoomFlow($room_id,$stime='',$etime=''){ +// $give_where = []; +// $give_where['room_id'] = $room_id; +//// $give_where['from'] = ["in",[2,3,6]]; +//// $give_where['from'] = 2; +// if(!empty($stime)){ +// $give_where['createtime'] = ['>=',strtotime($stime)]; +// } +// if(!empty($etime)){ +// $give_where['createtime'] = ['<',strtotime($etime)]; +// } +// if(!empty($stime) && !empty($etime)){ +//// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]]; +// $give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]]; +// } +// $total_price = db::name('vs_guild_flow')->where($give_where) +// ->sum('flow_price'); +// return $total_price; +// } public function getRoomFlow($room_id,$stime='',$etime=''){ $give_where = []; - $give_where['room_id'] = $room_id; + $give_where['from'] = $room_id; // $give_where['from'] = ["in",[2,3,6]]; -// $give_where['from'] = 2; + $give_where['from'] = 2; if(!empty($stime)){ $give_where['createtime'] = ['>=',strtotime($stime)]; } @@ -85,8 +105,23 @@ class Room extends Model // $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]]; $give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]]; } - $total_price = db::name('vs_guild_flow')->where($give_where) - ->sum('flow_price'); + $tables = GiftTableManager::getTablesByTimeRange( + strtotime($stime), + strtotime($etime) + ); + $all_total_price =0; + if($tables){ + foreach ($tables as $table_name){ + //表前缀 + $table_prefix = config('database.prefix'); + $table_name = str_replace($table_prefix, '', $table_name); + $total_price = db::name($table_name) + ->where($give_where) + ->sum('total_price'); + $all_total_price += $total_price; + } + } + $total_price = $all_total_price; return $total_price; } diff --git a/application/guildadmin/controller/Room.php b/application/guildadmin/controller/Room.php index e9627ad1..38375f19 100644 --- a/application/guildadmin/controller/Room.php +++ b/application/guildadmin/controller/Room.php @@ -49,8 +49,16 @@ class Room extends GuildAdmin $room_id = input('room_id',''); $search_user_id = input('user_id',''); $status = input('status',''); - $search_stime_str = input('search_stime',''); - $search_etime_str = input('search_etime',''); + $firstDay = date('Y-m-01'); + $lastDay = date('Y-m-t 23:59:59'); + $search_stime_str = input('search_stime',$firstDay); + $search_etime_str = input('search_etime',$lastDay); + if(empty($search_stime_str)){ + $search_stime_str = $firstDay; + } + if(empty($search_etime_str)){ + $search_etime_str = $lastDay; + } $s_money_search = input('s_money_search',''); $e_money_search = input('e_money_search',''); if($this->auth->id != 1) { @@ -82,28 +90,63 @@ class Room extends GuildAdmin ->select(); $rum_lists = []; //总流水 + $tables = GiftTableManager::getTablesByTimeRange( + strtotime($search_stime_str), + strtotime($search_etime_str) + ); + + $room_consumption =[]; + if($tables){ + foreach ($lists as $vs) { + $search_stime = $search_stime_str; + $search_etime = $search_etime_str; + if($search_stime!=""){ + if($vs['apply_time'] && strtotime($search_stime) < $vs['apply_time']) { + $search_stime = date('Y-m-d H:i:s',$vs['apply_time']); + } + }else{ + $search_stime = date('Y-m-d H:i:s',$vs['apply_time']); + } + if($search_etime!=""){ + if($vs['quit_time'] && (strtotime($search_etime) > $vs['quit_time'])){ + $search_etime = date('Y-m-d H:i:s',$vs['quit_time']); + } + }else{ + if($vs['quit_time']){ + $search_etime = date('Y-m-d H:i:s',$vs['quit_time']); + }else{ + $search_etime = date('Y-m-d H:i:s',time()); + } + } + $all_total_price =0; + $total_price = 0; + foreach ($tables as $table_name) { + //表前缀 + $table_prefix = config('database.prefix'); + $table_name = str_replace($table_prefix, '', $table_name); + $total_price = db::name($table_name) + ->where(['from_id' => $vs['room_id'], 'from' => 2]) + ->where(['createtime' => ['between',[strtotime($search_stime),strtotime($search_etime)]]]) + ->sum('total_price'); + $all_total_price += $total_price; + $room_consumption[$vs['id']] = $all_total_price; + } + } + } $total_consumption = 0; foreach ($lists as $k=>$v){ $search_stime = $search_stime_str; $search_etime = $search_etime_str; if($search_stime!=""){ - if($search_stime!="" && $v['apply_time'] < strtotime($search_stime)){ - $search_stime = $search_stime; - }else{ - $search_stime = date('Y-m-d H:i:s',$v['apply_time']) ; + if($v['apply_time'] && strtotime($search_stime) < $v['apply_time']) { + $search_stime = date('Y-m-d H:i:s',$v['apply_time']); } }else{ - $search_stime = date('Y-m-d H:i:s',$v['apply_time']) ; + $search_stime = date('Y-m-d H:i:s',$v['apply_time']); } if($search_etime!=""){ - if($v['quit_time']){ - if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){ - $search_etime = $search_etime; - }else{ - $search_etime = date('Y-m-d H:i:s',$v['quit_time']); - } - }else{ - $search_etime = $search_etime; + if($v['quit_time'] && (strtotime($search_etime) > $v['quit_time'])){ + $search_etime = date('Y-m-d H:i:s',$v['quit_time']); } }else{ if($v['quit_time']){ @@ -144,7 +187,8 @@ class Room extends GuildAdmin //房间状态 $rum_lists[$k]['room_status']= $v['room_status']==1 ? '正常' : '封禁'; //房间流水 - $rum_lists[$k]['consumption']= model('adminapi/Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime); +// $rum_lists[$k]['consumption']= model('adminapi/Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime); + $rum_lists[$k]['consumption']= $room_consumption[$v['id']]??0; $rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']); $total_consumption += $rum_lists[$k]['consumption'];