作者 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->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,62 +431,76 @@ class RelayInquiry extends Command
}
$this->logChannel()->info('随机域名', array_column($random_data, 'url'));
foreach ($random_data as $item) {
//手机号过滤
$phone = $form->phone;
$filter_phone = $this->get_rand($this->filter_phone);
if($filter_phone == 0){
$phone = trim(str_replace("+", '', $phone));
}elseif($filter_phone == 1){
$phone = '';
$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);
if($filter_phone == 0){
$phone = trim(str_replace("+", '', $phone));
}elseif($filter_phone == 1){
$phone = '';
}
// 推送站点
$domain = $item['url'];
$is_v6 = $item['is_v6'];
$re_website = 'https://' . $domain . '/';
//urls
list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
if(!$urls){
continue;
}
//ip
$ip_data = $this->getIpData($form->country_name);
$ip = $ip_data->ip;
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url);
$lang = $lang ?: $msg_lang;
// 推送站点
$domain = $item['url'];
$is_v6 = $item['is_v6'];
$re_website = 'https://' . $domain . '/';
$this->output('获取转发设备信息');
// 客户端 头信息 来源
$device_port = $form->email ? '1' : '2'; //1 pc 2移动端
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$referrer = $this->getReferer($country_name, $lang);
$this->output('写入数据');
//urls
list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
if(!$urls){
continue;
}
$pre = 0;
$start_time = time();
$seconds = rand(300, 7200); // 开始时间 从5-2小时后开始
$exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
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));
foreach ($urls as $k=>$v){
$pre++;
$seconds += rand(5,60);
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_VISIT, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
// 最后一次访问询盘 加上询盘
if($is_inquiry && $k+1 >= count($urls)){
$seconds += rand(30,120);
//ip
$ip_data = $this->getIpData($form->country_name);
$ip = $ip_data->ip;
$country_name = $ip_data->ip_area;
//message
list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url);
$lang = $lang ?: $msg_lang;
$this->output('获取转发设备信息');
// 客户端 头信息 来源
$device_port = $form->email ? '1' : '2'; //1 pc 2移动端
$user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
$referrer = $this->getReferer($country_name, $lang);
$this->output('写入数据');
$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) {
$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));
foreach ($urls as $k=>$v){
$pre++;
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
$seconds += rand(5,60);
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_VISIT, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
// 最后一次访问询盘 加上询盘
if($is_inquiry && $k+1 >= count($urls)){
$seconds += rand(30,120);
$pre++;
ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, $pre, $v, date('Y-m-d H:i:s', $start_time + $seconds));
}
}
}
}
... ... @@ -601,16 +605,20 @@ class RelayInquiry extends Command
$form_message = $message;
$message_id = 0;
// TODO 当原始询盘内容长度大于15个字符, 直接发送原始内容。
// TODO 当原始询盘内容长度大于15个字符, 60%几率直接发送原始内容。
if (strlen($message) >= 15) {
//原内容非英语,转为对应语种
if (is_numeric($form_message)) { //数字会被识别为中文
$lang = 'en';
} else {
$translateSl = Translate::translateSl($form_message);
$lang = $translateSl['texts']['sl'] ?? 'en';
$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';
} else {
$translateSl = Translate::translateSl($form_message);
$lang = $translateSl['texts']['sl'] ?? 'en';
}
return [$message, $message_id, $lang??''];
}
return [$message, $message_id, $lang??''];
}
//开启文案替换
... ...
... ... @@ -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)){
... ...