登录
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ApprovalFlowsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ApprovalInstancesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ApprovalRecordsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class CorpFeishuAppValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class CorpValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'name' => 'require|max:255',
|
||||
'abbr' => 'require|in:hesu,xinyouhe,paika,simate,mbaf',
|
||||
'tenant_key' => 'string',
|
||||
'sort' => 'number',
|
||||
'status' => 'require|in:0,1'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.number' => 'ID必须是数字',
|
||||
'name.require' => '企业名称不能为空',
|
||||
'name.max' => '企业名称长度不能超过255个字符',
|
||||
'abbr.require' => '企业缩写不能为空',
|
||||
'abbr.in' => '企业缩写必须是 hesu,xinyouhe,paika,simate,mbaf 中的一个',
|
||||
'tenant_key.string' => '飞书企业标识必须是字符串',
|
||||
'sort.number' => '排序值必须是数字',
|
||||
'status.require' => '状态不能为空',
|
||||
'status.in' => '状态必须是0或1'
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'store' => ['name', 'abbr', 'tenant_key', 'sort', 'status'],
|
||||
'update' => ['id', 'name', 'abbr', 'tenant_key', 'sort', 'status']
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class CountryValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class FinPaymentApplyValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class FinReceiptHisValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class FinReceiptValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
// 'payment_apply_id' => 'integer|gt:0',
|
||||
// 'country_id' => 'require|integer|gt:0',
|
||||
// 'remitter' => 'require',
|
||||
// 'account_id' => 'require|integer|gt:0',
|
||||
// 'currency_id' => 'require|integer|gt:0',
|
||||
// 'amount' => 'require|gt:0',
|
||||
// 'exchange_rate' => 'require|gt:0',
|
||||
// 'arrived_at' => 'require',
|
||||
// 'is_domestic_return' => 'require|integer',
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
// 'payment_apply_id.integer' => '付款申请ID必须是整数',
|
||||
// 'payment_apply_id.gt' => '付款申请ID必须大于0',
|
||||
// 'country_id.require' => '付款来源国家ID不能为空',
|
||||
// 'country_id.integer' => '付款来源国家ID必须是整数',
|
||||
// 'country_id.gt' => '付款来源国家ID必须大于0',
|
||||
// 'remitter.require' => '汇款人不能为空',
|
||||
// 'account_id.require' => '收款账号ID不能为空',
|
||||
// 'account_id.integer' => '收款账号ID必须是整数',
|
||||
// 'account_id.gt' => '收款账号ID必须大于0',
|
||||
// 'currency_id.require' => '收款币种ID不能为空',
|
||||
// 'currency_id.integer' => '收款币种ID必须是整数',
|
||||
// 'currency_id.gt' => '收款币种ID必须大于0',
|
||||
// 'amount.require' => '收款金额不能为空',
|
||||
// 'amount.gt' => '收款金额必须大于0',
|
||||
// 'exchange_rate.require' => '实际汇率不能为空',
|
||||
// 'exchange_rate.gt' => '实际汇率必须大于0',
|
||||
// 'arrived_at.require' => '到账时间不能为空',
|
||||
// 'arrived_at.gt' => '到账时间必须大于0',
|
||||
// 'is_domestic_return.require' => '是否回转内地不能为空',
|
||||
// 'is_domestic_return.integer' => '是否回转内地必须是整数',
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
// 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'exchange_rate', 'arrived_at'
|
||||
],
|
||||
|
||||
'update' => [
|
||||
// 'payment_apply_id'
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class FinanceReconDubaiFilesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
use app\common\model\InquiryLog;
|
||||
|
||||
class InquiryLogValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
'id' => 'require|integer|gt:0',
|
||||
'order_no' => 'require|alphaDash|length:36',
|
||||
'enter_user_id'=> 'integer|egt:0',
|
||||
'recipient' => 'integer|egt:0',
|
||||
'quality' => 'require|in:1,2,3',
|
||||
'channel' => 'integer|between:0,99',
|
||||
'email' => 'email|max:255|checkEmailContactUnique',
|
||||
'tel' => 'max:255|checkTelContactUnique',
|
||||
'whatsapp' => 'max:255|checkWhatsappContactUnique',
|
||||
'country' => 'integer|egt:0|requireWith:contacts',
|
||||
'contacts' => 'require|max:255|requireWithout:email,tel,whatsapp|checkContactUnique',
|
||||
'content' => 'string',
|
||||
'status' => 'in:0,1,2',
|
||||
'r_time' => 'integer|egt:0',
|
||||
't_time' => 'integer|egt:0'
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.integer' => 'ID必须是整数',
|
||||
'id.gt' => 'ID必须大于0',
|
||||
'order_no.require' => '订单号不能为空',
|
||||
'order_no.alphaDash'=> '订单号只能包含字母、数字和下划线',
|
||||
'order_no.length' => '订单号长度必须为36位',
|
||||
'enter_user_id.integer' => '录入人ID必须是整数',
|
||||
'enter_user_id.egt' => '录入人ID不能为负数',
|
||||
'recipient.integer' => '接单人ID必须是整数',
|
||||
'recipient.egt' => '接单人ID不能为负数',
|
||||
'quality.require' => '询单等级不能为空',
|
||||
'quality.in' => '询单等级只能是1、2或3',
|
||||
'channel.integer' => '渠道编号必须是整数',
|
||||
'channel.between' => '渠道编号范围0-99',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.max' => '邮箱长度不能超过255个字符',
|
||||
'tel.max' => '电话长度不能超过255个字符',
|
||||
'whatsapp.max' => 'WhatsApp长度不能超过255个字符',
|
||||
'country.integer' => '国家代码必须是整数',
|
||||
'country.egt' => '国家代码不能为负数',
|
||||
'contacts.require' => '联系人不能为空',
|
||||
'contacts.max' => '联系人长度不能超过255个字符',
|
||||
'content.string' => '询单内容必须是字符串',
|
||||
'status.in' => '状态值只能是0、1或2',
|
||||
'r_time.integer' => '发布时间必须是整数',
|
||||
'r_time.egt' => '发布时间不能为负数',
|
||||
't_time.integer' => '跟踪时间必须是整数',
|
||||
't_time.egt' => '跟踪时间不能为负数',
|
||||
'email.checkEmailContactUnique' => '邮箱联系方式已存在',
|
||||
'tel.checkTelContactUnique' => '电话联系方式已存在',
|
||||
'whatsapp.checkWhatsappContactUnique' => 'WhatsApp联系方式已存在',
|
||||
'contacts.requireWithout' => '至少需要提供一种联系方式',
|
||||
'contacts.checkContactUnique' => '联系人已存在',
|
||||
'country.requireWith' => '国家必须与联系人一起提供'
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
'enter_user_id', 'quality', 'channel', 'email', 'tel', 'whatsapp', 'country', 'contacts', 'content', 'recipient'
|
||||
],
|
||||
'update' => [
|
||||
'quality', 'channel', 'email', 'tel', 'whatsapp', 'country', 'contacts', 'content', 'recipient'
|
||||
],
|
||||
'release' => [
|
||||
'status', 'r_time'
|
||||
],
|
||||
'allocation' => [
|
||||
'status', 't_time'
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 验证联系方式唯一性
|
||||
*/
|
||||
protected function checkContactUnique($value, $rule, $data, $field, $title)
|
||||
{
|
||||
// 如果是更新操作且联系人未修改,跳过检查
|
||||
if ($this->currentScene == 'update') {
|
||||
$original = InquiryLog::find($data['id']);
|
||||
if ($original && $original->contacts == $value && $original->country == ($data['country'] ?? 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($data['email']) && empty($data['tel']) && empty($data['whatsapp'])) {
|
||||
$query = InquiryLog::where('contacts', trim($value))
|
||||
->where('country', $data['country']);
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$query->where('id', '<>', $data['id']);
|
||||
}
|
||||
|
||||
return !$query->exists();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱联系方式唯一性
|
||||
*/
|
||||
protected function checkEmailContactUnique($value, $rule, $data, $field, $title)
|
||||
{
|
||||
if (empty($value)) return true;
|
||||
|
||||
// 如果是更新操作且邮箱未修改,跳过检查
|
||||
if ($this->currentScene == 'update' && !empty($data['id'])) {
|
||||
$original = InquiryLog::find($data['id']);
|
||||
if ($original && $original->email == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = InquiryLog::where('email', trim($value));
|
||||
if (!empty($data['id'])) {
|
||||
$query->where('id', '<>', $data['id']);
|
||||
}
|
||||
return !$query->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证电话联系方式唯一性
|
||||
*/
|
||||
protected function checkTelContactUnique($value, $rule, $data, $field, $title)
|
||||
{
|
||||
if (empty($value)) return true;
|
||||
|
||||
// 如果是更新操作且电话未修改,跳过检查
|
||||
if ($this->currentScene == 'update' && !empty($data['id'])) {
|
||||
$original = InquiryLog::find($data['id']);
|
||||
if ($original && $original->tel == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = InquiryLog::where('tel', trim($value));
|
||||
if (!empty($data['id'])) {
|
||||
$query->where('id', '<>', $data['id']);
|
||||
}
|
||||
return !$query->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证WhatsApp联系方式唯一性
|
||||
*/
|
||||
protected function checkWhatsappContactUnique($value, $rule, $data, $field, $title)
|
||||
{
|
||||
if (empty($value)) return true;
|
||||
|
||||
// 如果是更新操作且WhatsApp未修改,跳过检查
|
||||
if ($this->currentScene == 'update' && !empty($data['id'])) {
|
||||
$original = InquiryLog::find($data['id']);
|
||||
if ($original && $original->whatsapp == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = InquiryLog::where('whatsapp', trim($value));
|
||||
if (!empty($data['id'])) {
|
||||
$query->where('id', '<>', $data['id']);
|
||||
}
|
||||
return !$query->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InquiryTransmitConfigValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InquiryTransmitValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvItemValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionApproveValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionAttachmentValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemReturnValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionItemValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class InvRequisitionValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
'applicant_id' => 'number',
|
||||
'borrow_reason' => 'require|max:255',
|
||||
'use_start_date' => 'require|date',
|
||||
'use_end_date' => 'date',
|
||||
'items' => 'require|array',
|
||||
'items.*.item_id' => 'require|number',
|
||||
'items.*.request_qty' => 'require|number|gt:0',
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
'applicant_id.number' => '申请人格式错误',
|
||||
'borrow_reason.require' => '领用事由不能为空',
|
||||
'borrow_reason.max' => '领用事由最多不能超过255个字符',
|
||||
'use_start_date.require' => '使用开始日期不能为空',
|
||||
'use_start_date.date' => '使用开始日期格式错误',
|
||||
'use_end_date.date' => '预计归还日期格式错误',
|
||||
'items.require' => '申请物品明细不能为空',
|
||||
'items.array' => '申请物品明细格式错误',
|
||||
'items.*.item_id.require' => '物品ID不能为空',
|
||||
'items.*.item_id.number' => '物品ID格式错误',
|
||||
'items.*.request_qty.require' => '申请数量不能为空',
|
||||
'items.*.request_qty.number' => '申请数量格式错误',
|
||||
'items.*.request_qty.gt' => '申请数量必须大于0',
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
],
|
||||
|
||||
'apply' => [
|
||||
'applicant_id',
|
||||
'borrow_reason',
|
||||
'use_start_date',
|
||||
'use_end_date',
|
||||
'items'
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class MessageNotificationsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class MessageUserStatusValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class PurchaseOrderItemsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class PurchaseOrdersValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ResourceValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class RoleValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'system_id' => 'require|integer',
|
||||
'name' => 'require|max:64',
|
||||
'desc' => 'max:128',
|
||||
'sort' => 'integer',
|
||||
'status' => 'in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '角色ID不能为空',
|
||||
'system_id.require' => '系统ID不能为空',
|
||||
'name.require' => '角色名称不能为空',
|
||||
'name.max' => '角色名称不能超过64个字符',
|
||||
'desc.max' => '描述不能超过128个字符',
|
||||
'sort.integer' => '排序为数字',
|
||||
'status.in' => '状态值必须为0或1',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'store' => ['name', 'desc', 'sort'],
|
||||
'update' => ['id', 'name', 'desc', 'sort', 'status'],
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class StockOrderAccountsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class StockOrderItemOptionsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class StockOrderItemsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class StockOrdersFilesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class StockOrdersValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'number|egt:0',
|
||||
'order_no' => 'require|max:40|unique:stock_orders',
|
||||
'pi_no' => 'require|max:64',
|
||||
'biz_date' => 'require',
|
||||
'salesperson_id' => 'number|egt:0',
|
||||
'salesperson_snapshot' => 'max:64',
|
||||
'clearance_country_id' => 'require|number|egt:0',
|
||||
'clearance_country_snapshot' => 'require|max:64',
|
||||
'customer_source_id' => 'require|number|egt:0',
|
||||
'customer_source_snapshot' => 'require|max:64',
|
||||
'customer_id' => 'require|number|egt:0',
|
||||
'customer_snapshot' => 'require|max:128',
|
||||
'customer_country_id' => 'require|number|egt:0',
|
||||
'customer_country_snapshot' => 'require|max:64',
|
||||
'declarant_name' => 'require|max:64',
|
||||
'eta_ship_date' => 'number|egt:0',
|
||||
'shipping_method_id' => 'require|number',
|
||||
'shipping_method_snapshot' => 'require|max:32',
|
||||
'cif_total_amount' => 'require|float|egt:0',
|
||||
'domestic_port_id' => 'require|number|egt:0',
|
||||
'domestic_port_snapshot' => 'require|max:64',
|
||||
'trade_term_id' => 'require|number|egt:0',
|
||||
'trade_term_snapshot' => 'require|max:64',
|
||||
'clearance_port_id' => 'require|number|egt:0',
|
||||
'clearance_port_snapshot' => 'require|max:64',
|
||||
'latest_arrival_date' => 'number|egt:0',
|
||||
'contract_exchange_rate' => 'require|float|egt:0',
|
||||
'settlement_currency' => 'require|length:3|alpha',
|
||||
'remark' => 'max:255',
|
||||
'contract' => 'max:255',
|
||||
'is_use' => 'in:0,1',
|
||||
'object_id' => 'number|egt:0',
|
||||
'is_final' => 'in:0,1',
|
||||
'approval_status' => 'in:0,1,2,3',
|
||||
'status' => 'in:0,1',
|
||||
'file_url' => 'max:255',
|
||||
'pick_up_date' => 'number|egt:0',
|
||||
'collect_all_date' => 'number|egt:0',
|
||||
'created_at' => 'number|egt:0',
|
||||
'updated_at' => 'number|egt:0',
|
||||
'deleted_at' => 'number|egt:0',
|
||||
];
|
||||
|
||||
/**
|
||||
* 错误提示信息
|
||||
*/
|
||||
protected $message = [
|
||||
'order_no.require' => '备货单编号不能为空',
|
||||
'order_no.max' => '备货单编号长度不能超过40个字符',
|
||||
'order_no.unique' => '备货单编号已存在',
|
||||
'pi_no.require' => 'PI号不能为空',
|
||||
'pi_no.max' => 'PI号长度不能超过64个字符',
|
||||
'biz_date.require' => '单据日期不能为空',
|
||||
'clearance_country_id.require' => '清关目的国ID不能为空',
|
||||
'clearance_country_snapshot.require' => '清关目的国名称不能为空',
|
||||
'customer_source_id.require' => '客户来源ID不能为空',
|
||||
'customer_source_snapshot.require' => '客户来源名称不能为空',
|
||||
'customer_id.require' => '客户ID不能为空',
|
||||
'customer_snapshot.require' => '客户名称不能为空',
|
||||
'customer_country_id.require' => '客户所在国ID不能为空',
|
||||
'customer_country_snapshot.require' => '客户所在国名称不能为空',
|
||||
'declarant_name.require' => '清关人不能为空',
|
||||
'shipping_method_id.require' => '出运方式ID不能为空',
|
||||
'shipping_method_snapshot.require' => '出运方式不能为空',
|
||||
'cif_total_amount.require' => '合计到岸价不能为空',
|
||||
'cif_total_amount.float' => '合计到岸价必须为数字',
|
||||
'cif_total_amount.egt' => '合计到岸价不能为负数',
|
||||
'domestic_port_id.require' => '国内收货港ID不能为空',
|
||||
'domestic_port_snapshot.require' => '国内收货港名称不能为空',
|
||||
'trade_term_id.require' => '贸易条款ID不能为空',
|
||||
'trade_term_snapshot.require' => '贸易条款名称不能为空',
|
||||
'clearance_port_id.require' => '清关目的港ID不能为空',
|
||||
'clearance_port_snapshot.require' => '清关目的港名称不能为空',
|
||||
'contract_exchange_rate.require' => '合同汇率不能为空',
|
||||
'contract_exchange_rate.float' => '合同汇率必须为数字',
|
||||
'contract_exchange_rate.egt' => '合同汇率不能为负数',
|
||||
'settlement_currency.require' => '结算币种不能为空',
|
||||
'settlement_currency.length' => '结算币种必须为3个字符',
|
||||
'settlement_currency.alpha' => '结算币种必须为字母',
|
||||
'approval_status.in' => '审批状态值不正确',
|
||||
'status.in' => '状态值不正确',
|
||||
'is_final.in' => '是否终版值不正确',
|
||||
'is_use.in' => '是否开过终版值不正确',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
// 创建场景
|
||||
'store' => [
|
||||
'pi_no', 'biz_date',
|
||||
'clearance_country_id', 'clearance_country_snapshot', 'customer_source_id',
|
||||
'customer_source_snapshot', 'customer_id', 'customer_snapshot',
|
||||
'customer_country_id', 'customer_country_snapshot', 'declarant_name',
|
||||
'shipping_method_id', 'shipping_method_snapshot',
|
||||
'domestic_port_id', 'domestic_port_snapshot',
|
||||
'trade_term_id', 'trade_term_snapshot', 'clearance_port_id',
|
||||
'clearance_port_snapshot', 'contract_exchange_rate',
|
||||
'settlement_currency'
|
||||
],
|
||||
|
||||
// 更新场景
|
||||
'update' => [
|
||||
'pi_no', 'biz_date',
|
||||
'clearance_country_id', 'clearance_country_snapshot', 'customer_source_id',
|
||||
'customer_source_snapshot', 'customer_id', 'customer_snapshot',
|
||||
'customer_country_id', 'customer_country_snapshot', 'declarant_name',
|
||||
'shipping_method_id', 'shipping_method_snapshot',
|
||||
'domestic_port_id', 'domestic_port_snapshot',
|
||||
'trade_term_id', 'trade_term_snapshot', 'clearance_port_id',
|
||||
'clearance_port_snapshot', 'contract_exchange_rate',
|
||||
'settlement_currency'
|
||||
],
|
||||
|
||||
// 提交审批场景
|
||||
'submit' => [
|
||||
'id' => 'require|number|egt:1',
|
||||
'status' => 'require|in:1'
|
||||
],
|
||||
|
||||
// 审批场景
|
||||
'approve' => [
|
||||
'id' => 'require|number|egt:1',
|
||||
'approval_status' => 'require|in:1,2,3'
|
||||
],
|
||||
|
||||
// 状态更新场景
|
||||
'status' => [
|
||||
'id' => 'require|number|egt:1',
|
||||
'status' => 'require|in:0,1'
|
||||
],
|
||||
|
||||
// 简略验证场景(用于快速验证)
|
||||
'simple' => [
|
||||
'order_no', 'biz_date', 'cif_total_amount', 'settlement_currency'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* 自定义验证规则 - 验证时间戳是否合理
|
||||
*/
|
||||
protected function checkTimestamp($value, $rule, $data = [])
|
||||
{
|
||||
if ($value === 0 || $value === '0') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 时间戳应该在1970年到现在+1年的范围内
|
||||
$minTimestamp = 0;
|
||||
$maxTimestamp = time() + (365 * 24 * 60 * 60);
|
||||
|
||||
return $value >= $minTimestamp && $value <= $maxTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证规则 - 验证金额格式
|
||||
*/
|
||||
protected function checkMoney($value, $rule, $data = [])
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证小数点位数不超过2位
|
||||
if (strpos($value, '.') !== false) {
|
||||
$decimalPart = explode('.', $value)[1];
|
||||
if (strlen($decimalPart) > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景验证前回调 - 添加自定义规则
|
||||
*/
|
||||
// protected function sceneBefore($scene)
|
||||
// {
|
||||
// // 为时间戳字段添加自定义验证
|
||||
// $timestampFields = ['biz_date', 'eta_ship_date', 'latest_arrival_date', 'pick_up_date', 'collect_all_date', 'created_at', 'updated_at', 'deleted_at'];
|
||||
// foreach ($timestampFields as $field) {
|
||||
// if (isset($this->scene[$scene][$field])) {
|
||||
// $this->rule[$field] .= '|checkTimestamp';
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 为金额字段添加自定义验证
|
||||
// $moneyFields = ['cif_total_amount', 'contract_exchange_rate'];
|
||||
// foreach ($moneyFields as $field) {
|
||||
// if (isset($this->scene[$scene][$field])) {
|
||||
// $this->rule[$field] .= '|checkMoney';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysOpLogValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysUpdateLogValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SystemsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UploadedFilesValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'file_name' => 'require|max:255',
|
||||
'file_path' => 'require|max:500',
|
||||
'file_size' => 'require|integer|gt:0',
|
||||
'file_type' => 'require|max:100',
|
||||
'category' => 'require|max:50',
|
||||
'original_name' => 'max:255',
|
||||
'extension' => 'max:20',
|
||||
'partition' => 'max:50',
|
||||
'upload_ip' => 'ip',
|
||||
'user_agent' => 'max:500',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证消息
|
||||
*/
|
||||
protected $message = [
|
||||
'file_name.require' => '文件名不能为空',
|
||||
'file_name.max' => '文件名长度不能超过255个字符',
|
||||
'file_path.require' => '文件路径不能为空',
|
||||
'file_path.max' => '文件路径长度不能超过500个字符',
|
||||
'file_size.require' => '文件大小不能为空',
|
||||
'file_size.integer' => '文件大小必须是整数',
|
||||
'file_size.gt' => '文件大小必须大于0',
|
||||
'file_type.require' => '文件类型不能为空',
|
||||
'file_type.max' => '文件类型长度不能超过100个字符',
|
||||
'category.require' => '文件分类不能为空',
|
||||
'category.max' => '文件分类长度不能超过50个字符',
|
||||
'original_name.max' => '原始文件名长度不能超过255个字符',
|
||||
'extension.max' => '文件扩展名长度不能超过20个字符',
|
||||
'partition.max' => '分区名称长度不能超过50个字符',
|
||||
'upload_ip.ip' => '上传IP格式不正确',
|
||||
'user_agent.max' => '用户代理长度不能超过500个字符',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'create' => ['file_name', 'file_path', 'file_size', 'file_type', 'category'],
|
||||
'update' => ['file_name', 'file_path', 'file_size', 'file_type', 'category', 'original_name', 'extension', 'partition'],
|
||||
'search' => ['category', 'partition', 'file_type'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证文件上传
|
||||
*/
|
||||
public function sceneUpload()
|
||||
{
|
||||
return $this->append('file_name', 'require|max:255')
|
||||
->append('file_path', 'require|max:500')
|
||||
->append('file_size', 'require|integer|gt:0')
|
||||
->append('file_type', 'require|max:100')
|
||||
->append('category', 'require|max:50')
|
||||
->append('original_name', 'max:255')
|
||||
->append('extension', 'max:20')
|
||||
->append('partition', 'max:50')
|
||||
->append('upload_ip', 'ip')
|
||||
->append('user_agent', 'max:500');
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证文件信息更新
|
||||
*/
|
||||
public function sceneUpdateInfo()
|
||||
{
|
||||
return $this->append('file_name', 'require|max:255')
|
||||
->append('category', 'require|max:50')
|
||||
->append('original_name', 'max:255');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UsedcarCrawlResultsImagesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UsedcarCrawlResultsValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UserGroupMembersValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UserGroupValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use app\common\model\Corp;
|
||||
use app\common\model\Systems;
|
||||
use app\common\model\User;
|
||||
use think\Validate;
|
||||
|
||||
class UserValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'chsDash|max:60',
|
||||
'avatar' => 'regex:/^(https?:\/\/\S+|\\/[\S\/]+)$/',
|
||||
'password' => 'require|min:8|max:20|alphaNum',
|
||||
'confirm_password' => 'require|confirm:password',
|
||||
'account' => 'require|checkAccount|checkAccountUnique',
|
||||
'phone' => 'checkMobile|checkPhoneUnique',
|
||||
'email' => 'email|checkEmailUnique',
|
||||
'login_type' => 'require|in:upwd,feishu,qrcode',
|
||||
'system_code' => 'require|checkSystemCode',
|
||||
'corp_abbr' => 'require|checkCorpAbbr',
|
||||
'feishu_code' => 'require|string'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.chsDash' => '姓名只能是汉字、字母、数字和下划线_及破折号-',
|
||||
'name.max' => '姓名最多不能超过60个字符',
|
||||
'avatar.regex' => '头像必须是合法的URL或有效的文件路径',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.min' => '密码长度不能少于8位',
|
||||
'password.max' => '密码长度不能超过20位',
|
||||
'password.alphaNum' => '密码只能包含字母和数字',
|
||||
'confirm_password.require' => '请再次输入密码',
|
||||
'confirm_password.confirm' => '两次输入的密码不一致',
|
||||
'account.require' => '账号不能为空',
|
||||
'account.checkAccount' => '账号必须是有效的手机号或邮箱',
|
||||
'account.checkAccountUnique' => '账号已被注册',
|
||||
'phone.checkMobile' => '手机号格式不正确',
|
||||
'phone.checkPhoneUnique' => '手机号已被使用',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.checkEmailUnique' => '邮箱已被使用',
|
||||
'login_type.require' => '请选择登录方式',
|
||||
'login_type.in' => '登录方式不支持',
|
||||
'system_code.require' => '系统码不能为空',
|
||||
'system_code.checkSystemCode' => '系统码不存在或不合法',
|
||||
'corp_abbr.require' => '公司标识不能为空',
|
||||
'corp_abbr.checkCorpAbbr' => '公司标识不存在或不合法',
|
||||
'feishu_code.require' => '飞书code不能为空',
|
||||
'feishu_code.string' => '飞书code必须是字符串'
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'upwd_register' => ['name', 'account', 'password', 'confirm_password'],
|
||||
'feishu_register' => ['feishu_code'],
|
||||
'upwd_login' => ['account' => 'require|checkAccount', 'password'],
|
||||
'feishu_auth' => ['corp_abbr', 'system_code', 'login_type'],
|
||||
'feishu_login' => ['feishu_code'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证账号格式(手机号或邮箱)
|
||||
*/
|
||||
protected function checkAccount($value)
|
||||
{
|
||||
return $this->isMobile($value) || $this->isEmail($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证账号唯一性(注册场景用)
|
||||
*/
|
||||
protected function checkAccountUnique($value, $rule, $data, $field, $title)
|
||||
{
|
||||
// 登录场景不检查唯一性
|
||||
if (isset($this->currentScene) && $this->currentScene === 'login') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$type = $this->getAccountType($value);
|
||||
$field = ($type === 'phone') ? 'phone' : 'email';
|
||||
$value = ($type === 'phone') ? $this->formatPhone($value) : $value;
|
||||
|
||||
return !User::where($field, $value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为手机号
|
||||
*/
|
||||
protected function isMobile($value)
|
||||
{
|
||||
$mobile = preg_replace('/[\s+\-]/', '', $value);
|
||||
return preg_match('/^(\+86|0086)?1[3-9]\d{9}$/', $mobile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为邮箱
|
||||
*/
|
||||
protected function isEmail($value)
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号类型(phone/email)
|
||||
*/
|
||||
public function getAccountType($account)
|
||||
{
|
||||
return $this->isMobile($account) ? 'phone' : 'email';
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化手机号(移除+86和空格)
|
||||
*/
|
||||
public function formatPhone($phone)
|
||||
{
|
||||
return preg_replace('/^(\+86|0086)|[\s\-]/', '', $phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号唯一性验证
|
||||
*/
|
||||
protected function checkPhoneUnique($value)
|
||||
{
|
||||
return !User::where('phone', $this->formatPhone($value))->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱唯一性验证
|
||||
*/
|
||||
protected function checkEmailUnique($value)
|
||||
{
|
||||
return !User::where('email', $value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 system_code 是否在系统表中存在
|
||||
*/
|
||||
protected function checkSystemCode($value, $rule, $data, $field)
|
||||
{
|
||||
return Systems::where('code', $value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 corp_abbr 企业标识是否存在
|
||||
*/
|
||||
protected function checkCorpAbbr($value, $rule, $data, $field)
|
||||
{
|
||||
return Corp::where('abbr', $value)->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehDictI18nValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehDictMappingValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehMoneyValueValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehVehicleListingValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehVehicleSkuValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 规则定义
|
||||
*/
|
||||
protected $rule = [
|
||||
'sku_code' => 'max:40|alphaNum',
|
||||
'fingerprint' => 'length:64|alphaNum',
|
||||
'brand_code' => 'require|max:32',
|
||||
'brand_name' => 'require|max:64',
|
||||
'series_code' => 'max:64',
|
||||
'series_name' => 'max:128',
|
||||
'model_code' => 'max:64',
|
||||
'model_name' => 'require|max:128',
|
||||
'model_year' => 'require|number|between:1900,2100',
|
||||
'trim_code' => 'max:64',
|
||||
'trim_level_code' => 'max:64',
|
||||
'edition_code' => 'max:64',
|
||||
'trim' => 'max:128',
|
||||
'trim_level' => 'max:64',
|
||||
'edition_name' => 'max:64',
|
||||
'body_type_code' => 'max:32',
|
||||
'drive_type_code' => 'max:16',
|
||||
'motor_layout_code' => 'max:32',
|
||||
'fuel_type_code' => 'max:16',
|
||||
'engine_disp_l' => 'float|between:0,99.9',
|
||||
'engine_turbo' => 'in:0,1',
|
||||
'engine_power_kw' => 'number|between:0,2000',
|
||||
'battery_kwh' => 'float|between:0,999.99',
|
||||
'transmission_code' => 'max:16',
|
||||
'gears' => 'number|between:1,20',
|
||||
'range_km' => 'number|between:0,2000',
|
||||
'range_std_code' => 'max:16',
|
||||
'doors' => 'number|between:2,10',
|
||||
'seats' => 'number|between:1,20',
|
||||
'weight_kg' => 'number|between:0,10000',
|
||||
'dimensions_mm' => 'array',
|
||||
'color_exterior_code'=> 'max:32',
|
||||
'color_exterior_text'=> 'max:64',
|
||||
'color_interior_code'=> 'max:32',
|
||||
'color_interior_text'=> 'max:64',
|
||||
'options_official' => 'array',
|
||||
'features' => 'array',
|
||||
'emission_std_code' => 'max:16',
|
||||
'origin_country' => 'alpha|length:2',
|
||||
'currency' => 'require|alpha|length:3',
|
||||
'msrp' => 'float|between:0,9999999999.99',
|
||||
'is_active' => 'in:0,1',
|
||||
'corp_id' => 'require|number',
|
||||
'remark' => 'max:255',
|
||||
'created_by' => 'number',
|
||||
'updated_by' => 'number',
|
||||
'created_at' => 'require|number',
|
||||
'updated_at' => 'require|number',
|
||||
];
|
||||
|
||||
/**
|
||||
* 字段别名
|
||||
*/
|
||||
protected $field = [
|
||||
'sku_code' => 'SKU编码',
|
||||
'fingerprint' => '规格指纹',
|
||||
'brand_code' => '品牌代码',
|
||||
'brand_name' => '品牌名称',
|
||||
'series_code' => '车系代码',
|
||||
'series_name' => '车系名称',
|
||||
'model_code' => '车型代码',
|
||||
'model_name' => '车型名称',
|
||||
'model_year' => '年款',
|
||||
'trim_code' => '版型代码',
|
||||
'trim_level_code' => '配置等级代码',
|
||||
'edition_code' => '特别版代码',
|
||||
'trim' => '版型/细分配置',
|
||||
'trim_level' => '配置等级',
|
||||
'edition_name' => '特别版名称',
|
||||
'body_type_code' => '车身类型',
|
||||
'drive_type_code' => '驱动方式',
|
||||
'motor_layout_code' => '电机布置',
|
||||
'fuel_type_code' => '能源类型',
|
||||
'engine_disp_l' => '排量(L)',
|
||||
'engine_turbo' => '是否涡轮',
|
||||
'engine_power_kw' => '最大功率(kW)',
|
||||
'battery_kwh' => '电池容量(kWh)',
|
||||
'transmission_code' => '变速箱代码',
|
||||
'gears' => '挡位数',
|
||||
'range_km' => '续航里程',
|
||||
'range_std_code' => '续航标准',
|
||||
'doors' => '门数',
|
||||
'seats' => '座位数',
|
||||
'weight_kg' => '整备质量',
|
||||
'dimensions_mm' => '车身尺寸',
|
||||
'color_exterior_code'=> '外观色代码',
|
||||
'color_exterior_text'=> '外观色名称',
|
||||
'color_interior_code'=> '内饰色代码',
|
||||
'color_interior_text'=> '内饰色名称',
|
||||
'options_official' => '官方选装',
|
||||
'features' => '功能配置',
|
||||
'emission_std_code' => '排放标准',
|
||||
'origin_country' => '原产国',
|
||||
'currency' => '币种',
|
||||
'msrp' => '建议零售价',
|
||||
'is_active' => '是否启用',
|
||||
'corp_id' => '公司ID',
|
||||
'remark' => '备注',
|
||||
'created_by' => '创建人',
|
||||
'updated_by' => '更新人',
|
||||
'created_at' => '创建时间',
|
||||
'updated_at' => '更新时间',
|
||||
];
|
||||
|
||||
/**
|
||||
* 场景定义
|
||||
*/
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
'brand_code', 'brand_name', 'model_year','currency'
|
||||
],
|
||||
'update' => [
|
||||
'id', 'brand_code','brand_name', 'model_year','currency'
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehVehicleUnitValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user