Merge branch 'fix/member_user_info' of wmtx/platform into release

优化游戏统计及公会统计打开速度
master
廖金灵 5 years ago committed by Gogs
commit e885a75d1d

@ -698,6 +698,9 @@ class FinanceController extends ThinkController
*游戏统计
*/
public function gameStatistics($p = 1) {
if(!array_key_exists("timestart",$_REQUEST)){
$this->redirect(ACTION_NAME, array('timestart' => date('Y-m-d',strtotime('-30 day')),"timeend"=>date('Y-m-d')));
}
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$row = $_REQUEST['row'] ?? 10;
@ -738,8 +741,9 @@ class FinanceController extends ThinkController
$data[$key]['all_cash_count'] = $value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'];
}
$allData = D("spend")->gameStatistics($map);//列表总数
$count = count($allData);
$count = D("spend")->gameStatisticsCount($map);//列表总数
// $allData = D("spend")->gameStatistics($map);//列表总数
// $count = count($allData);
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);//分页

@ -111,6 +111,7 @@ class FinancePromoteController extends AdminController
"inside_cash_count"=>0,
);
foreach($senddata as $k=>$v){
$v['company_belong'] = $v['company_belong'] ?:0;
$v['company_belong'] = getCompanyBlong($v['company_belong']);
if(empty($v['company_name'])) $v['company_name']= $this->COMPANY_NAME;
if(empty($v['p_id'])) $v['p_id']= "0";
@ -213,7 +214,7 @@ class FinancePromoteController extends AdminController
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_id,0) company_id,company_name,IFNULL(promote.company_belong,0) company_belong";
return M()
->table("tab_spend s")
->table("tab_spend s use index(promote_time)")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
@ -372,7 +373,7 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL(promote.company_belong,0) company_belong";
return M()
->table("tab_spend s")
->table("tab_spend s use index(promote_time)")
->field($field)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id", "left")
@ -788,7 +789,7 @@ class FinancePromoteController extends AdminController
if($_REQUEST['promote_id'] == 0){
$isgf = true;
}
$map['s.promote_id'] = $_REQUEST['promote_id'];
$map['s.promote_id'] = array("in",implode(",",array_column(getPrmoteChlidAccount($_REQUEST['promote_id'],"id"),"id")).",".$_REQUEST['promote_id']);
}
//检索
if (isset($_REQUEST['sn'])) {

@ -840,7 +840,7 @@ class SpendModel extends Model
*/
public function gameStatistics($map, $row = 0, $page = 1)
{
$query = $this->alias("s")
$query = M("Spend s use index(game_time)","tab_")
->field("s.game_id,s.game_name,p.partner as partner_name, g.game_type_name,
SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
@ -856,13 +856,25 @@ SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count,g.sd
$data = $query->select();
return $data;
}
public function gameStatisticsCount($map)
{
$query = M("Spend s use index(game_time)","tab_")
->field("game_id")
->where(['s.pay_status' => 1, 'pay_game_status' => 1])
->where($map)
->group('s.game_id');
$data = $query->select();
return count($data);
}
/**
*获取游戏统计列表数据
*/
public function totalGameStatistics($map, $join = true)
{
$query = $this->alias("s")
$query = M("Spend s use index(game_time)","tab_")
->field("SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count");

@ -41,7 +41,7 @@
<!--游戏类型搜索END-->
<div class="input-list">
<a class="sch-btn" href="{:U('Finance/gameStatistics')}" style="background:#fff;color: #000;border: #000 solid 1px;width: 100px">返回</a>
<a class="sch-btn" href="javascript:history.go(-1)" style="background:#fff;color: #000;border: #000 solid 1px;width: 100px">返回</a>
</div>
<input type="hidden" name="count_date" value="{$_GET['count_date']}"/>
<input type="hidden" name="game_id" value="{$_GET['game_id']}"/>

@ -1989,15 +1989,15 @@ function getPrmoteChlidAccount($id=0,$field="*")
$promote = M("promote","tab_");
//获取自己的等级
$self = $promote->field("chain,level")->where("id = '{$id}'")->find();
if($self['chain'] == "/"){
$self['chain'] = "/".$id."/";
}
$map['status'] = 1;
$map["chain"] = array("LIKE","%{$self['chain']}%");
$map["level"] = array("GT",$self['level']);
$data = $promote->field($field)->where($map)->select();
if(empty($data)){return array();}
return $data;
# code...
}
/**

@ -1445,3 +1445,10 @@ CREATE TABLE `tab_promote_game_available_balance` (
ALTER TABLE `tab_spend`
ADD INDEX `pay_channel`(`pay_way`, `pay_status`, `game_id`) USING BTREE,
ADD INDEX `pay_channel_type`(`pay_status`, `pay_way`) USING BTREE;
-- 为游戏统计新增spend索引 chenzhi 2020/03/11
ALTER TABLE `tab_spend`
ADD INDEX `game_time`(`game_id`,`pay_time`) USING BTREE;
-- 为公会统计新增spend索引 chenzhi 2020/03/11
ALTER TABLE `tab_spend`
ADD INDEX `promote_time`(`promote_id`,`pay_time`) USING BTREE;
Loading…
Cancel
Save