截流自动化的商城平台
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.

Closure.php 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <?php
  2. namespace app\common\model\content;
  3. use app\common\basics\Models;
  4. class Closure extends Models
  5. {
  6. /**
  7. * @Notes: 关联文章分类模型
  8. * @Author: 张无忌
  9. */
  10. public function category()
  11. {
  12. return $this->hasOne('ClosureCategory', 'id', 'cid');
  13. }
  14. public function category2()
  15. {
  16. return $this->hasOne('IndustryCategory', 'id', 'yid');
  17. }
  18. public function setContentAttr($value,$data)
  19. {
  20. $content = $data['content'];
  21. if (!empty($content)) {
  22. $content = HtmlSetImage($content);
  23. }
  24. return $content;
  25. }
  26. public function getContentAttr($value,$data)
  27. {
  28. $content = $data['content'];
  29. if (!empty($content)) {
  30. $content = HtmlGetImage($content);
  31. }
  32. return $content;
  33. }
  34. private function replaceContent($content)
  35. {
  36. // 替换空格
  37. $content = preg_replace("/\s+/", "", $content);
  38. // var_dump(111, $content);
  39. str_replace("|", '|', $content);
  40. $arr = explode('|', $content);
  41. $arr = array_filter($arr);
  42. return implode('|', $arr);
  43. }
  44. private function replaceContent2($content)
  45. {
  46. // 替换空格
  47. $content = preg_replace("/\s+/", "", $content);
  48. // str_replace("-", '-', $content);
  49. $arr = explode('-', $content);
  50. $arr = array_filter($arr);
  51. if (count($arr) > 3) {
  52. throw new \Exception('匹配词不能超过3个');
  53. }
  54. if (count($arr) <= 0) {
  55. throw new \Exception('匹配词选项填写错误');
  56. }
  57. return implode('-', $arr);
  58. }
  59. /*
  60. * 处理表达数据
  61. */
  62. public function postDataHandle($post=[]){
  63. // var_dump(123, $post['b3']);
  64. $post['b3'] = $this->replaceContent($post['b3']);
  65. // var_dump(456, $post['b3']);
  66. // return true;
  67. $post['a7'] = $this->replaceContent($post['a7']);
  68. $post['e7'] = $this->replaceContent($post['e7']);
  69. $post['f10'] = $this->replaceContent($post['f10']);
  70. $post['f11'] = $this->replaceContent($post['f11']);
  71. $post['f12'] = $this->replaceContent($post['f12']);
  72. $post['f13'] = $this->replaceContent($post['f13']);
  73. $post['f14'] = $this->replaceContent($post['f14']);
  74. $post['f15'] = $this->replaceContent($post['f15']);
  75. $post['f17'] = $this->replaceContent($post['f17']);
  76. $post['f19'] = $this->replaceContent($post['f19']);
  77. $post['f20'] = $this->replaceContent($post['f20']);
  78. $post['f24'] = $this->replaceContent($post['f24']);
  79. $post['k6'] = $this->replaceContent($post['k6']);
  80. //处理b2
  81. $str = [];
  82. foreach ($post['b2_1'] as $k => $v) {
  83. if(!empty($v)) {
  84. $v_str = $this->replaceContent2($v);
  85. $str[] = $v . '_' . $post['b2_2'][$k] . '-' . $post['b2_3'][$k] . '-' . $post['b2_4'][$k];
  86. }
  87. }
  88. $str_l = '';
  89. foreach ($str as $k => $v) {
  90. if(!empty($v)) {
  91. if ($k > 0) {
  92. $str_l .= '|' . $v;
  93. } else {
  94. $str_l .= $v;
  95. }
  96. }
  97. }
  98. $min_a = $post['b2_2'][0];
  99. foreach ($post['b2_2'] as $k => $v) {
  100. if(!empty($v)) {
  101. if ($k > 0) {
  102. if ((int)$v < (int)$min_a) {
  103. $min_a = (int)$v;
  104. }
  105. }
  106. }
  107. }
  108. //笔记评论数处理
  109. $str2 = [];
  110. foreach ($post['c1_1'] as $k => $v) {
  111. if(!empty($v)) {
  112. $str2[$v] = [
  113. "start_num" => (int)$post['c1_2'][$k],
  114. "end_num" => (int)$post['c1_3'][$k]
  115. ];
  116. }
  117. }
  118. //视频评论数处理
  119. $str3 = [];
  120. foreach ($post['d1_1'] as $k => $v) {
  121. if(!empty($v)) {
  122. $str3[$v] = [
  123. "start_num" => (int)$post['d1_2'][$k],
  124. "end_num" => (int)$post['d1_3'][$k]
  125. ];
  126. }
  127. }
  128. //截流独立互动设置
  129. $str4 = [
  130. "每浏览几个点赞_data_num" => (int)$post['e3_1'][0],
  131. "每浏览几个点赞多少个_data_start" => (int)$post['e3_1'][1],
  132. "每浏览几个点赞多少个_data_end" => (int)$post['e3_1'][2],
  133. "每浏览几个收藏_data_num" => (int)$post['e3_2'][0],
  134. "每浏览几个收藏多少个_data_start" => (int)$post['e3_2'][1],
  135. "每浏览几个收藏多少个_data_end" => (int)$post['e3_2'][2],
  136. "每浏览几个评论_data_num" => (int)$post['e3_3'][0],
  137. "每浏览几个评论多少个_data_start" => (int)$post['e3_3'][1],
  138. "每浏览几个评论多少个_data_end" => (int)$post['e3_3'][2],
  139. "每浏览几个关注_data_num" => (int)$post['e3_4'][0],
  140. "每浏览几个关注多少个_data_start" => (int)$post['e3_4'][1],
  141. "每浏览几个关注多少个_data_end" => (int)$post['e3_4'][2],
  142. "每浏览几个访问用户_data_num" => (int)$post['e3_5'][0],
  143. "每浏览几个访问用户多少个_data_start" => (int)$post['e3_5'][1],
  144. "每浏览几个访问用户多少个_data_end" => (int)$post['e3_5'][2],
  145. "每访问几个用户进行关注_data_num" => (int)$post['e3_6'][0],
  146. "每访问几个用户进行关注多少个_data_start" => (int)$post['e3_6'][1],
  147. "每访问几个用户进行关注多少个_data_end" => (int)$post['e3_6'][2],
  148. ];
  149. //非截流互动设置
  150. $str5 = [
  151. "每浏览几个点赞_data_num" => (int)$post['e4_1'][0],
  152. "每浏览几个点赞多少个_data_start" => (int)$post['e4_1'][1],
  153. "每浏览几个点赞多少个_data_end" => (int)$post['e4_1'][2],
  154. "每浏览几个收藏_data_num" => (int)$post['e4_2'][0],
  155. "每浏览几个收藏多少个_data_start" => (int)$post['e4_2'][1],
  156. "每浏览几个收藏多少个_data_end" => (int)$post['e4_2'][2],
  157. "每浏览几个评论_data_num" => (int)$post['e4_3'][0],
  158. "每浏览几个评论多少个_data_start" => (int)$post['e4_3'][1],
  159. "每浏览几个评论多少个_data_end" => (int)$post['e4_3'][2],
  160. "每浏览几个关注_data_num" => (int)$post['e4_4'][0],
  161. "每浏览几个关注多少个_data_start" => (int)$post['e4_4'][1],
  162. "每浏览几个关注多少个_data_end" => (int)$post['e4_4'][2],
  163. "每浏览几个访问用户_data_num" => (int)$post['e4_5'][0],
  164. "每浏览几个访问用户多少个_data_start" => (int)$post['e4_5'][1],
  165. "每浏览几个访问用户多少个_data_end" => (int)$post['e4_5'][2],
  166. "每访问几个用户进行关注_data_num" => (int)$post['e4_6'][0],
  167. "每访问几个用户进行关注多少个_data_start" => (int)$post['e4_6'][1],
  168. "每访问几个用户进行关注多少个_data_end" => (int)$post['e4_6'][2],
  169. ];
  170. //默认互动参数
  171. $str6 = [
  172. "每浏览几个点赞_data_num" => (int)$post['e5_1'][0],
  173. "每浏览几个点赞多少个_data_start" => (int)$post['e5_1'][1],
  174. "每浏览几个点赞多少个_data_end" => (int)$post['e5_1'][2],
  175. "每浏览几个收藏_data_num" => (int)$post['e5_2'][0],
  176. "每浏览几个收藏多少个_data_start" => (int)$post['e5_2'][1],
  177. "每浏览几个收藏多少个_data_end" => (int)$post['e5_2'][2],
  178. "每浏览几个评论_data_num" => (int)$post['e5_3'][0],
  179. "每浏览几个评论多少个_data_start" => (int)$post['e5_3'][1],
  180. "每浏览几个评论多少个_data_end" => (int)$post['e5_3'][2],
  181. "每浏览几个关注_data_num" => (int)$post['e5_4'][0],
  182. "每浏览几个关注多少个_data_start" => (int)$post['e5_4'][1],
  183. "每浏览几个关注多少个_data_end" => (int)$post['e5_4'][2],
  184. "每浏览几个访问用户_data_num" => (int)$post['e5_5'][0],
  185. "每浏览几个访问用户多少个_data_start" => (int)$post['e5_5'][1],
  186. "每浏览几个访问用户多少个_data_end" => (int)$post['e5_5'][2],
  187. "每访问几个用户进行关注_data_num" => (int)$post['e5_6'][0],
  188. "每访问几个用户进行关注多少个_data_start" => (int)$post['e5_6'][1],
  189. "每访问几个用户进行关注多少个_data_end" => (int)$post['e5_6'][2],
  190. ];
  191. //评论随机语句
  192. $str7 = [];
  193. foreach ($post['f21_1'] as $k => $v) {
  194. if(!empty($v)) {
  195. $str7[$v] = $this->replaceContent($post['f21_2'][$k]);
  196. }
  197. }
  198. //私信随机语句
  199. $str8 = [];
  200. foreach ($post['f25_1'] as $k => $v) {
  201. if(!empty($v)) {
  202. $str8[$v] = $this->replaceContent($post['f25_2'][$k]);
  203. }
  204. }
  205. //替换
  206. $post['f16'] = str_replace("|", ",", $post['f15']);
  207. $post['f18'] = str_replace("|", ",", $post['f17']);
  208. //处理数据
  209. $json = [
  210. "数据入口_type" => $post['a1'],
  211. "是否组合" => (int)$post['a4'],
  212. "推荐转搜索_start" => (int)$post['a5'][0],
  213. "推荐转搜索_end" => (int)$post['a5'][1],
  214. "搜索转推荐_start" => (int)$post['a6'][0],
  215. "搜索转推荐_end" => (int)$post['a6'][1],
  216. "切换搜索词" => $post['a7'],
  217. "切换方式" => (int)$post['a8'],
  218. "搜索筛选" => (int)$post['a9'],
  219. "排序依据" => $post['a10'],
  220. "笔记类型" => $post['a11'],
  221. "发布时间" => $post['a12'],
  222. "搜索范围" => $post['a13'],
  223. "运行时长_time" => (int)$post['a2'],
  224. "操作总数_data_num" => (int)$post['a3'],
  225. "是否分类_is_type" => (int)$post['b1'],
  226. "数据分类_default_type_list" => $str_l,
  227. "数据分类_type_list" => $str_l,
  228. "最小范围数_data_num" => (int)$min_a,
  229. "列表标题过滤词列表_data_list" => $post['b3'],
  230. "列表翻页随机来回滑动屏幕次数_data_start" => (int)$post['b4'][0],
  231. "列表翻页随机来回滑动屏幕次数_data_end" => (int)$post['b4'][1],
  232. "浏览内容详情返回列表随机滑动屏幕次数_data_start" => (int)$post['b5'][0],
  233. "浏览内容详情返回列表随机滑动屏幕次数_data_end" => (int)$post['b5'][1],
  234. "列表每次循环至少滑动多少次_data_num" => (int)$post['b6'],
  235. "是否忽略直播的内容对象_data_num" => (int)$post['b7'],
  236. "浏览内容笔记类型指定评论数判断观看时长_data_list" => $str2,
  237. "浏览内容笔记类型随机往上滑动次数_data_start" => (int)$post['c2'][0],
  238. "浏览内容笔记类型随机往上滑动次数_data_end" => (int)$post['c2'][1],
  239. "浏览内容笔记类型随机往上滑动次数等待秒数_data_start" => (int)$post['c3'][0],
  240. "浏览内容笔记类型随机往上滑动次数等待秒数_data_end" => (int)$post['c3'][1],
  241. "浏览内容笔记类型评论总数与滑动次数比例_data_num" => (int)$post['c4'],
  242. "浏览内容笔记类型评论区展开回复次数_data_start" => (int)$post['c5'][0],
  243. "浏览内容笔记类型评论区展开回复次数_data_end" => (int)$post['c5'][1],
  244. "浏览内容笔记类型评论区展开回复随机概率_data_start" => (int)$post['c6'][0],
  245. "浏览内容笔记类型评论区展开回复随机概率_data_end" => (int)$post['c6'][1],
  246. "浏览内容笔记类型评论区展开更多回复随机概率_data_start" => (int)$post['c7'][0],
  247. "浏览内容笔记类型评论区展开更多回复随机概率_data_end" => (int)$post['c7'][1],
  248. "浏览内容笔记类型随机来回观看概率_data_start" => (int)$post['c8'][0],
  249. "浏览内容笔记类型随机来回观看概率_data_end" => (int)$post['c8'][1],
  250. "浏览内容笔记类型随机来回观看向上滑动次数_data_start" => (int)$post['c9'][0],
  251. "浏览内容笔记类型随机来回观看向上滑动次数_data_end" => (int)$post['c9'][1],
  252. "浏览内容笔记类型随机来回观看向下滑动次数_data_start" => (int)$post['c10'][0],
  253. "浏览内容笔记类型随机来回观看向下滑动次数_data_end" => (int)$post['c10'][1],
  254. "浏览内容视频类型不互动观看时长_data_start" => (int)$post['d2'][0],
  255. "浏览内容视频类型不互动观看时长_data_end" => (int)$post['d2'][1],
  256. "浏览内容视频类型指定评论数判断观看时长_data_list" => $str3,
  257. "浏览内容视频类型后往下浏览视频个数_data_start" => (int)$post['d3'][0],
  258. "浏览内容视频类型后往下浏览视频个数_data_end" => (int)$post['d3'][1],
  259. "浏览内容视频类型评论区最多滑动次数_data_start" => (int)$post['d4'][0],
  260. "浏览内容视频类型评论区最多滑动次数_data_end" => (int)$post['d4'][1],
  261. "浏览内容视频类型评论区展开回复次数_data_start" => (int)$post['d5'][0],
  262. "浏览内容视频类型评论区展开回复次数_data_end" => (int)$post['d5'][1],
  263. "浏览内容视频类型评论区展开回复随机概率_data_start" => (int)$post['d6'][0],
  264. "浏览内容视频类型评论区展开回复随机概率_data_end" => (int)$post['d6'][1],
  265. "每浏览几个视频完整观看_data_num" => (int)$post['d7'][0],
  266. "每浏览几个视频完整观看多少个_data_start" => (int)$post['d7'][1],
  267. "每浏览几个视频完整观看多少个_data_end" => (int)$post['d7'][2],
  268. "每浏览用户几个视频完整观看_data_num" => (int)$post['d8'][0],
  269. "每浏览用户几个视频完整观看多少个_data_start" => (int)$post['d8'][1],
  270. "每浏览用户几个视频完整观看多少个_data_end" => (int)$post['d8'][2],
  271. "每浏览截流几个视频完整观看_data_num" => (int)$post['d9'][0],
  272. "每浏览截流几个视频完整观看多少个_data_start" => (int)$post['d9'][1],
  273. "每浏览截流几个视频完整观看多少个_data_end" => (int)$post['d9'][2],
  274. "是否开启互动" => (int)$post['e1'],
  275. "互动场景" => $post['e2'],
  276. "场景1_是否开启全局默认互动" => 1,
  277. "场景2_是否开启截流与非截流独立互动" => 1,
  278. "截流互动独立设置_list" => $str4,
  279. "非截流互动独立设置_list" => $str5,
  280. "默认互动参数" => $str6,
  281. "进入用户主页观看多少个内容_data_num" => (int)$post['e6'],
  282. "互动评论随机语句" => $post['e7'],
  283. "是否开启强制截流模式" => (int)$post['f1'],
  284. "截流对象是否进行互动行为_data_num" => (int)$post['f2'],
  285. "截流用户是否进行关注_01或随机_2" => (int)$post['f3'],
  286. "截流用户是否进行关注随机概率_百分比" => (int)$post['f4'],
  287. "截流笔记内容对象评论区最多滑动多少次_data_num" => (int)$post['f5'],
  288. "截流视频内容对象评论区最多滑动多少次_data_num" => (int)$post['f6'],
  289. "截流进入用户存在内容可评论总数_data_num" => (int)$post['f7'],
  290. "截流笔记内容最多成功匹配多少个评论_data_start" => (int)$post['f8'][0],
  291. "截流笔记内容最多成功匹配多少个评论_data_end" => (int)$post['f8'][1],
  292. "截流视频内容最多成功匹配多少个评论_data_start" => (int)$post['f9'][0],
  293. "截流视频内容最多成功匹配多少个评论_data_end" => (int)$post['f9'][1],
  294. "截流指定账号列表_data_list" => $post['f10'],
  295. "截流账号关键词列表_data_list" => $post['f11'],
  296. "截流账号过滤词列表_data_list" => $post['f12'],
  297. "截流内容名称关键词" => $post['f13'],
  298. "截流内容名称过滤词" => $post['f14'],
  299. "截流笔记内容满足时间条件的关键词正则" => $post['f15'],
  300. "截流笔记内容满足时间条件的关键词" => $post['f16'], //原 $post['f16'] 替换成逗号即可
  301. "截流视频内容满足时间条件的关键词正则" => $post['f17'],
  302. "截流视频内容满足时间条件的关键词" => $post['f18'], //原 $post['f18'] 替换成逗号即可
  303. "截流评论账号过滤词" => $post['f19'],
  304. "截流评论名称关键词" => $post['f20'],
  305. "截流评论随机语句" => $str7,
  306. "截流评论是否开启" => (int)$post['f22'],
  307. "截流私信名称关键词" => $post['f24'],
  308. "截流私信随机语句" => $str8,
  309. "截流私信是否开启" => (int)$post['f23'],
  310. "截流私信条数" => (int)$post['f26'],
  311. "截流是否开启" => (int)$post['f27'],
  312. "评论转为私信" => (int)$post['f28'],
  313. "私信转为评论" => (int)$post['f29'],
  314. "评论钩子是否开启" => (int)$post['k1'],
  315. "评论钩子是否互动评论" => (int)$post['k2'],
  316. "点赞数条件" => (int)$post['k3'],
  317. "收藏数条件" => (int)$post['k4'],
  318. "评论数条件" => (int)$post['k5'],
  319. "评论钩子内容" => $post['k6']
  320. ];
  321. return [$json, $post];
  322. }
  323. }