存客宝应用接口初始化
This commit is contained in:
31
application/cunkebao/validate/DistributionChannel.php
Normal file
31
application/cunkebao/validate/DistributionChannel.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 分销渠道验证器
|
||||
*/
|
||||
class DistributionChannel extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require|length:1,50',
|
||||
'phone' => 'regex:^1[3-9]\d{9}$',
|
||||
'wechatId' => 'max:50',
|
||||
'remarks' => 'max:200',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '渠道名称不能为空',
|
||||
'name.length' => '渠道名称长度必须在1-50个字符之间',
|
||||
'phone.regex' => '手机号格式不正确,请输入11位数字且以1开头',
|
||||
'wechatId.max' => '微信号长度不能超过50个字符',
|
||||
'remarks.max' => '备注信息长度不能超过200个字符',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['name', 'phone', 'wechatId', 'remarks'],
|
||||
];
|
||||
}
|
||||
|
||||
48
application/cunkebao/validate/Task.php
Normal file
48
application/cunkebao/validate/Task.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 任务验证器
|
||||
*/
|
||||
class Task extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require|max:100',
|
||||
'device_id' => 'number',
|
||||
'scene_id' => 'number',
|
||||
'scene_config' => 'array',
|
||||
'status' => 'in:0,1,2,3',
|
||||
'priority' => 'between:1,10',
|
||||
'created_by' => 'number'
|
||||
];
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'name.require' => '任务名称不能为空',
|
||||
'name.max' => '任务名称不能超过100个字符',
|
||||
'device_id.number' => '设备ID必须是数字',
|
||||
'scene_id.number' => '场景ID必须是数字',
|
||||
'scene_config.array'=> '场景配置必须是数组',
|
||||
'status.in' => '状态值无效',
|
||||
'priority.between' => '优先级必须在1到10之间',
|
||||
'created_by.number' => '创建者ID必须是数字'
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
* @var array
|
||||
*/
|
||||
protected $scene = [
|
||||
'create' => ['name', 'device_id', 'scene_id', 'scene_config', 'status', 'priority', 'created_by'],
|
||||
'update' => ['name', 'device_id', 'scene_id', 'scene_config', 'status', 'priority']
|
||||
];
|
||||
}
|
||||
51
application/cunkebao/validate/Traffic.php
Normal file
51
application/cunkebao/validate/Traffic.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 流量验证器
|
||||
*/
|
||||
class Traffic extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'mobile' => 'require|mobile',
|
||||
'gender' => 'in:0,1,2',
|
||||
'age' => 'number|between:0,120',
|
||||
'tags' => 'max:255',
|
||||
'province' => 'max:50',
|
||||
'city' => 'max:50',
|
||||
'source_channel' => 'max:50',
|
||||
'source_detail' => 'array'
|
||||
];
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'mobile.require' => '手机号不能为空',
|
||||
'mobile.mobile' => '手机号格式不正确',
|
||||
'gender.in' => '性别值无效',
|
||||
'age.number' => '年龄必须是数字',
|
||||
'age.between' => '年龄必须在0到120之间',
|
||||
'tags.max' => '标签不能超过255个字符',
|
||||
'province.max' => '省份不能超过50个字符',
|
||||
'city.max' => '城市不能超过50个字符',
|
||||
'source_channel.max' => '来源渠道不能超过50个字符',
|
||||
'source_detail.array'=> '来源详情必须是数组'
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
* @var array
|
||||
*/
|
||||
protected $scene = [
|
||||
'create' => ['mobile', 'gender', 'age', 'tags', 'province', 'city', 'source_channel', 'source_detail'],
|
||||
'update' => ['gender', 'age', 'tags', 'province', 'city']
|
||||
];
|
||||
}
|
||||
386
application/cunkebao/validate/Workbench.php
Normal file
386
application/cunkebao/validate/Workbench.php
Normal file
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Workbench extends Validate
|
||||
{
|
||||
// 工作台类型定义
|
||||
const TYPE_AUTO_LIKE = 1; // 自动点赞
|
||||
const TYPE_MOMENTS_SYNC = 2; // 朋友圈同步
|
||||
const TYPE_GROUP_PUSH = 3; // 群消息推送
|
||||
const TYPE_GROUP_CREATE = 4; // 自动建群
|
||||
const TYPE_TRAFFIC_DISTRIBUTION = 5; // 流量分发
|
||||
const TYPE_IMPORT_CONTACT = 6; // 流量分发
|
||||
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require|max:100',
|
||||
'type' => 'require|in:1,2,3,4,5,6',
|
||||
//'autoStart' => 'require|boolean',
|
||||
// 自动点赞特有参数
|
||||
'interval' => 'requireIf:type,1|number|min:1',
|
||||
'maxLikes' => 'requireIf:type,1|number|min:1',
|
||||
'startTime' => 'requireIf:type,1|dateFormat:H:i',
|
||||
'endTime' => 'requireIf:type,1|dateFormat:H:i',
|
||||
'contentTypes' => 'requireIf:type,1|array|contentTypeEnum:text,image,video',
|
||||
//'targetGroups' => 'requireIf:type,1|array',
|
||||
// 朋友圈同步特有参数
|
||||
//'syncInterval' => 'requireIf:type,2|number|min:1',
|
||||
'syncCount' => 'requireIf:type,2|number|min:1',
|
||||
'syncType' => 'requireIf:type,2|in:1,2,3,4',
|
||||
'startTime' => 'requireIf:type,2|dateFormat:H:i',
|
||||
'endTime' => 'requireIf:type,2|dateFormat:H:i',
|
||||
'accountGroups' => 'requireIf:type,2|in:1,2',
|
||||
'contentGroups' => 'requireIf:type,2|array',
|
||||
// 群消息推送特有参数
|
||||
'pushType' => 'requireIf:type,3|in:0,1', // 推送方式 0定时 1立即
|
||||
'targetType' => 'requireIf:type,3|in:1,2', // 推送目标类型:1=群推送,2=好友推送
|
||||
'groupPushSubType' => 'checkGroupPushSubType|in:1,2', // 群推送子类型:1=群群发,2=群公告(仅当targetType=1时有效)
|
||||
'maxPerDay' => 'requireIf:type,3|number|min:1',
|
||||
'pushOrder' => 'requireIf:type,3|in:1,2', // 1最早 2最新
|
||||
'isLoop' => 'requireIf:type,3|in:0,1',
|
||||
'status' => 'requireIf:type,3|in:0,1',
|
||||
'wechatGroups' => 'checkGroupPushTarget|array|min:1', // 当targetType=1时必填
|
||||
'wechatFriends' => 'checkFriendPushTarget|array', // 当targetType=2时可选(可以为空)
|
||||
'ownerWechatId' => 'checkFriendPushService', // 当targetType=2且未选择好友/流量池时必填
|
||||
'contentGroups' => 'requireIf:type,3|array|min:1',
|
||||
// 群公告特有参数
|
||||
'announcementContent' => 'checkAnnouncementContent|max:5000', // 群公告内容(当groupPushSubType=2时必填)
|
||||
'enableAiRewrite' => 'checkEnableAiRewrite|in:0,1', // 是否启用AI智能话术改写
|
||||
'aiRewritePrompt' => 'checkAiRewritePrompt|max:500', // AI改写提示词(当enableAiRewrite=1时必填)
|
||||
// 自动建群特有参数
|
||||
'groupNameTemplate' => 'requireIf:type,4|max:50',
|
||||
'maxGroupsPerDay' => 'requireIf:type,4|number|min:1',
|
||||
'groupSizeMin' => 'requireIf:type,4|number|min:1|max:50',
|
||||
'groupSizeMax' => 'requireIf:type,4|number|min:1|max:50',
|
||||
// 流量分发特有参数
|
||||
'distributeType' => 'requireIf:type,5|in:1,2',
|
||||
'maxPerDay' => 'requireIf:type,5|number|min:1',
|
||||
'timeType' => 'requireIf:type,5|in:1,2',
|
||||
'accountGroups' => 'requireIf:type,5|array|min:1',
|
||||
// 通用参数
|
||||
'deviceGroups' => 'requireIf:type,1,2,5|array',
|
||||
'trafficPools' => 'checkFriendPushPools',
|
||||
];
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'name.require' => '请输入任务名称',
|
||||
'name.max' => '任务名称最多100个字符',
|
||||
'type.require' => '请选择工作台类型',
|
||||
'type.in' => '工作台类型错误',
|
||||
'autoStart.require' => '请选择是否自动启动',
|
||||
'autoStart.boolean' => '自动启动参数必须为布尔值',
|
||||
// 自动点赞相关提示
|
||||
'interval.requireIf' => '请设置点赞间隔',
|
||||
'interval.number' => '点赞间隔必须为数字',
|
||||
'interval.min' => '点赞间隔必须大于0',
|
||||
'maxLikes.requireIf' => '请设置每日最大点赞数',
|
||||
'maxLikes.number' => '每日最大点赞数必须为数字',
|
||||
'maxLikes.min' => '每日最大点赞数必须大于0',
|
||||
'startTime.requireIf' => '请设置开始时间',
|
||||
'startTime.dateFormat' => '开始时间格式错误',
|
||||
'endTime.requireIf' => '请设置结束时间',
|
||||
'endTime.dateFormat' => '结束时间格式错误',
|
||||
'contentTypes.requireIf' => '请选择点赞内容类型',
|
||||
'contentTypes.array' => '点赞内容类型必须是数组',
|
||||
'contentTypes.contentTypeEnum' => '点赞内容类型只能是text、image、video',
|
||||
// 朋友圈同步相关提示
|
||||
/* 'syncInterval.requireIf' => '请设置同步间隔',
|
||||
'syncInterval.number' => '同步间隔必须为数字',
|
||||
'syncInterval.min' => '同步间隔必须大于0',*/
|
||||
'syncCount.requireIf' => '请设置同步数量',
|
||||
'syncCount.number' => '同步数量必须为数字',
|
||||
'syncCount.min' => '同步数量必须大于0',
|
||||
'syncType.requireIf' => '请选择同步类型',
|
||||
'syncType.in' => '同步类型错误',
|
||||
'startTime.requireIf' => '请设置发布开始时间',
|
||||
'startTime.dateFormat' => '发布开始时间格式错误',
|
||||
'endTime.requireIf' => '请设置发布结束时间',
|
||||
'endTime.dateFormat' => '发布结束时间格式错误',
|
||||
'accountGroups.requireIf' => '请选择账号类型',
|
||||
'accountGroups.in' => '账号类型错误',
|
||||
'contentGroups.requireIf' => '请选择内容库',
|
||||
'contentGroups.array' => '内容库格式错误',
|
||||
// 群消息推送相关提示
|
||||
'pushType.requireIf' => '请选择推送方式',
|
||||
'startTime.requireIf' => '请设置推送开始时间',
|
||||
'startTime.dateFormat' => '推送开始时间格式错误',
|
||||
'endTime.requireIf' => '请设置推送结束时间',
|
||||
'endTime.dateFormat' => '推送结束时间格式错误',
|
||||
'maxPerDay.requireIf' => '请设置每日最大推送数',
|
||||
'maxPerDay.number' => '每日最大推送数必须为数字',
|
||||
'maxPerDay.min' => '每日最大推送数必须大于0',
|
||||
'pushOrder.requireIf' => '请选择推送顺序',
|
||||
'pushOrder.in' => '推送顺序错误',
|
||||
'isLoop.requireIf' => '请选择是否循环推送',
|
||||
'isLoop.in' => '循环推送参数错误',
|
||||
'targetType.requireIf' => '请选择推送目标类型',
|
||||
'targetType.in' => '推送目标类型错误,只能选择群推送或好友推送',
|
||||
'wechatGroups.requireIf' => '请选择推送群组',
|
||||
'wechatGroups.checkGroupPushTarget' => '群推送时必须选择推送群组',
|
||||
'wechatGroups.array' => '推送群组格式错误',
|
||||
'wechatGroups.min' => '至少选择一个推送群组',
|
||||
'groupPushSubType.checkGroupPushSubType' => '群推送子类型错误',
|
||||
'groupPushSubType.in' => '群推送子类型只能是群群发或群公告',
|
||||
'announcementContent.checkAnnouncementContent' => '群公告必须输入公告内容',
|
||||
'announcementContent.max' => '公告内容最多5000个字符',
|
||||
'enableAiRewrite.checkEnableAiRewrite' => 'AI智能话术改写参数错误',
|
||||
'enableAiRewrite.in' => 'AI智能话术改写参数只能是0或1',
|
||||
'aiRewritePrompt.checkAiRewritePrompt' => '启用AI智能话术改写时,必须输入改写提示词',
|
||||
'aiRewritePrompt.max' => '改写提示词最多500个字符',
|
||||
'wechatFriends.requireIf' => '请选择推送好友',
|
||||
'wechatFriends.checkFriendPushTarget' => '好友推送时必须选择推送好友',
|
||||
'wechatFriends.array' => '推送好友格式错误',
|
||||
'deviceGroups.requireIf' => '请选择设备',
|
||||
'deviceGroups.array' => '设备格式错误',
|
||||
'ownerWechatId.checkFriendPushService' => '好友推送需选择客服或提供好友/流量池',
|
||||
// 自动建群相关提示
|
||||
'groupNameTemplate.requireIf' => '请设置群名称前缀',
|
||||
'groupNameTemplate.max' => '群名称前缀最多50个字符',
|
||||
'maxGroupsPerDay.requireIf' => '请设置最大建群数量',
|
||||
'maxGroupsPerDay.number' => '最大建群数量必须为数字',
|
||||
'maxGroupsPerDay.min' => '最大建群数量必须大于0',
|
||||
'groupSizeMin.requireIf' => '请设置每个群的人数',
|
||||
'groupSizeMin.number' => '每个群的人数必须为数字',
|
||||
'groupSizeMin.min' => '每个群的人数必须大于0',
|
||||
'groupSizeMin.max' => '每个群的人数最大50人',
|
||||
'groupSizeMax.requireIf' => '请设置每个群的人数',
|
||||
'groupSizeMax.number' => '每个群的人数必须为数字',
|
||||
'groupSizeMax.min' => '每个群的人数必须大于0',
|
||||
'groupSizeMax.max' => '每个群的人数最大50人',
|
||||
// 流量分发相关提示
|
||||
'distributeType.requireIf' => '请选择流量分发类型',
|
||||
'distributeType.in' => '流量分发类型错误',
|
||||
'maxPerDay.requireIf' => '请设置每日最大流量',
|
||||
'maxPerDay.number' => '每日最大流量必须为数字',
|
||||
'maxPerDay.min' => '每日最大流量必须大于0',
|
||||
'timeType.requireIf' => '请选择时间类型',
|
||||
|
||||
// 通用提示
|
||||
'deviceGroups.require' => '请选择设备',
|
||||
'deviceGroups.array' => '设备格式错误',
|
||||
'targetGroups.require' => '请选择目标用户组',
|
||||
'targetGroups.array' => '目标用户组格式错误',
|
||||
'accountGroups.requireIf' => '流量分发时必须选择分发账号',
|
||||
'accountGroups.array' => '分发账号格式错误',
|
||||
'accountGroups.min' => '至少选择一个分发账号',
|
||||
'trafficPools.checkFriendPushPools' => '好友推送时请选择好友或流量池',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'create' => ['name', 'type', 'autoStart', 'deviceGroups', 'targetGroups',
|
||||
'interval', 'maxLikes', 'startTime', 'endTime', 'contentTypes',
|
||||
'syncCount', 'syncType', 'accountGroups',
|
||||
'pushType', 'targetType', 'groupPushSubType', 'startTime', 'endTime', 'maxPerDay', 'pushOrder', 'isLoop', 'status', 'wechatGroups', 'wechatFriends', 'trafficPools', 'ownerWechatId', 'contentGroups',
|
||||
'announcementContent', 'enableAiRewrite', 'aiRewritePrompt',
|
||||
'groupNameTemplate', 'maxGroupsPerDay', 'groupSizeMin', 'groupSizeMax',
|
||||
'distributeType', 'timeType', 'accountGroups',
|
||||
],
|
||||
'update_status' => ['id', 'status'],
|
||||
'update' => ['name', 'type', 'autoStart', 'deviceGroups', 'targetGroups',
|
||||
'interval', 'maxLikes', 'startTime', 'endTime', 'contentTypes',
|
||||
'syncCount', 'syncType', 'accountGroups',
|
||||
'pushType', 'targetType', 'groupPushSubType', 'startTime', 'endTime', 'maxPerDay', 'pushOrder', 'isLoop', 'status', 'wechatGroups', 'wechatFriends', 'trafficPools', 'ownerWechatId', 'contentGroups',
|
||||
'announcementContent', 'enableAiRewrite', 'aiRewritePrompt',
|
||||
'groupNameTemplate', 'maxGroupsPerDay', 'groupSizeMin', 'groupSizeMax',
|
||||
'distributeType', 'timeType', 'accountGroups',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* 自定义验证规则
|
||||
*/
|
||||
protected function contentTypeEnum($value, $rule, $data)
|
||||
{
|
||||
$allowTypes = explode(',', $rule);
|
||||
foreach ($value as $type) {
|
||||
if (!in_array($type, $allowTypes)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证群推送目标(当targetType=1时,wechatGroups必填)
|
||||
*/
|
||||
protected function checkGroupPushTarget($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
// 如果targetType=1(群推送),则wechatGroups必填
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
if ($targetType == 1) {
|
||||
// 检查值是否存在且有效
|
||||
if (!isset($value) || $value === null || $value === '') {
|
||||
return false;
|
||||
}
|
||||
if (!is_array($value) || count($value) < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证好友推送目标(当targetType=2时,wechatFriends可选,可以为空)
|
||||
*/
|
||||
protected function checkFriendPushTarget($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
// 如果targetType=2(好友推送),wechatFriends可以为空数组
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
if ($targetType == 2) {
|
||||
// 如果提供了值,则必须是数组
|
||||
if (isset($value) && $value !== null && $value !== '') {
|
||||
if (!is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证好友推送时设备必填(当targetType=2时,deviceGroups必填)
|
||||
*/
|
||||
protected function checkFriendPushService($value, $rule, $data)
|
||||
{
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
if ($targetType == 2) {
|
||||
if ($value !== null && $value !== '' && !is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hasFriends = isset($data['wechatFriends']) && is_array($data['wechatFriends']) && count($data['wechatFriends']) > 0;
|
||||
$hasPools = isset($data['trafficPools']) && is_array($data['trafficPools']) && count($data['trafficPools']) > 0;
|
||||
$hasServices = is_array($value) && count(array_filter($value, function ($item) {
|
||||
if (is_array($item)) {
|
||||
return !empty($item['ownerWechatId'] ?? $item['wechatId'] ?? $item['id']);
|
||||
}
|
||||
return $item !== null && $item !== '';
|
||||
})) > 0;
|
||||
|
||||
if (!$hasFriends && !$hasPools && !$hasServices) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证好友推送时是否选择好友或流量池(至少其一)
|
||||
*/
|
||||
protected function checkFriendPushPools($value, $rule, $data)
|
||||
{
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
if ($targetType == 2) {
|
||||
$hasFriends = isset($data['wechatFriends']) && !empty($data['wechatFriends']);
|
||||
$hasPools = isset($value) && $value !== null && $value !== '' && is_array($value) && count($value) > 0;
|
||||
if (!$hasFriends && !$hasPools) {
|
||||
return false;
|
||||
}
|
||||
if (isset($value) && $value !== null && $value !== '') {
|
||||
if (!is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证群推送子类型(当targetType=1时,groupPushSubType必填且只能是1或2)
|
||||
*/
|
||||
protected function checkGroupPushSubType($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
// 如果targetType=1(群推送),则groupPushSubType必填
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
if ($targetType == 1) {
|
||||
// 检查值是否存在且有效
|
||||
if (!isset($value) || !in_array(intval($value), [1, 2])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证群公告内容(当groupPushSubType=2时,announcementContent必填)
|
||||
*/
|
||||
protected function checkAnnouncementContent($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
// 如果targetType=1且groupPushSubType=2(群公告),则announcementContent必填
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
$groupPushSubType = isset($data['groupPushSubType']) ? intval($data['groupPushSubType']) : 1; // 默认1
|
||||
if ($targetType == 1 && $groupPushSubType == 2) {
|
||||
// 检查值是否存在且有效
|
||||
if (!isset($value) || $value === null || trim($value) === '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证AI智能话术改写(当enableAiRewrite=1时,aiRewritePrompt必填)
|
||||
*/
|
||||
protected function checkEnableAiRewrite($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型且是群公告
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
$groupPushSubType = isset($data['groupPushSubType']) ? intval($data['groupPushSubType']) : 1; // 默认1
|
||||
if ($targetType == 1 && $groupPushSubType == 2) {
|
||||
// 检查值是否存在且有效
|
||||
if (!isset($value) || !in_array(intval($value), [0, 1])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证AI改写提示词(当enableAiRewrite=1时,aiRewritePrompt必填)
|
||||
*/
|
||||
protected function checkAiRewritePrompt($value, $rule, $data)
|
||||
{
|
||||
// 如果是群消息推送类型且是群公告
|
||||
if (isset($data['type']) && $data['type'] == self::TYPE_GROUP_PUSH) {
|
||||
$targetType = isset($data['targetType']) ? intval($data['targetType']) : 1; // 默认1
|
||||
$groupPushSubType = isset($data['groupPushSubType']) ? intval($data['groupPushSubType']) : 1; // 默认1
|
||||
$enableAiRewrite = isset($data['enableAiRewrite']) ? intval($data['enableAiRewrite']) : 0; // 默认0
|
||||
if ($targetType == 1 && $groupPushSubType == 2 && $enableAiRewrite == 1) {
|
||||
// 如果启用AI改写,提示词必填
|
||||
if (!isset($value) || $value === null || trim($value) === '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user