From 6fcaa1362c8f7e281d38008a4eba906a696240d8 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Mon, 21 Sep 2020 14:05:01 +0800
Subject: [PATCH 01/14] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/Common/extend.php | 14 ++++++++++++++
.../Controller/AuthManagerController.class.php | 3 +++
.../Controller/PromoteCompanyController.class.php | 1 +
Application/Base/Service/MarketService.class.php | 1 +
.../Base/Service/PromoteCompanyService.class.php | 1 +
Application/Base/Service/PromoteService.class.php | 1 +
6 files changed, 21 insertions(+)
diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php
index 39aa08532..b8814f0e9 100644
--- a/Application/Admin/Common/extend.php
+++ b/Application/Admin/Common/extend.php
@@ -1653,6 +1653,20 @@ function getPowerPromoteIds()
return $promoteIds;
}
+function resetUserAuth()
+{
+ $userAuth = session('user_auth');
+ $adminData = getAdminData($userAuth['uid']);
+ $groupId = getGameGroup($userAuth['uid']);
+ $userAuth['data_empower_type'] = $adminData['data_empower_type'];
+ $userAuth['data_president'] = $adminData['data_president'];
+ $userAuth['show_data'] = $adminData['show_data'];
+ session('user_group_id',$groupId);
+ session('user_auth', $userAuth);
+ session('user_auth_sign', data_auth_sign($userAuth));
+ session('user_auth_promote_ids', null);
+}
+
/**
* 为数据权限添加筛选参数
* @param array $map 查询条件
diff --git a/Application/Admin/Controller/AuthManagerController.class.php b/Application/Admin/Controller/AuthManagerController.class.php
index c72fca0cf..cbd5bd396 100644
--- a/Application/Admin/Controller/AuthManagerController.class.php
+++ b/Application/Admin/Controller/AuthManagerController.class.php
@@ -571,6 +571,9 @@ class AuthManagerController extends AdminController{
'data_president'=>$promoteData,
'show_data'=>$show_data
))) {
+
+ resetUserAuth();
+
addOperationLog(array(
"op_type"=>1,
"key"=> M("AuthGroup")->where("id={$gid}")->field("title")->find()['title'],
diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php
index 0e0e997d3..f845ecbdb 100644
--- a/Application/Admin/Controller/PromoteCompanyController.class.php
+++ b/Application/Admin/Controller/PromoteCompanyController.class.php
@@ -1262,6 +1262,7 @@ class PromoteCompanyController extends ThinkController
$dataPresident = array_diff($dataPresident, $subPromoteIds);
}
M('auth_group',"sys_")->where(['title'=>'市场总监'])->save(['data_president'=>implode(',', $dataPresident)]);
+ resetUserAuth();
}
}
}
diff --git a/Application/Base/Service/MarketService.class.php b/Application/Base/Service/MarketService.class.php
index e68505fcd..522064a5f 100644
--- a/Application/Base/Service/MarketService.class.php
+++ b/Application/Base/Service/MarketService.class.php
@@ -47,6 +47,7 @@ class MarketService
$dataPresident = explode(',', $authGroup['data_president']);
if (!in_array($promote['id'], $dataPresident)) {
M('auth_group', 'sys_')->where(['title'=>'市场总监'])->save(['data_president' => $authGroup['data_president'] . ',' . $promote['id']]);
+ resetUserAuth();
}
}
diff --git a/Application/Base/Service/PromoteCompanyService.class.php b/Application/Base/Service/PromoteCompanyService.class.php
index a34dfe286..0cae4434e 100644
--- a/Application/Base/Service/PromoteCompanyService.class.php
+++ b/Application/Base/Service/PromoteCompanyService.class.php
@@ -276,6 +276,7 @@ class PromoteCompanyService
$dataPresident = array_diff($dataPresident, $subPromoteIds);
}
M('auth_group', 'sys_')->where(['title' => '市场总监'])->save(['data_president' => implode(',', $dataPresident)]);
+ resetUserAuth();
}
}
}
diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php
index 39236b921..5c640d99c 100644
--- a/Application/Base/Service/PromoteService.class.php
+++ b/Application/Base/Service/PromoteService.class.php
@@ -1032,6 +1032,7 @@ class PromoteService {
$id = M('promote', 'tab_')->getLastInsID();
$info = M('sys_auth_group')->where(['title'=>'市场总监'])->find();
M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]);
+ resetUserAuth();
}
return $insert;
From ad34536256ab8373c21cea7a0ff378f1f45aedea Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Mon, 21 Sep 2020 18:40:48 +0800
Subject: [PATCH 02/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/Common/extend.php | 11 +
.../Controller/FinanceController.class.php | 309 ++++++------------
.../Admin/View/Finance/valueDetail.html | 288 ++++++----------
3 files changed, 196 insertions(+), 412 deletions(-)
diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php
index b8814f0e9..c80c2022e 100644
--- a/Application/Admin/Common/extend.php
+++ b/Application/Admin/Common/extend.php
@@ -3102,3 +3102,14 @@ function dateFormat($date) {
return date("Y.m.d",strtotime($date));
}
+
+function getOrderHtml($field, $orderField, $orderType)
+{
+ if ($orderField == $field && $orderType == 'asc') {
+ return '▲';
+ } elseif ($orderField == $field && $orderType == 'desc') {
+ return '▼';
+ } else {
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php
index 4ecf1027c..b4578608c 100644
--- a/Application/Admin/Controller/FinanceController.class.php
+++ b/Application/Admin/Controller/FinanceController.class.php
@@ -1446,245 +1446,118 @@ class FinanceController extends ThinkController
$this->display();
}
-
- public function valueDetail($p=1) {
-
+ public function valueDetail($p=1)
+ {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$row=10;
- if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
- $nowTime = date('Y-m-d');
- $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
- $initEndTime = date('Y-m-d', time());
- $sort = $_REQUEST['sort'];
- if (empty($sort)) {
- $sort = 13;
- }
- if(!empty($_REQUEST['user_account'])) {
- $map['account'] = $_REQUEST['user_account'];
- $map0['account'] = $_REQUEST['user_account'];
- $userId = M('user', 'tab_')->where(['account'=>$_REQUEST['user_account']])->getField('id');
-
- $map1['user_id'] = $userId;
- $map2['user_id'] = $userId;
- $map3['user_id'] = $userId;
- $map4['user_id'] = $userId;
+ if(isset($_REQUEST['row'])) {
+ $row = $_REQUEST['row'];
+ } else {
+ $row = 10;
}
- if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
- $map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
-
- } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
- $map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
- } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
- $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
+ $isExport = I('export', 0);
+ $startedAt = I('timestart', '');
+ $endedAt = I('timeend', '');
+ $userAccount = I('user_account', '');
+ $orderField = I('order_field', '');
+ $orderType = I('order_type', '');
- }elseif (empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) {
- $map['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
-
- }
- $order = 'id desc';
- if ($sort == 1) {
- $order = 'spendvalue desc';
- }
- if ($sort == 2) {
- $order = 'deposit desc';
+ $map = [];
+ $lastMap = [];
+ $map['_string'] = $lastMap['_string'] = '1=1';
+ if ($startedAt != '') {
+ $map['_string'] .= ' and create_time >=' . strtotime($startedAt . ' 00:00:00');
}
- if ($sort == 3 || $sort == 5) {
- $order = 'spendvalue desc';
+ if ($endedAt != '') {
+ $map['_string'] .= ' and create_time <=' . strtotime($endedAt . ' 23:59:59');
+ $lastMap['_string'] .= ' and create_time <=' . strtotime($endedAt . ' 23:59:59');
}
- if ($sort == 4) {
- $order = 'spendvalue asc';
+ $userMap = [];
+ if ($userAccount != '') {
+ $userMap['account'] = $userAccount;
}
+ $valueSubSql = M('value_detail_log', 'tab_')->field([
+ 'abs(IFNULL(sum(IF(pay_type=1,value,0)), 0)) amount1',
+ 'IFNULL(sum(IF(pay_type=2,value,0)), 0) amount2',
+ 'IFNULL(sum(IF(pay_type=3,value,0)), 0) amount3',
+ 'user_id'
+ ])
+ ->where($map)
+ ->group('user_id')
+ ->select(false);
+
+ $lastSubSql = M('value_detail_log', 'tab_')->field(['CONVERT(SUBSTRING_INDEX(group_concat(id order by `create_time` desc),",",1), UNSIGNED INTEGER)'])
+ ->where($lastMap)
+ ->group('user_id')
+ ->select(false);
+ $reaminSubSql = M('value_detail_log', 'tab_')->field('user_id, after_value amount')
+ ->where(['_string' => 'id in(' . $lastSubSql . ')'])
+ ->group('user_id')
+ ->select(false);
+
+
+ $this->checkListOrCountAuthRestMap($userMap, []);
- if ($sort == 6) {
- $order = 'deposit desc';
- }
- if ($sort == 7) {
- $order = 'deposit asc';
- }
+ $query = M('user', 'tab_')
+ ->alias('a')
+ ->where($userMap)
+ ->join('left join (' . $valueSubSql . ') b on a.id=b.user_id')
+ ->join('left join (' . $reaminSubSql . ') c on a.id=c.user_id');
+ $countQuery = clone $query;
+ $sumQuery = clone $query;
- if ($sort == 9) {
- $order = 'promoteCoin desc';
- }
- if ($sort == 10) {
- $order = 'promoteCoin asc';
+ $order = 'id desc';
+ if ($orderField != '') {
+ $order = $orderField . ' ' . ($orderType == '' ? 'desc' : $orderType);
}
- if ($sort == 11) {
- $order = 'id asc';
- }
- if ($sort == 12) {
- $order = 'id desc';
- }
+ $columns = ['a.account', 'a.id', 'a.balance', 'b.amount1 spend_value', 'b.amount2 deposit_value', 'b.amount3 promote_value', 'c.amount remain'];
- if ($sort == 16) {
- $order = 'restvalue desc';
- }
- if ($sort == 17) {
- $order = 'restvalue asc';
+ $records = [];
+ if ($isExport == 1) {
+ $records = $query->field($columns)->order($order)->limit(10000)->select();
+ } else {
+ $records = $query->field($columns)->order($order)->page($page, $row)->select();
}
- if ($sort == 19) {
- $order = 'totalvalue desc';
+ foreach ($records as $key => $record) {
+ $records[$key]['spend_value'] = number_format(abs(floatval($record['spend_value'])), 2, '.', '');
+ $records[$key]['deposit_value'] = number_format(abs(floatval($record['deposit_value'])), 2, '.', '');
+ $records[$key]['promote_value'] = number_format(floatval($record['promote_value']), 2, '.', '');
+ $records[$key]['remain'] = number_format(floatval($record['remain']), 2, '.', '');
}
- if ($sort == 20) {
- $order = 'totalvalue asc';
+
+ $count = $countQuery->count();
+ $sumColumns = ['sum(a.balance) balance', 'sum(b.amount1) spend_value', 'sum(b.amount2) deposit_value', 'sum(b.amount3) promote_value', 'sum(c.amount) remain'];
+ $summary = $sumQuery->field($sumColumns)->find();
+
+ if($isExport == 1) {
+ $getData = $_GET;
+ unset($getData['export']);
+ addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$getData),'menu'=>"财务-数据统计-平台币统计-导出"]);
+ data2csv($records, '平台币统计', [
+ 'id' => '账号ID',
+ 'account' => '玩家账号',
+ 'balance' => '当前平台币余额',
+ 'remain' => '平台币余额',
+ 'spend_value' => '平台币直充支出',
+ 'deposit_value' => '平台币直充金额',
+ 'promote_value' => '后台发放平台币',
+ ]);
}
- $this->assign('sorting', $sort);
- $map5['v.pay_type'] = 1;
- $map5['v.create_time'] = $map['create_time'];
- $map5[] = ['u.id = v.user_id'] ;
-
- $map6[] = ['u.id = v.user_id'];
- $map6['v.pay_type'] = 2;
- $map6['v.create_time'] = $map['create_time'];
- $map7[] = ['u.id = v.user_id'];
- $map7['v.pay_type'] = 3;
- $map7['v.create_time'] = $map['create_time'];
-
- $map8[] = ['u.id = v.user_id'];
- $map8['v.create_time'] = $map['create_time'];
-
- $map9[] = ['u.id = v.user_id'];
- $map9['v.pay_type'] = 3;
- if (!empty($map['create_time'][1][1])) {
- $map9['v.create_time'] = ['elt', $map['create_time'][1][1] ];
- }
- if (!empty($map['create_time'][1][0]) && empty($map['create_time'][1][1])) {
- $map9['v.create_time'] = ['egt', $map['create_time'][1][0] ];
+ $page = set_pagination($count, $row);
+ if($page) {
+ $this->assign('_page', $page);
}
-
- $valueQuery5 = M('value_detail_log', 'tab_')->alias('v')->field('IFNULL(sum(abs(v.value)), 0) as spend_value')
- ->where($map5)->buildSql();
- $valueQuery6 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value')
- ->where($map6)->buildSql();
- $valueQuery7 = M('value_detail_log', 'tab_')->alias('v')->field('sum(v.value) as spend_value')
- ->where($map7)->buildSql();
- $valueQuery9 = M('value_detail_log', 'tab_')->alias('v')->field('IFNULL(sum(abs(v.value)), 0) as spend_value')
- ->where($map9)->buildSql();
- $valueQuery8 = M('value_detail_log', 'tab_')->alias('v')->field('after_value')->where($map8)->order('create_time desc')->limit(1)->buildSql();
- $datas = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery8}) - ({$valueQuery9}) > 0, ({$valueQuery8}) - ({$valueQuery9}), 0) as restvalue")->where($map0)->page($page,$row)->order($order)->group('u.id')->select();
- $query = M('user', 'tab_')->alias('u')->field("u.id, u.account, {$valueQuery8} as totalvalue, {$valueQuery5} as spendvalue, {$valueQuery6} as deposit, {$valueQuery7} as promoteCoin , if (({$valueQuery8}) - ({$valueQuery9}) > 0, ({$valueQuery8}) - ({$valueQuery9}), 0) as restvalue")->where($map0)->order($order)->group('u.id')->buildSql();
- $allTotalValue1 = M()->alias('t')->table($query)->sum('t.totalvalue');
- $allRestValue = M()->alias('rest')->table($query)->sum('rest.restvalue');
-
- // var_dump($datas);die();
- // $datas = M('user', 'tab_')
- // ->field('id, account')
- // ->where($map0)
- // ->page($page,$row)
- // ->order('id desc')
- // ->select();
-
- $count = M('user', 'tab_')
- ->field('id, account')
- ->where($map)
- ->count();
- $ids = array_column($datas, 'id');
- if(empty($ids)) {
- $ids = [-100];
- }
- $allDatas = [];
-
- foreach($datas as $key => $data) {
- $id = $data['id'];
- $account = $data['account'];
- $allDatas[$key]['user_id'] = $id;
- $allDatas[$key]['user_account'] = $account;
- $spend = $data['spendvalue'];
- if(empty($spend)) {
- $spend = '0.00';
- }else {
- $spend = number_format(abs($spend),2,'.','');
- }
- $deposit = $data['deposit'];
- if(empty($deposit)) {
- $deposit = '0.00';
- }
- $promoteCoin = $data['promotecoin'];
- if(empty($promoteCoin)) {
- $promoteCoin = '0.00';
- }
- $restValue = $data['restvalue'];
- if(empty($restValue)) {
- $restValue = '0.00';
- }
- $alltotalvalue = $data['totalvalue'];
- if(empty($alltotalvalue)) {
- $alltotalvalue = '0.00';
- }
- // $allDatas[$key]['bind_balance'] = $bind_balance;
- $allDatas[$key]['after_value'] = $alltotalvalue ;
- $allDatas[$key]['rest_value'] = $restValue ;
- $allDatas[$key]['spend_amount'] = $spend;
- $allDatas[$key]['deposit_amount'] = $deposit;
- $allDatas[$key]['coin_amount'] = $promoteCoin;
- }
- $map1['create_time'] = $map['create_time'];
- $map1['pay_type'] = 1;
- $totalSpend = M('value_detail_log', 'tab_')->where($map1)->sum('value');
- $totalSpend = empty($totalSpend) ? '0.00' : $totalSpend;
- $totalSpend = number_format(abs($totalSpend),2,'.','');
-
- $map2['create_time'] = $map['create_time'];
- $map2['pay_type'] = 2;
- $deposit = M('value_detail_log', 'tab_')->where($map2)->sum('value');
- $deposit= empty($deposit) ? '0.00' : number_format($deposit,2,'.','');
-
- $map3['create_time'] = $map['create_time'];
- $map3['pay_type'] = 3;
- $allpromoteCoin = M('value_detail_log', 'tab_')->where($map3)->sum('value');
- $allpromoteCoin = empty($allpromoteCoin) ? '0.00' : number_format($allpromoteCoin,2,'.','');
- $map4['create_time'] = $map['create_time'];
- if($_REQUEST['user_account']) {
- $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->order('create_time desc')->limit(1)->select();
- }else {
- $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->order('create_time desc')->select();
- }
- // $banlaceTotal = '0.00';
- // foreach($banlace as $k222 => $vvv) {
- // $banlaceTotal += $vvv['after_value'];
- // }
- // $banlaceTotal = number_format($banlaceTotal,2,'.','');
- $map['user_id'] = ['in', $ids];
- // $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value, create_time')->where($map)->order('create_time desc')->limit(1)->select();
- // var_dump($newValueByTimeDatas);
- // // var_dump($newValueByTimeDatas);die();
- // foreach ($allDatas as $k => $allData) {
- // $allDatas[$k]['after_value'] = "0.00";
- // foreach ($newValueByTimeDatas as $key1 => $newValueByTimeData ) {
- // if (intval($allData['user_id']) == intval($newValueByTimeData['user_id'])) {
- // $allDatas[$k]['after_value'] = $newValueByTimeData['after_value'];
- // break;
- // }else {
- // $allDatas[$k]['after_value'] = "0.00";
-
- // }
- // }
-
- // }
-
- $this->checkListOrCountAuthRestMap($map,[]);
-
- $page = set_pagination($count,$row);
- if($page) {$this->assign('_page', $page);}
- if(empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) {
- $this->assign('starttime', $initBegTime);
- $this->assign('endtime', $initEndTime);
- }else {
- $this->assign('starttime', $_REQUEST['timestart']);
- $this->assign('endtime', $_REQUEST['timeend']);
- }
- $this->assign('banlaceTotal', $allTotalValue1);
- $this->assign('total', $totalSpend);
- $this->assign('deposit', $deposit);
- $this->assign('promoteCoin', $allpromoteCoin);
- $this->assign('data', $allDatas);
- $this->assign('resttotal', $allRestValue);
-
+ $this->assign('_page', $page);
+ $this->assign('records', $records);
+ $this->assign('summary', $summary);
+ $this->assign('orderField', $orderField);
+ $this->assign('orderType', $orderType);
$this->display();
}
diff --git a/Application/Admin/View/Finance/valueDetail.html b/Application/Admin/View/Finance/valueDetail.html
index bd31226fe..179221f70 100644
--- a/Application/Admin/View/Finance/valueDetail.html
+++ b/Application/Admin/View/Finance/valueDetail.html
@@ -90,35 +90,17 @@