diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 864f74521..1ab0c1f48 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1501,8 +1501,6 @@ function getPartner() { function getGameList($partner_id) { if ($partner_id) { $map['partner_id'] = $partner_id; - } else { - return []; } $data = M('game','tab_')->field("id,game_name")->where($map)->select(); diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 40a5e149b..23c9fa173 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -5305,7 +5305,7 @@ if ($key == 'model'){ array('cash_count','游戏现金流水'), array('balance_coin_count','平台币流水'), array('inside_cash_count','内冲流水'), - array('all_cash_count','总流水'), + array('all_count','总流水'), ); $map = []; @@ -5313,38 +5313,50 @@ if ($key == 'model'){ $map['count_date']=I('count_date'); } - if (!empty(I('game_id'))) { - $map['game_id']=I('game_id'); - } - if (!empty(I('collaborate_id'))) { - $map['collaborate_id']=I('collaborate_id'); - } - - if (empty(I('game_id'))) { - $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count+inside_cash_count) as all_cash_count"; - $allField = "cash_count+balance_coin_count+inside_cash_count"; - $InsideField = "inside_cash_count"; - } else { - $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count"; - $allField = "cash_count+balance_coin_count+bind_coin_count"; - $InsideField = "bind_coin_count"; - } - $group = "count_date"; +// if (!empty(I('game_id'))) { +// $map['game_id']=I('game_id'); +// } +// if (!empty(I('collaborate_id'))) { +// $map['collaborate_id']=I('collaborate_id'); +// } +// +// if (empty(I('game_id'))) { +// $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, +// sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count+inside_cash_count) as all_cash_count"; +// $allField = "cash_count+balance_coin_count+inside_cash_count"; +// $InsideField = "inside_cash_count"; +// } else { +// $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, +// sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count"; +// $allField = "cash_count+balance_coin_count+bind_coin_count"; +// $InsideField = "bind_coin_count"; +// } +// $group = "count_date"; +// $order = "id DESC"; +// $xlsData = D("spend_count")->getSpendCountData($map,$field,$group,$order); +// +// $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); +// $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); +// $sumInside = D("spend_count")->sumSpendCountField($map,$InsideField); +// $sumAll = D("spend_count")->sumSpendCountField($map,$allField); $order = "id DESC"; - $xlsData = D("spend_count")->getSpendCountData($map,$field,$group,$order); + $xlsData = M('spend_month_count','tab_') + ->field("cash_count,balance_coin_count,inside_cash_count,all_count,count_date") + ->where($map) + ->order($order) + ->select(); - $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); - $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); - $sumInside = D("spend_count")->sumSpendCountField($map,$InsideField); - $sumAll = D("spend_count")->sumSpendCountField($map,$allField); + $sumData = M('spend_month_count','tab_') + ->field("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,count_date") + ->where($map) + ->order($order) + ->find(); $sumData = [['count_date'=>'总计', - 'cash_count'=>$sumCash, - 'balance_coin_count'=>$sumBalance, - 'inside_cash_count'=>$sumInside, - 'all_cash_count'=>$sumAll]]; + 'cash_count'=>$sumData['cash_count'], + 'balance_coin_count'=>$sumData['balance_coin_count'], + 'inside_cash_count'=>$sumData['inside_cash_count'], + 'all_count'=>$sumData['all_count']]]; $xlsData = array_merge($xlsData,$sumData); $this->exportExcel($xlsName, $xlsCell, $xlsData); @@ -5384,6 +5396,10 @@ if ($key == 'model'){ $map['game_id'] = I("game_id"); } + if (!empty(I('partner_id'))) { + $map['partner_id']=I('collaborate_id'); + } + if (I('sign') == 2&&empty(I('root_id'))) { $map['_string'] = "parent_id >0 or root_id>0"; @@ -5405,9 +5421,9 @@ if ($key == 'model'){ } - $map['bind_coin_count'] = ['neq',0]; - $insideData = D("spend_count")->getSpendCountData($map,"game_id,bind_coin_count as count","promote_id,count_date,game_id"); - unset($map['bind_coin_count']); + $map['inside_cash_count'] = ['neq',0]; + $insideData = D("spend_count")->getSpendCountData($map,"game_id,inside_cash_count as count","promote_id,count_date"); + unset($map['inside_cash_count']); //内充流水与绑定流水数据 $insideDataSum = []; foreach ($insideData as $key => $value) { @@ -5420,7 +5436,7 @@ if ($key == 'model'){ $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count,game_name,partner_name"; + sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count,game_id,game_name,partner_name"; $group = "game_id"; $order = "id DESC"; @@ -5432,8 +5448,8 @@ if ($key == 'model'){ $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); - $sumInside = D("spend_count")->sumSpendCountField($map,"bind_coin_count"); - $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count+bind_coin_count"); + $sumInside = number_format(array_sum($insideDataSum),2,'.',''); + $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count") + array_sum($insideDataSum); $sumData = [['game_name'=>'总计', 'cash_count'=>$sumCash, @@ -5455,6 +5471,7 @@ if ($key == 'model'){ array('pay_order_number','支付订单号'), array('pay_time','充值时间'), array('user_account','玩家账号'), + array('user_nickname','玩家昵称'), array('game_name','游戏名称'), array('promote_account','所属推广员'), array('spend_ip','充值ip'), @@ -5503,13 +5520,13 @@ if ($key == 'model'){ $map['game_id'] = I("game_id"); } if (!empty(I('user_account'))) { - $map['user_account'] = I("user_account"); + $map['user_account'] = array('like','%'.I("user_account").'%'); } if (!empty(I('user_nickname'))) { - $map['user_nickname'] = I("user_nickname"); + $map['user_nickname'] = array('like',I("user_nickname").'%'); } - $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way"; + $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,user_nickname,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way"; $group = ""; $order = "pay_time DESC"; $xlsData = D('spend')->getSpendData($map,$field,$group,$order); diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index d8a12ba9a..8464863f1 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -16,17 +16,19 @@ class FinanceController extends ThinkController $row=10; if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} +// var_dump($row);die(); + $map = []; if(!empty(I('count_date'))){ $map['count_date']=I('count_date'); } - if (!empty(I('game_id'))) { - $map['game_id']=I('game_id'); - } - if (!empty(I('partner_id'))) { - $map['partner_id']=I('collaborate_id'); - } +// if (!empty(I('game_id'))) { +// $map['game_id']=I('game_id'); +// } +// if (!empty(I('partner_id'))) { +// $map['partner_id']=I('collaborate_id'); +// } // $data = M("spend_count","tab_") // ->field("count_date,cash_count,balance_coin_count,inside_cash_count,all_cash_count") @@ -34,61 +36,89 @@ class FinanceController extends ThinkController // ->page($page,$row) // ->group("count_date") // ->select(); - if (empty(I('game_id'))) { - $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count"; - $InsideField = "inside_cash_count"; - $map['inside_cash_count'] = ['neq',0]; - $insideData = D("spend_count")->getSpendCountData($map,"count_date,inside_cash_count as count","promote_id,count_date"); - unset($map['inside_cash_count']); - } else { - $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count"; - $InsideField = "bind_coin_count"; - $map['bind_coin_count'] = ['neq',0]; - $insideData = D("spend_count")->getSpendCountData($map,"count_date,bind_coin_count as count","promote_id,count_date,game_id"); - unset($map['bind_coin_count']); - } - //内充流水与绑定流水数据 - $insideDataSum = []; - foreach ($insideData as $key => $value) { - if (isset($insideDataSum[$value['count_date']])) { - $insideDataSum[$value['count_date']] = $insideDataSum[$value['count_date']] + $value['count']; - } else { - $insideDataSum[$value['count_date']] = $value['count']; - } - } +// if (empty(I('game_id'))) { +// $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, +// sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count"; +// $InsideField = "inside_cash_count"; +// $map['inside_cash_count'] = ['neq',0]; +// $insideData = D("spend_count")->getSpendCountData($map,"count_date,inside_cash_count as count","promote_id,count_date"); +// unset($map['inside_cash_count']); +// } else { +// $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, +// sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count"; +// $InsideField = "bind_coin_count"; +// $map['bind_coin_count'] = ['neq',0]; +// $insideData = D("spend_count")->getSpendCountData($map,"count_date,bind_coin_count as count","promote_id,count_date,game_id"); +// unset($map['bind_coin_count']); +// } +// //内充流水与绑定流水数据 +// $insideDataSum = []; +// foreach ($insideData as $key => $value) { +// if (isset($insideDataSum[$value['count_date']])) { +// $insideDataSum[$value['count_date']] = $insideDataSum[$value['count_date']] + $value['count']; +// } else { +// $insideDataSum[$value['count_date']] = $value['count']; +// } +// } // var_dump($insideDataSum); // var_dump(array_sum($insideDataSum)); // echo D("spend_count")->_sql(); // var_dump($insideData);die(); - $group = "count_date"; +// $group = "count_date"; +// $order = "id DESC"; +// $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row); +// +// foreach ($data as $key => $value) { +// $data[$key]['all_cash_count'] = $value['all_cash_count'] + $insideDataSum[$value['count_date']]; +// $data[$key]['inside_cash_count'] = $insideDataSum[$value['count_date']]; +// } +// +// $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); +// $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); +// $sumInside = array_sum($insideDataSum); +// $allField = "cash_count+balance_coin_count"; +// $sumAll = D("spend_count")->sumSpendCountField($map,$allField)+array_sum($insideDataSum); +// +// $count = D("spend_count")->getSpendCountData($map,$field,$group,''); + + $order = "id DESC"; - $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row); + $data = M('spend_month_count','tab_') + ->field("cash_count,balance_coin_count,inside_cash_count,all_count,count_date") + ->where($map) + ->page($page,$row) + ->order($order) + ->select(); - foreach ($data as $key => $value) { - $data[$key]['all_cash_count'] = $value['all_cash_count'] + $insideDataSum[$value['count_date']]; - $data[$key]['inside_cash_count'] = $insideDataSum[$value['count_date']]; - } + $count = M('spend_month_count','tab_') + ->field("cash_count,balance_coin_count,inside_cash_count,all_count,count_date") + ->where($map) + ->order($order) + ->select(); - $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); - $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); - $sumInside = array_sum($insideDataSum); - $allField = "cash_count+balance_coin_count"; - $sumAll = D("spend_count")->sumSpendCountField($map,$allField)+array_sum($insideDataSum); + $sumData = M('spend_month_count','tab_') + ->field("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,count_date") + ->where($map) + ->order($order) + ->find(); - $count = D("spend_count")->getSpendCountData($map,$field,$group,$order); + + +// echo D("spend_count")->_sql();die(); $count = count($count); $page = set_pagination($count,$row); +// var_dump($page);die(); if($page) {$this->assign('_page', $page);} $this->meta_title = '月结统计'; - $this->assign('sumCash',$sumCash); - $this->assign('sumBalance',$sumBalance); - $this->assign('sumInside',$sumInside); - $this->assign('sumAll',$sumAll); +// $this->assign('sumCash',$sumCash); +// $this->assign('sumBalance',$sumBalance); +// $this->assign('sumInside',$sumInside); +// $this->assign('sumAll',$sumAll); + + $this->assign('sumData',$sumData); $this->assign('data',$data); @@ -106,6 +136,10 @@ class FinanceController extends ThinkController $map['count_date']=I('count_date'); } + if (!empty(I('root_name'))) { + $map['promote_account'] = array('like','%'.I("root_name").'%'); + } + if (!empty(I("game_id"))) { $map['game_id'] = I("game_id"); } @@ -119,6 +153,12 @@ class FinanceController extends ThinkController } } +// if (!empty(I('partner_id'))) { +// $map['partner_id']=I('collaborate_id'); +// } + + + if (I('sign') == 2&&empty(I('root_id'))) { $map['_string'] = "parent_id >0 or root_id>0"; @@ -139,9 +179,9 @@ class FinanceController extends ThinkController $map['_string'] = "promote_id = {$promote_id}"; } - $map['bind_coin_count'] = ['neq',0]; - $insideData = D("spend_count")->getSpendCountData($map,"game_id,bind_coin_count as count","promote_id,count_date,game_id"); - unset($map['bind_coin_count']); + $map['inside_cash_count'] = ['neq',0]; + $insideData = D("spend_count")->getSpendCountData($map,"game_id,inside_cash_count as count","promote_id,count_date"); + unset($map['inside_cash_count']); //内充流水与绑定流水数据 $insideDataSum = []; foreach ($insideData as $key => $value) { @@ -151,16 +191,14 @@ class FinanceController extends ThinkController $insideDataSum[$value['game_id']] = $value['count']; } } +// var_dump($insideDataSum);die(); $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, - sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count,game_name,game_id,partner_name"; + sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count,game_name,game_id,partner_name"; $group = "game_id"; $order = "id DESC"; $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row); -// echo D("spend_count")->_sql();die(); - -// echo D("spend_count")->_sql();die(); foreach ($data as $key => $value) { $data[$key]['inside_cash_count'] = number_format($insideDataSum[$value['game_id']],2,'.',''); @@ -168,8 +206,8 @@ class FinanceController extends ThinkController $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); - $sumInside = D("spend_count")->sumSpendCountField($map,"bind_coin_count"); - $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count+bind_coin_count"); + $sumInside = number_format(array_sum($insideDataSum),2,'.',''); + $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count") + array_sum($insideDataSum); $count = D("spend_count")->getSpendCountData($map,$field,$group,$order); @@ -179,6 +217,7 @@ class FinanceController extends ThinkController $this->meta_title = '每月情况查看详情'; + $this->assign('from',I('from')); $this->assign('sumCash',$sumCash); $this->assign('sumBalance',$sumBalance); $this->assign('sumInside',$sumInside); @@ -242,7 +281,7 @@ class FinanceController extends ThinkController $map['user_nickname'] = array('like',I("user_nickname").'%'); } // var_dump($map);die(); - $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way"; + $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,user_nickname,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way"; $group = ""; $order = "pay_time DESC"; $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); @@ -481,10 +520,7 @@ class FinanceController extends ThinkController if (I('partner_id')) { $map['partner_id'] = I('partner_id'); - } else { - $this->ajaxReturn([],'json'); } - $data = M('game','tab_')->field("id,game_name")->where($map)->select(); $this->ajaxReturn($data,'json'); diff --git a/Application/Admin/View/Finance/gameFinance.html b/Application/Admin/View/Finance/gameFinance.html index 4d9385fb0..2d2962da6 100644 --- a/Application/Admin/View/Finance/gameFinance.html +++ b/Application/Admin/View/Finance/gameFinance.html @@ -39,12 +39,37 @@