作者 zhl

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

... ... @@ -332,17 +332,7 @@ class RelayInquiry extends Command
try {
$res = false;
foreach ($ad_task as $task){
//需要多个ip访问的国家 随机2-5次访问,只有一次询盘
if (in_array($val->country_name, $this->multiple_ip_visit_country)) {
$times = mt_rand(2, 5); //随机次数
$inquiry_time = mt_rand(1, $times); //第几次询盘
$this->output('多次访问模拟:' . $times);
for ($i = 1; $i <= $times; $i++) {
$res += $this->relayDetail($task, $val, $inquiry_time == $i);
}
}else{
$res += $this->relayDetail($task, $val);
}
$res += $this->relayShopDetail($task, $val);
$res += $this->relayFobDetail($task, $val);
}
... ... @@ -405,7 +395,7 @@ class RelayInquiry extends Command
* @param $form
* @return bool
*/
public function relayDetail($task, $form, $is_inquiry = true)
public function relayDetail($task, $form)
{
$this->output('获取转发对象');
if(empty($task['target'] )){
... ... @@ -441,6 +431,17 @@ class RelayInquiry extends Command
}
$this->logChannel()->info('随机域名', array_column($random_data, 'url'));
foreach ($random_data as $item) {
$times = 1;
$inquiry_time = 1;
//需要多个ip访问的国家 随机2-5次访问,只有一次询盘
if (in_array($form->country_name, $this->multiple_ip_visit_country)) {
$times = mt_rand(2, 5); //随机次数
$inquiry_time = mt_rand(1, $times); //第几次询盘
$this->output('多次访问模拟:' . $times);
}
for ($i = 1; $i <= $times; $i++) {
$is_inquiry = $inquiry_time == $i;
//手机号过滤
$phone = $form->phone;
$filter_phone = $this->get_rand($this->filter_phone);
... ... @@ -480,11 +481,13 @@ class RelayInquiry extends Command
$pre = 0;
$start_time = time();
$seconds = rand(300, 7200); // 开始时间 从5-2小时后开始
if($is_inquiry) {
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
if($exists){
if ($exists) {
$this->output('转发站点邮件已存在');
continue;
}
}
// 写入推送详情
$re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id, $device_port,
$user_agent, $referrer, $urls, $is_v6, date('Y-m-d H:i:s', $start_time + $seconds));
... ... @@ -500,6 +503,7 @@ class RelayInquiry extends Command
}
}
}
}
return true;
}
... ... @@ -601,8 +605,11 @@ class RelayInquiry extends Command
$form_message = $message;
$message_id = 0;
// TODO 当原始询盘内容长度大于15个字符, 直接发送原始内容。
// TODO 当原始询盘内容长度大于15个字符, 60%几率直接发送原始内容。
if (strlen($message) >= 15) {
$not_use_probability = AiCommand::where('key', 'fb_inquiry_text')->value('not_use_probability');
$randomNumber = rand(0, 100);
if($randomNumber < $not_use_probability){
//原内容非英语,转为对应语种
if (is_numeric($form_message)) { //数字会被识别为中文
$lang = 'en';
... ... @@ -612,6 +619,7 @@ class RelayInquiry extends Command
}
return [$message, $message_id, $lang??''];
}
}
//开启文案替换
if ($task['is_replace_text'] == 2) {
... ...
... ... @@ -41,9 +41,9 @@ class SyncSubmitTask extends Command
$time = time();
DB::enableQueryLog(); //启用查询日志
//清除之前的查询日志
DB::flushQueryLog();
// DB::enableQueryLog(); //启用查询日志
// //清除之前的查询日志
// DB::flushQueryLog();
$task_info = SyncSubmitTaskModel::find($task_id);
if (empty($task_info) || $task_info->status !=3) {
... ... @@ -56,7 +56,9 @@ class SyncSubmitTask extends Command
throw new \Exception('项目不存在');
}
$task_info->project_id = $project->id;
$time2 = time();
SyncSubmitTaskService::handler($task_info);
$this->output('处理用时:' . (time() - $time2));
$task_info->status = 1;
$task_info->save();
... ... @@ -85,10 +87,11 @@ class SyncSubmitTask extends Command
$use_time = time() - $time;
if($use_time > 1){
//数据库查询
$this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
$this->output('任务用时:' .$use_time);
// $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
//清除之前的查询日志
DB::flushQueryLog();
// DB::flushQueryLog();
}
}
... ...
... ... @@ -65,10 +65,20 @@ class Gpt
$time = time();
try {
$result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
->post($url);
$json = $result->json();
// $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
// ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
// ->post($url);
// $json = $result->json();
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', $url, [
'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
'headers' => $this->header,
'json' => $data,
'verify' => false,
])->getBody()->getContents();
$json = json_decode($result, true);
if (!isset($json['text']) || $json['code'] !==200) {
Log::error('openai_chat_qqs data:', $data);
Log::error('openai_chat_qqs result:' . (time() - $time), $json === null ? ['null'] : $json);
... ...
... ... @@ -153,4 +153,16 @@ class DomainInfo extends Base
$value = Arr::s2a($value);
return $value;
}
public static function getCacheInfoByProjectId($project_id){
$cache_key = 'DOMAIN_INFO_BY_PROJECT_ID_' . $project_id;
$data = Cache::get($cache_key);
if(!$data){
$data = DomainInfo::where('project_id', $project_id)->first();
if($data){
Cache::put($cache_key, $data, 3600);
}
}
return $data;
}
}
... ...
... ... @@ -75,7 +75,7 @@ class SyncSubmitTaskService
}
//域名 过滤国家或ip
$domain_info = DomainInfo::where('project_id', $project['id'])->first();
$domain_info = DomainInfo::getCacheInfoByProjectId($project['id']);
if(!empty($domain_info['not_allow_country'])){
$not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray();
if(in_array($data['country'], $not_allow_countries)){
... ...