diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php
index a40c1dcd9..b4f362db4 100644
--- a/Application/Admin/Controller/ExportController.class.php
+++ b/Application/Admin/Controller/ExportController.class.php
@@ -5392,10 +5392,14 @@ if ($key == 'model'){
if ($root_id == '0') {
$map['_string'] = "promote_id = {$root_id}";
} else if($root_id){
- $map['_string'] = "promote_id = {$root_id} or parent_id = {$root_id} or root_id = {$root_id}";
+ $map['_string'] = "promote_id = {$root_id} or chain like '%/{$root_id}/%'";
}
}
+ if (!empty(I('root_name'))) {
+ $map['promote_account'] = array('like','%'.I("root_name").'%');
+ }
+
if (!empty(I("game_id"))) {
$map['game_id'] = I("game_id");
}
@@ -5416,7 +5420,7 @@ if ($key == 'model'){
if(!empty(I('parent_id'))) {
$parent_id = I('parent_id');
- $map['_string'] = "promote_id = {$parent_id} or parent_id = {$parent_id}";
+ $map['_string'] = "promote_id = {$parent_id} or chain like '%/{$parent_id}/%'";
}
if (!empty(I('promote_id'))) {
@@ -5677,8 +5681,8 @@ if ($key == 'model'){
$map['promote_account']=['like','%'.I("root_name").'%'];
}
- $map['parent_id'] = 0;
- $map['root_id'] = 0;
+// $map['chain'] = "/";
+ $map['level'] = ['elt',1];
$xlsData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
@@ -5704,22 +5708,100 @@ if ($key == 'model'){
}
- function exportGetParentUser() {
+ public function exportMiniterUser() {
- //获取所有数据
if (!empty(I("count_date")) ) {
$month = I("count_date");
$map['count_date'] =$month;
+
}
$parentData = [];
if (!empty(I("root_id"))) {
$root_id = I("root_id");
+ $parentData = $this->getParentSpendData($root_id,$month,2);
+ $map['chain'] =['like','%'.$root_id.'%'];
+ $map['level'] = 2;
+ } else if(!empty(I("sign"))){
+ $map['parent_id'] = ['neq',0];
+ $map['root_id'] = ['eq',0];
+
+ } else {
+ if (I("root_id") == 0) {
+ $root_id = I("root_id");
+ $map['promote_id'] = $root_id;
+ }
+ }
+
+ if (!empty(I("root_name"))) {
+ $rootname = I("root_name");
+ $map['promote_account'] =['like','%'.$rootname.'%'];
+ }
+
+ $xlsName = '组长月结统计';
+
+ $xlsCell = array(
+ array('promote_account','会长渠道'),
+ array('cash_count','游戏现金流水'),
+ array('balance_coin_count','平台币支出'),
+ array('inside_cash_count','公会内充发放'),
+ array('bind_coin_count','公会内充支出'),
+ array('all_count','总流水'),
+ );
+
+
+ $xlsData = M('spend_user_count','tab_')
+ ->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
+ ->where($map)
+ ->group('promote_id')
+ ->select();
+ if (empty(I("root_name"))) {
+ $xlsData = array_merge($parentData,$xlsData);
+ }
+
+ $sumData = M('spend_user_count','tab_')
+ ->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
+ ->where($map)
+ ->find();
+ if (empty(I("root_name"))) {
+ $sumData['cash_count'] = number_format($sumData['cash_count'] + $parentData[0]['cash_count'], 2, '.', '');
+ $sumData['balance_coin_count'] = number_format($sumData['balance_coin_count'] + $parentData[0]['balance_coin_count'], 2, '.', '');
+ $sumData['inside_cash_count'] = number_format($sumData['inside_cash_count'] + $parentData[0]['inside_cash_count'], 2, '.', '');
+ $sumData['all_count'] = number_format($sumData['all_count'] + $parentData[0]['all_count'], 2, '.', '');
+ $sumData['bind_coin_count'] = number_format($sumData['bind_coin_count'] + $parentData[0]['bind_coin_count'], 2, '.', '');
+ }
- $parentData = $this->getParentSpendData($root_id,$month);
- $map['parent_id'] =$root_id;
+ $sumData = [['promote_account'=>'总计',
+ 'cash_count'=>$sumData['cash_count'],
+ 'balance_coin_count'=>$sumData['balance_coin_count'],
+ 'inside_cash_count'=>$sumData['inside_cash_count'],
+ 'bind_coin_count'=>$sumData['bind_coin_count'],
+ 'all_count'=>$sumData['all_count'],
+ ]];
+ $xlsData = array_merge($xlsData,$sumData);
+
+ $this->exportExcel($xlsName, $xlsCell, $xlsData);
+ }
+
+ function exportGetParentUser() {
+
+ //获取所有数据
+ if (!empty(I("count_date")) ) {
+ $month = I("count_date");
+ $map['count_date'] =$month;
+ }
+
+ $parentData = [];
+
+ if (!empty(I("parent_id"))) {
+ $root_id = I("parent_id");
+
+ $parentData = $this->getParentSpendData($root_id,$month,3);
+
+ $map['chain'] =['like','%'.$root_id.'%'];
+ $map['level'] = 3;
} else if(!empty(I("sign"))){
$map['parent_id'] = ['neq',0];
@@ -5796,9 +5878,10 @@ if ($key == 'model'){
$parentData = [];
if (!empty(I("parent_id"))) {
$parent_id = I("parent_id");
- $parentData = $this->getParentSpendData($parent_id,$month);
+ $parentData = $this->getParentSpendData($parent_id,$month,4);
- $map['parent_id'] =$parent_id;
+ $map['chain'] =['like','%'.$parent_id.'%'];
+ $map['level'] = 4;
}
if (!empty(I('sign'))) {
@@ -5853,7 +5936,7 @@ if ($key == 'model'){
}
- function getParentSpendData($root_id,$date) {
+ function getParentSpendData($root_id,$date,$level=2) {
$data = [];
if (!$root_id) {
@@ -5870,13 +5953,16 @@ if ($key == 'model'){
$data = M('spend_user_count','tab_')
->field('promote_id,promote_account, sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,sum(inside_cash_count) as inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)->select();
-
- $map1['parent_id'] = $data[0]['promote_id'];
+// dump($data);
+ $map1['chain'] = ['like','%/'.$data[0]['promote_id'].'/%'];
$map1['count_date'] = $date;
+ $map1['level'] = $level;
$sunData = M('spend_user_count','tab_')
->field('promote_id,promote_account, sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,sum(inside_cash_count) as inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map1)->find();
-
+// echo M('spend_user_count','tab_')->_sql();
+// dump($sunData);
+//die();
$data[0]['cash_count'] = number_format($data[0]['cash_count']-$sunData['cash_count'],2,'.','');
$data[0]['balance_coin_count'] = number_format($data[0]['balance_coin_count']-$sunData['balance_coin_count'],2,'.','');
$data[0]['inside_cash_count'] = number_format($data[0]['inside_cash_count']-$sunData['inside_cash_count'],2,'.','');
diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php
index 82e92ea12..2706d8429 100644
--- a/Application/Admin/Controller/FinanceController.class.php
+++ b/Application/Admin/Controller/FinanceController.class.php
@@ -149,7 +149,8 @@ class FinanceController extends ThinkController
if ($root_id == '0') {
$map['_string'] = "promote_id = {$root_id}";
} else if($root_id){
- $map['_string'] = "promote_id = {$root_id} or parent_id = {$root_id} or root_id = {$root_id}";
+ $map['_string'] = "promote_id = {$root_id} or chain like '%/{$root_id}/%'";
+// $map['_string'] = "promote_id = {$root_id} or parent_id = {$root_id} or root_id = {$root_id}";
}
}
@@ -171,7 +172,7 @@ class FinanceController extends ThinkController
if(!empty(I('parent_id'))) {
$parent_id = I('parent_id');
- $map['_string'] = "promote_id = {$parent_id} or parent_id = {$parent_id}";
+ $map['_string'] = "promote_id = {$parent_id} or chain like '%/{$parent_id}/%'";
}
if (!empty(I('promote_id'))) {
@@ -333,8 +334,8 @@ class FinanceController extends ThinkController
$map['promote_account']=['like','%'.I("root_name").'%'];
}
- $map['parent_id'] = 0;
- $map['root_id'] = 0;
+// $map['chain'] = "/";
+ $map['level'] = ['elt',1];
$subQueryAll = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
@@ -362,9 +363,8 @@ class FinanceController extends ThinkController
$this->assign('data',$subQueryAll);
$this->display();
}
- public function getParentUser($p = 1)
- {
+ public function getMiniterUser($p = 1) {
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$row=10;
@@ -381,10 +381,10 @@ class FinanceController extends ThinkController
if (!empty(I("root_id"))) {
$root_id = I("root_id");
if ($page == 1) {
- $parentData = $this->getParentSpendData($root_id,$month);
+ $parentData = $this->getParentSpendData($root_id,$month,2);
}
- $map['parent_id'] =$root_id;
-
+ $map['chain'] =['like','%'.$root_id.'%'];
+ $map['level'] = 2;
} else if(!empty(I("sign"))){
$map['parent_id'] = ['neq',0];
$map['root_id'] = ['eq',0];
@@ -402,6 +402,85 @@ class FinanceController extends ThinkController
}
+ $subQueryAll = M('spend_user_count','tab_')
+ ->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
+ ->where($map)
+ ->group('promote_id')
+ ->page($page,$row)
+ ->select();
+ if (empty(I("root_name"))) {
+ $subQueryAll = array_merge($parentData,$subQueryAll);
+ }
+
+ $sumData = M('spend_user_count','tab_')
+ ->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
+ ->where($map)
+ ->find();
+ if (empty(I("root_name"))) {
+ $sumData['cash_count'] = number_format($sumData['cash_count'] + $parentData[0]['cash_count'], 2, '.', '');
+ $sumData['balance_coin_count'] = number_format($sumData['balance_coin_count'] + $parentData[0]['balance_coin_count'], 2, '.', '');
+ $sumData['inside_cash_count'] = number_format($sumData['inside_cash_count'] + $parentData[0]['inside_cash_count'], 2, '.', '');
+ $sumData['all_count'] = number_format($sumData['all_count'] + $parentData[0]['all_count'], 2, '.', '');
+ $sumData['bind_coin_count'] = number_format($sumData['bind_coin_count'] + $parentData[0]['bind_coin_count'], 2, '.', '');
+ }
+
+ $count = M('spend_user_count','tab_')
+ ->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
+ ->where($map)
+ ->group('promote_id')
+ ->select();
+
+ $count = count($count);
+ $page = set_pagination($count,$row);
+ if($page) {$this->assign('_page', $page);}
+ $this->meta_title = '组长流水';
+
+ $this->assign('sumData',$sumData);
+ $this->assign('data',$subQueryAll);
+ $this->display();
+ }
+
+ public function getParentUser($p = 1)
+ {
+
+ $page = intval($p);
+ $page = $page ? $page : 1; //默认显示第一页数据
+ $row=10;
+ if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
+
+ if (!empty(I("count_date")) ) {
+ $month = I("count_date");
+ $map['count_date'] =$month;
+
+ }
+
+ $parentData = [];
+
+ if (!empty(I("parent_id"))) {
+ $root_id = I("parent_id");
+ if ($page == 1) {
+ $parentData = $this->getParentSpendData($root_id,$month,3);
+ }
+ $map['chain'] =['like','%'.$root_id.'%'];
+ $map['level'] = 3;
+
+ } else if(!empty(I("sign"))){
+ $map['parent_id'] = ['neq',0];
+ $map['root_id'] = ['eq',0];
+
+ } else {
+ if (I("parent_id") == 0) {
+ $root_id = I("parent_id");
+ $map['promote_id'] = $root_id;
+ }
+ }
+
+ if (!empty(I("root_name"))) {
+ $rootname = I("root_name");
+ $map['promote_account'] =['like','%'.$rootname.'%'];
+ }
+
+
$subQueryAll = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
@@ -457,10 +536,11 @@ class FinanceController extends ThinkController
$parent_id = I("parent_id");
if ($page == 1) {
- $parentData = $this->getParentSpendData($parent_id,$month);
+ $parentData = $this->getParentSpendData($parent_id,$month,4);
}
- $map['parent_id'] =$parent_id;
+ $map['chain'] =['like','%'.$parent_id.'%'];
+ $map['level'] = 4;
}
if (!empty(I('sign'))) {
@@ -539,7 +619,7 @@ class FinanceController extends ThinkController
$this->ajaxReturn($data,'json');
}
- function getParentSpendData($root_id,$date) {
+ function getParentSpendData($root_id,$date,$level=2) {
$data = [];
if (!$root_id) {
@@ -556,13 +636,16 @@ class FinanceController extends ThinkController
$data = M('spend_user_count','tab_')
->field('promote_id,promote_account, sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,sum(inside_cash_count) as inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)->select();
-
- $map1['parent_id'] = $data[0]['promote_id'];
+// dump($data);
+ $map1['chain'] = ['like','%/'.$data[0]['promote_id'].'/%'];
$map1['count_date'] = $date;
+ $map1['level'] = $level;
$sunData = M('spend_user_count','tab_')
->field('promote_id,promote_account, sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,sum(inside_cash_count) as inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map1)->find();
-
+// echo M('spend_user_count','tab_')->_sql();
+// dump($sunData);
+//die();
$data[0]['cash_count'] = number_format($data[0]['cash_count']-$sunData['cash_count'],2,'.','');
$data[0]['balance_coin_count'] = number_format($data[0]['balance_coin_count']-$sunData['balance_coin_count'],2,'.','');
$data[0]['inside_cash_count'] = number_format($data[0]['inside_cash_count']-$sunData['inside_cash_count'],2,'.','');
diff --git a/Application/Admin/View/Finance/getMiniterUser.html b/Application/Admin/View/Finance/getMiniterUser.html
new file mode 100644
index 000000000..c97fbc25f
--- /dev/null
+++ b/Application/Admin/View/Finance/getMiniterUser.html
@@ -0,0 +1,286 @@
+会长->部长月结统计
+
+
+
+
+
+
+
+
+
+
+
+ 部长渠道
+
+
+
+
+
+
+
+
+
+
+
+ 操作
+
+
+
+ aOh! 暂时还没有内容!
+
+ {$data.promote_account}
+ {$data.cash_count}
+ {$data.balance_coin_count}
+ {$data.inside_cash_count}
+ {$data.bind_coin_count}
+ {$data.all_count}
+
+
+
+
+ 总计
+ {$sumData.cash_count}
+ {$sumData.balance_coin_count}
+ {$sumData.inside_cash_count}
+ {$sumData.bind_coin_count}
+ {$sumData.all_count}
+
+ 游戏查看
+
+
+