188 lines
5.1 KiB
PHP
188 lines
5.1 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\bid;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\dept\Dept;
|
||
use app\common\model\dept\Orgs;
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\project\Project;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 购买标书验证器
|
||
* Class BidBuyBiddingDocumentValidate
|
||
* @package app\adminapi\validate\bid
|
||
*/
|
||
class BidBuyBiddingDocumentValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require',
|
||
'org_id' => 'require|checkOrg',
|
||
'dept_id' => 'require|checkDept',
|
||
'project_id' => 'require|checkProject',
|
||
'bid_document_no' => 'require',
|
||
'invite_tenders_company_name' => 'require',
|
||
'bid_company_name' => 'require',
|
||
'buyer' => 'checkBuyer',
|
||
'amount' => 'float|egt:0',
|
||
'project_fund_source' => 'checkProjectFundSource',
|
||
'bid_date' => 'dateFormat:Y-m-d',
|
||
'buy_date' => 'dateFormat:Y-m-d',
|
||
'invite_tenders_type' => 'checkInviteTendersType',
|
||
'is_margin' => 'in:0,1',
|
||
'margin_amount' => 'float|egt:0',
|
||
'annex' => 'checkAnnex',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'org_id.require' => '请选择组织',
|
||
'dept_id.require' => '请选择部门',
|
||
'project_id.require' => '请选择项目',
|
||
'bid_document_no.require' => '请填写标书编号',
|
||
'invite_tenders_company_name.require' => '请填写招标公司名称',
|
||
'bid_company_name.require' => '请填写投标公司名称',
|
||
'amount.float' => '购买标书金额值必须是数字',
|
||
'amount.egt' => '购买标书金额值必须大于等于0',
|
||
'bid_date.dateFormat' => '投标时间数据格式错误',
|
||
'buy_date.dateFormat' => '购买标书时间数据格式错误',
|
||
'is_margin.in' => '是否需要保证金选项数据错误',
|
||
'margin_amount.float' => '保证金金额值必须是数字',
|
||
'margin_amount.egt' => '保证金金额值必须大于等于0',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return BidBuyBiddingDocumentValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id', true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return BidBuyBiddingDocumentValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return BidBuyBiddingDocumentValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return BidBuyBiddingDocumentValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/27 18:22
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkOrg($value): bool|string
|
||
{
|
||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||
if($org->isEmpty()){
|
||
return '组织不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkDept($value,$rule,$data): bool|string
|
||
{
|
||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||
if($dept->isEmpty()){
|
||
return '部门不存在';
|
||
}
|
||
if($dept['org_id'] != $data['org_id']){
|
||
return '部门无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$project = Project::where('id',$value)->findOrEmpty();
|
||
if($project->isEmpty()){
|
||
return '项目不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkBuyer($value): bool|string
|
||
{
|
||
$admin = Admin::where('id',$value)->findOrEmpty();
|
||
if($admin->isEmpty()){
|
||
return '购买人员信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProjectFundSource($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','construction_funds_sources')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '招标项目资金来源无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkInviteTendersType($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','bidding_method')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '招标方式无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAnnex($value): bool|string
|
||
{
|
||
if(!empty($value) && $value != ''){
|
||
$annex = json_decode($value,true);
|
||
if(empty($annex) || !is_array($annex)){
|
||
return '附件格式错误';
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |