diff --git a/application/adminapi/controller/Room.php b/application/adminapi/controller/Room.php index e0582908..411ea78c 100644 --- a/application/adminapi/controller/Room.php +++ b/application/adminapi/controller/Room.php @@ -676,19 +676,43 @@ class Room extends adminApi if($type == 2){ $start_time = strtotime(date('Y-m-d')); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 3){ $start_time = strtotime(date('Y-m-d',strtotime('-1 day'))); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 4){ $start_time = strtotime(date('Y-m-d',strtotime('-2 day'))); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 1){ $start_time = 1748676768;//2025-06-00 15:32:48 $end_time = time(); + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); } - - $profit = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price'); - return $profit; + $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('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price'); + $all_total_price += $total_price; + } + } + return $all_total_price; } diff --git a/application/api/model/Room.php b/application/api/model/Room.php index 29d58677..c559d57f 100644 --- a/application/api/model/Room.php +++ b/application/api/model/Room.php @@ -3,6 +3,7 @@ namespace app\api\model; use app\common\controller\Push; +use app\common\library\GiftTableManager; use think\Cache; use think\Db; use think\Log; @@ -432,13 +433,37 @@ class Room extends Model $week = strtotime(date('Y-m-d', strtotime('this week Monday'))); //本周的房间流水 if($room_type == 6){ - $total_transaction = db::name('vs_give_gift') - ->where(['from_id' => $room_id, 'from' =>6, 'createtime' => ['between', [$week, time()]]]) - ->sum('total_price'); + $tables = GiftTableManager::getTablesByTimeRange( + $week, + time() + ); + $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(['from_id' => $room_id, 'from' =>6, 'createtime' => ['between', [$week, time()]]])->sum('total_price'); + $all_total_price += $total_price; + } + } + $total_transaction = $all_total_price; }else{ - $total_transaction = db::name('vs_give_gift') - ->where(['from_id' => $room_id, 'from' =>2, 'createtime' => ['between', [$week, time()]]]) - ->sum('total_price'); + $tables = GiftTableManager::getTablesByTimeRange( + $week, + time() + ); + $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(['from_id' => $room_id, 'from' =>2, 'createtime' => ['between', [$week, time()]]])->sum('total_price'); + $all_total_price += $total_price; + } + } + $total_transaction = $all_total_price; } $ss = 0; diff --git a/application/guildadmin/controller/Room.php b/application/guildadmin/controller/Room.php index 7f19c8f9..e9627ad1 100644 --- a/application/guildadmin/controller/Room.php +++ b/application/guildadmin/controller/Room.php @@ -289,19 +289,43 @@ class Room extends GuildAdmin if($type == 2){ $start_time = strtotime(date('Y-m-d')); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 3){ $start_time = strtotime(date('Y-m-d',strtotime('-1 day'))); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 4){ $start_time = strtotime(date('Y-m-d',strtotime('-2 day'))); $end_time = $start_time + 86400; + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); }elseif ($type == 1){ $start_time = 1748676768;//2025-06-00 15:32:48 $end_time = time(); + $tables = GiftTableManager::getTablesByTimeRange( + $start_time, + $end_time + ); } - - $profit = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price'); - return $profit; + $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('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price'); + $all_total_price += $total_price; + } + } + return $all_total_price; } //房间访客 //type 1:今日 2:昨日 3:所有