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

test

上级 36e6275e
...@@ -40,11 +40,8 @@ class Payment ...@@ -40,11 +40,8 @@ class Payment
$paymentFk = (new EmPaymentFk())->get(['oafk_numb' => $numb]); $paymentFk = (new EmPaymentFk())->get(['oafk_numb' => $numb]);
$payment = (new EmPayment())->get(['payment_id' => $paymentFk->payment_id]); $payment = (new EmPayment())->get(['payment_id' => $paymentFk->payment_id]);
if($payment->payment_type == 2){ //更新账户余额
$account = EmAccount::get(['account_id'=>$payment->account_id]); (new Account())->computerAmountFromPay($payment->account_id,$payment->amount);
$account->amount += $payment->amount ;
$account->save();
}
$res = (new WriteOff())->writeOffFromPayment($payment->payment_id); $res = (new WriteOff())->writeOffFromPayment($payment->payment_id);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace app\em\controller; namespace app\em\controller;
use app\admin\controller\Base; use app\admin\controller\Base;
use app\em\model\EmAccount; use app\em\model\EmAccount;
use app\em\model\EmAccountAmount;
/** /**
* 电表账户 * 电表账户
...@@ -94,10 +95,33 @@ class Account extends Base ...@@ -94,10 +95,33 @@ class Account extends Base
return $account->save(); return $account->save();
} }
public function computerAmount($em_id,$balance){ public function computerAmountFromInv($em_id,$balance,$invoice_id = ''){
//更新账户余额 //更新账户余额
$account = (new EmAccount())->get(['em_id'=>$em_id]); $account = (new EmAccount())->get(['em_id'=>$em_id]);
$account->amount -= $balance;
if($res = $account->save()){
$this->recordAmount($invoice_id,'抄表单',$balance);
}
return $res;
}
public function computerAmountFromPay($account_id,$balance){
//更新账户余额
$account = (new EmAccount())->get(['account_id'=>$account_id]);
$account->amount += $balance; $account->amount += $balance;
return $account->save();
if($res = $account->save()){
$this->recordAmount($account_id,'缴费单',$balance);
}
return $res;
}
protected function recordAmount($numb,$type,$amount){
$record = new EmAccountAmount();
$record->numb = $numb;
$record->amount = $amount;
$record->type = $type;
return $record->save();
} }
} }
\ No newline at end of file
...@@ -238,9 +238,7 @@ class Invoice extends Base ...@@ -238,9 +238,7 @@ class Invoice extends Base
$eiu->save(); $eiu->save();
} }
$account = new Account(); (new Account())->computerAmountFromInv($useage->em_id,$inv->payment_amount,$inv->invoice_id);
$pay_amount = 0 - $inv->payment_amount;
$account->computerAmount($useage->em_id,$pay_amount);
return $inv; return $inv;
} }
......
<?php
namespace app\em\model;
class EmAccountAmount extends Base
{
protected $table = 'em_account_amount';
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论