作者 zhl

修改询盘链接 from.globalso.com => www.globalso.site

@@ -62,7 +62,7 @@ class InquiryDelay extends Command @@ -62,7 +62,7 @@ class InquiryDelay extends Command
62 * @time :2023/7/13 14:39 62 * @time :2023/7/13 14:39
63 */ 63 */
64 public function inquiryForward($post_data){ 64 public function inquiryForward($post_data){
65 - $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f'; 65 + $url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
66 $post_data_new = []; 66 $post_data_new = [];
67 $post_data_new['refer'] = $post_data['url']; 67 $post_data_new['refer'] = $post_data['url'];
68 $post_data_new['name'] = $post_data['name']; 68 $post_data_new['name'] = $post_data['name'];
@@ -57,8 +57,11 @@ class SyncInquiryProject extends Command @@ -57,8 +57,11 @@ class SyncInquiryProject extends Command
57 */ 57 */
58 public function handle() 58 public function handle()
59 { 59 {
  60 + echo '开始同步v5' . PHP_EOL;
60 $this->syncGloV5(); 61 $this->syncGloV5();
  62 + echo '开始同步v6' . PHP_EOL;
61 $this->syncGloV6(); 63 $this->syncGloV6();
  64 + echo '删除过期数据' . PHP_EOL;
62 $this->deleteExpire(); 65 $this->deleteExpire();
63 return true; 66 return true;
64 } 67 }
@@ -73,12 +76,14 @@ class SyncInquiryProject extends Command @@ -73,12 +76,14 @@ class SyncInquiryProject extends Command
73 $channel = Channel::pluck('contact_mobile', 'id')->toArray(); 76 $channel = Channel::pluck('contact_mobile', 'id')->toArray();
74 foreach ($result as $key=>$val) 77 foreach ($result as $key=>$val)
75 { 78 {
  79 + echo '同步项目:' . $val['postid'] . ' - ' . $val['company'] . PHP_EOL;
76 // 记录渠道商, 如果渠道有问题, 记录日志, 跳过当前项目, 处理数据后, 第二天再重新同步 80 // 记录渠道商, 如果渠道有问题, 记录日志, 跳过当前项目, 处理数据后, 第二天再重新同步
77 $channel_flag = false; 81 $channel_flag = false;
78 $channel_tmp = []; 82 $channel_tmp = [];
79 foreach ($val['agent'] as $v) { 83 foreach ($val['agent'] as $v) {
80 $channel_id = array_search($v, $channel); 84 $channel_id = array_search($v, $channel);
81 if (empty($channel_id)) { 85 if (empty($channel_id)) {
  86 + $this->log('ERROR 代理商找不到不记录当前项目, 代理商手机号码:' . $v);
82 $channel_flag = true; 87 $channel_flag = true;
83 break; 88 break;
84 } 89 }
@@ -106,16 +111,32 @@ class SyncInquiryProject extends Command @@ -106,16 +111,32 @@ class SyncInquiryProject extends Command
106 */ 111 */
107 public function syncGloV5Route($project_id, $route_domain) 112 public function syncGloV5Route($project_id, $route_domain)
108 { 113 {
109 - $result = http_get($route_domain . 'k_u_api.php'); 114 + try{
  115 + $result = http_get($route_domain . 'k_u_api.php');
  116 + if (empty($result)) {
  117 + $this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php');
  118 + return false;
  119 + }
  120 + } catch (\Exception $e) {
  121 + $this->log('syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage());
  122 + echo 'syncGloV5Route 未获取到路由信息:' . $project_id . ', 路由获取地址:' . $route_domain . 'k_u_api.php' . ', 错误信息:' . $e->getMessage() . PHP_EOL;
  123 + return false;
  124 + }
  125 +
110 foreach ($result as $key=>$val) { 126 foreach ($result as $key=>$val) {
111 try { 127 try {
112 $tmp = explode('|', $val); 128 $tmp = explode('|', $val);
113 $url_tmp = parse_url($tmp[0]); 129 $url_tmp = parse_url($tmp[0]);
114 $route = trim($url_tmp['path'], '/'); 130 $route = trim($url_tmp['path'], '/');
115 $title = str_replace('+', ' ', $tmp[1]); 131 $title = str_replace('+', ' ', $tmp[1]);
  132 + if (strlen($title) > 200 || strlen($route) > 200) {
  133 + $this->log('syncGloV5Route 路由或标题过长,无效记录');
  134 + continue;
  135 + }
116 InquiryProjectRoute::saveProjectRoute($project_id, $title, $route); 136 InquiryProjectRoute::saveProjectRoute($project_id, $title, $route);
117 } catch (\Exception $e) { 137 } catch (\Exception $e) {
118 $this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage()); 138 $this->log('syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage());
  139 + echo 'syncGloV5Route 解析路径:' . $val . ', 错误信息:' . $e->getMessage() . PHP_EOL;
119 } 140 }
120 } 141 }
121 return true; 142 return true;
@@ -140,6 +161,7 @@ class SyncInquiryProject extends Command @@ -140,6 +161,7 @@ class SyncInquiryProject extends Command
140 // 获取所有项目域名 161 // 获取所有项目域名
141 $domains = DomainInfo::whereIn('project_id', $project->pluck('id')->toArray())->pluck('domain', 'project_id')->toArray(); 162 $domains = DomainInfo::whereIn('project_id', $project->pluck('id')->toArray())->pluck('domain', 'project_id')->toArray();
142 foreach ($project as $key=>$val) { 163 foreach ($project as $key=>$val) {
  164 + echo '同步项目:' . $val->id . ' - ' . $val->title . PHP_EOL;
143 // 过滤暂停优化项目, 映射类型2, model没有定义常量 165 // 过滤暂停优化项目, 映射类型2, model没有定义常量
144 if (in_array(2, $val->level)) 166 if (in_array(2, $val->level))
145 continue; 167 continue;
@@ -167,6 +189,7 @@ class SyncInquiryProject extends Command @@ -167,6 +189,7 @@ class SyncInquiryProject extends Command
167 // 产品数量会比较多, 所以使用分页 同步数据 189 // 产品数量会比较多, 所以使用分页 同步数据
168 $id = 0; 190 $id = 0;
169 while (true) { 191 while (true) {
  192 + echo '同步项目路由:' . $id . PHP_EOL;
170 $product = Product::where('status', Product::STATUS_ON)->where('id', '>', $id)->orderBy('id', 'asc')->limit(1000)->get(['id', 'title', 'route']); 193 $product = Product::where('status', Product::STATUS_ON)->where('id', '>', $id)->orderBy('id', 'asc')->limit(1000)->get(['id', 'title', 'route']);
171 if ($product->isEmpty()) 194 if ($product->isEmpty())
172 break; 195 break;
@@ -243,7 +243,7 @@ class postInquiry extends Command @@ -243,7 +243,7 @@ class postInquiry extends Command
243 'source' => 5, 243 'source' => 5,
244 ]; 244 ];
245 245
246 - $result = Http::withoutVerifying()->timeout(30)->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data); 246 + $result = Http::withoutVerifying()->timeout(30)->post('https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data);
247 $res = $result->json(); 247 $res = $result->json();
248 //兼容接口返回格式 248 //兼容接口返回格式
249 if (!empty($res['data'][0]['status'])) { 249 if (!empty($res['data'][0]['status'])) {
@@ -255,7 +255,7 @@ class postInquiry extends Command @@ -255,7 +255,7 @@ class postInquiry extends Command
255 $log->remark = mb_substr($res['message'] ?? '', 0, 200); 255 $log->remark = mb_substr($res['message'] ?? '', 0, 200);
256 $log->save(); 256 $log->save();
257 257
258 - Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]); 258 + Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f', $data]);
259 return false; 259 return false;
260 } 260 }
261 return true; 261 return true;
@@ -17,7 +17,7 @@ use GuzzleHttp\Exception\GuzzleException; @@ -17,7 +17,7 @@ use GuzzleHttp\Exception\GuzzleException;
17 class FormGlobalsoApi 17 class FormGlobalsoApi
18 { 18 {
19 //接口地址 19 //接口地址
20 - protected $url = 'https://form.globalso.com'; 20 + protected $url = 'https://www.globalso.site';
21 21
22 /** 22 /**
23 * 设置询盘通知 23 * 设置询盘通知
@@ -179,7 +179,7 @@ class FormGlobalsoApi @@ -179,7 +179,7 @@ class FormGlobalsoApi
179 'num'=>15, 179 'num'=>15,
180 ]; 180 ];
181 $queryString = http_build_query($data); 181 $queryString = http_build_query($data);
182 - $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?".$queryString; 182 + $url = "https://www.globalso.site/api/external-interface/domain_con/15243d63ed5a5738?".$queryString;
183 try { 183 try {
184 $res = http_get($url,['charset=utf-8']); 184 $res = http_get($url,['charset=utf-8']);
185 } catch (\Exception | GuzzleException $e) { 185 } catch (\Exception | GuzzleException $e) {
@@ -207,7 +207,7 @@ class FormGlobalsoApi @@ -207,7 +207,7 @@ class FormGlobalsoApi
207 'sta_date'=>$month, 207 'sta_date'=>$month,
208 ]; 208 ];
209 $queryString = http_build_query($data); 209 $queryString = http_build_query($data);
210 - $url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?'.$queryString; 210 + $url = 'https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
211 $res = http_get($url,['charset=utf-8']); 211 $res = http_get($url,['charset=utf-8']);
212 echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL; 212 echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
213 return $res; 213 return $res;
@@ -501,7 +501,7 @@ if (!function_exists('getInquiryInformation')) { @@ -501,7 +501,7 @@ if (!function_exists('getInquiryInformation')) {
501 { 501 {
502 $token = md5($domain . date("Y-m-d")); 502 $token = md5($domain . date("Y-m-d"));
503 $source = '1,3'; 503 $source = '1,3';
504 - $url = "https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}"; 504 + $url = "https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}";
505 $client = new Client(['verify' => false]); 505 $client = new Client(['verify' => false]);
506 $http = $client->get($url); 506 $http = $client->get($url);
507 $data = []; 507 $data = [];
@@ -172,7 +172,7 @@ class InquiryInfoLogic extends BaseLogic @@ -172,7 +172,7 @@ class InquiryInfoLogic extends BaseLogic
172 * @time :2023/7/13 14:39 172 * @time :2023/7/13 14:39
173 */ 173 */
174 public function inquiryForward($post_data){ 174 public function inquiryForward($post_data){
175 - $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f'; 175 + $url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f';
176 $post_data_new = []; 176 $post_data_new = [];
177 $post_data_new['refer'] = $post_data['url']; 177 $post_data_new['refer'] = $post_data['url'];
178 $post_data_new['name'] = $post_data['name']; 178 $post_data_new['name'] = $post_data['name'];
@@ -23,7 +23,7 @@ class InquiryRelayService @@ -23,7 +23,7 @@ class InquiryRelayService
23 { 23 {
24 $date = date('Y-m-d'); 24 $date = date('Y-m-d');
25 $token = md5($date . 'qqs'); 25 $token = md5($date . 'qqs');
26 - $url = 'https://form.globalso.com/api/external-interface/echo_inquriy/d1483a8e57cb485a?date=' . $date . '&token=' . $token . '&type=2'; 26 + $url = 'https://www.globalso.site/api/external-interface/echo_inquriy/d1483a8e57cb485a?date=' . $date . '&token=' . $token . '&type=2';
27 $result = http_get($url); 27 $result = http_get($url);
28 return $result; 28 return $result;
29 } 29 }
@@ -105,4 +105,8 @@ class InquiryRelayService @@ -105,4 +105,8 @@ class InquiryRelayService
105 curl_close($ch); 105 curl_close($ch);
106 return $result; 106 return $result;
107 } 107 }
  108 +
  109 +########################################################################################################################
  110 +# 询盘结束, 同步项目及路由 #
  111 +########################################################################################################################
108 } 112 }
@@ -29,7 +29,7 @@ class SyncService @@ -29,7 +29,7 @@ class SyncService
29 public function projectAcceptAddress($project_id = 0) 29 public function projectAcceptAddress($project_id = 0)
30 { 30 {
31 try { 31 try {
32 - $url = 'https://form.globalso.com/api/globalsov6'; 32 + $url = 'https://www.globalso.site/api/globalsov6';
33 // 项目信息 33 // 项目信息
34 $project = Project::with('deploy_build')->with('deploy_optimize')->where(['id'=>$project_id])->first(); 34 $project = Project::with('deploy_build')->with('deploy_optimize')->where(['id'=>$project_id])->first();
35 // 不满足条件 不同步到表单系统 35 // 不满足条件 不同步到表单系统