136 lines
3.6 KiB
PHP
136 lines
3.6 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\bid\BidBuyBiddingDocument;
|
||
use app\common\model\contract\Contract;
|
||
use app\common\model\project\Project;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 甲方结算验证器
|
||
* Class ProjectSettlementValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectSettlementValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require',
|
||
'project_id' => 'require|checkProject',
|
||
'contract_id' => 'require|checkContract',
|
||
'settlement_amount' => 'require|float|egt:0',
|
||
'settlement_date' => 'require|dateFormat:Y-m-d',
|
||
'annex' => 'checkAnnex',
|
||
'approve_detail' => 'require|checkApproveDetail',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'project_id.require' => '请选择项目',
|
||
'contract_id.require' => '请选择合同',
|
||
'settlement_amount.require' => '请填写结算金额',
|
||
'settlement_amount.float' => '结算金额值必须是数字',
|
||
'settlement_amount.egt' => '结算金额值必须大于等于0',
|
||
'settlement_date.require' => '请选择结算日期',
|
||
'settlement_date.dateFormat' => '结算日期格式错误',
|
||
'approve_detail.require' => '请填写审批流程信息',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectSettlementValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/29 10:22
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectSettlementValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/29 10:22
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectSettlementValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/29 10:22
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectSettlementValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/29 10:22
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$data = Project::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkContract($value,$rule,$data): bool|string
|
||
{
|
||
$contract = Contract::where('id',$value)->findOrEmpty();
|
||
if($contract->isEmpty()){
|
||
return '合同不存在';
|
||
}
|
||
$bid = BidBuyBiddingDocument::where('id',$contract['buy_bidding_document_id'])->findOrEmpty();
|
||
if($bid->isEmpty() || $bid['project_id'] != $data['project_id']){
|
||
return '合同无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAnnex($value): bool|string
|
||
{
|
||
if(!empty($value) && $value != ''){
|
||
if(!is_array($value)){
|
||
return '附件必须是json数组';
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |