支付限额导出

master
sunke 5 years ago
parent 5c8221d9dc
commit ac54bb41a4

@ -2716,6 +2716,133 @@ class ExportController extends Controller
fclose($fp);
exit;
break;
case 30:
$xlsCell = array(
"限制序号","限制支付渠道", "限制规则", "限制方式", "限制时间"
);
$params = I('get.');
$payType = $params['pay_type'];
$limit_type = $params['limit_type'];
$map = [];
if (!empty($payType)) {
$map['pay_type'] = $payType;
}
if (!empty($limit_type)) {
$map['limit_type'] = $limit_type;
}
$datas = M('pay_limit_conf', 'tab_')
->field('id')
->where($map)
->order('id desc')
->select();
$csvFileName = '支付限额配置'.'.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流中
$counts = count($datas);
$perSize = 10000;//每次查询的条数
$pages = ceil($counts / $perSize);
for($i = 1; $i <= $pages; $i++) {
$datas = M('pay_limit_conf', 'tab_')
->where($map)
->order('id desc')
->limit(($i-1)*$perSize ,$perSize)
->select();
foreach ($datas as $key => $data) {
$csvdata['id'] = $data['id'];
if ($data['pay_type'] == 'alipay') {
$pay_type = '支付宝';
}
if ($data['pay_type'] == 'wxpay') {
$pay_type = '微信';
}
if ($data['pay_type'] == 'yeepay') {
$pay_type = '易宝';
}
if ($data['pay_type'] == 'sqpay') {
$pay_type = '双乾';
}
if ($data['limit_time_type'] == 'day') {
$limit_time_type = '每日,';
}
if ($data['limit_time_type'] == 'week') {
$limit_time_type = '每周,';
}
if ($data['limit_time_type'] == 'month') {
$limit_time_type = '每月,';
}
if ($data['limit_time_type'] == 'fix') {
$limit_time_type = '特殊,';
}
$csvdata['pay_type'] = $pay_type;
$limit_rule = '';
if ( $data['user_total_limit']) {
$limit_rule .= '玩家全渠道总流水限额'.$data['user_total_limit'];
}
if ( $data['total_limit']) {
$limit_rule .= '全渠道总流水限额'.$data['total_limit'];
}
if ( $data['user_one_limit']) {
$limit_rule .= '玩家单笔限制'.$data['user_one_limit'];
}
if ($limit_rule == '') {
$limit_rule = '暂无规则';
}
$csvdata['limit_rule'] = $limit_rule;
if ($data['limit_type'] == 'force') {
$csvdata['limit_type'] = '强制模式';
}
if ($data['limit_type'] == 'obstacles') {
$csvdata['limit_type'] = '障碍模式';
}
$start_timeArr = str_split($data['start_time'], 1);
$startTimeStr = '';
foreach ($start_timeArr as $timeKey => $start_time) {
if ($timeKey == 1 || $timeKey == 3) {
$startTimeStr .= $start_time.':';
}else {
$startTimeStr .= $start_time;
}
}
$end_timeArr = str_split($data['end_time'], 1);
$endTimeStr = '';
foreach ($end_timeArr as $timeKey1 => $end_time) {
if ($timeKey1 == 1 || $timeKey1 == 3) {
$endTimeStr .= $end_time. ':';
}else {
$endTimeStr .= $end_time;
}
}
$csvdata['limit_time'] = $limit_time_type .$data['limit_time_type_remark'].' '.$startTimeStr.'~'.$endTimeStr;
mb_convert_variables('GBK', 'UTF-8', $csvdata);
fputcsv($fp, $csvdata);
}
unset($csvdata);//释放变量的内存
//刷新输出缓冲到浏览器
ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
}
fclose($fp);
exit;
break;
default:
$xlsName = $xlsCell = $xlsData = [];

@ -78,6 +78,7 @@
</table>
<!-- 分页 -->
<div class="page">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>30,'xlsname'=>'支付限额配置'),I('get.')))}">导出</a>
{$_page}
</div>
</div>

Loading…
Cancel
Save