engineering/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php
2024-04-12 14:48:11 +08:00

196 lines
5.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\marketing;
use app\common\model\dict\DictData;
use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\validate\BaseValidate;
/**
* 市场经营--投标管理--投标评审验证器
* Class MarketingBidEvaluationValidate
* @package app\adminapi\validate\marketing
*/
class MarketingBidEvaluationValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'business_opportunity_id' => 'require|checkBusinessOpportunity',
'bid_type' => 'checkBidType',
'bid_nature' => 'checkBidNature',
'bid_code' => 'require',
'bid_margin' => 'float|egt:0',
'bid_amount' => 'float|egt:0',
'quotation_amount' => 'float|egt:0',
'end_date' => 'dateFormat:Y-m-d',
'bid_date' => 'require|dateFormat:Y-m-d',
'annex' => 'checkAnnex',
'flow_id' => 'require|checkFlow',
'path' => 'require',
'reg_date' => 'require|dateFormat:Y-m-d',
'review_status' => 'require|in:0,1',
'reg_result' => 'require|in:0,1',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'business_opportunity_id' => '业务机会id',
'bid_type' => '招标方式',
'bid__nature' => '投标性质',
'bid_code' => '投标项目编号',
'bid_margin' => '投标保证金',
'bid_amount' => '报名和标书费',
'quotation_amount' => '报价范围',
'end_date' => '报名截止日期',
'bid_date' => '投标日期',
'service_duration' => '服务工期',
'bid_address' => '投标地点',
'bid_agency' => '招标代理单位',
'bid_agency_address' => '联系地址',
'bid_agency_contacts' => '联系人',
'bid_agency_telephone' => '联系方式',
'flow_id' => '审批流id',
'path' => '路径',
'reg_date' => '报名时间',
'review_status' => '资审情况',
'reg_result' => '报名结果',
];
/**
* @notes 添加场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneAdd()
{
return $this->remove('id', true)
->remove('flow_id', true)
->remove('path', true)
->remove('reg_date', true)
->remove('review_status', true)->remove('reg_result', true);
}
/**
* @notes 编辑场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneEdit()
{
return $this->remove('flow_id', true)->remove('path', true)->remove('reg_date', true)
->remove('review_status', true)->remove('reg_result', true);
}
/**
* @notes 删除场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 15:42
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 审批场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneApprove()
{
return $this->only(['id', 'flow_id', 'path']);
}
/**
* @notes 报名场景
* @return MarketingBidEvaluationValidate
* @author likeadmin
* @date 2024/04/11 14:27
*/
public function sceneReg()
{
return $this->only(['id', 'reg_date', 'review_status', 'reg_result']);
}
public function checkData($value): bool|string
{
$data = MarketingBidEvaluation::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkBusinessOpportunity($value): bool|string
{
$data = MarketingBusinessOpportunity::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '关联业务机会数据不存在' : true;
}
public function checkBidType($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'bidding_method')->column('value');
if (!in_array($value, $dict)) {
return '招标方式数据值无效';
}
return true;
}
public function checkBidNature($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'bid_nature')->column('value');
if (!in_array($value, $dict)) {
return '投标性质数据值无效';
}
return true;
}
}