新增打款账号编辑

master
chenzhi 4 years ago
parent 1fb81f9e3e
commit 844a6d501e

@ -0,0 +1,122 @@
<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use Think\Model;
/**
* 支付/付款商户
*/
class TransferMerchantController extends ThinkController
{
public $TransferMerchant;
public function __construct()
{
$this->TransferMerchant = D("TransferMerchant");
parent::__construct();
}
public function lists()
{
$this->assign('statementPaymentInfo', $this->TransferMerchant->getStatementPaymentInfo());
$this->assign('underPaymentInfo', $this->TransferMerchant->getUnderPaymentInfo());
$this->display();
}
public function edit()
{
$ways = I('ways', 0);
if ($ways == 0) {
$this->error('参数错误');
}
$info = [];
if($ways == 1){
$info = $this->TransferMerchant->getStatementPaymentInfo();
}elseif($ways == 2){
$info = $this->TransferMerchant->getUnderPaymentInfo();
}else {
$this->error('参数错误');
}
$allaccount = $this->TransferMerchant->getField("id,account,name,main_name,is_free,config");
foreach ($allaccount as $key => &$val) {
$config = json_decode($val["config"],true);
foreach ($config as $k => $v) {
$val[$k] = $v;
}
unset($val["config"]);
$val['is_free_str'] = $this->TransferMerchant::IS_FREE_STR[$val['is_free']];
}
$way_str = $this->TransferMerchant::WAY_STR[$ways];
$this->meta_title = $way_str."设置";
$this->assign('allaccount', $allaccount);
$this->assign('ways',$ways);
$this->assign('info',$info);
$this->assign('way_str', $way_str);
$this->display('form');
}
public function save()
{
$id = I('id', 0);
$ways = I('ways',0);
if(empty($id) || empty($ways) || !in_array($ways,[1,2])){
$this->ajaxReturn([
'status' => 0,
'message' => '参数错误'
]);
}
if($ways == 1){
$info = $this->TransferMerchant->getStatementPaymentInfo();
}elseif($ways == 2){
$info = $this->TransferMerchant->getUnderPaymentInfo();
}
$flag = false;
if($info['id'] == $id){
$this->ajaxReturn([
'status' => 1,
'message' => '保存成功'
]);
}
$idinfo = $this->TransferMerchant->field("id,ways")->where("id = {$id}")->find();
if($idinfo['ways'] > 0){
$idsave = [
'id'=>$id,
'ways'=>$idinfo['ways']-0+$ways
];
}else{
$idsave = [
'id'=>$id,
'ways'=>$ways
];
}
$this->TransferMerchant->save($idsave);
//修改之前的
if($info['ways'] == 3){
$infosave = [
'id'=>$info['id'],
'ways'=>$info['ways']-$ways
];
}else{
$infosave = [
'id'=>$info['id'],
'ways'=>0
];
}
$this->TransferMerchant->save($infosave);
$this->ajaxReturn([
'status' => 1,
'message' => '保存成功'
]);
}
}

@ -0,0 +1,42 @@
<?php
namespace Admin\Model;
use Think\Model;
class TransferMerchantModel extends Model
{
protected $tablePrefix = 'tab_';
const WAY_STR =[
"0"=>"未启用",
"1"=>"线上对账打款",
"2"=>"线下打款",
"3"=>"通用一个账号"
];
const IS_FREE_STR = [
"1"=>"官方自营接口(提现免手续费)",
"2"=>"官方接口"
];
public function getStatementPaymentInfo()
{
$res = $this->where("ways = 1 or ways = 3")->find();
if($res){
return $this->setInfoStr($res);
}
return false;
}
public function getUnderPaymentInfo()
{
$res = $this->where("ways = 2 or ways = 3")->find();
if($res){
return $this->setInfoStr($res);
}
return false;
}
public function setInfoStr($item)
{
$item["is_free_str"] = self::IS_FREE_STR[$item["is_free"]];
return $item;
}
}

@ -0,0 +1,225 @@
<extend name="Public/base" />
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link href="__STATIC__/icons_alibaba/iconfont.css" rel="stylesheet">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="__STATIC__/provincecityarea/AreaData_min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.tabcon1711 input.time {
width: 150px;
}
#form .txt_area {
width: 300px;
height: 150px;
}
.tabcon1711 .form_unit {
margin-left: 2px;
}
.tabcon1711 .mustmark {
margin-left:-7px;
}
.list-ratio {
display: table;
}
.list-ratio .li-ratio {
display: flex;
margin-bottom: 20px;
align-items: center;
}
.list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
position: relative;
}
.list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
color: red;
position: absolute;
left: 0;
top: 30px;
white-space: nowrap;
display: none;
}
.iconfont-btn {
cursor: pointer;
}
.iconfont-style {
font-size: 18px;
color: #fff;
border-radius: 4px;
border: 0;
padding: 5px;
margin-left: 10px;
}
.iconfont-selected {
background-color: #0A9AF2;
}
.iconfont-selected:hover {
background-color: #03a9f4;
}
.iconfont-unselected {
background-color: #999;
}
.iconfont-unselected:hover {
background-color: #ababab;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<!-- <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
</div>
<!-- 标签页导航 -->
<div class="tab-wrap">
<div class="tab-content tabcon1711">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l">功能模块:</td>
<td class="r table_radio">
<input type="text" class="txt" name="wayStr" readonly value="{$way_str}">
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>账号:</td>
<td class="r">
<select name="id" id="id" class="select_gallery">
<?php foreach($allaccount as $key => $item):?>
<option value="<?=$key?>" <?php if($info && $info['id'] == $key):?>selected<?php endif;?>><?=$item['account']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l">商户主体:</td>
<td class="r table_radio">
<input type="text" class="txt setdom" name="main_name" readonly value="">
</td>
</tr>
<tr>
<td class="l">支付账户名称:</td>
<td class="r table_radio">
<input type="text" class="txt setdom" name="name" readonly value="">
</td>
</tr>
<tr>
<td class="l">接口类型:</td>
<td class="r table_radio">
<input type="text" class="txt setdom" name="is_free_str" readonly value="">
</td>
</tr>
<tr>
<td class="l noticeinfo">APPID:</td>
<td class="r table_radio">
<input name="appId" type="text" value="" readonly class="setdom">
<span class="notice-text"></span>
</td>
</tr>
<tr>
<td class="l noticeinfo">alipayUserId:</td>
<td class="r table_radio">
<input name="alipayUserId" readonly type="text" value="" class="setdom">
<span class="notice-text"></span>
</td>
</tr>
<tr>
<td class="l noticeinfo">私钥:</td>
<td class="r table_radio">
<input name="rsaPrivateKey" type="text" class="setdom" readonly value="">
</td>
</tr>
</tbody>
</table>
<div id="merchant-detail" style="margin-top: 10px;">
</div>
</div>
<input type="hidden" name="ways" id="ways" value="{$ways}" />
<div class="form-item cf">
<button class="submit_btn mlspacing" id="submit" type="submit" target-form="form-horizontal">
确认
</button>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
返回
</a>
</div>
</div>
</div>
</block>
<block name="script">
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
$(".select_gallery").select2();
var allaccount = {$allaccount|json_encode=512};
$(function(){
showTab();
$('#id').on({
change: function() {
var id = $(this).val();
setDomValue(id)
}
})
$('#id').change()
function setDomValue(id){
var data = {};
// if(id == "0"){
// data = {
// id:0,
// alipayUserId: "",
// appId: "",
// rsaPrivateKey: "",
// is_free_str:"",
// main_name:"",
// name:""
// }
// }else{
data = allaccount[id]
// }
$("#tab1 .setdom").each(function(index,dom){
let name = $(dom).attr("name");
$(dom).val(data[name])
})
}
$('#submit').click(function (e) {
var send = {
id:$("#id option:selected").val(),
ways:$("#ways").val()
}
var url = "{:U('save')}"
$.post(url,send).success(function(result){
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = '{:U("lists")}'
}, 200)
} else {
layer.msg(result.message)
}
});
});
});
</script>
</block>

@ -0,0 +1,161 @@
<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;
}
.el-card {
border-radius: 4px;
border: 1px solid #ebeef5;
background-color: #fff;
overflow: hidden;
color: #303133;
transition: .3s;
}
.el-card .card-body {
padding: 20px;
}
.el-card .card-header {
padding: 18px 20px;
border-bottom: 1px solid #ebeef5;
box-sizing: border-box;
}
.clearfix:after {
content:"";
display: block;
clear:both;
}
.set-default-btn {
border: none;
background: #3C95C8;
font-size: 14px;
font-weight: normal;
color: #fff;
cursor: pointer;
border-radius: 3px;
display: inline-block;
text-align: center;
border-bottom: none;
width: 55px;
height: 28px;
line-height: 26px;
}
</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 clearfix main-place top_nav_list navtab_list">
<h3 class="page_title">打款配置</h3>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>功能模块</th>
<th>账号</th>
<th>商户主体</th>
<th>支付账号名称</th>
<th>接口类型</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<tr >
<td>线上对账打款</td>
<empty name ="statementPaymentInfo">
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<else />
<td>{$statementPaymentInfo.account}</td>
<td>{$statementPaymentInfo.main_name}</td>
<td>{$statementPaymentInfo.name}</td>
<td>{$statementPaymentInfo.is_free_str}</td>
</empty>
<td>
<a href="<?=U('edit', ['ways' => 1])?>">编辑</a>
</td>
</tr>
<tr >
<td>线下打款</td>
<empty name ="underPaymentInfo">
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<else />
<td>{$underPaymentInfo.account}</td>
<td>{$underPaymentInfo.main_name}</td>
<td>{$underPaymentInfo.name}</td>
<td>{$underPaymentInfo.is_free_str}</td>
</empty>
<td>
<a href="<?=U('edit', ['ways' => 2])?>">编辑</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</block>
<block name="script">
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
</script>
</block>
Loading…
Cancel
Save