engineering/app/adminapi/validate/bid/BidBuyBiddingDocumentValidate.php
2024-02-19 15:22:01 +08:00

156 lines
4.2 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\auth\Admin;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidBuyBiddingDocument;
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|checkData',
'project_id' => 'require|checkProject',
'bid_decision_id' => 'require|checkBidDecision',
'bid_document_no' => 'require',
'invite_tenders_company_name' => 'require',
'bid_company_name' => 'require',
'buyer' => 'checkBuyer',
'amount' => 'float|egt:0',
'project_fund_source' => 'checkProjectFundSource',
'buy_date' => 'dateFormat:Y-m-d',
'flow_id' => 'require|checkFlow',
'path' => 'require',
];
protected $message = [
'id.require' => '缺少必要参数',
'project_id.require' => '请选择项目',
'bid_decision_id.require' => '请选择投标决策',
'bid_document_no.require' => '请填写标书编号',
'invite_tenders_company_name.require' => '请填写招标公司名称',
'bid_company_name.require' => '请填写投标公司名称',
'amount.float' => '购买标书金额值必须是数字',
'amount.egt' => '购买标书金额值必须大于等于0',
'buy_date.dateFormat' => '购买标书时间数据格式错误',
];
/**
* @notes 添加场景
* @return BidBuyBiddingDocumentValidate
* @author likeadmin
* @date 2023/11/27 18:22
*/
public function sceneAdd()
{
return $this->remove('id', true)->remove('flow_id',true)->remove('path',true);
}
/**
* @notes 编辑场景
* @return BidBuyBiddingDocumentValidate
* @author likeadmin
* @date 2023/11/27 18:22
*/
public function sceneEdit()
{
return $this->remove('flow_id',true)->remove('path',true);
}
/**
* @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 sceneApprove()
{
return $this->only(['id','flow_id','path']);
}
public function checkData($value): bool|string
{
$data = BidBuyBiddingDocument::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 checkBidDecision($value,$rule,$data): bool|string
{
$bid_decision = BidBiddingDecision::where('id',$value)->findOrEmpty();
if($bid_decision->isEmpty()){
return '投标决策信息不存在';
}
if($bid_decision['project_id'] != $data['project_id']){
return '投标决策信息无效';
}
return true;
}
public function checkBuyer($value): bool|string
{
$admin = Admin::where('id',$value)->findOrEmpty();
if($admin->isEmpty()){
return '购买人员信息不存在';
}
return true;
}
}