engineering/app/adminapi/validate/bid/BidBiddingDecisionValidate.php
2024-02-19 15:14:34 +08:00

178 lines
5.1 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\bid;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\dict\DictData;
use app\common\model\project\Project;
use app\common\validate\BaseValidate;
/**
* 投标决策验证器
* Class BidBiddingDecisionValidate
* @package app\adminapi\validate\bid
*/
class BidBiddingDecisionValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'project_estimation' => 'require|float|egt:0',
'bidding_project_fund_source' => 'checkBiddingProjectFundSource',
'bidding_time' => 'dateFormat:Y-m-d',
'bid_type' => 'checkBidType',
'is_margin' => 'require|in:1,2',
'margin_amount' => 'requireIf:is_margin,1|float|egt:0',
'bid_opening_date' => 'dateFormat:Y-m-d',
'margin_amount_return_date' => 'dateFormat:Y-m-d',
'is_internal_resources' => 'in:1,2',
'project_assurance' => 'checkProjectAssurance',
'annex' => 'checkAnnex',
'flow_id' => 'require|checkFlow',
'path' => 'require',
];
protected $message = [
'id.require' => '缺少必要参数',
'project_id.require' => '请选择项目',
'project_estimation.require' => '请填写项目估算',
'project_estimation.float' => '项目估算值必须是数字',
'project_estimation.egt' => '项目估算值必须大于等于0',
'bidding_time.dateFormat' => '投标时间数据格式错误',
'is_margin.require' => '请选择是否需要保证金',
'is_margin.in' => '是否需要保证金选项值错误',
'margin_amount.requireIf' => '请填写保证金金额',
'margin_amount.float' => '保证金金额值必须是数字',
'margin_amount.egt' => '保证金金额值必须大于等于0',
'bid_opening_date.dateFormat' => '开标日期数据格式错误',
'margin_amount_return_date.dateFormat' => '保证金退还时间数据格式错误',
'is_internal_resources.in' => '有无内部资源选项值错误',
];
/**
* @notes 添加场景
* @return BidBiddingDecisionValidate
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function sceneAdd()
{
return $this->remove('id', true)->remove('flow_id',true)->remove('path',true);
}
/**
* @notes 编辑场景
* @return BidBiddingDecisionValidate
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function sceneEdit()
{
return $this->remove('flow_id',true)->remove('path',true);
}
/**
* @notes 删除场景
* @return BidBiddingDecisionValidate
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return BidBiddingDecisionValidate
* @author likeadmin
* @date 2023/11/27 18:14
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneApprove()
{
return $this->only(['id','flow_id','path']);
}
public function checkData($value): bool|string
{
$data = BidBiddingDecision::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$project = Project::where('id',$value)->findOrEmpty();
if($project->isEmpty()){
return '项目不存在';
}
return true;
}
public function checkBiddingProjectFundSource($value): bool|string
{
$dictData = DictData::where('type_value','construction_funds_sources')->column('value');
if(!in_array($value,$dictData)){
return '招标项目资金来源无效';
}
return true;
}
public function checkBidType($value): bool|string
{
$dictData = DictData::where('type_value','bidding_method')->column('value');
if(!in_array($value,$dictData)){
return '招标方式无效';
}
return true;
}
public function checkProjectAssurance($value): bool|string
{
$dictData = DictData::where('type_value','project_assurance')->column('value');
if(!in_array($value,$dictData)){
return '项目把握度无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
}