123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- <?php
-
-
- namespace app\shop\validate\content;
-
- use app\common\model\content\Closure as ClosureModel;
-
- use app\common\basics\Validate;
-
- class ClosureValidate extends Validate
- {
- protected $rule = [
- 'id' => 'require|number',
- 'cid' => 'require|number',
- 'title' => 'require',
- // 'version' => 'require|checkVersion',
- 'a2' => 'require|number|checkPost',
- 'a3' => 'require|number',
- ];
-
- protected $message = [
- 'id.require' => 'id不可为空',
- 'id.number' => 'id必须为数字',
- 'cid.require' => '请选择分类',
- 'cid.number' => '分类选择异常',
- 'title.require' => '请填写文章标题',
- 'version.require' => '请填写版本号',
- 'a2.require' => '运行时长不可为空',
- 'a2.number' => '运行时长必须为数字',
- 'a3.require' => '操作总数不可为空',
- 'a3.number' => '操作总数必须为数字',
- ];
-
- protected $scene = [
- 'id' => ['id'],
- 'add' => [
- 'cid', 'title',
- 'a2',
- 'a3'
- ],
- 'edit' => [
- 'id', 'cid', 'title',
- 'a2',
- 'a3'
- ],
- ];
-
- /*
- * 检查版本号
- */
- protected function checkVersion($value,$rule,$data){
- $where[] = ['shop_id','=',$data['shop_id']];
- $where[] = ['del','=',0];
- // 如果有id代表是编辑校验分类名称
- if(isset($data['id'])){
- $where[] = ['id','<>',$data['id']];
- }
- $where[] = ['version','=',$data['version']];
- $where[] = ['cid','=',$data['cid']];
- $where[] = ['yid','=',$data['yid']];
-
- $name = ClosureModel::where($where)->value('version');
- if($name){
- return '版本号已存在';
- }
- return true;
- }
-
- /*
- * 验证所有post 参数
- * 通过a1字段 触发函数
- */
- protected function checkPost($value,$rule,$data){
-
-
- $msg = "-不能为空!";
- if(empty($data['a7'])){
- return "切换搜索词".$msg;
- }
- if(empty($data['e7'])){
- return "互动评论随机语句".$msg;
- }
- if(empty($data['f10'])){
- return "指定账号列表".$msg;
- }
- if(empty($data['f11'])){
- return "账号关键词列表".$msg;
- }
- if(empty($data['f12'])){
- return "账号过滤词列表".$msg;
- }
- if(empty($data['f13'])){
- return "标题名称关键词".$msg; //截流内容名称关键词
- }
- if(empty($data['f14'])){
- return "标题名称过滤词".$msg; //截流内容名称过滤词
- }
- if(empty($data['f15'])){
- return "笔记评论满足时间条件的关键词".$msg; //截流笔记内容满足时间条件的关键词正则
- }
- if(empty($data['f17'])){
- return "视频评论满足时间条件的关键词".$msg; //截流视频内容满足时间条件的关键词正则
- }
- if(empty($data['f19'])){
- return "评论账号过滤词".$msg;
- }
- if(empty($data['f20'])){
- return "评论名称关键词".$msg;
- }
- if(empty($data['f24'])){
- return "私信名称关键词".$msg;
- }
- if(empty($data['k6'])){
- return "评论钩子内容".$msg;
- }
-
- if((int)$data['a2'] < 900){
- return "运行时长不能小于900秒!";
- }
-
- if((int)$data['a3'] < 100){
- return "操作总数不能小于100个!";
- }
-
- if((int)$data['a4'] === 1){
- //组合模式
- if($data['a1'] == '推荐'){
- if((int)$data['a5'][0] < 120){
- return "推荐时长不能小于120秒";
- }
- if((int)$data['a5'][1] < 120){
- return "搜索时长不能小于120秒!";
- }
- }else if($data['a1'] == '搜索') {
- if ((int)$data['a6'][0] < 120) {
- return "搜索时长不能小于120秒";
- }
- if ((int)$data['a6'][1] < 120) {
- return "推荐时长不能小于120秒!";
- }
- }else{
-
- }
- }
-
- //搜索词
- if(empty($data['a7'])){
- return "启动设置-搜索词-不能为空!";
- }
-
- //过滤词
- if (strpos($data['b3'], "|") === false) {
- return "列表设置-过滤词格式不正确!";
- }
- //分类规则
- foreach ($data['b2_1'] as $k100 => $v100) {
- if(empty($v100) && $k100 !== 1){
- return "列表设置-分类规则-匹配词不能为空!";
- }
- }
- foreach ($data['b2_2'] as $k101 => $v101) {
- if(empty($v101) && $k101 !== 1){
- return "列表设置-分类规则-每[]个不能为空!";
- }
- }
- foreach ($data['b2_3'] as $k102 => $v102) {
- if(empty($v102) && $k102 !== 1){
- return "列表设置-分类规则-点击[]个不能为空!";
- }
- if($v102 > $data['b2_4'][$k102] && $k102 !== 1){
- return "列表设置-分类规则-点击范围大小错误";
- }
- }
- foreach ($data['b2_4'] as $k103 => $v103) {
- if(empty($v103) && $k103 !== 1){
- return "列表设置-分类规则-到[]个不能为空!";
- }
- }
-
- //列表操作 滑动操作
- if(empty($data['b4'])){
- return "列表设置-滑动操作-随机滑动-不能为空!";
- }
- if((int)$data['b4'][0] > (int)$data['b4'][1]){
- return "列表设置-滑动操作-随机滑动-范围大小错误";
- }
- if(empty($data['b5'])){
- return "列表设置-滑动操作-返回滑动-不能为空!";
- }
- if((int)$data['b5'][0] > (int)$data['b5'][1]){
- return "列表设置-滑动操作-返回滑动-范围大小错误";
- }
- if(empty($data['b6'])){
- return "列表设置-滑动操作-列表滑动-不能为空!";
- }
-
-
- //浏览笔记
- foreach ($data['c1_1'] as $k => $v) {
- if(empty($v) && $k > 2){
- return "浏览笔记-观看时长-评论数-不能为空!";
- }else if(strpos($v, "-") === false && $k > 2) {
- return "浏览笔记-观看时长-评论数规则格式不正确!";
- }else{
- if($k !== 2){
- if(empty($data['c1_2'][$k]) || $data['c1_2'][$k] == 0){
- return "浏览笔记-观看时长-观看秒数不能为空或等于0!";
- }else if(empty($data['c1_3'][$k]) || $data['c1_3'][$k] == 0){
- return "浏览笔记-观看时长-观看秒数不能为空或等于0!";
- }else if((int)$data['c1_2'][$k] > (int)$data['c1_3'][$k]){
- return "浏览笔记-观看时长-观看时间大小有误!";
- }
- }
- }
- }
-
- //随机滑动
- if(empty($data['c2'][0]) || $data['c2'][0] == 0){
- return "浏览笔记-随机滑动-次数不能为空或等于0!";
- }else if(empty($data['c2'][1]) || $data['c2'][1] == 0){
- return "浏览笔记-随机滑动-次数不能为空或等于0!";
- }else if((int)$data['c2'][0] > (int)$data['c2'][1]){
- return "浏览笔记-随机滑动-次数大小有误!";
- }
-
- //滑动等待
- if(empty($data['c3'][0]) || $data['c3'][0] == 0){
- return "浏览笔记-滑动等待-次数不能为空或等于0!";
- }else if(empty($data['c3'][1]) || $data['c3'][1] == 0){
- return "浏览笔记-滑动等待-次数不能为空或等于0!";
- }else if((int)$data['c3'][0] > (int)$data['c3'][1]){
- return "浏览笔记-滑动等待-次数大小有误!";
- }
-
- //评论区
- if(empty($data['c4'])){
- return "浏览笔记-评论区-滑动比例-不能为空!";
- }
-
- //展开回复
- if(empty($data['c5'][0]) || $data['c5'][0] == 0){
- return "浏览笔记-展开回复-次数不能为空或等于0!";
- }else if(empty($data['c5'][1]) || $data['c5'][1] == 0){
- return "浏览笔记-展开回复-次数不能为空或等于0!";
- }else if((int)$data['c5'][0] > (int)$data['c5'][1]){
- return "浏览笔记-展开回复-次数大小有误!";
- }
- //展开概率
- if(empty($data['c6'][0]) || $data['c6'][0] == 0){
- return "浏览笔记-展开概率-最小数不能为空或等于0!";
- }else if(empty($data['c6'][1]) || $data['c6'][1] == 0){
- return "浏览笔记-展开概率-最大数不能为空或等于0!";
- }else if((int)$data['c6'][0] > (int)$data['c6'][1]){
- return "浏览笔记-展开概率-数大小有误!";
- }
- //更多回复
- if(empty($data['c7'][0]) || $data['c7'][0] == 0){
- return "浏览笔记-更多回复-最小数不能为空或等于0!";
- }else if(empty($data['c7'][1]) || $data['c7'][1] == 0){
- return "浏览笔记-更多回复-最大数不能为空或等于0!";
- }else if((int)$data['c7'][0] > (int)$data['c7'][1]){
- return "浏览笔记-更多回复-大小有误!";
- }
- //来回观看
- if(empty($data['c8'][0]) || $data['c8'][0] == 0){
- return "浏览笔记-来回观看-最小数不能为空或等于0!";
- }else if(empty($data['c8'][1]) || $data['c8'][1] == 0){
- return "浏览笔记-来回观看-最大数不能为空或等于0!";
- }else if((int)$data['c8'][0] > (int)$data['c8'][1]){
- return "浏览笔记-来回观看-大小有误!";
- }
- //向上滑动
- if(empty($data['c9'][0]) || $data['c9'][0] == 0){
- return "浏览笔记-向上滑动-次数不能为空或等于0!";
- }else if(empty($data['c9'][1]) || $data['c9'][1] == 0){
- return "浏览笔记-向上滑动-次数不能为空或等于0!";
- }else if((int)$data['c9'][0] > (int)$data['c9'][1]){
- return "浏览笔记-向上滑动-次数大小有误!";
- }
- //向下滑动
- if(empty($data['c10'][0]) || $data['c10'][0] == 0){
- return "浏览笔记-向下滑动-次数不能为空或等于0!";
- }else if(empty($data['c10'][1]) || $data['c10'][1] == 0){
- return "浏览笔记-向下滑动-次数不能为空或等于0!";
- }else if((int)$data['c10'][0] > (int)$data['c10'][1]){
- return "浏览笔记-向下滑动-次数大小有误!";
- }
-
- //浏览视频
- foreach ($data['d1_1'] as $k2 => $v2) {
- //echo $k;
- //dump($v);
- if(empty($v2) && $k2 > 2){
- return "浏览视频-观看时长-评论数-不能为空!";
- }else if(strpos($v2, "-") === false && $k2 > 2) {
- return "浏览视频-观看时长-评论数规则格式不正确!";
- }else{
- if($k2 !== 2){
- if(empty($data['d1_2'][$k2]) || $data['d1_2'][$k2] == 0){
- return "浏览视频-观看时长-观看秒数不能为空或等于0!";
- }else if(empty($data['d1_3'][$k2]) || $data['d1_3'][$k2] == 0){
- return "浏览视频-观看时长-观看秒数不能为空或等于0!";
- }else if((int)$data['d1_2'][$k2] > (int)$data['d1_3'][$k2]){
- return "浏览视频-观看时长-观看时间大小有误!";
- }
- }
- }
- }
-
- //非列表视频操作 - 观看时长
- if(empty($data['d2'][0]) || $data['d2'][0] == 0){
- return "浏览视频-非列表视频操作-观看时长-秒数不能为空或等于0!";
- }else if(empty($data['d2'][1]) || $data['d2'][1] == 0){
- return "浏览视频-非列表视频操作-观看时长-秒数不能为空或等于0!";
- }else if((int)$data['d2'][0] > (int)$data['d2'][1]){
- return "浏览视频-非列表视频操作-观看时长-秒数大小有误!";
- }
-
- //往下浏览
- if(empty($data['d3'][0]) || $data['d3'][0] == 0){
- return "浏览视频-非列表视频操作-往下浏览-个数不能为空或等于0!";
- }else if(empty($data['d3'][1]) || $data['d3'][1] == 0){
- return "浏览视频-非列表视频操作-往下浏览-个数不能为空或等于0!";
- }else if((int)$data['d3'][0] > (int)$data['d3'][1]){
- return "浏览视频-非列表视频操作-往下浏览-个数大小有误!";
- }
-
- //滑动次数
- if(empty($data['d4'][0]) || $data['d4'][0] == 0){
- return "浏览视频-评论区操作-滑动次数-次数不能为空或等于0!";
- }else if(empty($data['d4'][1]) || $data['d4'][1] == 0){
- return "浏览视频-评论区操作-滑动次数-次数不能为空或等于0!";
- }else if((int)$data['d4'][0] > (int)$data['d4'][1]){
- return "浏览视频-评论区操作-滑动次数-次数大小有误!";
- }
-
- //展开回复
- if(empty($data['d5'][0]) || $data['d5'][0] == 0){
- return "浏览视频-评论区操作-展开回复-次数不能为空或等于0!";
- }else if(empty($data['d5'][1]) || $data['d5'][1] == 0){
- return "浏览视频-评论区操作-展开回复-次数不能为空或等于0!";
- }else if((int)$data['d5'][0] > (int)$data['d5'][1]){
- return "浏览视频-评论区操作-展开回复-次数大小有误!";
- }
- //展开概率
- if(empty($data['d6'][0]) || $data['d6'][0] == 0){
- return "浏览视频-评论区操作-展开概率-次数不能为空或等于0!";
- }else if(empty($data['d6'][1]) || $data['d6'][1] == 0){
- return "浏览视频-评论区操作-展开概率-次数不能为空或等于0!";
- }else if((int)$data['d6'][0] > (int)$data['d6'][1]){
- return "浏览视频-评论区操作-展开概率-次数大小有误!";
- }
-
- //列表视频 是否完整观看以及观看时长
- if(empty($data['d7'][0])){
- return "浏览视频-是否完整观看-列表视频-每[]个不能为空!";
- }
- if(empty($data['d7'][1])){
- return "浏览视频-是否完整观看-列表视频-点击[]个不能为空!";
- }
- if($data['d7'][1] > $data['d7'][2]){
- return "浏览视频-是否完整观看-列表视频-点击范围大小错误";
- }
- //浏览视频-是否完整观看-列表视频-到[]个不能为空
- if(empty($data['d7'][2])){
- return "浏览视频-是否完整观看-列表视频-到[]个不能为空!";
- }
-
- //列表视频 是否完整观看以及观看时长
- if(empty($data['d8'][0])){
- return "浏览视频-是否完整观看-用户视频-每[]个不能为空!";
- }
- if(empty($data['d8'][1])){
- return "浏览视频-是否完整观看-用户视频-点击[]个不能为空!";
- }
- if($data['d8'][1] > $data['d8'][2]){
- return "浏览视频-是否完整观看-用户视频-点击范围大小错误";
- }
- if(empty($data['d8'][2])){
- return "浏览视频-是否完整观看-用户视频-到[]个不能为空!";
- }
-
- //列表视频 是否完整观看以及观看时长
- if(empty($data['d9'][0])){
- return "浏览视频-是否完整观看-截流视频-每[]个不能为空!";
- }
- if(empty($data['d9'][1])){
- return "浏览视频-是否完整观看-截流视频-点击[]个不能为空!";
- }
- if($data['d9'][1] > $data['d9'][2]){
- return "浏览视频-是否完整观看-截流视频-点击范围大小错误";
- }
- if(empty($data['d9'][2])){
- return "浏览视频-是否完整观看-截流视频-到[]个不能为空!";
- }
-
- //互动设置
- if((int)$data['e1'] === 1){
- if($data['e2'] == '场景1_是否开启全局默认互动'){
- $ks = ['e5_1','e5_2','e5_3','e5_4','e5_5','e5_6'];
- foreach ($ks as $k112 => $v112) {
- //只验证默认参数
- if(empty($data[$v112][0])){
- return "互动设置-默认互动-第".$k112."行-每[]个不能为空!";
- }
- if(empty($data[$v112][1])){
- return "互动设置-默认互动-第".$k112."行-点击[]个不能为空!";
- }
- if($data[$v112][1] > $data[$v112][2]){
- return "互动设置-默认互动-第".$k112."行-点击范围大小错误";
- }
- if(empty($data[$v112][2])){
- return "互动设置-默认互动-第".$k112."行-到[]个不能为空!";
- }
- }
- }else{
- //验证 截流和非截流
- $ks = ['e3_1','e3_2','e3_3','e3_4','e3_5','e3_6'];
- foreach ($ks as $k111 => $v111) {
- //只验证默认参数
- if(empty($data[$v111][0])){
- return "互动设置-截流互动-第".$k111."行-每[]个不能为空!";
- }
- if(empty($data[$v111][1])){
- return "互动设置-截流互动-第".$k111."行-点击[]个不能为空!";
- }
- if($data[$v111][1] > $data[$v111][2]){
- return "互动设置-截流互动-第".$k111."行-点击范围大小错误";
- }
- if(empty($data[$v111][2])){
- return "互动设置-截流互动-第".$k111."行-到[]个不能为空!";
- }
- }
- $ks = ['e4_1','e4_2','e4_3','e4_4','e4_5','e4_6'];
- foreach ($ks as $k110 => $v110) {
- //只验证默认参数
- if(empty($data[$v110][0])){
- return "互动设置-非截流互动-第".$k110."行-每[]个不能为空!";
- }
- if(empty($data[$v110][1])){
- return "互动设置-非截流互动-第".$k110."行-点击[]个不能为空!";
- }
- if($data[$v110][1] > $data[$v110][2]){
- return "互动设置-非截流互动-第".$k110."行-点击范围大小错误";
- }
- if(empty($data[$v110][2])){
- return "互动设置-非截流互动-第".$k110."行-到[]个不能为空!";
- }
- }
- }
- }
-
- //用户作品
- if(empty($data['e6'])){
- return "互动设置-其他-用户作品-不能为空!";
- }
-
- //截流设置
- if(empty($data['f4'])){
- return "截流设置-截流相关互动设置-关注概率-不能为空!";
- }
-
- //内容评论区截流
- if(empty($data['f5']) || $data['f5'] == 0){
- return "截流设置-内容评论区截流-笔记滑动-不能为空或者不能等于0!";
- }
-
- //内容评论区截流
- if(empty($data['f6']) || $data['f6'] == 0){
- return "截流设置-内容评论区截流-视频滑动-不能为空或者不能等于0!";
- }
-
- //截流总数
- if(empty($data['f7']) || $data['f7'] == 0){
- return "截流设置-内容评论区截流-截流总数-不能为空或者不能等于0!";
- }
-
- //笔记匹配
- if(empty($data['f8'][0]) || $data['f8'][0] == 0){
- return "截流设置-内容评论区截流-笔记匹配-个数不能为空或等于0!";
- }else if(empty($data['f8'][1]) || $data['f8'][1] == 0){
- return "截流设置-内容评论区截流-笔记匹配-个数不能为空或等于0!";
- }else if((int)$data['f8'][0] > (int)$data['f8'][1]){
- return "截流设置-内容评论区截流-笔记匹配-个数大小有误!";
- }
- //视频匹配
- if(empty($data['f9'][0]) || $data['f9'][0] == 0){
- return "截流设置-内容评论区截流-视频匹配-个数不能为空或等于0!";
- }else if(empty($data['f9'][1]) || $data['f9'][1] == 0){
- return "截流设置-内容评论区截流-视频匹配-个数不能为空或等于0!";
- }else if((int)$data['f9'][0] > (int)$data['f9'][1]){
- return "截流设置-内容评论区截流-视频匹配-个数大小有误!";
- }
-
- //评论内容
- foreach ($data['f21_1'] as $k108 => $v108) {
- if($k108 !== 1) {
- if (empty($v108)) {
- return "截流设置-评论内容-关键词-请填写关键词";
- }
- }
- }
- foreach ($data['f21_2'] as $k107 => $v107) {
- if($k107 !== 1) {
- if (empty($v107)) {
- return "截流设置-评论内容-评论语句-请填写评论语句";
- }
- }
- }
-
- //私信内容
- foreach ($data['f25_1'] as $k106 => $v106) {
- if($k106 !== 1) {
- if (empty($v106)) {
- return "截流设置-私信内容-关键词-请填写关键词";
- }
- }
- }
- foreach ($data['f25_2'] as $k105 => $v105) {
- if($k105 !== 1) {
- if (empty($v105)) {
- return "截流设置-私信内容-私信语句-请填写私信语句";
- }
- }
- }
-
- //评论钩子设置
- if((int)$data['k3'] < 0){
- return "其他设置-评论钩子设置-点赞数不能小于0";
- }
- if((int)$data['k4'] < 0){
- return "其他设置-评论钩子设置-点赞数不能小于0";
- }
- if((int)$data['k5'] < 0){
- return "其他设置-评论钩子设置-点赞数不能小于0";
- }
-
- if(empty($data['k6'])) {
- return "请输入评论内容!";
- }
-
- return true;
- }
-
- }
|