|
@@ -3,7 +3,12 @@ |
|
@@ -3,7 +3,12 @@ |
|
3
|
namespace App\Models\Inquiry;
|
3
|
namespace App\Models\Inquiry;
|
|
4
|
|
4
|
|
|
5
|
|
5
|
|
|
|
|
6
|
+use App\Helper\Arr;
|
|
6
|
use App\Models\Base;
|
7
|
use App\Models\Base;
|
|
|
|
8
|
+use App\Utils\HttpUtils;
|
|
|
|
9
|
+use GuzzleHttp\Exception\GuzzleException;
|
|
|
|
10
|
+use Illuminate\Support\Facades\Cache;
|
|
|
|
11
|
+use Illuminate\Support\Facades\Http;
|
|
7
|
|
12
|
|
|
8
|
/**
|
13
|
/**
|
|
9
|
* Class InquiryRelateDomain
|
14
|
* Class InquiryRelateDomain
|
|
@@ -17,5 +22,39 @@ class InquiryRelateDomain extends Base |
|
@@ -17,5 +22,39 @@ class InquiryRelateDomain extends Base |
|
17
|
//设置关联表名
|
22
|
//设置关联表名
|
|
18
|
protected $table = 'gl_inquiry_relate_domain';
|
23
|
protected $table = 'gl_inquiry_relate_domain';
|
|
19
|
|
24
|
|
|
20
|
-
|
25
|
+ /**
|
|
|
|
26
|
+ * 获取关联域名
|
|
|
|
27
|
+ * @throws \Exception
|
|
|
|
28
|
+ * @author zbj
|
|
|
|
29
|
+ * @date 2025/4/12
|
|
|
|
30
|
+ */
|
|
|
|
31
|
+ public static function getRelateDomain($domain){
|
|
|
|
32
|
+ $list_cache_key = 'RelateDomainList';
|
|
|
|
33
|
+ $data = Cache::get($list_cache_key);
|
|
|
|
34
|
+ if(!$data){
|
|
|
|
35
|
+ $data = [];
|
|
|
|
36
|
+ $page = 1;
|
|
|
|
37
|
+ while (true) {
|
|
|
|
38
|
+ try {
|
|
|
|
39
|
+ $res = HttpUtils::get('https://www.cmer.site/api/globalso_site', ['pagesite' => 100, 'page' => $page]);
|
|
|
|
40
|
+ if($res) {
|
|
|
|
41
|
+ $res = Arr::s2a($res);
|
|
|
|
42
|
+ $arr = [];
|
|
|
|
43
|
+ foreach ($res['data']['data'] as $item){
|
|
|
|
44
|
+ $arr[$item['domain']] = $item['globalso_domain'];
|
|
|
|
45
|
+ }
|
|
|
|
46
|
+ $data = array_merge($data, $arr);
|
|
|
|
47
|
+ if ($res['data']['last_page'] == $page) {
|
|
|
|
48
|
+ break;
|
|
|
|
49
|
+ }
|
|
|
|
50
|
+ }
|
|
|
|
51
|
+ $page++;
|
|
|
|
52
|
+ } catch (\Exception | GuzzleException $e) {
|
|
|
|
53
|
+ throw new \Exception('关联域名接口错误' . $e->getMessage());
|
|
|
|
54
|
+ }
|
|
|
|
55
|
+ }
|
|
|
|
56
|
+ Cache::put($list_cache_key, $data, 3600);
|
|
|
|
57
|
+ }
|
|
|
|
58
|
+ return $data[$domain]??'';
|
|
|
|
59
|
+ }
|
|
21
|
} |
60
|
} |