engineering/app/adminapi/validate/finance/FinanceRefundApplyValidate.php
shengchanzhe 627445edda 更新
2024-01-14 19:47:49 +08:00

150 lines
3.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\finance;
use app\common\model\bank\BankAccount;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
use app\common\validate\BaseValidate;
/**
* FinanceRefundApply验证器
* Class FinanceRefundApplyValidate
* @package app\adminapi\validate\finance
*/
class FinanceRefundApplyValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'contract_id' => 'require|checkContract',
'refund_date' => 'require|dateFormat:Y-m-d',
'reason' => 'require',
'amount' => 'require|float|gt:0',
'refund_type' => 'require|checkRefundType',
'annex' => 'checkAnnex',
'collection_bank' => 'require',
'collection_account' => 'require',
'bank_account_id' => 'require|checkBankAccount',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'contract_id' => '项目合同',
'refund_date' => '退款日期',
'reason' => '退款原因',
'amount' => '退款金额',
'refund_type' => '退款方式',
'collection_bank' => '收款银行',
'collection_account' => '收款账号',
'bank_account_id' => '付款银行账号'
];
/**
* @notes 添加场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkContract($value): bool|string
{
$data = Contract::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目合同不存在';
}
return true;
}
public function checkRefundType($value): bool|string
{
$dict = DictData::where('type_value','refund_type')->column('value');
if(!in_array($value,$dict)){
return '退款方式无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = $value;//json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
public function checkBankAccount($value): bool|string
{
$bank = BankAccount::where('id',$value)->findOrEmpty();
if($bank->isEmpty()){
return '付款银行账户信息不存在';
}
return true;
}
}