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

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