From 556c42cc72035fba021f9818d2734952dba5eb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Mon, 19 Jan 2026 10:57:02 +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/cron/controller/Subsidy.php | 29 +++++++++++++++++++++---- application/cron/controller/Test.php | 23 ++++++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/application/cron/controller/Subsidy.php b/application/cron/controller/Subsidy.php index 7f344009..1e31d8e2 100644 --- a/application/cron/controller/Subsidy.php +++ b/application/cron/controller/Subsidy.php @@ -3,6 +3,7 @@ namespace app\cron\controller; use app\common\controller\adminApi; +use app\common\library\GiftTableManager; use think\Controller; use think\Db; @@ -63,11 +64,31 @@ class Subsidy // if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){ // $week_end_time_seach = $v['quit_time']; // } -// $transaction_one = db::name('vs_give_gift') -// ->whereIn('from_id',$v['room_id']) -// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) -// ->sum('total_price'); +// $tables = GiftTableManager::getTablesByTimeRange( +// $week_start_time_seach, +// $week_end_time_seach +// ); +// $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) +// ->whereIn('from_id',$v['room_id']) +// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) +// ->sum('total_price'); +// $all_total_price += $total_price; +// } +// } +// $transaction_one = $all_total_price; // $transaction += $transaction_one; +// +//// $transaction_one = db::name('vs_give_gift') +//// ->whereIn('from_id',$v['room_id']) +//// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) +//// ->sum('total_price'); +//// $transaction += $transaction_one; // } // // if($transaction > 0){ diff --git a/application/cron/controller/Test.php b/application/cron/controller/Test.php index 766282b2..3ee614a0 100644 --- a/application/cron/controller/Test.php +++ b/application/cron/controller/Test.php @@ -3,6 +3,7 @@ namespace app\cron\controller; use app\common\controller\Push; +use app\common\library\GiftTableManager; use think\Cache; use think\Db; use Yzh\YunPay; @@ -739,10 +740,24 @@ class Test if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){ $week_end_time_seach = $v['quit_time']; } - $transaction_one = db::name('vs_give_gift') - ->whereIn('from_id',$v['room_id']) - ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) - ->sum('total_price'); + $tables = GiftTableManager::getTablesByTimeRange( + $week_start_time_seach, + $week_end_time_seach + ); + $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) + ->whereIn('from_id',$v['room_id']) + ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]]) + ->sum('total_price'); + $all_total_price += $total_price; + } + } + $transaction_one = $all_total_price; $transaction += $transaction_one; }