更新到账操作

This commit is contained in:
yaooo 2023-11-04 14:50:38 +08:00
parent b069478887
commit ea14c3ef45
1 changed files with 21 additions and 8 deletions

View File

@ -58,7 +58,12 @@ class FinanceIncome extends ApiController
if($auth == 0){
$this->apiError("你没有到账管理权限请联系管理员或者HR");
}
if (empty($param['enter_type'])) {
$this->apiError("到账类型不能为空");
}
if (empty($param['inid'])) {
$this->apiError("发票id不能为空");
}
$inid = $param['inid'];
$admin_id = $this->uid;
//计算已到账的金额
@ -67,6 +72,12 @@ class FinanceIncome extends ApiController
$invoiceAmount = Invoice::where(['id'=>$inid])->value('amount');
if($param['enter_type']==1){ //单个到账记录
//相关内容多个数组
if (empty($param['amount'])) {
$this->apiError("到账金额不能为空");
}
if (empty($param['enter_time'])) {
$this->apiError("到账日期不能为空");
}
$enterPriceData=isset($param['amount'])? $param['amount'] : '';
$enterTimeData=isset($param['enter_time'])? $param['enter_time'] : '';
$remarksData=isset($param['remarks'])? $param['remarks'] : '';
@ -89,7 +100,7 @@ class FinanceIncome extends ApiController
$enter_price += $value*100;
}
if(($enter_price + $hasIncome*100)> $invoiceAmount*100){
return to_assign(1,'到账金额大于发票金额,不允许保存');
$this->apiError('到账金额大于发票金额,不允许保存');
}
else{
$res = InvoiceIncome::strict(false)->field(true)->insertAll($insert);
@ -104,15 +115,15 @@ class FinanceIncome extends ApiController
Invoice::where(['id'=>$inid])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
}
add_log('add',$inid,$param);
return to_assign();
$this->apiSuccess('操作成功');
}
else{
return to_assign(1,'保存失败');
$this->apiError('保存失败');
}
}
}
else{
return to_assign(1,'提交的到账数据异常,请核对再提交');
$this->apiError('提交的到账数据异常,请核对再提交');
}
}
else if($param['enter_type']==2){ //全部到账记录
@ -130,8 +141,9 @@ class FinanceIncome extends ApiController
//设置发票全部到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>2,'enter_amount'=>$invoiceAmount,'enter_time'=>time()]);
add_log('add',$inid,$param);
return to_assign();
$this->apiSuccess('操作成功');
}
$this->apiError('保存失败');
}
else if ($param['enter_type']==3) {//全部反账记录
//作废初始化发票到账数据
@ -140,8 +152,9 @@ class FinanceIncome extends ApiController
//设置发票全部没到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
add_log('tovoid',$inid,$param);
return to_assign();
}
$this->apiSuccess('操作成功');
}
$this->apiError('保存失败');
}
}