engineering/app/adminapi/validate/marketing/MarketingContractValidate.php
2024-04-09 14:05:25 +08:00

312 lines
9.3 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\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\dict\DictData;
use app\common\model\marketing\MarketingContract;
use app\common\model\marketing\MarketingCustom;
use app\common\validate\BaseValidate;
/**
* 市场经营--合同信息验证器
* Class MarketingContractValidate
* @package app\adminapi\validate\marketing
*/
class MarketingContractValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'related_contract_id' => 'checkRelatedContract',
'contract_name' => 'require',
'part_a' => 'require|checkPartA',
'part_b' => 'require',
'part_b_signatory' => 'checkPartBSignatory',
'business_nature' => 'require|checkBusinessNature',
'industry_nature' => 'require|checkIndustryNature',
'fund_sources' => 'require|checkFundSources',
'const_area' => 'require|checkConstArea',
'project_money' => 'float|egt:0',
'signed_amount' => 'require|float|gt:0',
'signed_rate' => 'float|egt:0',
'start_date' => 'dateFormat:Y-m-d',
'end_date' => 'dateFormat:Y-m-d',
'performance_money' => 'float|egt:0',
'performance_money_expiration_time' => 'dateFormat:Y-m-d',
'signed_dept' => 'require|checkSignedDept',
'signed_head' => 'require|checkSignedHead',
'supervise_dept' => 'require|checkSuperviseDept',
'project_manager' => 'checkProjectManager',
'implement_method' => 'checkImplementMethod',
'seal_name' => 'checkSealName',
'is_limit' => 'integer|in:0,1',
'limit_num' => 'integer|egt:0',
'file_type' => 'checkFileType',
'seal_num' => 'integer|egt:0',
'seal_user' => 'checkSealUser',
'plance_seal' => 'integer|in:0,1',
'send_date' => 'dateFormat:Y-m-d',
'create_user' => 'require',
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
'annex' => 'checkAnnex',
'flow_id' => 'require|checkFlow',
'path' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'related_contract_id' => '关联主合同id',
'contract_type' => '合同类型 0-主合同 1-框架协议 2-补充协议',
'contract_name' => '合同名称',
'contract_code' => '合同编号',
'part_a' => '甲方签约单位',
'part_a_contact' => '联系人',
'part_a_address' => '业主地址',
'part_b' => '乙方签约单位',
'part_b_signatory' => '乙方签约人',
'business_nature' => '业务性质',
'industry_nature' => '行业性质',
'fund_sources' => '资金来源',
'const_area' => '建设区域',
'agreement_nature' => '协议性质',
'project_money' => '工程总投资',
'project_scale' => '工程规模及概况',
'signed_amount' => '签订金额',
'signed_rate' => '合同签订费率',
'service_duration' => '合同服务工期',
'start_date' => '计划开始日期',
'end_date' => '计划结束日期',
'performance_money' => '履约金',
'performance_money_expiration_time' => '履约金到期时间',
'payment_method' => '合同付款方式',
'content' => '合同主要内容',
'signed_dept' => '签订部门',
'signed_head' => '签订负责人',
'supervise_dept' => '监管部门',
'project_manager' => '项目总监/经理',
'implement_method' => '实施方式',
'seal_name' => '盖章名称',
'is_limit' => '是否限制',
'limit_num' => '限制次数',
'file_type' => '文件类型',
'seal_num' => '盖章份数',
'seal_user' => '盖章人',
'plance_seal' => '骑缝盖章',
'send_date' => '发出日期',
'mailing_number' => '邮寄编号',
'create_user' => '录入人',
'create_time' => '录入时间',
];
/**
* @notes 添加场景
* @return MarketingContractValidate
* @author likeadmin
* @date 2024/04/03 09:19
*/
public function sceneAdd()
{
return $this->remove('id', true)->remove('flow_id', true)->remove('path', true);
}
/**
* @notes 编辑场景
* @return MarketingContractValidate
* @author likeadmin
* @date 2024/04/03 09:19
*/
public function sceneEdit()
{
return $this->remove('flow_id', true)->remove('path', true);
}
/**
* @notes 删除场景
* @return MarketingContractValidate
* @author likeadmin
* @date 2024/04/03 09:19
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingContractValidate
* @author likeadmin
* @date 2024/04/03 09:19
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneApprove()
{
return $this->only(['id', 'flow_id', 'path']);
}
public function checkData($value): bool|string
{
$data = MarketingContract::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkRelatedContract($value)
{
if (empty($value)) return true;
$data = MarketingContract::where('id', $value)->where('contract_type', 1)->findOrEmpty();
return $data->isEmpty() ? '关联协议框架数据不存在' : true;
}
public function checkAgreementNature($value): bool|string
{
$dict = DictData::where('type_value', 'agreement_nature')->column('value');
if (!in_array($value, $dict)) {
return '协议性质数据值无效';
}
return true;
}
public function checkPartA($value): bool|string
{
$data = MarketingCustom::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '甲方签订单位数据不存在' : true;
}
public function checkPartBSignatory($value): bool|string
{
if (empty($value)) return true;
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '乙方签约人数据不存在' : true;
}
public function checkBusinessNature($value): bool|string
{
$dict = DictData::where('type_value', 'cost_consultation_business_nature')->column('value');
if (!in_array($value, $dict)) {
return '业务性质数据值无效';
}
return true;
}
public function checkIndustryNature($value): bool|string
{
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('value');
if (!in_array($value, $dict)) {
return '行业性质数据值无效';
}
return true;
}
public function checkFundSources($value): bool|string
{
$dict = DictData::where('type_value', 'cost_consultation_fund_sources')->column('value');
if (!in_array($value, $dict)) {
return '资金来源数据值无效';
}
return true;
}
public function checkConstArea($value): bool|string
{
$dict = DictData::where('type_value', 'cost_consultation_const_area')->column('value');
if (!in_array($value, $dict)) {
return '建设区域数据值无效';
}
return true;
}
public function checkSignedDept($value): bool|string
{
$data = Dept::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '签订部门数据不存在' : true;
}
public function checkSignedHead($value): bool|string
{
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '签订负责人数据不存在' : true;
}
public function checkSuperviseDept($value): bool|string
{
$data = Dept::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '监管部门数据不存在' : true;
}
public function checkProjectManager($value): bool|string
{
if (empty($value)) return true;
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '项目经理数据不存在' : true;
}
public function checkImplementMethod($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_way')->column('value');
if (!in_array($value, $dict)) {
return '实施方式数据值无效';
}
return true;
}
public function checkSealName($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_seal_name')->column('value');
if (!in_array($value, $dict)) {
return '盖章名称数据值无效';
}
return true;
}
public function checkFileType($value): bool|string
{
if (empty($value)) return true;
$dict = DictData::where('type_value', 'cost_consultation_file_type')->column('value');
if (!in_array($value, $dict)) {
return '文件类型数据值无效';
}
return true;
}
public function checkSealUser($value): bool|string
{
if (empty($value)) return true;
$data = Admin::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '盖章人数据不存在' : true;
}
}