优化:Give_Gift 表查询处理
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Db;
|
||||
use Yzh\YunPay;
|
||||
|
||||
@@ -86,6 +87,12 @@ class Statistical extends adminApi
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$begin_time = empty($begin_time) ? $firstDay : $begin_time;
|
||||
$end_time = empty($end_time) ? $lastDay : $end_time;
|
||||
|
||||
$where=[];
|
||||
$group = 'user_id';
|
||||
if($type == 2){
|
||||
@@ -118,11 +125,18 @@ class Statistical extends adminApi
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')
|
||||
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
$table_name = substr($tables[0], 3);//截取可查询的表名
|
||||
|
||||
$count = db::name($table_name)
|
||||
->where($where)
|
||||
->group($group)
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
$lists = db::name($table_name)
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number')
|
||||
->where($where)
|
||||
->group($group)
|
||||
|
||||
Reference in New Issue
Block a user