130 lines
3.3 KiB
PHP
130 lines
3.3 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\financial;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\financial\FinancialBorrowMoney;
|
||
use app\common\model\financial\FinancialRepayment;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 财务管理--还款单验证器
|
||
* Class FinancialRepaymentValidate
|
||
* @package app\adminapi\validate\financial
|
||
*/
|
||
class FinancialRepaymentValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'borrow_money_id' => 'require|checkBorrowMoney',
|
||
'payer' => 'require|checkPayer',
|
||
'amount' => 'require|float|gt:0',
|
||
'create_user' => 'require',
|
||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'borrow_money_id' => '借款单id',
|
||
'code' => '单据编号',
|
||
'payer' => '还款人',
|
||
'amount' => '还款金额',
|
||
'desc' => '说明',
|
||
'create_user' => '经办人',
|
||
'create_time' => '还款日期',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return FinancialRepaymentValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['borrow_money_id', 'payer', 'amount', 'desc', 'create_user', 'create_time']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return FinancialRepaymentValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id', 'borrow_money_id', 'payer', 'amount', 'desc', 'create_user', 'create_time']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return FinancialRepaymentValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return FinancialRepaymentValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 11:15
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = FinancialRepayment::where('id', $value)->findOrEmpty();
|
||
if ($data->isEmpty()) return '数据不存在';
|
||
return true;
|
||
}
|
||
|
||
public function checkBorrowMoney($value): bool|string
|
||
{
|
||
$data = FinancialBorrowMoney::where('id', $value)->findOrEmpty();
|
||
if ($data->isEmpty()) return '借款单不存在';
|
||
return true;
|
||
}
|
||
|
||
public function checkPayer($value): bool|string
|
||
{
|
||
$data = Admin::where('id', $value)->findOrEmpty();
|
||
if ($data->isEmpty()) return '还款人信息不存在';
|
||
return true;
|
||
}
|
||
|
||
} |