新增更新支付信息功能ok

master
chenzhi 4 years ago
parent c45d82ff75
commit 1427e7e744

@ -110,7 +110,7 @@ class PaymentController extends BaseController
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where($map)
->page($page,$row)
->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
->order("statement_num desc")
->select();
$handleData = [];
@ -232,6 +232,93 @@ class PaymentController extends BaseController
$this->assign("PayStatus", $this->PayStatus);
$this->display();
}
//是否需要更新支付信息
public function IsCanChangeCompanyInfo($id = 0)
{
//获取原值
$oldInfo = M("company_statement_info","tab_")->field("company_info,company_id,company_type,company_name")->where("id = {$id}")->find();
if(empty($oldInfo)){
$this->ajaxReturn(['status' =>0 ,'msg'=>'未找到此结算单信息','data'=>[]]);
}
$oldCompanyInfo = json_decode($oldInfo['company_info'],true);
//获取新值
if($oldInfo['company_type'] == 3){
$Model = M("partner","tab_");
}else{
$Model = M("promote_company","tab_");
}
$newCompanyInfo = $Model->field("ali_user,ali_account")->where("id = {$oldInfo['company_id']}")->find();
if( ($oldCompanyInfo['ali_user'] == $newCompanyInfo['ali_user']) && ($oldCompanyInfo['ali_account'] == $newCompanyInfo['ali_account']) ){
$this->ajaxReturn(['status' =>0 ,'msg'=>'支付宝打款信息已是最新,无需更新','data'=>[]]);
}
$this->ajaxReturn(['status' =>1 ,'msg'=>'ok','data'=>[
'id'=>$id,
'company_name'=>$oldInfo['company_name'],
'old_ali_user'=>$oldCompanyInfo['ali_user'],
'old_ali_account'=>$oldCompanyInfo['ali_account'],
'new_ali_user'=>$newCompanyInfo['ali_user'],
'new_ali_account'=>$newCompanyInfo['ali_account']
]]);
}
//执行更新支付信息
public function DoChangeCompanyInfo()
{
$id = I("post.id",0);
$oldInfo = M("company_statement_info","tab_")->field("id,company_info,company_id,company_type,company_name,pool_id,withdraw_type")->where("id = {$id}")->find();
$oldCompanyInfo = json_decode($oldInfo['company_info'],true);
//获取新值
if($oldInfo['company_type'] == 3){
$Model = M("partner","tab_");
}else{
$Model = M("promote_company","tab_");
}
$newCompanyInfo = $Model->field("ali_user,ali_account")->where("id = {$oldInfo['company_id']}")->find();
//子单修改
$sWhere = [
'company_id' => $oldInfo['company_id'],
'pay_status'=> ['neq',1],
'statement_info_id' => $id
];
$StatementDB = M("pay_statement_info","tab_");
$statementInfo = $StatementDB
->where($sWhere)
->field('id,company_info')
->select();
foreach ($statementInfo as $k => $v) {
$v['company_info'] = $this->changeAliInfo($v['company_info'],$newCompanyInfo);
$StatementDB->save($v);
}
//修改结算单
if($oldInfo['company_type'] != 2 || $oldInfo['withdraw_type'] == 3){
//获取汇总单号
$statement_num = M("company_statement_pool","tab_")->where("id = {$oldInfo['pool_id']}")->getField("statement_num");
$StatementDB = M("company_statement","tab_");
$statementList = $StatementDB->field('id,pay_type,first_party_info,second_party_info')->where(['verify_log'=>["like","%{$statement_num}%"],'company_id'=>$oldInfo['company_id']])->select();
foreach ($statementList as $k => $v) {
if($v['pay_type'] == 1){
$v['first_party_info'] = $this->changeAliInfo($v['first_party_info'],$newCompanyInfo);
}else{
$v['second_party_info'] = $this->changeAliInfo($v['second_party_info'],$newCompanyInfo);
}
$StatementDB->save($v);
}
}
//修改自身
$oldInfo['company_info'] = $this->changeAliInfo($oldInfo['company_info'],$newCompanyInfo);
$res = M("company_statement_info","tab_")->save($oldInfo);
if(empty($res)){
$this->ajaxReturn(['status' =>0 ,'msg'=>'更新信息失败','data'=>[]]);
}
$this->ajaxReturn(['status' =>1 ,'msg'=>'支付信息更新成功','data'=>[]]);
}
protected function changeAliInfo($item,$newInfo)
{
$companyInfo = json_decode($item,true);
$companyInfo['ali_user'] = $newInfo['ali_user'];
$companyInfo['ali_account'] = $newInfo['ali_account'];
return json_encode($companyInfo,JSON_UNESCAPED_UNICODE);
}
//导出
public function export() {

@ -8,7 +8,7 @@
<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="__STATIC__/layer3/layer.js"></script>
<script src="__STATIC__/juicer-min.js" type="text/javascript"></script>
<style>
.select2-container--default .select2-selection--single {
color: #000;
@ -279,6 +279,10 @@
<if condition="$data['pay_status'] neq 0 and count($data['son_info']) elt 1">
<a class='confirm paymentInfo' data-id="{$data['son_info'][0]['id']}">打款详情</a>
</if>
<if condition="$data['pay_status'] neq 1">
<a class='confirm changeCompanyInfo' data-id="{$data['id']}">支付信息更新</a>
<a class='confirm changeCompanyInfo' data-id="{$data['id']}">转线下支付</a>
</if>
<!-- <if condition="$data['pay_check'] eq 0">-->
<!-- <a class='confirm setPayment' data-id='{$data.id}'>打款信息确认</a>-->
<!-- </if>-->
@ -393,6 +397,64 @@
</div>
</div>
<div id="changeInfoShow">
</div>
<script id="changeInfoTpl" type="text/template">
<div style="width: 100vw;height:100vh;padding: 0;position: absolute;top: 0;z-index: 9999;background-color:rgba(0,0,0,.6);right: 1px;">
<div class="layui-layer layui-layer-hui" style="width:800px;height:440px;z-index: 19891015; top:28%; left:50%;margin-left: -400px;border-radius: 2%;background-color:white;color: #0a001f;">
<div style="padding: 15px 30px 15px 20px;font-size: 18px;">信息更新提示</div>
<div class="layui-layer-content" style="font-size: 16px;color: red;text-align: left;">信息更新后,子单及汇总单上该公司的信息将同步更新</div>
<div class="layui-layer-content" style="font-size: 22px;padding: 5px 25px;height: 200px;overflow-x:hidden;overflow-y:scroll">
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>合作公司名称</th>
<th>原支付宝用户</th>
<th>原支付宝账号</th>
<th>新支付宝用户</th>
<th>新支付宝账号</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<tr>
<td>${company_name}</td>
<td>${old_ali_user}</td>
<td>${old_ali_account}</td>
<td>${new_ali_user}</td>
<td>${new_ali_account}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div style="text-align: right;margin-top: 20px">
<div style="font-size: 28px;display: inline-block;">
<div class="search_list" style="justify-content:flex-end;width:100%;">
<div class="input-list" style="float: right;">
<a class="sch-btn" href="javascript:;" style="width: 150px;background: white;border: 1px solid black;color: black" id="changeInfoBack">返回</a>
</div>
</div>
</div>
<div style="padding: 0 20px 0 0;font-size: 28px;display: inline-block;">
<div class="search_list" style="justify-content:flex-end;width:100%;">
<div class="input-list" style="float: right;">
<a class="sch-btn" href="javascript:;" style="width: 150px;" id="changeInfoSure">确认修改</a>
</div>
</div>
</div>
</div>
</div>
</div>
</script>
</block>
@ -434,175 +496,72 @@
}
//支付信息更新类
var ChangePayInfo = {
defaultData:{
id:0,
company_name:"",
old_ali_user:"",
old_ali_account:"",
new_ali_user:"",
new_ali_account:""
}
,data : {}
,dataInit(id){
var url = "{:U('IsCanChangeCompanyInfo')}"+"&id="+id;
$.get(url,function(rep){
if(rep.status == 1){
ChangePayInfo.data = rep.data;
ChangePayInfo.display();
}else{
ChangePayInfo.remove();
layer.msg("<font style='color: white'>"+rep.msg+"</font>");
}
console.log(data);
})
}
,doChangeCompanyInfo(){
var url = "{:U('DoChangeCompanyInfo')}";
var id = this.data.id;
$.post(url,{id:id},function(rep){
if(rep.status == 1){
ChangePayInfo.remove();
layer.msg("<font style='color: white'>"+rep.msg+"</font>",{time:1000},function(){
window.location.reload();
});
}else{
ChangePayInfo.remove();
layer.msg("<font style='color: white'>"+rep.msg+"</font>");
}
})
}
,display(){
var tpl = $("#changeInfoTpl").html();
var html = juicer(tpl, ChangePayInfo.data);
$("#changeInfoShow").html(html);
this.event();
}
,remove(){
ChangePayInfo.data = ChangePayInfo.defaultData;
$("#changeInfoShow").html('');
}
,event(){
$("#changeInfoSure,#changeInfoBack").off("click");
$("#changeInfoBack").on("click",function() {
ChangePayInfo.remove();
})
$("#changeInfoSure").on("click",function() {
ChangePayInfo.doChangeCompanyInfo();
})
}
}
$("#back,#window").click(function() {
$('#window').hide();
});
$(function(){
// $(".return_verify").click(function () {
//
// var status = $(this).data('value');
// var verifytip = 0;
// var paytip = 0;
// var canpay = 0;
//
// var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
//
// var verifystatus = $(elem).data('verifystatus');
// var pay_status = $(elem).data('paystatus');
//
// if (verifystatus == 0) {
// verifytip = 1;
// return ;
// }
//
// if (pay_status != 0) {
// paytip = 1;
// return ;
// }
//
// return $(elem).data('verify_id');
//
// }).get();
//
// if (verifytip == 1) {
// layer.msg("<font style='color:white'>" + '请选择已审核的打款单' + "</font>");
// return;
// }
//
// if (paytip == 1) {
// layer.msg("<font style='color:white'>" + '请选择未打款的打款单' + "</font>");
// return;
// }
//
// if(text.length < 1){
// layer.msg("<font style='color:white'>" + '请先选择要操作的打款单' + "</font>");
// return;
// }
//
// layer.confirm('【提示】是否取消审核'+((status==1)?'通过':'拒绝'), {
// btn: ['确认','取消'],
// title:false
// }, function(){
// $.ajax({
// type:'post',
// dataType:'json',
// data: {'id':text,'status':status},
// url:"{:U('verify')}",
// success:function(data) {
//
// if (data.status ==1) {
// //弹框
// layer.msg("<font style='color:white'>审批撤回成功</font>");
// setTimeout(function(){
// window.location.reload();
// },1500);
// } else {
// layer.msg("<font style='color:white'>审批撤回失败</font>");
// }
// },
// error:function() {
// alert('服务器开小差了,请稍后再试。');
// // checkcode(mobile);
// }
// });
//
// });
//
// });
//
//
// $(".verify").click(function () {
//
// var status = $(this).data('value');
// var verifytip = 0;
// var paytip = 0;
// var canpay = 0;
// var paychecktip = 0;
//
// var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
//
// var verifystatus = $(elem).data('verifystatus');
// var pay_status = $(elem).data('paystatus');
//
// if (verifystatus > 0) {
// verifytip = 1;
// return ;
// }
//
// if (pay_status != 0) {
// paytip = 1;
// return ;
// }
//
// if($(elem).data("pay") != 1) {
// canpay = 1;
// return;
// }
//
// if($(elem).data("pay_check") == 0) {
// paychecktip = 1;
// return;
// }
//
// return $(elem).data('verify_id');
//
// }).get();
//
// if (paychecktip == 1) {
// layer.msg("<font style='color:white'>" + '请选择打款信息已确认的打款单' + "</font>");
// return;
// }
//
// if (verifytip == 1) {
// layer.msg("<font style='color:white'>" + '请选择未审核的打款单' + "</font>");
// return;
// }
//
// if (paytip == 1) {
// layer.msg("<font style='color:white'>" + '请选择未打款的打款单' + "</font>");
// return;
// }
//
// if (canpay == 1) {
// layer.msg("<font style='color:white'>" + '请选择信息配置完全的打款单' + "</font>");
// return;
// }
//
// if(text.length < 1){
// layer.msg("<font style='color:white'>" + '请先选择要操作的打款单' + "</font>");
// return;
// }
//
// layer.confirm('【提示】是否确认审核'+((status==1)?'通过':'拒绝'), {
// btn: ['确认','取消'],
// title:false
// }, function(){
// $.ajax({
// type:'post',
// dataType:'json',
// data: {'id':text,'status':status},
// url:"{:U('verify')}",
// success:function(data) {
// layer.msg("<font style='color:white'>" + data.msg + "</font>");
// if (data.status ==1) {
// //弹框
// setTimeout(function(){
// window.location.reload();
// },1500);
// }
// },
// error:function() {
// alert('服务器开小差了,请稍后再试。');
// // checkcode(mobile);
// }
// });
//
// });
//
// });
$("#export").click(function () {
var flag = false;
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
@ -622,6 +581,10 @@
$("body").append(iframeExcel);
}
});
$(".changeCompanyInfo").on("click",function() {
const id = $(this).data('id');
ChangePayInfo.dataInit(id);
})
var company_id = "{$_GET['company_id']??0}";
$("#company_type").on("change",function(){

Loading…
Cancel
Save