Merge branch 'feature/PlatFormCoinData' of wmtx/platform into release

平台币统计修改
master
廖金灵 5 years ago committed by Gogs
commit 81d4e20976

@ -2474,53 +2474,51 @@ class ExportController extends Controller
$params = I('get.');
$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');
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initEndTime = date('Y-m-d', time());
if(!empty($params['user_account'])){
$userInfo = M('user', 'tab_')->where(['account'=>I('user_account')])->getField('id');
$map['user_account'] = $params['user_account'];
$mapBanlance['user_account'] = $params['user_account'];
$mapSpend['user_account'] = $params['user_account'];
$mapDeposit['user_account'] = $params['user_account'];
$mapPromoteCoin['target_id'] = $userInfo;
$map['account'] = $_REQUEST['user_account'];
$userId = M('user', 'tab_')->where(['account'=>$_REQUEST['user_account']])->getField('id');
$map1['user_id'] = $userId;
$map2['user_id'] = $userId;
$map3['user_id'] = $userId;
$map4['user_id'] = $userId;
}
if (!empty($params['timestart']) && !empty($params['timeend'])) {
$map['create_time'] = array('between', [strtotime($params['timestart']), strtotime($params['timeend']) + 86399]);
$mapPromoteCoin['create_time'] = array('between', [strtotime($params['timestart']), strtotime($params['timeend']) + 86399]);
$mapDeposit['create_time'] = array('between', [strtotime($params['timestart']), strtotime($params['timeend']) + 86399]);
$mapSpend['pay_time'] = array('between', [strtotime($params['timestart']), strtotime($params['timeend']) + 86399]);
} elseif (!empty($params['timestart']) && empty($params['timeend'])) {
$map['create_time'] = array('between', [strtotime($params['timestart']), time()]);
$mapPromoteCoin['create_time'] = array('between', [strtotime($params['timestart']), time()]);
$mapDeposit['create_time'] = array('between', [strtotime($params['timestart']), time()]);
$mapSpend['pay_time'] = array('between', [strtotime($params['timestart']), time()]);
} elseif (empty($params['timestart']) && !empty($params['timeend'])) {
$map['create_time'] = array('elt', (strtotime($params['timeend']) + 86399));
$mapPromoteCoin['create_time'] = array('elt', (strtotime($params['timeend']) + 86399));
$mapDeposit['create_time'] = array('elt', (strtotime($params['timeend']) + 86399));
$mapSpend['pay_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
}
elseif (empty($_REQUEST['timestart']) && empty($_REQUEST['timeend']) && empty($params['user_account'])) {
$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]);
}
$total = M('deposit', 'tab_')->where($mapDeposit)->sum('pay_amount');
$totalSpend = M('spend', 'tab_')->where($mapSpend)->sum('pay_amount');
$total_bind_balance = M('user_play', 'tab_')->where($mapBanlance)->sum('bind_balance');
$totalPromoteCoin = M('promote_coin_record', 'tab_')->where($mapPromoteCoin)->sum('coin');
$total = empty($total) ? '0.00' : $total;
$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;
$total_bind_balance = empty($total_bind_balance) ? '0.00' : $total_bind_balance;
$totalPromoteCoin = empty($totalPromoteCoin) ? '0.00' : $totalPromoteCoin;
$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;
foreach($banlace as $k222 => $vvv) {
$banlaceTotal += $vvv['after_value'];
}
$csvFileName = '平台币统计'.'.csv';
//设置好告诉浏览器要下载excel文件的headers
@ -2533,69 +2531,77 @@ class ExportController extends Controller
$fp = fopen('php://output', 'a');//打开output流
mb_convert_variables('GBK', 'UTF-8', $xlsCell);
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
// $datas = M('user_play','tab_')
// ->group('user_id')
// ->field("id,user_id,user_account,bind_balance")
// ->where($map)
// ->page($page,$row)
// ->select();
$count = M('user_play','tab_')
->field("id,user_id,user_account,bind_balance")
$count = M('user', 'tab_')
->field('id, account')
->where($map)
->count('DISTINCT user_id');
->count();
$perSize = 10000;//每次查询的条数
$perSize = 1000;//每次查询的条数
$pages = ceil($count / $perSize);
for($i = 1; $i <= $pages; $i++) {
$datas = M('user_play','tab_')
->group('user_id')
->field("user_id,user_account,bind_balance")
$datas = M('user', 'tab_')
->field('id, account')
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->select();
$allDatas = [];
foreach($datas as $key => $data) {
$allDatas['user_id'] = $data['id'];
$allDatas['user_account'] = $data['account'];
$spend = M('value_detail_log', 'tab_')->where(['user_id'=>$id, 'pay_type'=>1])->sum('value');
$map5['user_id'] = $id;
$map5['pay_type'] = 1;
$map5['create_time'] = $map['create_time'];
$spend = M('value_detail_log', 'tab_')->where($map5)->sum('value');
if(empty($spend)) {
$spend = '0.00';
}
$map6['user_id'] = $id;
$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';
}
$map7['user_id'] = $id;
$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';
}
foreach($datas as $data) {
$user_id = $data['user_id'];
$mapSpend['user_id'] = $user_id;
$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';
}
$deposit = M('deposit', 'tab_')->where($mapDeposit)->sum('pay_amount');
if (empty($deposit)) {
$deposit = '0.00';
}
$promoteCoin = M('promote_coin_record', 'tab_')->where($mapPromoteCoin)->sum('coin');
if (empty($promoteCoin)) {
$promoteCoin = '0.00';
}
$data['user_id'] = $data['user_id'];
$data['user_account'] = $data['user_account'];
$data['bind_balance'] = $bind_balance;
$data['spend_amount'] = $spend;
$data['deposit_amount'] = $deposit;
$data['coin_amount'] = $promoteCoin;
mb_convert_variables('GBK', 'UTF-8', $data);
fputcsv($fp, $data);
}
unset($datas);//释放变量的内存
$map8['user_id'] = $id;
$map8['create_time'] = $map['create_time'];
$newValueByTimeDatas = M('value_detail_log', 'tab_')->field('after_value')->where($map8)->group('user_id')->select();
if(empty($newValueByTimeDatas)) {
$aValue = '0.00';
}else {
$aValue = $newValueByTimeDatas['after_value'];
}
$allDatas['bind_balance'] = $aValue;
$allDatas['spend_amount'] = $spend;
$allDatas['deposit_amount'] = $deposit;
$allDatas['coin_amount'] = $promoteCoin;
mb_convert_variables('GBK', 'UTF-8', $allDatas);
fputcsv($fp, $allDatas);
}
unset($allDatas);//释放变量的内存
//刷新输出缓冲到浏览器
ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
}
$alldatas['user_id'] = "汇总(检索时间内所有数据的统计)";
$alldatas['user_account'] = "";
$alldatas['bind_balance'] = $total_bind_balance;
$alldatas['spend_amount'] = $totalSpend;
$alldatas['deposit_amount'] = $total;
$alldatas['coin_amount'] = $totalPromoteCoin;
mb_convert_variables('GBK', 'UTF-8', $alldatas);
fputcsv($fp, $alldatas);
$alldatas1['user_id'] = "汇总(检索时间内所有数据的统计)";
$alldatas1['user_account'] = "";
$alldatas1['bind_balance'] = $banlaceTotal;
$alldatas1['spend_amount'] = $totalSpend;
$alldatas1['deposit_amount'] = $deposit;
$alldatas1['coin_amount'] = $promoteCoin;
mb_convert_variables('GBK', 'UTF-8', $alldatas1);
fputcsv($fp, $alldatas1);
fclose($fp);
//操作日志
@ -2612,6 +2618,7 @@ class ExportController extends Controller
$params = I('get.');
$map = [];
$orderNumber = $params['order_number'];
if($orderNumber) {
$map['order_number'] = $params['order_number'];
}
@ -2679,9 +2686,14 @@ class ExportController extends Controller
ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
}
if ($total >= 0) {
$fuhao = '+';
}else {
$fuhao = '-';
}
$alldatas['order_number'] = "汇总(检索时间内所有数据的统计)";
$alldatas['create_time'] = "";
$alldatas['type'] = "";
$alldatas['type'] = $fuhao;
$alldatas['value'] = $total;
$alldatas['after_value'] = "";
@ -2689,7 +2701,7 @@ class ExportController extends Controller
fputcsv($fp, $alldatas);
fclose($fp);
exit;
break;
break;
default:
$xlsName = $xlsCell = $xlsData = [];

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

@ -102,6 +102,7 @@
<tr>
<td>汇总(检索时间内所有数据的统计)</td>
<td colspan="8">
<if condition="$total egt 0"><span style="color:red">{$fuhao}</span><else/><span style="color:green">{$fuhao}</span></if>
<if condition="$total egt 0"><span style="color:red">{$total}</span><else/><span style="color:green">{$total}</span></if>
</td>
</tr>

@ -109,7 +109,7 @@
<tr>
<td>{$data.user_id}</td>
<td>{$data.user_account}</td>
<td>{$data.bind_balance}</td>
<td>{$data.after_value}</td>
<td><span>{$data.spend_amount}</span></td>
<td>{$data.deposit_amount}</td>
<td>{$data.coin_amount}</td>
@ -122,10 +122,10 @@
</empty>
<tr>
<td colspan="2">汇总(检索时间内所有数据的统计)</td>
<td>{$total_bind_balance}</td>
<td>{$totalSpend}</td>
<td>{$banlaceTotal}</td>
<td>{$total}</td>
<td>{$totalPromoteCoin}</td>
<td>{$deposit}</td>
<td>{$promoteCoin}</td>
<td></td>
</tr>
</tbody>

Loading…
Cancel
Save