更新code权限

This commit is contained in:
yaooo 2023-11-04 14:27:57 +08:00
parent d05f6389dd
commit b069478887
2 changed files with 83 additions and 82 deletions

View File

@ -163,7 +163,7 @@ abstract class ApiController
$authList = Cache::get('RulesSrc' . $uid); $authList = Cache::get('RulesSrc' . $uid);
$pathUrl = $prefixMod . '/' . $conMod . '/' . $action; $pathUrl = $prefixMod . '/' . $conMod . '/' . $action;
if (!in_array($pathUrl, $authList)) { if (!in_array($pathUrl, $authList)) {
$this->apiError('用户无权限'); $this->apiError('用户无权限', [], 2);
} }
} }

View File

@ -51,105 +51,105 @@ class FinanceIncome extends ApiController
//新增 //新增
public function add() public function add()
{ {
$this->checkAuth();
$param = get_params(); $param = get_params();
$this->uid = JWT_UID; $this->uid = JWT_UID;
$auth = isAuthIncome($this->uid); $auth = isAuthIncome($this->uid);
if($auth == 0){ if($auth == 0){
$this->apiError("你没有到账管理权限请联系管理员或者HR"); $this->apiError("你没有到账管理权限请联系管理员或者HR");
} }
$inid = $param['inid'];
$admin_id = $this->uid;
//计算已到账的金额
$hasIncome = InvoiceIncome::where(['inid'=>$inid,'status'=>1])->sum('amount');
//查询发票金额
$invoiceAmount = Invoice::where(['id'=>$inid])->value('amount');
if($param['enter_type']==1){ //单个到账记录
//相关内容多个数组
$enterPriceData=isset($param['amount'])? $param['amount'] : '';
$enterTimeData=isset($param['enter_time'])? $param['enter_time'] : '';
$remarksData=isset($param['remarks'])? $param['remarks'] : '';
//把合同协议关联的单个内容的发票入账明细重新添加
if($enterPriceData){
$inid = $param['inid']; $enter_price = 0;
$admin_id = $this->uid; $insert = [];
//计算已到账的金额 $time = time();
$hasIncome = InvoiceIncome::where(['inid'=>$inid,'status'=>1])->sum('amount'); foreach ($enterPriceData as $key => $value) {
//查询发票金额 if (!$value ) continue;
$invoiceAmount = Invoice::where(['id'=>$inid])->value('amount'); $insert[] = [
if($param['enter_type']==1){ //单个到账记录 'inid' => $inid,
//相关内容多个数组 'amount' => $value,
$enterPriceData=isset($param['amount'])? $param['amount'] : ''; 'enter_time' => $enterTimeData[$key]? strtotime($enterTimeData[$key]) : 0,
$enterTimeData=isset($param['enter_time'])? $param['enter_time'] : ''; 'remarks' => $remarksData[$key],
$remarksData=isset($param['remarks'])? $param['remarks'] : ''; 'admin_id' => $admin_id,
'create_time' => $time
//把合同协议关联的单个内容的发票入账明细重新添加 ];
if($enterPriceData){ $enter_price += $value*100;
$enter_price = 0; }
$insert = []; if(($enter_price + $hasIncome*100)> $invoiceAmount*100){
$time = time(); return to_assign(1,'到账金额大于发票金额,不允许保存');
foreach ($enterPriceData as $key => $value) {
if (!$value ) continue;
$insert[] = [
'inid' => $inid,
'amount' => $value,
'enter_time' => $enterTimeData[$key]? strtotime($enterTimeData[$key]) : 0,
'remarks' => $remarksData[$key],
'admin_id' => $admin_id,
'create_time' => $time
];
$enter_price += $value*100;
}
if(($enter_price + $hasIncome*100)> $invoiceAmount*100){
return to_assign(1,'到账金额大于发票金额,不允许保存');
}
else{
$res = InvoiceIncome::strict(false)->field(true)->insertAll($insert);
if($res!==false){
if(($enter_price + $hasIncome*100) == $invoiceAmount*100){
//发票全部到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>2,'enter_amount'=>$invoiceAmount,'enter_time'=>time()]);
}
else if(($enter_price + $hasIncome*100) < $invoiceAmount*100){
$incomeTotal=($enter_price + $hasIncome*100)/100;
//发票部分到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
}
add_log('add',$inid,$param);
return to_assign();
}
else{
return to_assign(1,'保存失败');
}
}
} }
else{ else{
return to_assign(1,'提交的到账数据异常,请核对再提交'); $res = InvoiceIncome::strict(false)->field(true)->insertAll($insert);
} if($res!==false){
} if(($enter_price + $hasIncome*100) == $invoiceAmount*100){
else if($param['enter_type']==2){ //全部到账记录 //发票全部到账
$enter_price = ($invoiceAmount*100-$hasIncome*100)/100; Invoice::where(['id'=>$inid])->update(['is_cash'=>2,'enter_amount'=>$invoiceAmount,'enter_time'=>time()]);
$data = [ }
'inid' => $inid, else if(($enter_price + $hasIncome*100) < $invoiceAmount*100){
'amount' => $enter_price, $incomeTotal=($enter_price + $hasIncome*100)/100;
'enter_time' => isset($param['enter_time'])? strtotime($param['enter_time']) : 0, //发票部分到账
'remarks' => '一次性全部到账', Invoice::where(['id'=>$inid])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
'admin_id' => $admin_id, }
'create_time' => time() add_log('add',$inid,$param);
]; return to_assign();
$res = InvoiceIncome::strict(false)->field(true)->insertGetId($data); }
if($res!==false){ else{
//设置发票全部到账 return to_assign(1,'保存失败');
Invoice::where(['id'=>$inid])->update(['is_cash'=>2,'enter_amount'=>$invoiceAmount,'enter_time'=>time()]); }
add_log('add',$inid,$param);
return to_assign();
} }
} }
else if ($param['enter_type']==3) {//全部反账记录 else{
//作废初始化发票到账数据 return to_assign(1,'提交的到账数据异常,请核对再提交');
$res = InvoiceIncome::where(['inid'=>$inid])->update(['status'=>'6','update_time'=>time()]); }
if($res!==false){ }
//设置发票全部没到账 else if($param['enter_type']==2){ //全部到账记录
Invoice::where(['id'=>$inid])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]); $enter_price = ($invoiceAmount*100-$hasIncome*100)/100;
add_log('tovoid',$inid,$param); $data = [
return to_assign(); 'inid' => $inid,
} 'amount' => $enter_price,
'enter_time' => isset($param['enter_time'])? strtotime($param['enter_time']) : 0,
'remarks' => '一次性全部到账',
'admin_id' => $admin_id,
'create_time' => time()
];
$res = InvoiceIncome::strict(false)->field(true)->insertGetId($data);
if($res!==false){
//设置发票全部到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>2,'enter_amount'=>$invoiceAmount,'enter_time'=>time()]);
add_log('add',$inid,$param);
return to_assign();
} }
}
else if ($param['enter_type']==3) {//全部反账记录
//作废初始化发票到账数据
$res = InvoiceIncome::where(['inid'=>$inid])->update(['status'=>'6','update_time'=>time()]);
if($res!==false){
//设置发票全部没到账
Invoice::where(['id'=>$inid])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
add_log('tovoid',$inid,$param);
return to_assign();
}
}
} }
//查看 //查看
public function view() public function view()
{ {
$this->checkAuth();
$this->uid = JWT_UID; $this->uid = JWT_UID;
$id = empty(get_params('id')) ? 0 : get_params('id'); $id = empty(get_params('id')) ? 0 : get_params('id');
$model = new Invoice(); $model = new Invoice();
@ -181,6 +181,7 @@ class FinanceIncome extends ApiController
//删除到账记录 //删除到账记录
public function delete() public function delete()
{ {
$this->checkAuth();
$param = get_params(); $param = get_params();
$this->uid = JWT_UID; $this->uid = JWT_UID;
if(empty($param['id'])){ if(empty($param['id'])){