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; }