@ -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');