提交 1916dbba authored 作者: chengye's avatar chengye

test

上级 41009558
......@@ -38,23 +38,25 @@ class WriteOff extends Controller
//查询可消的额度
$payments_balance = $invModel->where('invoice_id','in',$invsArr)->sum('payment_balance');
}
//如果可以完全销账 则继续销账
if($payment->balance > $payments_balance){
$invs = $invModel->field('invoice_id')
->where('account_id','=',$payment->account_id)
->where('payment_balance','neq',0)
->whereNotIn('invoice_id',$invsArr)
if($payment->balance > $payments_balance) {
//如果可以完全销账 则继续销账
$invss = $invModel->field('invoice_id')
->where('account_id', '=', $payment->account_id)
->where('payment_balance', 'neq', 0)
->whereNotIn('invoice_id', $invsArr)
->order('invoice_id asc')
->select();
if(!$invs->isEmpty()) {
foreach ($invs as $inv){
if (!$invss->isEmpty()) {
foreach ($invss as $inv) {
$invsArr[] = $inv->invoice_id;
}
}
}
$paymentIds[] = $payment->payment_id;
//销账日志
$logMsg = date('Y-m-d H-i-s').'paymentIds :' .implode('-',$paymentIds) .'invoiceIds :' .implode('-',$invsArr);
Log::info($logMsg);
//处理账户金额
return $this->writeOff($paymentIds,$invsArr);
}
......@@ -122,10 +124,10 @@ class WriteOff extends Controller
Log::info('执行销账:');
//获取可销账缴费单
$payments = EmPayment::where('payment_id','in',$paymentIds)->select();
$payments = EmPayment::where('payment_id','in',$paymentIds)->order('payment_id asc')->select();
//获取可销账账单
$invs = EmInvoice::where('invoice_id','in',$invoiceIds)->select();
$invs = EmInvoice::where('invoice_id','in',$invoiceIds)->order('invoice_id asc')->select();
$result = 0;
foreach ($payments as $key => $payment){
......@@ -157,6 +159,11 @@ class WriteOff extends Controller
$payment->balance = 0;
}
//更新账单状态
$inv->save();
//更新缴费状态
$payment->save();
//查找是否已经存在相关联的账单关系
$model = (new EmPaymentInvoice())->where(['payment_id'=>$payment->payment_id,'invoice_id'=>$inv->invoice_id])->find();
if(!$model){
......@@ -167,14 +174,7 @@ class WriteOff extends Controller
}
$result++;
//更新账单状态
$inv->save();
//更新缴费状态
$payment->save();
unset($payments[$key]);
$balanceMode->isUpdate(false)->save();
$this->computerAmount($inv->account_id,$balanceMode->balance);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论