提交 eb109369 authored 作者: wangkr's avatar wangkr

调整 账单balance的条件,按照balance剩余数值生成缴费单

上级 a6ff70f8
......@@ -188,7 +188,7 @@ class Payment extends Base
if(!$payment) return json(['status'=>0,'message'=>'单据:'.$epiModel->payment_id.'出现异常,单据与账单关系存在,但缴费单不存在!']);
//如果缴费单并未缴费
if($payment->amount > 0){
if($payment->balance > 0){
$message = '账单号: '.$inv->invoice_id.' 已经与缴费单:'.$payment->payment_id.'挂起,无法生成缴费单';
return json(['status'=>0,'message'=>$message]);
} else {
......@@ -475,16 +475,21 @@ class Payment extends Base
if($inv->payment_balance == 0){
$inv->paid_amount = $inv->payment_amount;
} else {
$inv->paid_amount = $inv->payment_amount - $inv->payment_balance;
$inv->paid_amount = $inv->payment_balance;
}
}
}
$payway = $this->getFkInfo(1);
$org = $this->getFkInfo(2);
$this->assign('invs',$invs);
$this->assign('payment_id',$payment_id);
$this->assign('payee',$this->getGys($staff->email));
$this->assign('org',$this->getFkInfo(2));
$this->assign('payway',$this->getFkInfo(1));
$this->assign('org',$org);
$this->assign('date',date('Y-m-d H:i:s'));
$this->assign('payway',$payway);
return $this->fetch('pay_oa');
}
......@@ -503,19 +508,19 @@ class Payment extends Base
$details = [];
if($payment->payment_type == 2 || $payment->payment_type == 4){
$details[0]['charge_type'] = "维护电费";
$details[0]['charge_type'] = $post['fkitem'];
$details[0]['amount'] = $payment->amount;
$details[0]['cbzxid'] = $this->getCbzxIdByEmId($payment->em_id);
} else {
$invs = (new EmPayment())->getinvsInfo($payment->payment_id);
foreach ($invs as $k => $inv){
$details[$k]['charge_type'] = "维护电费";
$details[$k]['charge_type'] = $post['fkitem'];
if($inv->payment_balance == 0){
$details[$k]['amount'] = 0;
} else if($inv->payment_amount == $inv->payment_balance){
$details[$k]['amount'] = $inv->payment_amount;
} else {
$details[$k]['amount'] = $inv->payment_amount - $inv->payment_balance;
$details[$k]['amount'] = $inv->payment_balance;
}
$details[$k]['cbzxid'] = $this->getDetailsFields($inv->account_id);
}
......@@ -531,6 +536,7 @@ class Payment extends Base
'info'=>$post['info'],
'cause'=>$post['cause'],
'date'=>$post['date'],
'payment_id' => $payment->payment_id,
'details'=> $details
];
......@@ -587,9 +593,14 @@ class Payment extends Base
$res = httpPOST($url,$data);
$res = json_decode($res,true);
foreach ($res['data'] as $k => $v){
$temp = [];
if(!empty($v['bank_info'])){
foreach ($v['bank_info'] as $a => $b){
$temp[$a] = '银行名称: '.$b['open_bank_name']. '账号: '.$b['bank_code'];
$info = "账户名称:" . $b['bank_holder'] .',';
$info .= "开户银行:" . $b['open_bank_name'].',';
$info .= "银行账号:" . $b['bank_code'].',';
$info .= "开户行地址:" . $b['open_address'];
$temp[$a] = $info;
}
$res['data'][$k]['bankInfo'] = json_encode($temp);
}
......@@ -599,9 +610,9 @@ class Payment extends Base
//获取付款所需信息
public function getFkInfo($type){
$url = config('oafk.base_url').config('oafk.type') . $this->apiKey();
$data = ['type'=>$type];
$res = httpPOST($url, $data);
$res = httpPOST($url,['type'=>$type]);
$res = json_decode($res,true);
return $res['data'];
}
......@@ -609,9 +620,8 @@ class Payment extends Base
//创建付款编号
public function createFkNumb($data){
$url = config('oafk.base_url').config('oafk.fk') . $this->apiKey();
$res = httpPOST($url, ['data'=>json_encode($data)]);
// $end = strpos($res,'}');
// $str = substr($res,$start,$end);
$data = ['data'=>$data];
$res = httpPOST($url, $data);
$res = json_decode($res,true);
return $res;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论