From 27d4e7835d626b8c557286abf5b5a8f2844d3a46 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 13:50:30 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=B4=A2=E5=BC=951?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/FinancePromoteController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index a2bbb9684..1affaa292 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -213,7 +213,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 +372,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") From 76cd530239dadd6014258c3dababf5259e633acb Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 13:55:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AD=90=E6=B8=A0=E9=81=93=E5=9F=BA=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Common/Common/extend.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 9f9414132..137cfaa5c 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -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... } /** From a69ef9e11845ce4a32395cf16430ba1de362b736 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 14:06:08 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=B9=B3=E5=8F=B0=E5=B8=81=E5=86=85=E5=85=85?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E4=B8=8D=E7=AC=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/FinancePromoteController.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 1affaa292..41f04b0bf 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -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"; @@ -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'] = $map['s.promote_id'] = array("in",implode(",",array_column(getPrmoteChlidAccount($_REQUEST['promote_id'],"id"),"id")).",".$_REQUEST['promote_id']); } //检索 if (isset($_REQUEST['sn'])) { From a33bf22e5295c2449478f60a5e8b578179f8e001 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 14:08:27 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/FinancePromoteController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 41f04b0bf..93bbeb607 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -789,7 +789,7 @@ class FinancePromoteController extends AdminController if($_REQUEST['promote_id'] == 0){ $isgf = true; } - $map['s.promote_id'] = $map['s.promote_id'] = array("in",implode(",",array_column(getPrmoteChlidAccount($_REQUEST['promote_id'],"id"),"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'])) { From 381327ae217c490cbabf47f86b0d3a0901c60c3c Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 14:33:11 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/FinanceController.class.php | 8 ++++++-- Application/Admin/Model/SpendModel.class.php | 16 ++++++++++++++-- .../Admin/View/Finance/gameStatisticsDetail.html | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 4c97a2eac..d66eded35 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -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);//分页 diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index bab8b51aa..67ccfa30a 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -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"); diff --git a/Application/Admin/View/Finance/gameStatisticsDetail.html b/Application/Admin/View/Finance/gameStatisticsDetail.html index 486c4e509..67a583667 100644 --- a/Application/Admin/View/Finance/gameStatisticsDetail.html +++ b/Application/Admin/View/Finance/gameStatisticsDetail.html @@ -41,7 +41,7 @@ From ccaa9d3a78a1cc7e20e7cb2876d199e9df21a2f7 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 11 Mar 2020 14:34:43 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=BB=9F=E8=AE=A1sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/update.sql | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Data/update.sql b/Data/update.sql index f6537638b..2b4e67000 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1444,4 +1444,11 @@ CREATE TABLE `tab_promote_game_available_balance` ( -- 2020-03-05 zyx spend添加索引 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; \ No newline at end of file +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; \ No newline at end of file