提交 c4e048c7 authored 作者: chengye's avatar chengye

test

上级 cb599ead
......@@ -238,11 +238,6 @@ class Invoice extends Base
return $inv;
}
protected function recharge(){
}
public function updatePayment(){
$data = Request::param();
......@@ -286,80 +281,6 @@ class Invoice extends Base
return $this->fetch('merge_list');
}
/**
* @param $account_id
* @param $invoiceIds
* @param $paymentIds
* @return mixed
*/
/*
private function writeOff($paymentIds,$invoiceIds){
//获取可销账缴费单
$payments = EmPayment::where('payment_id','in',$paymentIds)->select();
//获取可销账账单
$invs = EmInvoice::where('invoice_id','in',$invoiceIds)->select();
$result = 0;
foreach ($payments as $key => $payment){
if($payment->balance == 0) continue;
foreach ($invs as $index => $inv) {
$balanceMode = new EmPaymentInvoiceBalance();
$balanceMode->payment_id = $payment->payment_id;
if ($inv->payment_balance == 0) continue;
$balanceMode->invoice_id = $inv->invoice_id;
//如果该缴费单可以完全消除当前账单额度
if ($payment->balance >= $inv->payment_balance) {
//单笔销账多少
$balanceMode->balance = $inv->payment_balance;
$payment->balance = $payment->balance - $inv->payment_balance;
//账单额度变化
$inv->payment_balance = 0;
//更新账户status 首字母 = 2
$inv->status = setInvoiceStatus($inv->status, 2);
} else {
//单笔销账多少
$balanceMode->balance = $payment->balance;
//账单额度变化
$inv->status = setInvoiceStatus($inv->status, 1);
$inv->payment_balance = $inv->payment_balance - $payment->balance;
//缴费额度变化
$payment->balance = 0;
}
//查找是否已经存在相关联的账单关系
$model = (new EmPaymentInvoice())->where(['payment_id'=>$payment->payment_id,'invoice_id'=>$inv->invoice_id])->find();
if(!$model){
$model = new EmPaymentInvoice();
$model->payment_id = $payment->payment_id;
$model->invoice_id = $inv->invoice_id;
$model->save();
}
$result++;
//更新账单状态
$inv->save();
//更新缴费状态
$payment->save();
unset($payments[$key]);
$balanceMode->isUpdate(false)->save();
//更新账户余额
$account = EmAccount::get(['account_id'=>$inv->account_id]);
$account->amount -= $balanceMode->balance;
$account->save();
}
}
$msg = $result == 0 ? '已审核,没有可销账的账单.' : '已审核,成功销账 '.$result.' 笔账单.';
return $msg;
}
*/
public function writeOffFromSettle($account_id,$settle_id){
//获取缴费单对象
$settle = EmSettle::where('settle_id','=',$settle_id)->find();
......
......@@ -146,13 +146,29 @@ class Payment extends Base
//首先查询这些账单是否具备生成条件
$eiModel = new EmInvoice();
$invs = $eiModel->where('payment_balance','neq',0)
->where(['invoice_id'=>$ids])->order('invoice_id asc')->select();
$invs = $eiModel->alias('a')
->field('a.*,b.em_type_id')
->join(['em'=>'b'],'a.em_id = b.id')
->where('a.payment_balance','neq',0)
->where(['a.invoice_id'=>$ids])->order('a.invoice_id asc')->select();
if($invs->isEmpty()) {
$invIds = implode(',',$ids);
return json(['status'=>0,'message'=>'账单号: '.$invIds.' 不能重复生成缴费单!']);
return json(['status'=>0,'message'=>'账单号: '.$invIds.' 已缴清,不能重复生成缴费单!']);
}
$rInvs = [];
foreach ($invs as $inv){
if($inv->em_type_id == 2 || $inv->em_type_id ==4){
$rInvs[] = $inv['invoice_id'];
}
}
if(!empty($rInvs)){
$rInvsStr = implode(',',$rInvs);
return json(['status'=>0,'message'=>'账单号: '.$rInvsStr.'未充值卡表账单,不能进行合并缴费']);
}
//过滤不可以生成缴费单的账单ID
$idsArr = [];
$amount = 0;
......
......@@ -128,13 +128,10 @@
if(obj.data.em_type_id == 2) {
layer.msg('预付费表无法进行账单合并', {
time: 3000
},function(){
$(obj).attr('checked',false)
});
}
});
laydate.render({
elem:'#date_end',
trigger:'click',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论