作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into master-server

... ... @@ -47,6 +47,27 @@ class PostInquiryForward extends Command
parent::__construct();
}
/**
* 芯片网站
* @var array
*/
protected $xp_websites = [
'www.shinecomponents.com',
'www.hk-allchips.com',
'www.xinjiada-ic.com',
'www.sic-components.com',
'www.chip1-vip.com',
'www.flash-turtle.com',
'www.xinteerchip.com',
'www.conevoelec.com'
];
/**
* 5.0询盘转发到自己站点的网站
* @var array
*/
protected $self_websites = [205570, 64532, 150535, 292114, 124579, 237114, 194809, 278184, 166223, 366238, 277923, 297045, 309218, 75191, 57616];
public function handle()
{
... ... @@ -129,21 +150,23 @@ class PostInquiryForward extends Command
'referrer_url' => $detail['referrer'],
'user_agent' => $detail['user_agent'],
];
$res = Http::withoutVerifying()->timeout(30)->post($website . 'api/traffic_visit/', $data)->json();
$url = $website . 'api/traffic_visit/';
$res = Http::withoutVerifying()->timeout(30)->post($url, $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward visit error', [$res, $website . 'api/traffic_visit/', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward visit error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward visit success', [$res, $url, $data]);
} else {
//v4 v5分离项目 往测试链接推
$project_info = InquiryProject::select(['is_split', 'test_domain'])->where('domain', 'like', '%' . $detail['website'] . '%')->first();
if (!$project_info) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = '获取域名对应项目失败';
$log->remark = '获取分离项目测试域名失败';
$log->save();
return false;
... ... @@ -161,16 +184,19 @@ class PostInquiryForward extends Command
'user_agent' => $detail['user_agent'],
"ip" => $detail['ip'],
];
$res = Http::get($website . 'wp-admin/admin-ajax.php', $data);
$url = $website . 'wp-admin/admin-ajax.php';
$res = Http::withoutVerifying()->timeout(30)->get($url, $data);
$status = $res->status();
if ($status != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res->body() ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit error', [$res->body(), $website . 'wp-admin/admin-ajax.php', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit error', [$res->body(), $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 visit success', [$res->body(), $url, $data]);
}
$log->status = InquiryRelayDetailLog::STATUS_SUCCESS;
$log->save();
... ... @@ -179,12 +205,18 @@ class PostInquiryForward extends Command
public function inquiry(InquiryRelayDetail $detail, InquiryRelayDetailLog $log)
{
// v6
if (in_array($detail['website'], $this->xp_websites)) {
// 芯片网站
$res = $this->xpInquiry($detail, $log);
} else {
if ($detail['is_v6']) {
// v6
$res = $this->v6Inquiry($detail, $log);
} else {
// v5
$res = $this->v5Inquiry($detail, $log);
}
}
if (!$res) {
return false;
... ... @@ -196,6 +228,47 @@ class PostInquiryForward extends Command
return true;
}
public function xpInquiry($detail, $log)
{
$data = [
'refer' => $log['url'],
'contact_name' => $detail['name'],
'email' => $detail['email'],
'tel' => $detail['phone'],
'ip' => $detail['ip'],
'remark' => $detail['message'],
'submit_time' => date('Y-m-d H:i:s', time() + 20),
];
$url = 'https://' . $detail['website'] . '/api/store/webmail?flag=opencart';
$post_data = json_encode($data);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36');
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($post_data)));
$curl_response = curl_exec($curl);
curl_close($curl);
$res = json_decode($curl_response, true);
if (empty($res['code']) || $res['code'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['msg'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward xp inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward xp inquiry success', [$res, $url, $data]);
return false;
}
public function v6Inquiry($detail, $log)
{
$website = 'https://' . $detail['website'] . '/';
... ... @@ -211,19 +284,46 @@ class PostInquiryForward extends Command
} else {
$data['__amp_source_origin'] = trim($website, '/');
}
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd?source=5', $data)->json();
$url = $website . 'api/inquiryQd?source=5';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['code']) || $res['code'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v6 inquiry success', [$res, $url, $data]);
return true;
}
public function v5Inquiry($detail, $log)
{
$project_id = InquiryProject::where('version', '<', 6)->where('domain', 'like', '%' . $detail['website'] . '%')->value('primary_id') ?? 0;
if (in_array($project_id, $this->self_websites)) {
//发送到自己站点项目
$data = [
'Name' => $detail['name'],
'Phone' => $detail['phone'],
'Message' => $detail['message'],
'Email' => $detail['email'],
'submit_ip' => $detail['ip'],
'refer' => $log['url'],
'submit_time' => date('Y-m-d H:i:s', time() + 60)
];
$url = 'https://' . $detail['website'] . '/wp-admin/admin-ajax.php?action=live_remort_receive';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data);
$status = $res->status();
if ($status != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res->body() ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$res->body(), $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry success', [$res->body(), $url, $data]);
} else {
$data = [
'name' => $detail['name'],
'phone' => $detail['phone'],
... ... @@ -235,21 +335,19 @@ class PostInquiryForward extends Command
'submit_time' => date('Y-m-d H:i:s'),
'source' => 5,
];
$result = Http::withoutVerifying()->timeout(30)->post('https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data);
$res['data'][0]['status'] = 'success';
//兼容接口返回格式
if (!empty($res['data'][0]['status'])) {
$res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
!empty($res['data'][0]['msg']) && $res['message'] = $res['data'][0]['msg'];
}
if (empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200, 300])) {
$url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
$res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = InquiryRelayDetailLog::STATUS_FAIL;
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$result->body(), 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data]);
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry error', [$res, $url, $data]);
return false;
}
Log::channel('inquiry_forward')->error('post_inquiry_forward v4|v5 inquiry success', [$res, $url, $data]);
}
return true;
}
... ...
... ... @@ -153,6 +153,20 @@ class RelayInquiryForward extends Command
protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀
/**
* 芯片网站
* @var array
*/
protected $xp_websites = [
'www.shinecomponents.com',
'www.hk-allchips.com',
'www.xinjiada-ic.com',
'www.sic-components.com',
'www.chip1-vip.com',
'www.flash-turtle.com',
'www.xinteerchip.com',
'www.conevoelec.com'
];
public function handle()
{
... ... @@ -207,9 +221,14 @@ class RelayInquiryForward extends Command
public function completeDetail($inquiry_detail)
{
//visit urls
$visit_urls = $this->getUrls($inquiry_detail['is_v6'], $inquiry_detail['website'], $inquiry_detail['email']);
$inquiry_url = json_decode($inquiry_detail['urls'], true);
if (in_array($inquiry_detail['website'], $this->xp_websites)) {
//芯片网站无需模拟访问,直接发送询盘
$urls = $inquiry_url;
} else {
$visit_urls = $this->getUrls($inquiry_detail['is_v6'], $inquiry_detail['website'], $inquiry_detail['email']);
$urls = array_merge($visit_urls, $inquiry_url);
}
//lang
if (is_numeric($inquiry_detail['message'])) { //数字会被识别为中文
... ... @@ -303,8 +322,8 @@ class RelayInquiryForward extends Command
$all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url);
if (count($all_urls) > 1) {
// 随机访问1-6个页面
$deep = rand(1, 6);
// 随机访问1-5个页面
$deep = rand(1, 5);
$visit_urls = Arr::random($all_urls, $deep > count($all_urls) ? count($all_urls) : $deep);
$urls = array_merge($urls, $visit_urls);
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\Inquiry;
use App\Helper\Translate;
use App\Helper\Validate;
use App\Models\Inquiry\InquiryInfo;
use App\Services\InquiryRelayService;
use Illuminate\Console\Command;
... ... @@ -64,6 +65,9 @@ class SyncInquiryRelay extends Command
//+86区号过滤
continue;
}
if (strpos($item['refer'], 'findsupply.com') !== false) {
$item['source_type'] = InquiryInfo::TYPE_FIND_SUPPLY;
}
$this->saveDate($item, $item['source_type']);
}
}
... ... @@ -164,7 +168,20 @@ class SyncInquiryRelay extends Command
$data['image'] = '';
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']);
//判断手机和邮箱是否有效
$email_status = 0;
if ($data['email']) {
$check_email = Validate::email($data['email']);
$email_status = $check_email ? 1 : 0;
}
$phone_status = 0;
if ($data['phone']) {
$num_phone = preg_replace('/\D/', '', $data['phone']) ?? ''; // \D 匹配所有非数字字符
$check_phone = Validate::phone($num_phone);
$phone_status = $check_phone ? 1 : 0;
}
$model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image'], $email_status, $phone_status);
return true;
}
... ...
... ... @@ -28,6 +28,9 @@ class InquiryForwardController extends BaseController
if (isset($this->param['url_keyword'])) {
$this->map['url_keyword'] = ['like', '%' . $this->map['url_keyword'] . '%'];
}
if (isset($this->param['message'])) {
$this->map['message'] = ['like', '%' . $this->map['message'] . '%'];
}
$lists = $inquiryForwardLogic->getInquiryLists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $lists);
}
... ... @@ -40,14 +43,15 @@ class InquiryForwardController extends BaseController
* @author Akun
* @date 2025/03/01 11:21
*/
public function getInquiryInfo(InquiryForwardLogic $inquiryForwardLogic){
public function getInquiryInfo(InquiryForwardLogic $inquiryForwardLogic)
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'ID不能为空',
]);
$info = $inquiryForwardLogic->infoInquiry();
$this->response('success',Code::SUCCESS,$info);
$this->response('success', Code::SUCCESS, $info);
}
/**
... ... @@ -190,7 +194,8 @@ class InquiryForwardController extends BaseController
* @author Akun
* @date 2025/03/01 9:22
*/
public function getInquiryDetailList(InquiryForwardLogic $inquiryForwardLogic){
public function getInquiryDetailList(InquiryForwardLogic $inquiryForwardLogic)
{
if (isset($this->param['country'])) {
$this->map['country'] = ['like', '%' . $this->map['country'] . '%'];
}
... ...
... ... @@ -14,7 +14,6 @@ use App\Models\Inquiry\InquiryProjectRoute;
use App\Models\Inquiry\InquiryRelayDetail;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
/**
... ... @@ -333,10 +332,17 @@ class InquiryForwardLogic extends BaseLogic
*/
public function expiredInquiry()
{
$rs = $this->model->edit(['status' => InquiryInfo::STATUS_INVALID], ['id' => $this->param['id']]);
if (isset($this->param['type']) && $this->param['type'] == 1) {
//启用
$status = InquiryInfo::STATUS_INIT;
} else {
//无效
$status = InquiryInfo::STATUS_INVALID;
}
$rs = $this->model->edit(['status' => $status], ['id' => $this->param['id']]);
if ($rs === false) {
$this->fail('设置无效失败');
$this->fail('设置失败');
}
return $this->success();
}
... ...
... ... @@ -37,6 +37,7 @@ class InquiryInfo extends Base
const TYPE_ADS = 2;
const TYPE_AI_SITE_GROUP = 3;
const TYPE_SPIDER = 4;
const TYPE_FIND_SUPPLY = 5;
/**
* 状态映射
... ... @@ -60,9 +61,10 @@ class InquiryInfo extends Base
{
return [
self::TYPE_SITE_GROUP => '站群询盘',
self::TYPE_ADS => 'ads采集站询盘',
self::TYPE_AI_SITE_GROUP => 'AI站群询盘',
self::TYPE_SPIDER => '蜘蛛询盘',
self::TYPE_ADS => 'ADS采集站',
self::TYPE_AI_SITE_GROUP => '自建AI站群',
self::TYPE_SPIDER => 'SC平台',
self::TYPE_FIND_SUPPLY => 'FS平台',
];
}
... ... @@ -83,15 +85,19 @@ class InquiryInfo extends Base
* @param $message_sign
* @param $origin_key
* @param string $image
* @param int $email_status
* @param int $phone_status
* @return bool
*/
public function createInquiry($name, $phone, $email, $ip, $country, $message, $message_cn, $type, $inquiry_date, $url, $url_title, $url_keyword, $message_sign, $origin_key, $image = '')
public function createInquiry($name, $phone, $email, $ip, $country, $message, $message_cn, $type, $inquiry_date, $url, $url_title, $url_keyword, $message_sign, $origin_key, $image = '', $email_status = 0, $phone_status = 0)
{
try {
$self = new self();
$self->name = $name;
$self->phone = $phone;
$self->phone_status = $phone_status;
$self->email = $email;
$self->email_status = $email_status;
$self->ip = $ip;
$self->country = $country;
$self->message = $message;
... ...
... ... @@ -185,6 +185,12 @@ return [
'level' => 'debug',
'days' => 14,
],
'inquiry_forward' => [
'driver' => 'daily',
'path' => storage_path('logs/inquiry_forward/laravel.log'),
'level' => 'debug',
'days' => 14,
],
],
//操作日志
'operator_log' =>[
... ...