新增商户支付导出

master
chenzhi 3 years ago
parent 2d1da379b0
commit d60330a093

@ -396,10 +396,15 @@ class PaymentMerchantController extends ThinkController
$alipayId = I('alipay_merchant_id', 0);
$weixinId = I('weixin_merchant_id', 0);
$expressId = I('express_merchant_id', 0);
$timeType = I('time_type', 1);
$export = I('export', 0);
$conditions = [];
$conditions = ["_string"=>"1=1"];
if ($companyBelong != -1) {
$conditions['company_belong'] = $companyBelong;
// $conditions['company_belong'] = $companyBelong;
$promoteCompanyIds = M("promote_company","tab_")->where("company_belong = '{$companyBelong}'")->getField("id",true);
$promoteCompanyIds = implode(",",$promoteCompanyIds);
$conditions['_string'].=" AND ( r.company_belong = {$companyBelong} or company_id in ({$promoteCompanyIds}) )";
}
if ($companyId != 0) {
$conditions['company_id'] = $companyId;
@ -422,7 +427,7 @@ class PaymentMerchantController extends ThinkController
[$start, $end] = $this->getEffectiveTimeRange($startedAt, $endedAt);
// var_dump($start, $end);die();
$timeCondition = ' ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
$timeCondition = ' AND ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
. ') OR (end_time >= ' . $start . ' AND end_time <= ' . $end . '))';
if (isset($conditions['_string'])) {
$conditions['_string'] .= $timeCondition;
@ -430,16 +435,25 @@ class PaymentMerchantController extends ThinkController
$conditions['_string'] = $timeCondition;
}
if($timeType == 2){
$now = strtotime(date("Y-m-d") . ' 00:00:00');
$conditions['_string'] .= ' AND ( start_time <= ' . $now . " AND end_time >= {$now} )";
}
$paymentRuleService = new PaymentRuleService();
$gameService = new GameService();
$paymentMerchantService = new PaymentMerchantService();
$companyService = new PromoteCompanyService();
$query = M('payment_rule', 'tab_')->where($conditions);
$query = M('payment_rule', 'tab_')->alias("r")->field("r.*,pc.company_belong pc_company_belong")->where($conditions)->join("tab_promote_company as pc on pc.id = r.company_id","left");
$countQuery = clone $query;
if($export == 1){
$items = $query->order('start_time desc')->select();
}else{
$items = $query->order('start_time desc')->page($page, $row)->select();
}
$items = $query->order('start_time desc')->page($page, $row)->select();
$count = $countQuery->count();
$gameTypes = $gameService->getGameTypes(null, 'id,type_name');
@ -457,7 +471,7 @@ class PaymentMerchantController extends ThinkController
foreach ($items as $item) {
$records[] = [
'id' => $item['id'],
'company_type_name' => $companyTypes[$item['company_belong']] ?? '--',
'company_type_name' => $companyTypes[$item['company_belong']] ?? ($companyTypes[$item['pc_company_belong']] ?? '--') ,
'company_name' => isset($companies[$item['company_id']]) ? $companies[$item['company_id']]['company_name'] : '--',
'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']]['name'] : '--',
'game_type_name' => isset($gameTypes[$item['game_type_id']]) ? $gameTypes[$item['game_type_id']]['type_name'] : '--',
@ -470,6 +484,21 @@ class PaymentMerchantController extends ThinkController
'effective_time_display' => $paymentRuleService->getEffectiveTimeDisplay($item)
];
}
if($export == 1){
data2csv($records,'支付商户配置',array(
"company_type_name"=>"公司类型",
"company_name"=>"推广公司",
"game_type_name"=>"游戏类型",
"game_name"=>"游戏产品",
"alipay_merchant_name"=>"支付宝支付配置",
"alipay_merchant_account"=>"商户账号",
"weixin_merchant_name"=>"微信支付配置",
"weixin_merchant_account"=>"商户账号",
'express_merchant_name' => '快捷支付配置',
'express_merchant_account' =>'商户账号',
'effective_time_display'=>'生效时间'
));
}
$page = set_pagination($count, $row);
if($page) {
@ -803,112 +832,4 @@ class PaymentMerchantController extends ThinkController
]
]);
}
public function effectiveRules()
{
$page = I('p', 1);
$row = I('row', 10);
$companyBelong = I('company_belong', -1);
$companyId = I('company_id', 0);
$gameTypeId = I('game_type_id', 0);
$gameId = I('game_id', 0);
$startedAt = I('started_at', '');
$endedAt = I('ended_at', '');
$alipayId = I('alipay_merchant_id', 0);
$weixinId = I('weixin_merchant_id', 0);
$expressId = I('express_merchant_id', 0);
$conditions = [];
if ($companyBelong != -1) {
$conditions['company_belong'] = $companyBelong;
}
if ($companyId != 0) {
$conditions['company_id'] = $companyId;
}
if ($gameTypeId != 0) {
$conditions['game_type_id'] = $gameTypeId;
}
if ($gameId != 0) {
$conditions['game_id'] = $gameId;
}
if ($alipayId != 0) {
$conditions['alipay_merchant_id'] = $alipayId;
}
if ($weixinId != 0) {
$conditions['weixin_merchant_id'] = $weixinId;
}
if ($expressId != 0) {
$conditions['express_merchant_id'] = $expressId;
}
[$start, $end] = $this->getEffectiveTimeRange($startedAt, $endedAt);
// var_dump($start, $end);die();
$timeCondition = ' ((start_time >= ' . $start . ' AND start_time <= ' . $end . ') OR (start_time <= ' . $start . ' AND end_time >= ' . $end
. ') OR (end_time >= ' . $start . ' AND end_time <= ' . $end . '))';
if (isset($conditions['_string'])) {
$conditions['_string'] .= $timeCondition;
} else {
$conditions['_string'] = $timeCondition;
}
$paymentRuleService = new PaymentRuleService();
$gameService = new GameService();
$paymentMerchantService = new PaymentMerchantService();
$companyService = new PromoteCompanyService();
$query = M('payment_rule', 'tab_')->where($conditions);
$countQuery = clone $query;
$items = $query->order('start_time desc')->page($page, $row)->select();
$count = $countQuery->count();
$gameTypes = $gameService->getGameTypes(null, 'id,type_name');
$games = $gameService->getBaseGames(null, 'id,name');
$companies = $companyService->getCompanies(null, 'id,company_name');
$companyTypes = PromoteCompanyService::$belongs;
$merchantIds = array_merge(
array_column($items, 'alipay_merchant_id'),
array_column($items, 'weixin_merchant_id'),
array_column($items, 'express_merchant_id')
);
$merchants = $paymentMerchantService->getMerchantsByIds($merchantIds, 'id,channel,name,account');
$records = [];
foreach ($items as $item) {
$records[] = [
'id' => $item['id'],
'company_type_name' => $companyTypes[$item['company_belong']] ?? '--',
'company_name' => isset($companies[$item['company_id']]) ? $companies[$item['company_id']]['company_name'] : '--',
'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']]['name'] : '--',
'game_type_name' => isset($gameTypes[$item['game_type_id']]) ? $gameTypes[$item['game_type_id']]['type_name'] : '--',
'alipay_merchant_name' => isset($merchants[$item['alipay_merchant_id']]) ? $merchants[$item['alipay_merchant_id']]['name'] : '系统默认商户',
'alipay_merchant_account' => isset($merchants[$item['alipay_merchant_id']]) ? $merchants[$item['alipay_merchant_id']]['account'] : '系统默认商户',
'weixin_merchant_name' => isset($merchants[$item['weixin_merchant_id']]) ? $merchants[$item['weixin_merchant_id']]['name'] : '系统默认商户',
'weixin_merchant_account' => isset($merchants[$item['weixin_merchant_id']]) ? $merchants[$item['weixin_merchant_id']]['account'] : '系统默认商户',
'express_merchant_name' => isset($merchants[$item['express_merchant_id']]) ? $merchants[$item['express_merchant_id']]['name'] : '系统默认商户',
'express_merchant_account' => isset($merchants[$item['express_merchant_id']]) ? $merchants[$item['express_merchant_id']]['account'] : '系统默认商户',
'effective_time_display' => $paymentRuleService->getEffectiveTimeDisplay($item)
];
}
$page = set_pagination($count, $row);
if($page) {
$this->assign('_page', $page);
}
$aliMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_ALIPAY);
$weixinMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_WEIXIN);
$expressMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_EXPRESS);
$this->assign('aliMerchants', $aliMerchants);
$this->assign('weixinMerchants', $weixinMerchants);
$this->assign('expressMerchants', $expressMerchants);
$this->assign('records', $records);
$this->assign('games', $games);
$this->assign('gameTypes', $gameTypes);
$this->assign('companyTypes', $companyTypes);
$this->assign('companies', $companies);
$this->display();
}
}

@ -1,289 +0,0 @@
<extend name="Public/base"/>
<block name="css">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" href="__CSS__/promote.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
height:28px;border-radius:3px;font-size:12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height:35px;
line-height:28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height:26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height:26px;line-height:26px;font-size:12px;
}
.select2-results__option[aria-selected] {font-size:12px;}
.textarea-style {
width: 200px;
height: 80px;
border-radius: 5px;
padding: 5px;
}
.mustmark {
color: #FF0000;
font-style: normal;
margin: 0 3px;
}
</style>
</block>
<block name="body">
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.form.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a href="{:U('rules')}">所有配置</a>
<a class="tabchose" href="{:U('effectiveRules')}">生效配置</a>
</div>
<h3 class="page_title">支付商户配置</h3>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<div class="input-list">
<select id="company_belong_select" name="company_belong" class="select_gallery" style="width:200px;">
<option value="">请选择公司类型</option>
<?php foreach($companyTypes as $key => $name):?>
<option value="<?=$key?>"><?=$name?></option>
<?php endforeach;?>
</select>
</div>
<!-- <div class="input-list input-list-promote search_label_rehab">
<select id="company_select" name="company_id" class="select_gallery" style="width:200px;">
<option value="">请选择公司</option>
<?php foreach($companies as $company):?>
<option value="<?=$company['id']?>"><?=$company['company_name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="game_type_select" name="game_type_id" class="select_gallery" style="width:200px;">
<option value="">请选择游戏类型</option>
<?php foreach($gameTypes as $gameType):?>
<option value="<?=$gameType['id']?>"><?=$gameType['type_name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="game_select" name="game_id" class="select_gallery" style="width:200px;">
<option value="">请选择游戏</option>
<?php foreach($games as $game):?>
<option value="<?=$game['id']?>"><?=$game['name']?></option>
<?php endforeach;?>
</select>
</div> -->
<div class="input-list">
<input type="text" id="started_at" name="started_at" class="time" value="" placeholder="生效时间" autocomplete="off" />
<!-- -
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" id="ended_at" name="ended_at" class="time" value="" placeholder="生效结束时间" autocomplete="off" />
<span class="add-on"><i class="icon-th"></i></span>
</div> -->
</div>
<!-- <br> -->
<div class="input-list input-list-promote search_label_rehab">
<select name="alipay_merchant_id" id="alipay-merchant-select" class="select_gallery" style="width:200px;">
<option value="0">支付宝支付配置商户</option>
<?php foreach($aliMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="weixin_merchant_id" id="weixin-merchant-select" class="select_gallery" style="width:200px;">
<option value="0">微信支付配置商户</option>
<?php foreach($weixinMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select name="express_merchant_id" id="express-merchant-select" class="select_gallery" style="width:200px;">
<option value="0">快捷支付配置商户</option>
<?php foreach($expressMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('effectiveRules')}">搜索</a>
</div>
<!-- <div class="input-list">
<a class="sch-btn" href="{:U('Export/expUser',array_merge(array('id'=>12,),I('get.')))}">导出</a>
</div> -->
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>公司类型</th>
<th>推广公司</th>
<th>游戏类型</th>
<th>游戏产品</th>
<th>支付宝支付配置</th>
<th>商户账号</th>
<th>微信支付配置</th>
<th>商户账号</th>
<th>快捷支付配置</th>
<th>商户账号</th>
<th>生效时间</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name ="records">
<td colspan="12" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="records" id="data">
<tr data-id="<?=$data['id']?>">
<td>{$data.company_type_name}</td>
<td>{$data.company_name}</td>
<td>{$data.game_type_name}</td>
<td>{$data.game_name}</td>
<td>{$data.alipay_merchant_name}</td>
<td>{$data.alipay_merchant_account}</td>
<td>{$data.weixin_merchant_name}</td>
<td>{$data.weixin_merchant_account}</td>
<td>{$data.express_merchant_name}</td>
<td>{$data.express_merchant_account}</td>
<td>{$data.effective_time_display}</td>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="Query/withdraw">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script src="__STATIC__/jquery.cookie.js" charset="utf-8"></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('rules')}");
$(function(){
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&"+$('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
})
$('.time').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
autoclose: true,
scrollMonth: false,
scrollTime: false,
scrollInput: false,
startView: 'month',
minView:'month',
maxView:'month',
});
function getIds() {
var ids = [];
$('.ids:checked').each(function() {
ids.push($(this).val());
})
return ids;
}
function deleteRule(id) {
$.ajax({
url: '{:U("deleteRule")}',
type: 'post',
dataType: 'json',
data: {id: id},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = window.location.href
}, 200)
} else {
layer.msg(result.message)
}
}
})
}
$('.delete-btn').on({
click: function() {
var id = $(this).parents('tr').eq(0).attr('data-id')
layer.confirm('确定要删除该规则 ?请确保删除后时间范围内规则完整!', {icon: 3, title:'提示'}, function(index){
deleteRule(id)
})
}
})
});
/* $(".export-btn").on("click",function(e){
e.preventDefault();
window.location.href=$(this).attr("href")
}) */
</script>
</block>

@ -48,10 +48,6 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="tabchose" href="{:U('rules')}">所有配置</a>
<a href="{:U('effectiveRules')}">生效配置</a>
</div>
<h3 class="page_title">支付商户配置</h3>
</div>
<div class="cf top_nav_list">
@ -100,6 +96,12 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="time_type" name="time_type" class="select_gallery" style="width:150px;">
<option value="1" <if condition="$_GET['time_type'] eq 1">selected</if>>历史所有</option>
<option value="2" <if condition="$_GET['time_type'] eq 2">selected</if>>当前生效</option>
</select>
</div>
<br>
<div class="input-list input-list-promote search_label_rehab">
<select name="alipay_merchant_id" id="alipay-merchant-select" class="select_gallery" style="width:200px;">
@ -189,10 +191,7 @@
</div>
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<!-- <a class="sch-btn export-btn"
href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a> -->
</if>
<a class="sch-btn export-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>

Loading…
Cancel
Save