@ -243,7 +243,7 @@ class ExportController extends Controller
->order("id desc")
->find();
$accessNum =$accessNum['count'];
$perSize = 2000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
$lastId = 0;
@ -1028,7 +1028,7 @@ class ExportController extends Controller
"支付订单号","CP订单号", "充值时间", "玩家账号", "游戏名称", L('Subordinate_channel'), "充值ip","区服ID", "游戏区服",
"角色ID","角色名称", "订单金额", "实付金额", "充值方式", L('Order_status'), "游戏通知状态", "消费"."{$total}"
);
$csvFileName = $xlsName.'.csv';
//设置好告诉浏览器要下载excel文件的headers
header('Content-Description: File Transfer');
@ -5090,6 +5090,8 @@ if ($key == 'model'){
array('grand_account','上线推广员'),
array('business_affairs','商务专员'),
array('status','状态'),
array('ver_status','身份认证'),
array('oa_associated','OA关联')
);
$model = M('Promote','tab_');
@ -5132,15 +5134,16 @@ if ($key == 'model'){
$row = $_REQUEST['row']?$_REQUEST['row']:10;
$data=$model
->where($map)
->order('create_time desc')
->select();
$xlsData = [];
if(is_array($data)){
// if(is_array($data)){
if($_REQUEST['type']==2) {
$data=$model
->where($map)
->order('create_time desc')
->select();
foreach($data as $k => $v) {
$v['create_time'] = date('Y-m-d H:i',$v['create_time']);
@ -5152,22 +5155,88 @@ if ($key == 'model'){
}
} else {
foreach($data as $k => $v) {
// sum_promote_total_money()
$xlsData = $model
->field("tab_promote.id,tab_promote.account,mobile_phone,balance_coin,total_money,tab_promote.create_time
,tab_promote.last_login_time,tab_business_affairs.account as business_affairs,tab_promote.status,
REPLACE(substring_index(tab_promote.chain, '/', 2),'/','') as top_promote,sum(pay_amount) as pay_amount,tab_promote.level as promote_levels,tab_promote.ver_status,tab_promote.oa_associated")
->join("left join tab_business_affairs on ba_id = tab_business_affairs.id")
->join("left join tab_spend on tab_promote.id = tab_spend.promote_id and pay_status=1")
->where($map)
->order('create_time desc')
->group("tab_promote.id")
->select(false);
$xlsData = M()->table("({$xlsData}) as a")
->field("a.id,a.account,a.mobile_phone,a.balance_coin,a.create_time,a.last_login_time,
a.promote_levels,tab_promote.account as grand_account,a.business_affairs,a.status,pay_amount as total_money,a.ver_status,a.oa_associated")
->join("left join tab_promote on tab_promote.id = a.top_promote")
->order('a.id desc')
->select();
$v['create_time'] = date('Y-m-d H:i',$v['create_time']);
$v['last_login_time'] = date('Y-m-d H:i',$v['last_login_time']);
foreach($xlsData as $k => & $v) {
$v['create_time'] = $v['create_time']?date('Y-m-d H:i',$v['create_time']):0;
$v['last_login_time'] = $v['last_login_time']?date('Y-m-d H:i',$v['last_login_time']):0;
if (!$v['business_affairs']) {
$v['business_affairs'] = "暂无";
}
if (!$v['grand_account']) {
$v['grand_account'] = $v['account'];
}
$v['status'] = get_info_status($v['status'],3);
$v['business_affairs'] = get_business_affairs_account($v['ba_id']);
$v['grand_account'] = getTopPromote($v['id'])['id'];
$v['promote_levels'] = get_promote_levels($v['id']);
// $v['business_affairs'] = get_business_affairs_account($v['ba_id']);
// $v['grand_account'] = getTopPromote($v['id'])['id'];
// $v['promote_levels'] = get_promote_levels($v['id']);
switch ($v['ver_status']) {
case '1':
$v['ver_status'] = "成功";
break;
case '2':
$v['ver_status'] = "拒绝";
break;
case '3':
$v['ver_status'] = "正在审核";
break;
case '4':
$v['ver_status'] = "修改审核中";
break;
default:
$v['ver_status'] = '未认证';
}
$xlsData[] = $v;
switch ($v['promote_levels']) {
case '1':
$v['promote_levels'] = "会长";
break;
case '2':
$v['promote_levels'] = "部门长";
break;
case '3':
$v['promote_levels'] = "组长";
break;
case '4':
$v['promote_levels'] = "组员";
break;
default:
$v['promote_levels'] = '';
}
if ($v['oa_associated']==1) {
$v['oa_associated'] = "关联";
} else {
$v['oa_associated'] = "未关联";
}
}
}
}
}
// }
$this->exportExcel($xlsName, $xlsCell, $xlsData);
@ -5830,175 +5899,262 @@ if ($key == 'model'){
}
public function spend_list()
{
public function spend_list() {
$xlsName = $_REQUEST['xlsname'];
$xlsName = $_REQUEST['xlsname'];
$xlsCell = array(
array('pay_order_number', "订单号"),
array('pay_time', "充值时间"),
array('promote_account', L('Subordinate_channel')),
array('parent_id', "上级推广员"),
array('user_account', "玩家账号"),
array('game_name', "游戏名称"),
array('server_name', L('Game_area_clothing')),
array('game_player_name', "角色名"),
array('spend_ip', "充值ip"),
array('pay_amount', "应付金额"),
array('cost', "实付金额"),
array('pay_way', "充值方式"),
array('promote_id', '商务专员'),
array('is_check','对账状态')
);
// $xlsCell = array(
// array('pay_order_number', "订单号"),
// array('pay_time', "充值时间"),
// array('promote_account', L('Subordinate_channel')),
// array('parent_id', "上级推广员"),
// array('user_account', "玩家账号"),
// array('game_name', "游戏名称"),
// array('server_name', L('Game_area_clothing')),
// array('game_player_name', "角色名"),
// array('spend_ip', "充值ip"),
// array('pay_amount', "应付金额"),
// array('cost', "实付金额"),
// array('pay_way', "充值方式"),
// array('promote_id', '商务专员'),
// array('is_check','对账状态')
// );
$xlsCell = array(
"订单号", "充值时间", L('Subordinate_channel'), "上线推广员", "玩家账号", "游戏名称", L('Game_area_clothing'),
"角色名", "充值ip", "应付金额", "实付金额", "充值方式", '商务专员', '对账状态'
);
if(isset($_REQUEST['game_name'])){
if($_REQUEST['game_name']=='全部'){
if (isset($_REQUEST['game_name'])) {
if ($_REQUEST['game_name'] == '全部') {
unset($_REQUEST['game_name']);
}else{
$map['game_name']=$_REQUEST['game_name'];
} else {
$map['game_name'] = $_REQUEST['game_name'];
unset($_REQUEST['game_name']);
}
}
if(!empty($_REQUEST['server_id'])){
$map['server_name']=$_REQUEST['server_id'];
if (!empty($_REQUEST['server_id'])) {
$map['server_name'] = $_REQUEST['server_id'];
unset($_REQUEST['server_id']);
}
if(!empty($_REQUEST['pay_order_number'])){
$map['pay_order_number']=array('like','%'.$_REQUEST['pay_order_number'].'%');
if (!empty($_REQUEST['pay_order_number'])) {
$map['pay_order_number'] = array('like', '%' . $_REQUEST['pay_order_number'] . '%');
unset($_REQUEST['pay_order_number']);
}
if(isset($_REQUEST['pay_way'])){
$map['pay_way'] = get_pay_way_map($_REQUEST['pay_way']);
unset($_REQUEST['pay_way']);
if (isset($_REQUEST['pay_way'])) {
$map['pay_way'] = get_pay_way_map($_REQUEST['pay_way']);
unset($_REQUEST['pay_way']);
}
if(isset($_REQUEST['user_account'])){
$map['user_account']=array('like','%'.$_REQUEST['user_account'].'%');
if (isset($_REQUEST['user_account'])) {
$map['user_account'] = array('like', '%' . $_REQUEST['user_account'] . '%');
unset($_REQUEST['user_account']);
}
if(isset($_REQUEST['spend_ip'])){
$map['spend_ip']=array('like','%'.$_REQUEST['spend_ip'].'%');
if (isset($_REQUEST['spend_ip'])) {
$map['spend_ip'] = array('like', '%' . $_REQUEST['spend_ip'] . '%');
unset($_REQUEST['spend_ip']);
}
if(isset($_REQUEST['time-start'])& & isset($_REQUEST['time-end'])){
$map['pay_time']=array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time_end']);
}elseif(isset($_REQUEST['time-start'])){
$map['pay_time'] = ['GT',strtotime(I('time-start'))];
if (isset($_REQUEST['time-start']) & & isset($_REQUEST['time-end'])) {
$map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['time-start']), strtotime($_REQUEST['time-end']) + 24 * 60 * 60 - 1));
unset($_REQUEST['time-start']);
}elseif(isset($_REQUEST['time-end'])){
$map['pay_time'] = ['LT',strtotime(I('time-end'))+86399];
unset($_REQUEST['time_end']);
} elseif (isset($_REQUEST['time-start'])) {
$map['pay_time'] = ['GT', strtotime(I('time-start'))];
unset($_REQUEST['time-start']);
} elseif (isset($_REQUEST['time-end'])) {
$map['pay_time'] = ['LT', strtotime(I('time-end')) + 86399];
unset($_REQUEST['time-end']);
}
if(isset($_REQUEST['start'])& & isset($_REQUEST['end'])){
$map['pay_time']=array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
}elseif(isset($_REQUEST['start'])){
$map['pay_time'] = ['GT',strtotime(I('start'))];
if (isset($_REQUEST['start']) & & isset($_REQUEST['end'])) {
$map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1));
unset($_REQUEST['start']);
}elseif(isset($_REQUEST['end'])){
$map['pay_time'] = ['LT',strtotime(I('end'))+86399];
unset($_REQUEST['end']);
} elseif (isset($_REQUEST['start'])) {
$map['pay_time'] = ['GT', strtotime(I('start'))];
unset($_REQUEST['start']);
} elseif (isset($_REQUEST['end'])) {
$map['pay_time'] = ['LT', strtotime(I('end')) + 86399];
unset($_REQUEST['end']);
}
if(isset($_REQUEST['promote_name'])){
if($_REQUEST['promote_name']=='全部'){
if (isset($_REQUEST['timeStart']) & & isset($_REQUEST['timeEnd'])) {
$map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['timeStart']), strtotime($_REQUEST['timeEnd']) + 24 * 60 * 60 - 1));
unset($_REQUEST['timeStart']);
unset($_REQUEST['timeEnd']);
} elseif (isset($_REQUEST['timeStart'])) {
$map['pay_time'] = ['GT', strtotime(I('timeStart'))];
unset($_REQUEST['timeStart']);
} elseif (isset($_REQUEST['timeEnd'])) {
$map['pay_time'] = ['LT', strtotime(I('timeEnd')) + 86399];
unset($_REQUEST['timeEnd']);
}
if (isset($_REQUEST['promote_name'])) {
if ($_REQUEST['promote_name'] == '全部') {
unset($_REQUEST['promote_name']);
}else if($_REQUEST['promote_name']=='自然注册'){
$map['promote_id']=array("lte",0);
} else if ($_REQUEST['promote_name'] == '自然注册') {
$map['promote_id'] = array("lte", 0);
unset($_REQUEST['promote_name']);
}else{
$map['promote_id']=get_promote_id($_REQUEST['promote_name']);
} else {
$map['promote_id'] = get_promote_id($_REQUEST['promote_name']);
unset($_REQUEST['promote_name']);
if(!empty(I('parent_id')) & & $map['promote_id']){
if (!empty(I('parent_id')) & & $map['promote_id']) {
if(I('parent_id') == $map['promote_id']) {
if (I('parent_id') == $map['promote_id']) {
} else {
$parent_id = I('parent_id');
$pro = M('promote', 'tab_')->field('id')->where("id={$map['promote_id']} and chain like '%/{$parent_id}/%'")->select();
} else {
$parent_id = I('parent_id');
$pro = M('promote','tab_')->field('id')->where("id={$map['promote_id']} and chain like '%/{$parent_id}/%'")->select();
if(!$pro) {
$map['promote_id'] = array('eq',999999999);
}
if (!$pro) {
$map['promote_id'] = array('eq', 999999999);
}
}
}
} else {
$pro = M('promote', 'tab_')->field('id')->where("chain like '%/{$map['promote_id']}/%'")->select();
$pro_ids = array_column($pro, 'id');
$pro_ids[] = $map['promote_id'];
if (!empty($pro_ids)) {
$map['promote_id'] = ['in', $pro_ids];
}else {
$map['promote_id'] = array('eq', 999999999);
}
} else {
$pro = M('promote', 'tab_')->field('id')->where("chain like '%/{$map['promote_id']}/%'")->select();
$pro_ids = array_column($pro, 'id');
$pro_ids[] = $map['promote_id'];
if (!empty($pro_ids)) {
$map['promote_id'] = ['in', $pro_ids];
} else {
$map['promote_id'] = array('eq', 999999999);
}
}
}
}
}else{
} else {
if(!empty(I('parent_id'))){
$parent_id = I('parent_id');
$pro = M('promote','tab_')->field('id')->where("chain like '%/{$parent_id}/%'")->select();
$pro_ids = array_column($pro,'id');
$pro_ids[] = I('parent_id');
if (!empty($pro_ids)){
$map['promote_id'] = ['in',$pro_ids];
}else{
$map['promote_id'] = array('eq',999999999);
}
} else {
$map['promote_id']=array("gt",0);
}
if (!empty(I('parent_id'))) {
$parent_id = I('parent_id');
$pro = M('promote', 'tab_')->field('id')->where("chain like '%/{$parent_id}/%'")->select();
$pro_ids = array_column($pro, 'id');
$pro_ids[] = I('parent_id');
if (!empty($pro_ids)) {
$map['promote_id'] = ['in', $pro_ids];
} else {
$map['promote_id'] = array('eq', 999999999);
}
} else {
$map['promote_id'] = array("gt", 0);
}
}
if(isset($_REQUEST['ba_id'])){
$all_promote_id = array_column(get_admin_promotes($_REQUEST['ba_id'],'ba_id'),'id');
if(empty($all_promote_id)){
$all_promote_id[]=-1;
if (isset($_REQUEST['ba_id'])) {
$all_promote_id = array_column(get_admin_promotes($_REQUEST['ba_id'], 'ba_id'), 'id');
if (empty($all_promote_id)) {
$all_promote_id[] = -1;
}
$map['promote_id']=array($map['promote_id'],array('in',implode(',',$all_promote_id)),'and');
$map['promote_id'] = array($map['promote_id'], array('in', implode(',', $all_promote_id)), 'and');
}
// var_dump(1);die();
$map['tab_spend.pay_status'] = 1;
$map['tab_spend.pay_status'] = 1;
$map['tab_spend.promote_id'] = $map['promote_id'];
unset($map['promote_id']);
$xlsData = D('Spend')
// 查询条件
->where($map)
/* 默认通过id逆序排列 */
->order('id desc')
/* 执行查询 */
->select();
$csvFileName = $xlsName . '.csv';
//设置好告诉浏览器要下载excel文件的headers
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="' . $csvFileName . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$fp = fopen('php://output', 'a');//打开output流
mb_convert_variables('GBK', 'UTF-8', $xlsCell);
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
foreach ($xlsData as $key => & $value) {
$xlsData[$key]['parent_id'] = get_top_promote($value['promote_id'], $value['parent_id']);
$xlsData[$key]['pay_way'] = get_pay_way($value['pay_way']);
$xlsData[$key]['promote_id'] = get_promote_business_account($value['promote_id']);
$xlsData[$key]['is_check'] = get_info_status($value['is_check'],37);
$xlsData[$key]['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']);
}
$accessNum =D('Spend')
// 查询条件
->where($map)
/* 默认通过id逆序排列 */
->order('tab_spend.id desc')
/* 执行查询 */
->count();
$perSize = 5000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
$lastId = 0;
for($i = 1; $i < = $pages; $i++) {
$xlsData = D('Spend')
->field("tab_spend.pay_order_number,tab_spend.pay_time,promote_account,parent_id,user_account,game_name,server_name,game_player_name,
spend_ip,pay_amount,cost,pay_way,tab_spend.promote_id,is_check,ba_id,
REPLACE(substring_index(tab_promote.chain, '/', 2),'/','') as top_promote,tab_business_affairs.account")
->join("left join tab_promote on tab_spend.promote_id = tab_promote.id")
->join("left join tab_business_affairs on tab_promote.ba_id = tab_business_affairs.id")
// 查询条件
->where($map)
->limit(($i-1)*$perSize ,$perSize)
/* 默认通过id逆序排列 */
->order('tab_spend.id desc')
/* 执行查询 */
->select(false);
// $xlsCell = array(
// array('pay_order_number', "订单号"),
// array('pay_time', "充值时间"),
// array('promote_account', L('Subordinate_channel')),
// array('parent_id', "上级推广员"),
// array('user_account', "玩家账号"),
// array('game_name', "游戏名称"),
// array('server_name', L('Game_area_clothing')),
// array('game_player_name', "角色名"),
// array('spend_ip', "充值ip"),
// array('pay_amount', "应付金额"),
// array('cost', "实付金额"),
// array('pay_way', "充值方式"),
// array('promote_id', '商务专员'),
// array('is_check','对账状态')
// );
$this->exportExcel($xlsName, $xlsCell, $xlsData);
$xlsData = M()->table("({$xlsData}) as a")
->field("a.pay_order_number,a.pay_time,a.promote_account,tab_promote.account as parent_id,
a.user_account,a.game_name,a.server_name,a.game_player_name,a.spend_ip,a.pay_amount,a.cost,
a.pay_way,a.account,a.is_check")
->join("left join tab_promote on a.top_promote=tab_promote.id")
->select();
}
foreach ($xlsData as $key => & $value) {
if (!$value['account']) {
$value['account'] = "暂无";
}
// $xlsData[$key]['parent_id'] = get_top_promote($value['promote_id'], $value['parent_id']);
$xlsData[$key]['pay_way'] = get_pay_way($value['pay_way']);
// $xlsData[$key]['promote_id'] = get_promote_business_account($value['promote_id']);
$xlsData[$key]['is_check'] = get_info_status($value['is_check'], 37);
$xlsData[$key]['pay_time'] = date('Y-m-d H:i:s', $value['pay_time']);
mb_convert_variables('GBK', 'UTF-8', $value);
fputcsv($fp, $value);
}
unset($xlsData);//释放变量的内存
//刷新输出缓冲到浏览器
ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
}
fclose($fp);
exit();
// $this->exportExcel($xlsName, $xlsCell, $xlsData);
}
function exportFinanceIndex() {