作者 刘锟

update

... ... @@ -46,8 +46,12 @@ class SyncInquiryRelay extends Command
{
$this->output('开始同步表单系统询盘');
$this->getInquiryForm();
$this->output('开始同步asp采集询盘');
$this->output('开始同步SC平台询盘');
$this->getInquirySzcm();
$this->output('开始同步FS平台询盘');
$this->getInquiryFs();
}
/**
... ... @@ -65,9 +69,6 @@ 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']);
}
}
... ... @@ -112,6 +113,37 @@ class SyncInquiryRelay extends Command
}
/**
* @return bool
* @throws \Exception
* @author Akun
* @date 2025/03/04 11:48
*/
public function getInquiryFs()
{
$service = new InquiryRelayService();
$next_page_url = 'https://www.findsupply.com/api/external?page=1&pagesize=50';
$model = new InquiryInfo();
while ($next_page_url) {
$result = $service->getInquiryFs($next_page_url);
$data = $result['data'];
$next_page_url = $result['next_page_url'];
if ($data) {
foreach ($data as $item) {
$message_sign = md5($item['name'] . $item['email'] . $item['phone'] . $item['ip'] . $item['time']);
$inquiry_info = $model->where('message_sign', $message_sign)->first();
if ($inquiry_info) {
$next_page_url = null;
break;
}
$this->saveDate($item, InquiryInfo::TYPE_FIND_SUPPLY);
}
}
}
return true;
}
/**
* 询盘数据入库
* @param $data
* @param $type
... ... @@ -148,6 +180,7 @@ class SyncInquiryRelay extends Command
$html = curl_c($data['refer'], false);
if (empty($data['title'])) {
$data['title'] = '';
preg_match_all('/<title>([\w\W]*?)<\/title>/', $html, $matches);
if (!empty($matches[1])) {
$data['title'] = substr($matches[1][0], 0, 255);
... ...
... ... @@ -36,8 +36,9 @@ class InquiryInfo extends Base
const TYPE_SITE_GROUP = 1;
const TYPE_ADS = 2;
const TYPE_AI_SITE_GROUP = 3;
const TYPE_SPIDER = 4;
const TYPE_FIND_SUPPLY = 5;
const TYPE_PROMOTION = 4;
const TYPE_SPIDER = 5;
const TYPE_FIND_SUPPLY = 6;
/**
* 状态映射
... ... @@ -60,9 +61,10 @@ class InquiryInfo extends Base
public function typeMap()
{
return [
self::TYPE_SITE_GROUP => '站群询盘',
self::TYPE_SITE_GROUP => '自建AI站',
self::TYPE_ADS => 'ADS采集站',
self::TYPE_AI_SITE_GROUP => '自建AI站群',
self::TYPE_AI_SITE_GROUP => '客户AI站',
self::TYPE_PROMOTION => '客户推广到期站',
self::TYPE_SPIDER => 'SC平台',
self::TYPE_FIND_SUPPLY => 'FS平台',
];
... ...
... ... @@ -5,6 +5,7 @@
* Date: 2025/2/13
* Time: 11:01
*/
namespace App\Services;
use Illuminate\Support\Facades\Log;
... ... @@ -37,30 +38,30 @@ class InquiryRelayService
{
try {
// 获取数据
$url = "https://api.szcmapi.com/get_inquiry.aspx?id=".$id;
$url = "https://api.szcmapi.com/get_inquiry.aspx?id=" . $id;
$json = $this->szcmCurl($url);
// 兼容过去到的数据, 比较乱
$json = trim(str_replace("\r\n", '\n', (string) $json));
$json = str_replace('3/4"','3/4',$json);
$json = str_replace('"Steklopribor"','Steklopribor',$json);
$json = str_replace('"Net30 days"','Net30 days',$json);
$json = trim(str_replace("\r\n", '\n', (string)$json));
$json = str_replace('3/4"', '3/4', $json);
$json = str_replace('"Steklopribor"', 'Steklopribor', $json);
$json = str_replace('"Net30 days"', 'Net30 days', $json);
$json = trim($json);
$json = str_replace("\n",'',$json);
$array = json_decode($json,true);
$json = str_replace("\n", '', $json);
$array = json_decode($json, true);
if (empty($array))
return false;
// 整合最终数据
$title = base64_decode($array['title']);
$title = str_replace("'",'',$title);
$title = str_replace("'", '', $title);
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
$title = str_replace("'",'',$title);
$title = str_replace("'", '', $title);
$message = html_entity_decode(addslashes(base64_decode($array['Message'])), ENT_QUOTES, 'UTF-8');
$message = str_replace("'",'',$message);
$message = str_replace("'", '', $message);
$email = trim($array['Email']);
$name = html_entity_decode($array['Name'], ENT_QUOTES, 'UTF-8');
$name = str_replace("'",'',$name);
$name = str_replace("'", '', $name);
$result = [
'image' => $array['image'] ?: '',
... ... @@ -106,6 +107,42 @@ class InquiryRelayService
return $result;
}
/**
* 获取findsupply询盘
* @param $url
* @return array
* @throws \Exception
* @author Akun
* @date 2025/03/04 10:48
*/
public function getInquiryFs($url)
{
$re = curl_get($url);
$result = [];
$next_page_url = '';
if (isset($re['status']) && $re['status'] == 200) {
$next_page_url = $re['data']['next_page_url'];
foreach ($re['data']['data'] as $v) {
$dateTime = new \DateTime($v['created_at']);
$time = $dateTime->format('Y-m-d H:i:s');
$result[] = [
'time' => $time,
'name' => $v['NAME'] ?: '',
'email' => $v['email'] ?: '',
'phone' => $v['phone_number'] ?: '',
'refer' => $v['page_url'] ?: '',
'message' => $v['content'] ?: '',
'ip' => $v['ip'] ?: '',
'source_address' => 'www.findsupply.com',
'title' => $v['products_title'] ?: '',
'submit_country' => $v['country'] ?: ''
];
}
}
return ['next_page_url' => $next_page_url, 'data' => $result];
}
########################################################################################################################
# 询盘结束, 同步项目及路由 #
########################################################################################################################
... ...