截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClosureValidate.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <?php
  2. namespace app\shop\validate\content;
  3. use app\common\model\content\Closure as ClosureModel;
  4. use app\common\basics\Validate;
  5. class ClosureValidate extends Validate
  6. {
  7. protected $rule = [
  8. 'id' => 'require|number',
  9. 'cid' => 'require|number',
  10. 'title' => 'require',
  11. // 'version' => 'require|checkVersion',
  12. 'a2' => 'require|number|checkPost',
  13. 'a3' => 'require|number',
  14. ];
  15. protected $message = [
  16. 'id.require' => 'id不可为空',
  17. 'id.number' => 'id必须为数字',
  18. 'cid.require' => '请选择分类',
  19. 'cid.number' => '分类选择异常',
  20. 'title.require' => '请填写文章标题',
  21. 'version.require' => '请填写版本号',
  22. 'a2.require' => '运行时长不可为空',
  23. 'a2.number' => '运行时长必须为数字',
  24. 'a3.require' => '操作总数不可为空',
  25. 'a3.number' => '操作总数必须为数字',
  26. ];
  27. protected $scene = [
  28. 'id' => ['id'],
  29. 'add' => [
  30. 'cid', 'title',
  31. 'a2',
  32. 'a3'
  33. ],
  34. 'edit' => [
  35. 'id', 'cid', 'title',
  36. 'a2',
  37. 'a3'
  38. ],
  39. ];
  40. /*
  41. * 检查版本号
  42. */
  43. protected function checkVersion($value,$rule,$data){
  44. $where[] = ['shop_id','=',$data['shop_id']];
  45. $where[] = ['del','=',0];
  46. // 如果有id代表是编辑校验分类名称
  47. if(isset($data['id'])){
  48. $where[] = ['id','<>',$data['id']];
  49. }
  50. $where[] = ['version','=',$data['version']];
  51. $where[] = ['cid','=',$data['cid']];
  52. $where[] = ['yid','=',$data['yid']];
  53. $name = ClosureModel::where($where)->value('version');
  54. if($name){
  55. return '版本号已存在';
  56. }
  57. return true;
  58. }
  59. /*
  60. * 验证所有post 参数
  61. * 通过a1字段 触发函数
  62. */
  63. protected function checkPost($value,$rule,$data){
  64. $msg = "-不能为空!";
  65. if(empty($data['a7'])){
  66. return "切换搜索词".$msg;
  67. }
  68. if(empty($data['e7'])){
  69. return "互动评论随机语句".$msg;
  70. }
  71. if(empty($data['f10'])){
  72. return "指定账号列表".$msg;
  73. }
  74. if(empty($data['f11'])){
  75. return "账号关键词列表".$msg;
  76. }
  77. if(empty($data['f12'])){
  78. return "账号过滤词列表".$msg;
  79. }
  80. if(empty($data['f13'])){
  81. return "标题名称关键词".$msg; //截流内容名称关键词
  82. }
  83. if(empty($data['f14'])){
  84. return "标题名称过滤词".$msg; //截流内容名称过滤词
  85. }
  86. if(empty($data['f15'])){
  87. return "笔记评论满足时间条件的关键词".$msg; //截流笔记内容满足时间条件的关键词正则
  88. }
  89. if(empty($data['f17'])){
  90. return "视频评论满足时间条件的关键词".$msg; //截流视频内容满足时间条件的关键词正则
  91. }
  92. if(empty($data['f19'])){
  93. return "评论账号过滤词".$msg;
  94. }
  95. if(empty($data['f20'])){
  96. return "评论名称关键词".$msg;
  97. }
  98. if(empty($data['f24'])){
  99. return "私信名称关键词".$msg;
  100. }
  101. if(empty($data['k6'])){
  102. return "评论钩子内容".$msg;
  103. }
  104. if((int)$data['a2'] < 900){
  105. return "运行时长不能小于900秒!";
  106. }
  107. if((int)$data['a3'] < 100){
  108. return "操作总数不能小于100个!";
  109. }
  110. if((int)$data['a4'] === 1){
  111. //组合模式
  112. if($data['a1'] == '推荐'){
  113. if((int)$data['a5'][0] < 120){
  114. return "推荐时长不能小于120秒";
  115. }
  116. if((int)$data['a5'][1] < 120){
  117. return "搜索时长不能小于120秒!";
  118. }
  119. }else if($data['a1'] == '搜索') {
  120. if ((int)$data['a6'][0] < 120) {
  121. return "搜索时长不能小于120秒";
  122. }
  123. if ((int)$data['a6'][1] < 120) {
  124. return "推荐时长不能小于120秒!";
  125. }
  126. }else{
  127. }
  128. }
  129. //搜索词
  130. if(empty($data['a7'])){
  131. return "启动设置-搜索词-不能为空!";
  132. }
  133. //过滤词
  134. if (strpos($data['b3'], "|") === false) {
  135. return "列表设置-过滤词格式不正确!";
  136. }
  137. //分类规则
  138. foreach ($data['b2_1'] as $k100 => $v100) {
  139. if(empty($v100) && $k100 !== 1){
  140. return "列表设置-分类规则-匹配词不能为空!";
  141. }
  142. }
  143. foreach ($data['b2_2'] as $k101 => $v101) {
  144. if(empty($v101) && $k101 !== 1){
  145. return "列表设置-分类规则-每[]个不能为空!";
  146. }
  147. }
  148. foreach ($data['b2_3'] as $k102 => $v102) {
  149. if(empty($v102) && $k102 !== 1){
  150. return "列表设置-分类规则-点击[]个不能为空!";
  151. }
  152. if($v102 > $data['b2_4'][$k102] && $k102 !== 1){
  153. return "列表设置-分类规则-点击范围大小错误";
  154. }
  155. }
  156. foreach ($data['b2_4'] as $k103 => $v103) {
  157. if(empty($v103) && $k103 !== 1){
  158. return "列表设置-分类规则-到[]个不能为空!";
  159. }
  160. }
  161. //列表操作 滑动操作
  162. if(empty($data['b4'])){
  163. return "列表设置-滑动操作-随机滑动-不能为空!";
  164. }
  165. if((int)$data['b4'][0] > (int)$data['b4'][1]){
  166. return "列表设置-滑动操作-随机滑动-范围大小错误";
  167. }
  168. if(empty($data['b5'])){
  169. return "列表设置-滑动操作-返回滑动-不能为空!";
  170. }
  171. if((int)$data['b5'][0] > (int)$data['b5'][1]){
  172. return "列表设置-滑动操作-返回滑动-范围大小错误";
  173. }
  174. if(empty($data['b6'])){
  175. return "列表设置-滑动操作-列表滑动-不能为空!";
  176. }
  177. //浏览笔记
  178. foreach ($data['c1_1'] as $k => $v) {
  179. if(empty($v) && $k > 2){
  180. return "浏览笔记-观看时长-评论数-不能为空!";
  181. }else if(strpos($v, "-") === false && $k > 2) {
  182. return "浏览笔记-观看时长-评论数规则格式不正确!";
  183. }else{
  184. if($k !== 2){
  185. if(empty($data['c1_2'][$k]) || $data['c1_2'][$k] == 0){
  186. return "浏览笔记-观看时长-观看秒数不能为空或等于0!";
  187. }else if(empty($data['c1_3'][$k]) || $data['c1_3'][$k] == 0){
  188. return "浏览笔记-观看时长-观看秒数不能为空或等于0!";
  189. }else if((int)$data['c1_2'][$k] > (int)$data['c1_3'][$k]){
  190. return "浏览笔记-观看时长-观看时间大小有误!";
  191. }
  192. }
  193. }
  194. }
  195. //随机滑动
  196. if(empty($data['c2'][0]) || $data['c2'][0] == 0){
  197. return "浏览笔记-随机滑动-次数不能为空或等于0!";
  198. }else if(empty($data['c2'][1]) || $data['c2'][1] == 0){
  199. return "浏览笔记-随机滑动-次数不能为空或等于0!";
  200. }else if((int)$data['c2'][0] > (int)$data['c2'][1]){
  201. return "浏览笔记-随机滑动-次数大小有误!";
  202. }
  203. //滑动等待
  204. if(empty($data['c3'][0]) || $data['c3'][0] == 0){
  205. return "浏览笔记-滑动等待-次数不能为空或等于0!";
  206. }else if(empty($data['c3'][1]) || $data['c3'][1] == 0){
  207. return "浏览笔记-滑动等待-次数不能为空或等于0!";
  208. }else if((int)$data['c3'][0] > (int)$data['c3'][1]){
  209. return "浏览笔记-滑动等待-次数大小有误!";
  210. }
  211. //评论区
  212. if(empty($data['c4'])){
  213. return "浏览笔记-评论区-滑动比例-不能为空!";
  214. }
  215. //展开回复
  216. if(empty($data['c5'][0]) || $data['c5'][0] == 0){
  217. return "浏览笔记-展开回复-次数不能为空或等于0!";
  218. }else if(empty($data['c5'][1]) || $data['c5'][1] == 0){
  219. return "浏览笔记-展开回复-次数不能为空或等于0!";
  220. }else if((int)$data['c5'][0] > (int)$data['c5'][1]){
  221. return "浏览笔记-展开回复-次数大小有误!";
  222. }
  223. //展开概率
  224. if(empty($data['c6'][0]) || $data['c6'][0] == 0){
  225. return "浏览笔记-展开概率-最小数不能为空或等于0!";
  226. }else if(empty($data['c6'][1]) || $data['c6'][1] == 0){
  227. return "浏览笔记-展开概率-最大数不能为空或等于0!";
  228. }else if((int)$data['c6'][0] > (int)$data['c6'][1]){
  229. return "浏览笔记-展开概率-数大小有误!";
  230. }
  231. //更多回复
  232. if(empty($data['c7'][0]) || $data['c7'][0] == 0){
  233. return "浏览笔记-更多回复-最小数不能为空或等于0!";
  234. }else if(empty($data['c7'][1]) || $data['c7'][1] == 0){
  235. return "浏览笔记-更多回复-最大数不能为空或等于0!";
  236. }else if((int)$data['c7'][0] > (int)$data['c7'][1]){
  237. return "浏览笔记-更多回复-大小有误!";
  238. }
  239. //来回观看
  240. if(empty($data['c8'][0]) || $data['c8'][0] == 0){
  241. return "浏览笔记-来回观看-最小数不能为空或等于0!";
  242. }else if(empty($data['c8'][1]) || $data['c8'][1] == 0){
  243. return "浏览笔记-来回观看-最大数不能为空或等于0!";
  244. }else if((int)$data['c8'][0] > (int)$data['c8'][1]){
  245. return "浏览笔记-来回观看-大小有误!";
  246. }
  247. //向上滑动
  248. if(empty($data['c9'][0]) || $data['c9'][0] == 0){
  249. return "浏览笔记-向上滑动-次数不能为空或等于0!";
  250. }else if(empty($data['c9'][1]) || $data['c9'][1] == 0){
  251. return "浏览笔记-向上滑动-次数不能为空或等于0!";
  252. }else if((int)$data['c9'][0] > (int)$data['c9'][1]){
  253. return "浏览笔记-向上滑动-次数大小有误!";
  254. }
  255. //向下滑动
  256. if(empty($data['c10'][0]) || $data['c10'][0] == 0){
  257. return "浏览笔记-向下滑动-次数不能为空或等于0!";
  258. }else if(empty($data['c10'][1]) || $data['c10'][1] == 0){
  259. return "浏览笔记-向下滑动-次数不能为空或等于0!";
  260. }else if((int)$data['c10'][0] > (int)$data['c10'][1]){
  261. return "浏览笔记-向下滑动-次数大小有误!";
  262. }
  263. //浏览视频
  264. foreach ($data['d1_1'] as $k2 => $v2) {
  265. //echo $k;
  266. //dump($v);
  267. if(empty($v2) && $k2 > 2){
  268. return "浏览视频-观看时长-评论数-不能为空!";
  269. }else if(strpos($v2, "-") === false && $k2 > 2) {
  270. return "浏览视频-观看时长-评论数规则格式不正确!";
  271. }else{
  272. if($k2 !== 2){
  273. if(empty($data['d1_2'][$k2]) || $data['d1_2'][$k2] == 0){
  274. return "浏览视频-观看时长-观看秒数不能为空或等于0!";
  275. }else if(empty($data['d1_3'][$k2]) || $data['d1_3'][$k2] == 0){
  276. return "浏览视频-观看时长-观看秒数不能为空或等于0!";
  277. }else if((int)$data['d1_2'][$k2] > (int)$data['d1_3'][$k2]){
  278. return "浏览视频-观看时长-观看时间大小有误!";
  279. }
  280. }
  281. }
  282. }
  283. //非列表视频操作 - 观看时长
  284. if(empty($data['d2'][0]) || $data['d2'][0] == 0){
  285. return "浏览视频-非列表视频操作-观看时长-秒数不能为空或等于0!";
  286. }else if(empty($data['d2'][1]) || $data['d2'][1] == 0){
  287. return "浏览视频-非列表视频操作-观看时长-秒数不能为空或等于0!";
  288. }else if((int)$data['d2'][0] > (int)$data['d2'][1]){
  289. return "浏览视频-非列表视频操作-观看时长-秒数大小有误!";
  290. }
  291. //往下浏览
  292. if(empty($data['d3'][0]) || $data['d3'][0] == 0){
  293. return "浏览视频-非列表视频操作-往下浏览-个数不能为空或等于0!";
  294. }else if(empty($data['d3'][1]) || $data['d3'][1] == 0){
  295. return "浏览视频-非列表视频操作-往下浏览-个数不能为空或等于0!";
  296. }else if((int)$data['d3'][0] > (int)$data['d3'][1]){
  297. return "浏览视频-非列表视频操作-往下浏览-个数大小有误!";
  298. }
  299. //滑动次数
  300. if(empty($data['d4'][0]) || $data['d4'][0] == 0){
  301. return "浏览视频-评论区操作-滑动次数-次数不能为空或等于0!";
  302. }else if(empty($data['d4'][1]) || $data['d4'][1] == 0){
  303. return "浏览视频-评论区操作-滑动次数-次数不能为空或等于0!";
  304. }else if((int)$data['d4'][0] > (int)$data['d4'][1]){
  305. return "浏览视频-评论区操作-滑动次数-次数大小有误!";
  306. }
  307. //展开回复
  308. if(empty($data['d5'][0]) || $data['d5'][0] == 0){
  309. return "浏览视频-评论区操作-展开回复-次数不能为空或等于0!";
  310. }else if(empty($data['d5'][1]) || $data['d5'][1] == 0){
  311. return "浏览视频-评论区操作-展开回复-次数不能为空或等于0!";
  312. }else if((int)$data['d5'][0] > (int)$data['d5'][1]){
  313. return "浏览视频-评论区操作-展开回复-次数大小有误!";
  314. }
  315. //展开概率
  316. if(empty($data['d6'][0]) || $data['d6'][0] == 0){
  317. return "浏览视频-评论区操作-展开概率-次数不能为空或等于0!";
  318. }else if(empty($data['d6'][1]) || $data['d6'][1] == 0){
  319. return "浏览视频-评论区操作-展开概率-次数不能为空或等于0!";
  320. }else if((int)$data['d6'][0] > (int)$data['d6'][1]){
  321. return "浏览视频-评论区操作-展开概率-次数大小有误!";
  322. }
  323. //列表视频 是否完整观看以及观看时长
  324. if(empty($data['d7'][0])){
  325. return "浏览视频-是否完整观看-列表视频-每[]个不能为空!";
  326. }
  327. if(empty($data['d7'][1])){
  328. return "浏览视频-是否完整观看-列表视频-点击[]个不能为空!";
  329. }
  330. if($data['d7'][1] > $data['d7'][2]){
  331. return "浏览视频-是否完整观看-列表视频-点击范围大小错误";
  332. }
  333. //浏览视频-是否完整观看-列表视频-到[]个不能为空
  334. if(empty($data['d7'][2])){
  335. return "浏览视频-是否完整观看-列表视频-到[]个不能为空!";
  336. }
  337. //列表视频 是否完整观看以及观看时长
  338. if(empty($data['d8'][0])){
  339. return "浏览视频-是否完整观看-用户视频-每[]个不能为空!";
  340. }
  341. if(empty($data['d8'][1])){
  342. return "浏览视频-是否完整观看-用户视频-点击[]个不能为空!";
  343. }
  344. if($data['d8'][1] > $data['d8'][2]){
  345. return "浏览视频-是否完整观看-用户视频-点击范围大小错误";
  346. }
  347. if(empty($data['d8'][2])){
  348. return "浏览视频-是否完整观看-用户视频-到[]个不能为空!";
  349. }
  350. //列表视频 是否完整观看以及观看时长
  351. if(empty($data['d9'][0])){
  352. return "浏览视频-是否完整观看-截流视频-每[]个不能为空!";
  353. }
  354. if(empty($data['d9'][1])){
  355. return "浏览视频-是否完整观看-截流视频-点击[]个不能为空!";
  356. }
  357. if($data['d9'][1] > $data['d9'][2]){
  358. return "浏览视频-是否完整观看-截流视频-点击范围大小错误";
  359. }
  360. if(empty($data['d9'][2])){
  361. return "浏览视频-是否完整观看-截流视频-到[]个不能为空!";
  362. }
  363. //互动设置
  364. if((int)$data['e1'] === 1){
  365. if($data['e2'] == '场景1_是否开启全局默认互动'){
  366. $ks = ['e5_1','e5_2','e5_3','e5_4','e5_5','e5_6'];
  367. foreach ($ks as $k112 => $v112) {
  368. //只验证默认参数
  369. if(empty($data[$v112][0])){
  370. return "互动设置-默认互动-第".$k112."行-每[]个不能为空!";
  371. }
  372. if(empty($data[$v112][1])){
  373. return "互动设置-默认互动-第".$k112."行-点击[]个不能为空!";
  374. }
  375. if($data[$v112][1] > $data[$v112][2]){
  376. return "互动设置-默认互动-第".$k112."行-点击范围大小错误";
  377. }
  378. if(empty($data[$v112][2])){
  379. return "互动设置-默认互动-第".$k112."行-到[]个不能为空!";
  380. }
  381. }
  382. }else{
  383. //验证 截流和非截流
  384. $ks = ['e3_1','e3_2','e3_3','e3_4','e3_5','e3_6'];
  385. foreach ($ks as $k111 => $v111) {
  386. //只验证默认参数
  387. if(empty($data[$v111][0])){
  388. return "互动设置-截流互动-第".$k111."行-每[]个不能为空!";
  389. }
  390. if(empty($data[$v111][1])){
  391. return "互动设置-截流互动-第".$k111."行-点击[]个不能为空!";
  392. }
  393. if($data[$v111][1] > $data[$v111][2]){
  394. return "互动设置-截流互动-第".$k111."行-点击范围大小错误";
  395. }
  396. if(empty($data[$v111][2])){
  397. return "互动设置-截流互动-第".$k111."行-到[]个不能为空!";
  398. }
  399. }
  400. $ks = ['e4_1','e4_2','e4_3','e4_4','e4_5','e4_6'];
  401. foreach ($ks as $k110 => $v110) {
  402. //只验证默认参数
  403. if(empty($data[$v110][0])){
  404. return "互动设置-非截流互动-第".$k110."行-每[]个不能为空!";
  405. }
  406. if(empty($data[$v110][1])){
  407. return "互动设置-非截流互动-第".$k110."行-点击[]个不能为空!";
  408. }
  409. if($data[$v110][1] > $data[$v110][2]){
  410. return "互动设置-非截流互动-第".$k110."行-点击范围大小错误";
  411. }
  412. if(empty($data[$v110][2])){
  413. return "互动设置-非截流互动-第".$k110."行-到[]个不能为空!";
  414. }
  415. }
  416. }
  417. }
  418. //用户作品
  419. if(empty($data['e6'])){
  420. return "互动设置-其他-用户作品-不能为空!";
  421. }
  422. //截流设置
  423. if(empty($data['f4'])){
  424. return "截流设置-截流相关互动设置-关注概率-不能为空!";
  425. }
  426. //内容评论区截流
  427. if(empty($data['f5']) || $data['f5'] == 0){
  428. return "截流设置-内容评论区截流-笔记滑动-不能为空或者不能等于0!";
  429. }
  430. //内容评论区截流
  431. if(empty($data['f6']) || $data['f6'] == 0){
  432. return "截流设置-内容评论区截流-视频滑动-不能为空或者不能等于0!";
  433. }
  434. //截流总数
  435. if(empty($data['f7']) || $data['f7'] == 0){
  436. return "截流设置-内容评论区截流-截流总数-不能为空或者不能等于0!";
  437. }
  438. //笔记匹配
  439. if(empty($data['f8'][0]) || $data['f8'][0] == 0){
  440. return "截流设置-内容评论区截流-笔记匹配-个数不能为空或等于0!";
  441. }else if(empty($data['f8'][1]) || $data['f8'][1] == 0){
  442. return "截流设置-内容评论区截流-笔记匹配-个数不能为空或等于0!";
  443. }else if((int)$data['f8'][0] > (int)$data['f8'][1]){
  444. return "截流设置-内容评论区截流-笔记匹配-个数大小有误!";
  445. }
  446. //视频匹配
  447. if(empty($data['f9'][0]) || $data['f9'][0] == 0){
  448. return "截流设置-内容评论区截流-视频匹配-个数不能为空或等于0!";
  449. }else if(empty($data['f9'][1]) || $data['f9'][1] == 0){
  450. return "截流设置-内容评论区截流-视频匹配-个数不能为空或等于0!";
  451. }else if((int)$data['f9'][0] > (int)$data['f9'][1]){
  452. return "截流设置-内容评论区截流-视频匹配-个数大小有误!";
  453. }
  454. //评论内容
  455. foreach ($data['f21_1'] as $k108 => $v108) {
  456. if($k108 !== 1) {
  457. if (empty($v108)) {
  458. return "截流设置-评论内容-关键词-请填写关键词";
  459. }
  460. }
  461. }
  462. foreach ($data['f21_2'] as $k107 => $v107) {
  463. if($k107 !== 1) {
  464. if (empty($v107)) {
  465. return "截流设置-评论内容-评论语句-请填写评论语句";
  466. }
  467. }
  468. }
  469. //私信内容
  470. foreach ($data['f25_1'] as $k106 => $v106) {
  471. if($k106 !== 1) {
  472. if (empty($v106)) {
  473. return "截流设置-私信内容-关键词-请填写关键词";
  474. }
  475. }
  476. }
  477. foreach ($data['f25_2'] as $k105 => $v105) {
  478. if($k105 !== 1) {
  479. if (empty($v105)) {
  480. return "截流设置-私信内容-私信语句-请填写私信语句";
  481. }
  482. }
  483. }
  484. //评论钩子设置
  485. if((int)$data['k3'] < 0){
  486. return "其他设置-评论钩子设置-点赞数不能小于0";
  487. }
  488. if((int)$data['k4'] < 0){
  489. return "其他设置-评论钩子设置-点赞数不能小于0";
  490. }
  491. if((int)$data['k5'] < 0){
  492. return "其他设置-评论钩子设置-点赞数不能小于0";
  493. }
  494. if(empty($data['k6'])) {
  495. return "请输入评论内容!";
  496. }
  497. return true;
  498. }
  499. }