Merge pull request 'feature/finance_payment_20210115' (#97) from feature/finance_payment_20210115 into release

新增线上转线下打款
master
陈志 4 years ago
commit 3df6e7246a

@ -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 = [];
@ -135,6 +135,8 @@ class PaymentController extends BaseController
$v['verify_status_str']="信息配置不全";
$v['can_pay'] = 0;
}
$v['ali_user'] = $companypay_info['ali_user'];
$v['ali_account'] = $companypay_info['ali_account'];
if($v['pay_check'] == 0){
$v['pay_check_detail'] = "--";
@ -223,12 +225,121 @@ class PaymentController extends BaseController
$this->assign('_page', $page);
}
$this->meta_title = '打款结算单';
// dd($CompanyInfo);
$this->assign("data",$CompanyInfo);
$this->assign("money",$money);
$this->assign("CompanyType", $this->CompanyType);
$this->assign("PayStatus", $this->PayStatus);
$this->display();
}
//是否需要更新支付信息
public function IsCanChangeCompanyInfo($id = 0)
{
//获取原值
list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
$oldCompanyInfo = json_decode($oldInfo['company_info'],true);
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);
list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
//子单修改
$sWhere = [
'company_id' => $oldInfo['company_id'],
'pay_status'=> ['neq',1],
'statement_info_id' => $id
];
$PayStatementDB = M("pay_statement_info","tab_");
$statementInfo = $PayStatementDB
->where($sWhere)
->field('id,company_info')
->select();
foreach ($statementInfo as $k => $v) {
$v['company_info'] = $this->changeAliInfo($v['company_info'],$newCompanyInfo);
$PayStatementDB->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 getStatementCompanyInfo($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();
if(empty($oldInfo)){
$this->ajaxReturn(['status' =>0 ,'msg'=>'未找到此结算单信息','data'=>[]]);
}
//获取新值
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();
return [$oldInfo,$newCompanyInfo];
}
//改变支付宝信息
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 setStatementPayTapy()
{
$id = I("post.id",0);
$PayStatementDB = M("pay_statement_info","tab_");
//判断线上打款
$sWhere = [
'company_id' => $oldInfo['company_id'],
'statement_info_id' => $id
];
$sCount = $PayStatementDB->where($sWhere)->where("pay_status = 1")->count();
if($sCount > 0) {
$this->ajaxReturn(['status' =>0 ,'msg'=>'已有付款成功的子单,无法转线下','data'=>[]]);
}
//删除打款
$PayStatementDB->where($sWhere)->delete();
//修改自身
$res = M("company_statement_info","tab_")->where("id = {$id}")->save(['verify_status' => 2, 'pay_check' => 0, 'pay_check_member_id' => 0, 'pay_check_time' => 0]);
if(empty($res)){
$this->ajaxReturn(['status' =>0 ,'msg'=>'转换失败','data'=>[]]);
}
$this->ajaxReturn(['status' =>1 ,'msg'=>'成功转为线下确认','data'=>[]]);
}
//导出
public function export() {
@ -242,7 +353,7 @@ class PaymentController extends BaseController
->field("s.*,p.statement_num statement_pool_num")
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where(['s.id'=>['in',$id]])
->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
->order("statement_num desc")
->select();
foreach ($data as $key => $value) {

@ -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;
@ -236,9 +236,11 @@
<th>结算时间</th>
<th>关联汇总单号</th>
<th>结算金额</th>
<th>支付宝真实姓名</th>
<th>支付宝账号</th>
<th>打款信息确认状态</th>
<!-- <th>审批状态</th>-->
<!-- <th>结算流水</th>-->
<th>打款状态</th>
<th>支付时间</th>
<th>预打款备注</th>
@ -261,11 +263,10 @@
<td>{$data.company_type}</td>
<td>{$data.valid}</td>
<td>{$data.statement_pool_num}</td>
<td>{$data.statement_money}</td>
<td>{$data.ali_user}</td>
<td>{$data.ali_account}</td>
<td>{$data.pay_check_detail}</td>
<!-- <td>{$data.verify|default='&#45;&#45;'}</td>-->
<!-- <td>{$data.platform_amount}</td>-->
<if condition="($data['verify_status'] eq -1) OR ($data['pay_status'] eq -1) ">
<td style="color: red;">{$data.verify_status_str}</td><else />
<td>{$data.verify_status_str}</td>
@ -274,10 +275,14 @@
<td>{$data.pay_time}</td>
<td>{$data.remark}</td>
<td>
<a class='confirm viewPool' data-id='{$data.id}'>查看</a>
<!-- <a class='confirm viewPool' data-id='{$data.id}'>查看</a> -->
<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 changePayTapy' data-id="{$data['id']}">转线下支付</a>
</if>
<!-- <if condition="$data['pay_check'] eq 0">-->
<!-- <a class='confirm setPayment' data-id='{$data.id}'>打款信息确认</a>-->
<!-- </if>-->
@ -295,6 +300,8 @@
<td>{$s_data.statement_pool_num}</td>
<td>{$s_data.statement_money}</td>
<td>{$data.ali_user}</td>
<td>{$data.ali_account}</td>
<td>{$data.pay_check_detail}</td>
<!-- <td>{$data.verify|default='&#45;&#45;'}</td>-->
<!-- <td>{$data.platform_amount}</td>-->
@ -390,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>
@ -431,175 +496,71 @@
}
//支付信息更新类
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>");
}
})
}
,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) {
@ -619,6 +580,31 @@
$("body").append(iframeExcel);
}
});
//修改公司信息
$(".changeCompanyInfo").on("click",function() {
const id = $(this).data('id');
ChangePayInfo.dataInit(id);
})
//线上转线下
$(".changePayTapy").on("click",function() {
const id = $(this).data('id');
//执行
layer.confirm('是否确定直接转为线下打款?转为线下打款后,该打款单将从线上打款移出转入“管理后台>财务>线下打款确认”中。如需回退需要进行重算,请慎重操作,是否确定?', {}, function(index){
var url = "{:U('setStatementPayTapy')}";
$.post(url,{id:id},function(rep){
if(rep.status == 1){
layer.msg("<font style='color: white'>"+rep.msg+"</font>",{time:1000},function(){
window.location.reload();
});
}else{
layer.msg("<font style='color: white'>"+rep.msg+"</font>");
}
})
},function(index) {
layer.close(index);
});
})
var company_id = "{$_GET['company_id']??0}";
$("#company_type").on("change",function(){

Loading…
Cancel
Save