|
|
@ -11,7 +11,6 @@ class FinanceController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
function index($p = 1) {
|
|
|
|
function index($p = 1) {
|
|
|
|
//总流水查询
|
|
|
|
//总流水查询
|
|
|
|
$allField = "";
|
|
|
|
|
|
|
|
$page = intval($p);
|
|
|
|
$page = intval($p);
|
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
|
$row=10;
|
|
|
|
$row=10;
|
|
|
@ -37,23 +36,47 @@ class FinanceController extends ThinkController
|
|
|
|
// ->select();
|
|
|
|
// ->select();
|
|
|
|
if (empty(I('game_id'))) {
|
|
|
|
if (empty(I('game_id'))) {
|
|
|
|
$field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,
|
|
|
|
$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";
|
|
|
|
sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count";
|
|
|
|
$allField = "cash_count+balance_coin_count+inside_cash_count";
|
|
|
|
|
|
|
|
$InsideField = "inside_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 {
|
|
|
|
} else {
|
|
|
|
$field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,
|
|
|
|
$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";
|
|
|
|
sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count) as all_cash_count";
|
|
|
|
$allField = "cash_count+balance_coin_count+bind_coin_count";
|
|
|
|
|
|
|
|
$InsideField = "bind_coin_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";
|
|
|
|
$order = "id DESC";
|
|
|
|
$data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row);
|
|
|
|
$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");
|
|
|
|
$sumCash = D("spend_count")->sumSpendCountField($map,"cash_count");
|
|
|
|
$sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count");
|
|
|
|
$sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count");
|
|
|
|
$sumInside = D("spend_count")->sumSpendCountField($map,$InsideField);
|
|
|
|
$sumInside = array_sum($insideDataSum);
|
|
|
|
$sumAll = D("spend_count")->sumSpendCountField($map,$allField);
|
|
|
|
$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);
|
|
|
|
$count = D("spend_count")->getSpendCountData($map,$field,$group,$order);
|
|
|
|
$count = count($count);
|
|
|
|
$count = count($count);
|
|
|
@ -94,7 +117,20 @@ class FinanceController extends ThinkController
|
|
|
|
// ->page($page,$row)
|
|
|
|
// ->page($page,$row)
|
|
|
|
// ->group("game_id")
|
|
|
|
// ->group("game_id")
|
|
|
|
// ->select();
|
|
|
|
// ->select();
|
|
|
|
|
|
|
|
$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']);
|
|
|
|
|
|
|
|
//内充流水与绑定流水数据
|
|
|
|
|
|
|
|
$insideDataSum = [];
|
|
|
|
|
|
|
|
foreach ($insideData as $key => $value) {
|
|
|
|
|
|
|
|
if (isset($insideDataSum[$value['game_id']])) {
|
|
|
|
|
|
|
|
$insideDataSum[$value['game_id']] = $insideDataSum[$value['game_id']] + $value['count'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$insideDataSum[$value['game_id']] = $value['count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// var_dump($insideData);
|
|
|
|
|
|
|
|
// var_dump($insideDataSum);die();
|
|
|
|
|
|
|
|
|
|
|
|
$field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count,
|
|
|
|
$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(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";
|
|
|
@ -102,6 +138,9 @@ class FinanceController extends ThinkController
|
|
|
|
$group = "game_id";
|
|
|
|
$group = "game_id";
|
|
|
|
$order = "id DESC";
|
|
|
|
$order = "id DESC";
|
|
|
|
$data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row);
|
|
|
|
$data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row);
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
$data[$key]['inside_cash_count'] = $insideDataSum[$value['game_id']];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sumCash = D("spend_count")->sumSpendCountField($map,"cash_count");
|
|
|
|
$sumCash = D("spend_count")->sumSpendCountField($map,"cash_count");
|
|
|
|
$sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count");
|
|
|
|
$sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count");
|
|
|
@ -142,6 +181,7 @@ class FinanceController extends ThinkController
|
|
|
|
$startTime=mktime(0,0,0,$tarry[1],1,$tarry[0]);
|
|
|
|
$startTime=mktime(0,0,0,$tarry[1],1,$tarry[0]);
|
|
|
|
$endTime =mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
|
|
|
|
$endTime =mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_time'] = array('between',array($startTime,$endTime));
|
|
|
|
$map['pay_time'] = array('between',array($startTime,$endTime));
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
if (!empty(I("game_id"))) {
|
|
|
|
if (!empty(I("game_id"))) {
|
|
|
@ -177,6 +217,7 @@ class FinanceController extends ThinkController
|
|
|
|
$this->display();
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//按月份获取会长统计
|
|
|
|
//按月份获取会长统计
|
|
|
|
public function getRootUser()
|
|
|
|
public function getRootUser()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -250,5 +291,102 @@ class FinanceController extends ThinkController
|
|
|
|
# code...
|
|
|
|
# code...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function presidentFinance($p = 1) {
|
|
|
|
|
|
|
|
$page = intval($p);
|
|
|
|
|
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
|
|
|
|
|
$row=10;
|
|
|
|
|
|
|
|
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map1['_string'] = '';
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
if (!empty(I('promote_account'))) {
|
|
|
|
|
|
|
|
$map['promote_account'] = I('promote_account');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty(I("count_date"))) {
|
|
|
|
|
|
|
|
$map['count_date'] = I('count_date');
|
|
|
|
|
|
|
|
$map1['_string'] = "count_date = {$map['count_date']} and ";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['parent_id'] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$field = "parent_id,root_id,promote_id,promote_account,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";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$group = "promote_id";
|
|
|
|
|
|
|
|
$order = "id DESC";
|
|
|
|
|
|
|
|
// $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row);
|
|
|
|
|
|
|
|
$data =
|
|
|
|
|
|
|
|
$data = M("spend_count","tab_")
|
|
|
|
|
|
|
|
->field($field)
|
|
|
|
|
|
|
|
->where($map)
|
|
|
|
|
|
|
|
->page($page,$row)
|
|
|
|
|
|
|
|
->group($group)->order($order)->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['inside_cash_count'] = ['neq',0];
|
|
|
|
|
|
|
|
$insideData = D("spend_count")->getSpendCountData($map,"promote_id,inside_cash_count as count","promote_id,count_date");
|
|
|
|
|
|
|
|
unset($map['inside_cash_count']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$insideDataSum = [];
|
|
|
|
|
|
|
|
foreach ($insideData as $key => $value) {
|
|
|
|
|
|
|
|
if (isset($insideDataSum[$value['promote_id']])) {
|
|
|
|
|
|
|
|
$insideDataSum[$value['promote_id']] = $insideDataSum[$value['promote_id']] + $value['count'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$insideDataSum[$value['promote_id']] = $value['count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// echo D("spend_count")->_sql();
|
|
|
|
|
|
|
|
// dump($insideDataSum);die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$promote_array = [];
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
if ($value['promote_id']!=0) {
|
|
|
|
|
|
|
|
array_push($promote_array,$value['promote_id']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$promote_id = implode(',',$promote_array);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($promote_id) {
|
|
|
|
|
|
|
|
$map1['_string'] = "(parent_id IN({$promote_id}) or root_id IN({$promote_id}))";
|
|
|
|
|
|
|
|
$sunData = D("spend_count")->getSpendCountData($map1,$field,$group,$order);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map1['inside_cash_count'] = ['neq',0];
|
|
|
|
|
|
|
|
$sunInsideData = D("spend_count")->getSpendCountData($map1,"promote_id,inside_cash_count as count","promote_id,count_date");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($sunInsideData as $key => $value) {
|
|
|
|
|
|
|
|
if (in_array($value['parent_id'],$promote_array)) {
|
|
|
|
|
|
|
|
$insideDataSum[$value['parent_id']] = $insideDataSum[$value['parent_id']] + $value['count'];
|
|
|
|
|
|
|
|
}else if (in_array($value['root_id'],$promote_array)) {
|
|
|
|
|
|
|
|
$insideDataSum[$value['root_id']] = $insideDataSum[$value['root_id']] + $value['count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$sunData = [];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dump($promote_id);die();
|
|
|
|
|
|
|
|
$handleData = [];
|
|
|
|
|
|
|
|
foreach ($sunData as $key =>$value) {
|
|
|
|
|
|
|
|
if (in_array($value['parent_id'],$promote_array)) {
|
|
|
|
|
|
|
|
$handleData[$value['parent_id']]['cash_count'] = $handleData[$value['parent_id']]['cash_count']+$value['cash_count'];
|
|
|
|
|
|
|
|
$handleData[$value['parent_id']]['balance_coin_count'] = $handleData[$value['parent_id']]['balance_coin_count']+$value['balance_coin_count'];
|
|
|
|
|
|
|
|
$handleData[$value['parent_id']]['inside_cash_count'] = $handleData[$value['parent_id']]['inside_cash_count']+$value['inside_cash_count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_array($value['root_id'],$promote_array)) {
|
|
|
|
|
|
|
|
$handleData[$value['root_id']]['cash_count'] = $handleData[$value['root_id']]['cash_count'] + $value['cash_count'];
|
|
|
|
|
|
|
|
$handleData[$value['root_id']]['balance_coin_count'] = $handleData[$value['root_id']]['balance_coin_count'] + $value['balance_coin_count'];
|
|
|
|
|
|
|
|
$handleData[$value['root_id']]['inside_cash_count'] = $handleData[$value['root_id']]['inside_cash_count']+ $value['inside_cash_count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data as $key => $value) {
|
|
|
|
|
|
|
|
$data[$key]['cash_count'] = $value['cash_count'] + $handleData[$value['promote_id']]['cash_count'];
|
|
|
|
|
|
|
|
$data[$key]['balance_coin_count'] = $value['balance_coin_count'] + $handleData[$value['promote_id']]['balance_coin_count'];
|
|
|
|
|
|
|
|
$data[$key]['inside_cash_count'] = $value['inside_cash_count'] + $handleData[$value['promote_id']]['inside_cash_count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assign('data',$data);
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|