更新到账记录处理

This commit is contained in:
yaooo 2023-11-04 14:18:05 +08:00
parent 4c25a9eeae
commit d05f6389dd
1 changed files with 24 additions and 16 deletions

View File

@ -146,6 +146,7 @@ class FinanceIncome extends ApiController
}
}
//查看
public function view()
{
@ -182,27 +183,34 @@ class FinanceIncome extends ApiController
{
$param = get_params();
$this->uid = JWT_UID;
if(empty($param['id'])){
$this->apiError('到账id不能为空');
}
if(empty($param['inid'])){
$this->apiError('到账记录id不能为空');
}
//作废初始化发票到账数据
$income = InvoiceIncome::where(['id'=>$param['id']])->find();
if(empty($income)){
$this->apiError('到账信息不存在');
}
$invoice = Invoice::where(['id'=>$income['inid']])->find();
if($income){
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
if($res!==false){
if($income['amount']*100 == $invoice['amount']*100){
//发票全部反到账
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
}
else if($income['amount']*100 < $invoice['amount']*100){
$incomeTotal = InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
//发票部分到账
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
}
add_log('enter',$income['inid'],$invoice);
$this->apiSuccess('操作成功');
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
if($res!==false){
if($income['amount']*100 == $invoice['amount']*100){
//发票全部反到账
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
}
else{
$this->apiError('操作失败');
else if($income['amount']*100 < $invoice['amount']*100){
$incomeTotal = InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
//发票部分到账
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
}
add_log('enter',$income['inid'],$invoice);
$this->apiSuccess('操作成功');
}
else{
$this->apiError('操作失败');
}
}