作者 zhl

Merge remote-tracking branch 'origin/master' into zhl

@@ -332,17 +332,7 @@ class RelayInquiry extends Command @@ -332,17 +332,7 @@ class RelayInquiry extends Command
332 try { 332 try {
333 $res = false; 333 $res = false;
334 foreach ($ad_task as $task){ 334 foreach ($ad_task as $task){
335 - //需要多个ip访问的国家 随机2-5次访问,只有一次询盘  
336 - if (in_array($val->country_name, $this->multiple_ip_visit_country)) {  
337 - $times = mt_rand(2, 5); //随机次数  
338 - $inquiry_time = mt_rand(1, $times); //第几次询盘  
339 - $this->output('多次访问模拟:' . $times);  
340 - for ($i = 1; $i <= $times; $i++) {  
341 - $res += $this->relayDetail($task, $val, $inquiry_time == $i);  
342 - }  
343 - }else{  
344 $res += $this->relayDetail($task, $val); 335 $res += $this->relayDetail($task, $val);
345 - }  
346 $res += $this->relayShopDetail($task, $val); 336 $res += $this->relayShopDetail($task, $val);
347 $res += $this->relayFobDetail($task, $val); 337 $res += $this->relayFobDetail($task, $val);
348 } 338 }
@@ -405,7 +395,7 @@ class RelayInquiry extends Command @@ -405,7 +395,7 @@ class RelayInquiry extends Command
405 * @param $form 395 * @param $form
406 * @return bool 396 * @return bool
407 */ 397 */
408 - public function relayDetail($task, $form, $is_inquiry = true) 398 + public function relayDetail($task, $form)
409 { 399 {
410 $this->output('获取转发对象'); 400 $this->output('获取转发对象');
411 if(empty($task['target'] )){ 401 if(empty($task['target'] )){
@@ -441,6 +431,17 @@ class RelayInquiry extends Command @@ -441,6 +431,17 @@ class RelayInquiry extends Command
441 } 431 }
442 $this->logChannel()->info('随机域名', array_column($random_data, 'url')); 432 $this->logChannel()->info('随机域名', array_column($random_data, 'url'));
443 foreach ($random_data as $item) { 433 foreach ($random_data as $item) {
  434 + $times = 1;
  435 + $inquiry_time = 1;
  436 +
  437 + //需要多个ip访问的国家 随机2-5次访问,只有一次询盘
  438 + if (in_array($form->country_name, $this->multiple_ip_visit_country)) {
  439 + $times = mt_rand(2, 5); //随机次数
  440 + $inquiry_time = mt_rand(1, $times); //第几次询盘
  441 + $this->output('多次访问模拟:' . $times);
  442 + }
  443 + for ($i = 1; $i <= $times; $i++) {
  444 + $is_inquiry = $inquiry_time == $i;
444 //手机号过滤 445 //手机号过滤
445 $phone = $form->phone; 446 $phone = $form->phone;
446 $filter_phone = $this->get_rand($this->filter_phone); 447 $filter_phone = $this->get_rand($this->filter_phone);
@@ -480,11 +481,13 @@ class RelayInquiry extends Command @@ -480,11 +481,13 @@ class RelayInquiry extends Command
480 $pre = 0; 481 $pre = 0;
481 $start_time = time(); 482 $start_time = time();
482 $seconds = rand(300, 7200); // 开始时间 从5-2小时后开始 483 $seconds = rand(300, 7200); // 开始时间 从5-2小时后开始
  484 + if($is_inquiry) {
483 $exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first(); 485 $exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
484 - if($exists){ 486 + if ($exists) {
485 $this->output('转发站点邮件已存在'); 487 $this->output('转发站点邮件已存在');
486 continue; 488 continue;
487 } 489 }
  490 + }
488 // 写入推送详情 491 // 写入推送详情
489 $re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port, 492 $re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port,
490 $user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds)); 493 $user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds));
@@ -500,6 +503,7 @@ class RelayInquiry extends Command @@ -500,6 +503,7 @@ class RelayInquiry extends Command
500 } 503 }
501 } 504 }
502 } 505 }
  506 + }
503 return true; 507 return true;
504 } 508 }
505 509
@@ -601,8 +605,11 @@ class RelayInquiry extends Command @@ -601,8 +605,11 @@ class RelayInquiry extends Command
601 $form_message = $message; 605 $form_message = $message;
602 $message_id = 0; 606 $message_id = 0;
603 607
604 - // TODO 当原始询盘内容长度大于15个字符, 直接发送原始内容。 608 + // TODO 当原始询盘内容长度大于15个字符, 60%几率直接发送原始内容。
605 if (strlen($message) >= 15) { 609 if (strlen($message) >= 15) {
  610 + $not_use_probability = AiCommand::where('key', 'fb_inquiry_text')->value('not_use_probability');
  611 + $randomNumber = rand(0, 100);
  612 + if($randomNumber < $not_use_probability){
606 //原内容非英语,转为对应语种 613 //原内容非英语,转为对应语种
607 if (is_numeric($form_message)) { //数字会被识别为中文 614 if (is_numeric($form_message)) { //数字会被识别为中文
608 $lang = 'en'; 615 $lang = 'en';
@@ -612,6 +619,7 @@ class RelayInquiry extends Command @@ -612,6 +619,7 @@ class RelayInquiry extends Command
612 } 619 }
613 return [$message, $message_id, $lang??'']; 620 return [$message, $message_id, $lang??''];
614 } 621 }
  622 + }
615 623
616 //开启文案替换 624 //开启文案替换
617 if ($task['is_replace_text'] == 2) { 625 if ($task['is_replace_text'] == 2) {
@@ -41,9 +41,9 @@ class SyncSubmitTask extends Command @@ -41,9 +41,9 @@ class SyncSubmitTask extends Command
41 $time = time(); 41 $time = time();
42 42
43 43
44 - DB::enableQueryLog(); //启用查询日志  
45 - //清除之前的查询日志  
46 - DB::flushQueryLog(); 44 +// DB::enableQueryLog(); //启用查询日志
  45 +// //清除之前的查询日志
  46 +// DB::flushQueryLog();
47 47
48 $task_info = SyncSubmitTaskModel::find($task_id); 48 $task_info = SyncSubmitTaskModel::find($task_id);
49 if (empty($task_info) || $task_info->status !=3) { 49 if (empty($task_info) || $task_info->status !=3) {
@@ -56,7 +56,9 @@ class SyncSubmitTask extends Command @@ -56,7 +56,9 @@ class SyncSubmitTask extends Command
56 throw new \Exception('项目不存在'); 56 throw new \Exception('项目不存在');
57 } 57 }
58 $task_info->project_id = $project->id; 58 $task_info->project_id = $project->id;
  59 + $time2 = time();
59 SyncSubmitTaskService::handler($task_info); 60 SyncSubmitTaskService::handler($task_info);
  61 + $this->output('处理用时:' . (time() - $time2));
60 $task_info->status = 1; 62 $task_info->status = 1;
61 $task_info->save(); 63 $task_info->save();
62 64
@@ -85,10 +87,11 @@ class SyncSubmitTask extends Command @@ -85,10 +87,11 @@ class SyncSubmitTask extends Command
85 $use_time = time() - $time; 87 $use_time = time() - $time;
86 if($use_time > 1){ 88 if($use_time > 1){
87 //数据库查询 89 //数据库查询
88 - $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); 90 + $this->output('任务用时:' .$use_time);
  91 +// $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
89 } 92 }
90 //清除之前的查询日志 93 //清除之前的查询日志
91 - DB::flushQueryLog(); 94 +// DB::flushQueryLog();
92 } 95 }
93 } 96 }
94 97
@@ -65,10 +65,20 @@ class Gpt @@ -65,10 +65,20 @@ class Gpt
65 65
66 $time = time(); 66 $time = time();
67 try { 67 try {
68 - $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()  
69 - ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')  
70 - ->post($url);  
71 - $json = $result->json(); 68 +// $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
  69 +// ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
  70 +// ->post($url);
  71 +// $json = $result->json();
  72 +
  73 + $client = new \GuzzleHttp\Client();
  74 + $result = $client->request('POST', $url, [
  75 + 'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
  76 + 'headers' => $this->header,
  77 + 'json' => $data,
  78 + 'verify' => false,
  79 + ])->getBody()->getContents();
  80 + $json = json_decode($result, true);
  81 +
72 if (!isset($json['text']) || $json['code'] !==200) { 82 if (!isset($json['text']) || $json['code'] !==200) {
73 Log::error('openai_chat_qqs data:', $data); 83 Log::error('openai_chat_qqs data:', $data);
74 Log::error('openai_chat_qqs result:' . (time() - $time), $json === null ? ['null'] : $json); 84 Log::error('openai_chat_qqs result:' . (time() - $time), $json === null ? ['null'] : $json);
@@ -153,4 +153,16 @@ class DomainInfo extends Base @@ -153,4 +153,16 @@ class DomainInfo extends Base
153 $value = Arr::s2a($value); 153 $value = Arr::s2a($value);
154 return $value; 154 return $value;
155 } 155 }
  156 +
  157 + public static function getCacheInfoByProjectId($project_id){
  158 + $cache_key = 'DOMAIN_INFO_BY_PROJECT_ID_' . $project_id;
  159 + $data = Cache::get($cache_key);
  160 + if(!$data){
  161 + $data = DomainInfo::where('project_id', $project_id)->first();
  162 + if($data){
  163 + Cache::put($cache_key, $data, 3600);
  164 + }
  165 + }
  166 + return $data;
  167 + }
156 } 168 }
@@ -75,7 +75,7 @@ class SyncSubmitTaskService @@ -75,7 +75,7 @@ class SyncSubmitTaskService
75 } 75 }
76 76
77 //域名 过滤国家或ip 77 //域名 过滤国家或ip
78 - $domain_info = DomainInfo::where('project_id', $project['id'])->first(); 78 + $domain_info = DomainInfo::getCacheInfoByProjectId($project['id']);
79 if(!empty($domain_info['not_allow_country'])){ 79 if(!empty($domain_info['not_allow_country'])){
80 $not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray(); 80 $not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray();
81 if(in_array($data['country'], $not_allow_countries)){ 81 if(in_array($data['country'], $not_allow_countries)){