Merge branch 'dev_zyx' into dev

master
zhengchanglong 5 years ago
commit 2d67812f90

@ -5303,8 +5303,10 @@ if ($key == 'model'){
$xlsCell = array(
array('count_date','月份'),
array('cash_count','游戏现金流水'),
array('balance_coin_count','平台币流水'),
array('balance_coin_deposit','平台币收入'),
array('inside_cash_count','内冲流水'),
array('bind_coin_count','内充支出'),
array('balance_coin_count','平台币支出'),
array('all_count','总流水'),
);
@ -5341,21 +5343,23 @@ if ($key == 'model'){
// $sumAll = D("spend_count")->sumSpendCountField($map,$allField);
$order = "id DESC";
$xlsData = M('spend_month_count','tab_')
->field("cash_count,balance_coin_count,inside_cash_count,all_count,count_date")
->field("cash_count,balance_coin_count,inside_cash_count,all_count,count_date,balance_coin_deposit,bind_coin_count")
->where($map)
->order($order)
->select();
$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")
->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,sum(balance_coin_deposit) as balance_coin_deposit,sum(bind_coin_count) as bind_coin_count")
->where($map)
->order($order)
->find();
$sumData = [['count_date'=>'总计',
'cash_count'=>$sumData['cash_count'],
'balance_coin_count'=>$sumData['balance_coin_count'],
'balance_coin_deposit'=>$sumData['balance_coin_deposit'],
'inside_cash_count'=>$sumData['inside_cash_count'],
'bind_coin_count'=>$sumData['bind_coin_count'],
'balance_coin_count'=>$sumData['balance_coin_count'],
'all_count'=>$sumData['all_count']]];
$xlsData = array_merge($xlsData,$sumData);
@ -5373,8 +5377,8 @@ if ($key == 'model'){
array('game_name','游戏'),
array('partner_name','合作方'),
array('cash_count','游戏现金流水'),
array('balance_coin_count','平台币流水'),
array('inside_cash_count','内冲流水'),
array('balance_coin_count','平台币支出'),
array('inside_cash_count','公会内充支出'),
array('all_cash_count','总流水'),
);
@ -5397,7 +5401,7 @@ if ($key == 'model'){
}
if (!empty(I('partner_id'))) {
$map['partner_id']=I('collaborate_id');
$map['partner_id']=I('partner_id');
}
if (I('sign') == 2&&empty(I('root_id'))) {
@ -5509,6 +5513,13 @@ if ($key == 'model'){
$map['promote_id'] = ['in',$promote_id];
}
if (!empty(I('partner_id'))&&empty(I("game_id"))) {
$wherePartner = I('partner_id');
$gameId = M("game","tab_")->field("id")->where("partner_id={$wherePartner}")->select();
$gameId = implode(',',array_column($gameId,'id'));
$map['game_id'] = ['in',$gameId];
}
if (!empty(I("count_date"))) {
$month = I("count_date");
$tarry = explode('-',$month);
@ -5530,19 +5541,97 @@ if ($key == 'model'){
$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";
$group = "";
$order = "pay_time DESC";
$xlsData = D('spend')->getSpendData($map,$field,$group,$order);
for($start = $startTime;$start<$endTime;$start=$start+86400) {
$map['pay_time'] = array('between',array($start,$start+86400));
$xlsData1 = D('spend')->getSpendData($map,$field,$group,$order);
if ($xlsData1) {
$xlsData[date('m-d',$start)] = $xlsData1;
}
}
foreach($xlsData as $key => $value) {
$xlsData[$key]['pay_way'] = getPayType($value['pay_way']);
foreach ($value as $k => $v) {
$xlsData[$key][$k]['pay_way'] = getPayType($value['pay_way']);
}
}
$map['pay_time'] = array('between',array($startTime,$endTime));
$sum = D('spend')->sumSpend($map,'pay_amount');
$sumData = [['pay_order_number'=>'总计',
$xlsData['10-'] = [['pay_order_number'=>'总计',
'pay_way'=>$sum]];
$xlsData = array_merge($xlsData,$sumData);
// $xlsData = array_merge($xlsData,$sumData);
// dump($xlsData);die();
$this->exportExcel($xlsName, $xlsCell, $xlsData);
$this->exportNewExcel($xlsName, $xlsCell, $xlsData);
}
public function exportNewExcel($expTitle, $expCellName, $expTableData)
{
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
// $fileName = session('user_auth.username').date('_YmdHis');//or $xlsTitle 文件名称可根据自己情况设定
$fileName = $expTitle;
$cellNum = count($expCellName);
$dataNum = count(current($expTableData));
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ');
$objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $expTitle);
$objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->setActiveSheetIndex(0)->setTitle(key($expTableData));
for ($i = 0; $i < $cellNum; $i++) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]);
}
for ($i = 0; $i < $dataNum; $i++) {
for ($j = 0; $j < $cellNum; $j++) {
$objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), current($expTableData)[$i][$expCellName[$j][0]]);
}
}
// var_dump($expTableData);die();
unset($expTableData[key($expTableData)]);
$sheetNum = 1;
foreach($expTableData as $key => $value) {
$dataNum = count($value);
$objPHPExcel->createSheet();
if ($key==0) {
break;
}
if ($key == '10-') {
$objPHPExcel->setActiveSheetIndex($sheetNum)->setTitle('总计');
} else {
$objPHPExcel->setActiveSheetIndex($sheetNum)->setTitle($key);
}
$objPHPExcel->getActiveSheet($sheetNum)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格
$objPHPExcel->setActiveSheetIndex($sheetNum)->setCellValue('A1', $expTitle);
$objPHPExcel->setActiveSheetIndex($sheetNum)->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
for ($i = 0; $i < $cellNum; $i++) {
$objPHPExcel->setActiveSheetIndex($sheetNum)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]);
}
for ($i = 0; $i < $dataNum; $i++) {
for ($j = 0; $j < $cellNum; $j++) {
$objPHPExcel->getActiveSheet($sheetNum)->setCellValue($cellName[$j] . ($i + 3), $value[$i][$expCellName[$j][0]]);
}
}
$sheetNum++;
}
//die();
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"');
header("Content-Disposition:attachment;filename=$fileName.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
function getPromoteList($root_id = 0) {
@ -5574,8 +5663,9 @@ if ($key == 'model'){
$xlsCell = array(
array('promote_account','会长渠道'),
array('cash_count','游戏现金流水'),
array('balance_coin_count','平台币流水'),
array('inside_cash_count','内充流水'),
array('balance_coin_count','平台币支出'),
array('inside_cash_count','公会内充发放'),
array('bind_coin_count','公会内充支出'),
array('all_count','总流水'),
);
@ -5586,13 +5676,13 @@ if ($key == 'model'){
$map['parent_id'] = 0;
$map['root_id'] = 0;
$xlsData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->group('promote_id')
->select();
$sumData = M('spend_user_count','tab_')
->field('sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->find();
@ -5601,6 +5691,7 @@ if ($key == 'model'){
'cash_count'=>$sumData['cash_count'],
'balance_coin_count'=>$sumData['balance_coin_count'],
'inside_cash_count'=>$sumData['inside_cash_count'],
'bind_coin_count'=>$sumData['bind_coin_count'],
'all_count'=>$sumData['all_count'],
]];
$xlsData = array_merge($xlsData,$sumData);
@ -5644,10 +5735,11 @@ if ($key == 'model'){
$xlsName = '组长月结统计';
$xlsCell = array(
array('promote_account','长渠道'),
array('promote_account','长渠道'),
array('cash_count','游戏现金流水'),
array('balance_coin_count','平台币流水'),
array('inside_cash_count','内充流水'),
array('balance_coin_count','平台币支出'),
array('inside_cash_count','公会内充发放'),
array('bind_coin_count','公会内充支出'),
array('all_count','总流水'),
);
@ -5655,7 +5747,7 @@ if ($key == 'model'){
// $map['parent_id'] =$root_id;
$xlsData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->group('promote_id')
->select();
@ -5664,7 +5756,7 @@ if ($key == 'model'){
}
$sumData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->find();
if (empty(I("root_name"))) {
@ -5672,12 +5764,14 @@ if ($key == 'model'){
$sumData['balance_coin_count'] = number_format($sumData['balance_coin_count'] + $parentData[0]['balance_coin_count'], 2, '.', '');
$sumData['inside_cash_count'] = number_format($sumData['inside_cash_count'] + $parentData[0]['inside_cash_count'], 2, '.', '');
$sumData['all_count'] = number_format($sumData['all_count'] + $parentData[0]['all_count'], 2, '.', '');
$sumData['bind_coin_count'] = number_format($sumData['bind_coin_count'] + $parentData[0]['bind_coin_count'], 2, '.', '');
}
$sumData = [['promote_account'=>'总计',
'cash_count'=>$sumData['cash_count'],
'balance_coin_count'=>$sumData['balance_coin_count'],
'inside_cash_count'=>$sumData['inside_cash_count'],
'bind_coin_count'=>$sumData['bind_coin_count'],
'all_count'=>$sumData['all_count'],
]];
$xlsData = array_merge($xlsData,$sumData);
@ -5715,16 +5809,17 @@ if ($key == 'model'){
$xlsName = '推广员月结统计';
$xlsCell = array(
array('promote_account','推广员渠道'),
array('promote_account','会长渠道'),
array('cash_count','游戏现金流水'),
array('balance_coin_count','平台币流水'),
array('inside_cash_count','内充流水'),
array('balance_coin_count','平台币支出'),
array('inside_cash_count','公会内充发放'),
array('bind_coin_count','公会内充支出'),
array('all_count','总流水'),
);
//获取数据
$xlsData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->group('promote_id')
->select();
@ -5732,18 +5827,20 @@ if ($key == 'model'){
$xlsData = array_merge($parentData,$xlsData);
$sumData = M('spend_user_count','tab_')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count')
->field('promote_id,promote_account,sum(cash_count) cash_count,sum(balance_coin_count) balance_coin_count,sum(inside_cash_count) inside_cash_count, sum(all_count) as all_count, sum(bind_coin_count) as bind_coin_count')
->where($map)
->find();
$sumData['cash_count'] = number_format($sumData['cash_count']+$parentData[0]['cash_count'],2,'.','');
$sumData['balance_coin_count'] = number_format($sumData['balance_coin_count']+$parentData[0]['balance_coin_count'],2,'.','');
$sumData['inside_cash_count'] = number_format($sumData['inside_cash_count']+$parentData[0]['inside_cash_count'],2,'.','');
$sumData['all_count'] = number_format($sumData['all_count']+$parentData[0]['all_count'],2,'.','');
$sumData['bind_coin_count'] = number_format($sumData['bind_coin_count']+$parentData[0]['bind_coin_count'],2,'.','');
$sumData = [['promote_account'=>'总计',
'cash_count'=>$sumData['cash_count'],
'balance_coin_count'=>$sumData['balance_coin_count'],
'inside_cash_count'=>$sumData['inside_cash_count'],
'bind_coin_count'=>$sumData['bind_coin_count'],
'all_count'=>$sumData['all_count'],
]];
$xlsData = array_merge($xlsData,$sumData);
@ -5767,19 +5864,20 @@ if ($key == 'model'){
}
$data = M('spend_user_count','tab_')
->field('promote_id,promote_account, 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_count')
->field('promote_id,promote_account, 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, sum(bind_coin_count) as bind_coin_count')
->where($map)->select();
$map1['parent_id'] = $data[0]['promote_id'];
$map1['count_date'] = $date;
$sunData = M('spend_user_count','tab_')
->field('promote_id,promote_account, 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_count')
->field('promote_id,promote_account, 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, sum(bind_coin_count) as bind_coin_count')
->where($map1)->find();
$data[0]['cash_count'] = number_format($data[0]['cash_count']-$sunData['cash_count'],2,'.','');
$data[0]['balance_coin_count'] = number_format($data[0]['balance_coin_count']-$sunData['balance_coin_count'],2,'.','');
$data[0]['inside_cash_count'] = number_format($data[0]['inside_cash_count']-$sunData['inside_cash_count'],2,'.','');
$data[0]['all_count'] = number_format($data[0]['all_count']-$sunData['all_count'],2,'.','');
$data[0]['bind_coin_count'] = number_format($data[0]['bind_coin_count']-$sunData['bind_coin_count'],2,'.','');
// $map['inside_cash_count'] = ['neq',0];
// $insideData = D("spend_count")->getSpendCountData($map,"promote_id,inside_cash_count as count","promote_id,count_date");

@ -153,9 +153,9 @@ class FinanceController extends ThinkController
}
}
// if (!empty(I('partner_id'))) {
// $map['partner_id']=I('collaborate_id');
// }
if (!empty(I('partner_id'))) {
$map['partner_id']=I('partner_id');
}
@ -232,6 +232,7 @@ class FinanceController extends ThinkController
function gameFinanceDetail($p = 1) {
set_time_limit(0);
if (!empty(I("promote_id"))) {
$promote_id[] = I("promote_id");
}
@ -257,7 +258,13 @@ class FinanceController extends ThinkController
$map['promote_id'] = ['in',$promote_id];
}
if (!empty(I('partner_id'))&&empty(I("game_id"))) {
$wherePartner = I('partner_id');
$gameId = M("game","tab_")->field("id")->where("partner_id={$wherePartner}")->select();
$gameId = implode(',',array_column($gameId,'id'));
$map['game_id'] = ['in',$gameId];
}
// var_dump($map);die();
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$row=10;

@ -177,7 +177,7 @@
<a href="{:U('Finance/gameFinanceDetail',
array('count_date'=>$_REQUEST['count_date'],'root_id'=>$_GET['root_id'],'partner_id'=>$_REQUEST['partner_id'],
'parent_id'=>$_REQUEST['parent_id'],'promote_id'=>$_REQUEST['promote_id'],'game_id'=>$_REQUEST['game_id'],'game_name'=>'全部游戏',
'sign'=>$_REQUEST['sign'],'from'=>$_REQUEST['from']))}" >查看</a>
'sign'=>$_REQUEST['sign'],'from'=>$_REQUEST['from'],'all'=>1))}" >查看</a>
</td>
</tr>
</notemtpy>

@ -42,8 +42,10 @@
<div class="input-list">
<a class="sch-btn" href="javascript:history.go(-1)" style="background:#fff;color: #000;border: #000 solid 1px;width: 100px">返回</a>
<if condition="$_GET['all'] neq 1">
<a class="sch-btn" href="{:U('Export/gameFinanceDetail',
array('count_date'=>$_GET['count_date'],'game_id'=>$_GET['game_id'],'game_name'=>$_GET['game_name'],'user_account'=>$_GET['user_account'],'user_nickname'=>$_GET['user_nickname'],'parent_id'=>$_GET['parent_id'],'root_id'=>$_GET['root_id'],false))}" style="width: 100px;border: #3C95C8 solid 1px;">导出</a>
</if>
</div>
<input type="hidden" name="count_date" value="{$_GET['count_date']}"/>
<input type="hidden" name="game_id" value="{$_GET['game_id']}"/>

Loading…
Cancel
Save