158 lines
3.9 KiB
PHP
158 lines
3.9 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\validate\project;
|
||
|
||
|
||
use app\common\model\bank\BankAccount;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectLoanApply;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 借款申请验证器
|
||
* Class ProjectLoanApplyValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectLoanApplyValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'apply_user' => 'require',
|
||
'loan_date' => 'require|dateFormat:Y-m-d',
|
||
'loan_amount' => 'require|float|gt:0',
|
||
'payee_name' => 'require',
|
||
'payee_bank' => 'require',
|
||
'payee_account' => 'require',
|
||
'annex' => 'checkAnnex',
|
||
'bank_account_id' => 'require|checkBankAccount',
|
||
'flow_id' => 'require|checkFlow',
|
||
'path' => 'require',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'apply_user' => '借款人',
|
||
'loan_date' => '借款申请日期',
|
||
'loan_amount' => '借款金额',
|
||
'payee_name' => '收款人姓名',
|
||
'payee_bank' => '收款银行',
|
||
'payee_account' => '收款账号',
|
||
'bank_account_id' => '付款银行账户id',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectLoanApplyValidate
|
||
* @author likeadmin
|
||
* @date 2024/01/17 11:05
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true)->remove('flow_id',true)->remove('path',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectLoanApplyValidate
|
||
* @author likeadmin
|
||
* @date 2024/01/17 11:05
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->remove('flow_id',true)->remove('path',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectLoanApplyValidate
|
||
* @author likeadmin
|
||
* @date 2024/01/17 11:05
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectLoanApplyValidate
|
||
* @author likeadmin
|
||
* @date 2024/01/17 11:05
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function sceneApprove()
|
||
{
|
||
return $this->only(['id','flow_id','path']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = ProjectLoanApply::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$data = Project::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAnnex($value): bool|string
|
||
{
|
||
if(!empty($value) && $value != ''){
|
||
if(!is_array($value)){
|
||
return '附件格式错误';
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkBankAccount($value): bool|string
|
||
{
|
||
$data = BankAccount::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '付款银行账户信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |