value_detail

master
sunke 5 years ago
parent 706623235d
commit 35f5cc03bb

@ -738,7 +738,7 @@ class FinanceController extends ThinkController
$endTime = time(); $endTime = time();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$data[$key]['all_cash_count'] = $value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count']; $data[$key]['all_cash_count'] = number_format($value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'],2,'.','');
} }
$count = D("spend")->gameStatisticsCount($map);//列表总数 $count = D("spend")->gameStatisticsCount($map);//列表总数
@ -1173,104 +1173,123 @@ class FinanceController extends ThinkController
$this->display(); $this->display();
} }
public function valueDetail($p = 1) {
public function valueDetail($p=1) {
$page = intval($p); $page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据 $page = $page ? $page : 1; //默认显示第一页数据
$row=10; $row=10;
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
$map = [];
$mapBanlance = [];
$mapSpend['pay_status'] = 1;
$mapSpend['pay_way'] = 0;
$mapDeposit['pay_status'] = 1;
$mapPromoteCoin['type'] = 2;
$mapPromoteCoin['sub_type'] = 4;
$nowTime = date('Y-m-d'); $nowTime = date('Y-m-d');
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initEndTime = date('Y-m-d', time()); $initEndTime = date('Y-m-d', time());
if(!empty(I('user_account'))){ if(!empty($_REQUEST['user_account'])) {
$userInfo = M('user', 'tab_')->where(['account'=>I('user_account')])->getField('id'); $map['account'] = $_REQUEST['user_account'];
$map['user_account']=I('user_account'); $map0['account'] = $_REQUEST['user_account'];
$mapBanlance['user_account'] = I('user_account'); $userId = M('user', 'tab_')->where(['account'=>$_REQUEST['user_account']])->getField('id');
$mapSpend['user_account'] = I('user_account');
$mapDeposit['user_account'] = I('user_account'); $map1['user_id'] = $userId;
$mapPromoteCoin['target_id'] = $userInfo; $map2['user_id'] = $userId;
$mapValue['user_id'] = $userInfo; $map3['user_id'] = $userId;
} $map4['user_id'] = $userId;
$mapValue['pay_type'] = ['gt', 0]; }
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]); $map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
$mapPromoteCoin['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
$mapDeposit['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
$mapSpend['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
$mapValue['create_time'] = array('between', [strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399]);
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
$map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]); $map['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
$mapPromoteCoin['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
$mapDeposit['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
$mapSpend['pay_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
$mapValue['create_time'] = array('between', [strtotime($_REQUEST['timestart']), time()]);
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
$mapPromoteCoin['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
$mapDeposit['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
$mapSpend['pay_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
$mapValue['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
}elseif (empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) { }elseif (empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) {
$map['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]); $map['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
$mapPromoteCoin['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
$mapDeposit['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
$mapSpend['pay_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
$mapValue['create_time'] = array('between', [strtotime($initBegTime), strtotime($initEndTime) + 86399]);
}
$datas = M('user_play','tab_') }
->group('user_id') $datas = M('user', 'tab_')
->field("id,user_id,user_account,bind_balance") ->field('id, account')
->where($map) ->where($map0)
->page($page,$row) ->page($page,$row)
->select(); ->select();
$count = M('user_play','tab_') $count = M('user', 'tab_')
->field("id,user_id,user_account,bind_balance") ->field('id, account')
->where($map) ->where($map)
->count('DISTINCT user_id'); ->count();
$total = M('deposit', 'tab_')->where($mapDeposit)->sum('pay_amount'); $ids = array_column($datas, 'id');
$totalSpend = M('spend', 'tab_')->where($mapSpend)->sum('pay_amount'); if(empty($ids)) {
$ids = [-100];
// $total_bind_balance = M('user_play', 'tab_')->where($mapBanlance)->sum('bind_balance'); }
$totalValueInit = M('value_detail_log', 'tab_')->where(['pay_type'=>0])->sum('after_value'); $allDatas = [];
$totalValueDetail = M('value_detail_log', 'tab_')->where($mapValue)->group('user_id')->order('desc create_time')->sum('after_value'); foreach($datas as $key => $data) {
$total_bind_balance = $totalValueInit + $totalValueDetail; $id = $data['id'];
$totalPromoteCoin = M('promote_coin_record', 'tab_')->where($mapPromoteCoin)->sum('coin'); $account = $data['account'];
$total = empty($total) ? '0.00' : $total; $allDatas[$key]['user_id'] = $id;
$totalSpend = empty($totalSpend) ? '0.00' : $totalSpend; $allDatas[$key]['user_account'] = $account;
$total_bind_balance = empty($total_bind_balance) ? '0.00' : $total_bind_balance; $map5['user_id'] = $id;
$totalPromoteCoin = empty($totalPromoteCoin) ? '0.00' : $totalPromoteCoin; $map5['pay_type'] = 1;
foreach ($datas as $key => $data) { $map5['create_time'] = $map['create_time'];
$user_id = $data['user_id']; $spend = M('value_detail_log', 'tab_')->where($map5)->sum('value');
$mapSpend['user_id'] = $user_id; if(empty($spend)) {
$mapDeposit['user_id'] = $user_id;
$mapPromoteCoin['target_id'] = $user_id;
$bind_balance = M('user_play', 'tab_')->where(['user_id' => $user_id])->sum('bind_balance');
$spend = M('spend', 'tab_')->where($mapSpend)->sum('pay_amount');
if (empty($spend)) {
$spend = '0.00'; $spend = '0.00';
} }
$deposit = M('deposit', 'tab_')->where($mapDeposit)->sum('pay_amount'); $map6['user_id'] = $id;
if (empty($deposit)) { $map6['pay_type'] = 2;
$map6['create_time'] = $map['create_time'];
$deposit = M('value_detail_log', 'tab_')->where($map6)->sum('value');
if(empty($deposit)) {
$deposit = '0.00'; $deposit = '0.00';
} }
$promoteCoin = M('promote_coin_record', 'tab_')->where($mapPromoteCoin)->sum('coin'); $map7['user_id'] = $id;
if (empty($promoteCoin)) { $map7['pay_type'] = 3;
$map7['create_time'] = $map['create_time'];
$promoteCoin = M('value_detail_log', 'tab_')->where($map7)->sum('value');
if(empty($promoteCoin)) {
$promoteCoin = '0.00'; $promoteCoin = '0.00';
} }
$datas[$key]['bind_balance'] = $bind_balance; // $allDatas[$key]['bind_balance'] = $bind_balance;
$datas[$key]['spend_amount'] = $spend; $allDatas[$key]['spend_amount'] = $spend;
$datas[$key]['deposit_amount'] = $deposit; $allDatas[$key]['deposit_amount'] = $deposit;
$datas[$key]['coin_amount'] = $promoteCoin; $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;
$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' : $deposit;
$map3['create_time'] = $map['create_time'];
$map3['pay_type'] = 3;
$allpromoteCoin = M('value_detail_log', 'tab_')->where($map3)->sum('value');
$allpromoteCoin = empty($promoteCoin) ? '0.00' : $promoteCoin;
$map4['create_time'] = $map['create_time'];
$banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->group('user_id')->select();
$banlaceTotal = '0.00';
foreach($banlace as $k222 => $vvv) {
$banlaceTotal += $vvv['after_value'];
}
$map['user_id'] = ['in', $ids];
$newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map)->group('user_id')->select();
// 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";
}
}
} }
$page = set_pagination($count,$row); $page = set_pagination($count,$row);
// var_dump($page);die();
if($page) {$this->assign('_page', $page);} if($page) {$this->assign('_page', $page);}
if(empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) { if(empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty(I('user_account'))) {
$this->assign('starttime', $initBegTime); $this->assign('starttime', $initBegTime);
@ -1279,11 +1298,14 @@ class FinanceController extends ThinkController
$this->assign('starttime', $_REQUEST['timestart']); $this->assign('starttime', $_REQUEST['timestart']);
$this->assign('endtime', $_REQUEST['endtime']); $this->assign('endtime', $_REQUEST['endtime']);
} }
$this->assign('totalPromoteCoin', $totalPromoteCoin); //var_dump($allDatas);die();
$this->assign('total_bind_balance', $total_bind_balance); $this->assign('banlaceTotal', $banlaceTotal);
$this->assign('totalSpend', $totalSpend); $this->assign('total', $totalSpend);
$this->assign('total', $total); $this->assign('deposit', $deposit);
$this->assign('data', $datas); $this->assign('promoteCoin', $allpromoteCoin);
$this->assign('data', $allDatas);
$this->display(); $this->display();
} }
@ -1333,8 +1355,15 @@ class FinanceController extends ThinkController
$total += $valueDetailData['value']; $total += $valueDetailData['value'];
} }
} }
if($total >= 0 ) {
$fuhao = '+';
}else {
$fuhao = '-';
}
$page = set_pagination($counts,$row); $page = set_pagination($counts,$row);
if($page) {$this->assign('_page', $page);} if($page) {$this->assign('_page', $page);}
$this->assign('fuhao', $fuhao);
$this->assign('total', $total); $this->assign('total', $total);
$this->assign('listdata', $vlaueDetailDatas); $this->assign('listdata', $vlaueDetailDatas);
$this->display(); $this->display();

Loading…
Cancel
Save