作者 赵彬吉

update

... ... @@ -55,7 +55,7 @@ class SyncSubmitTask extends Command
$project = Project::getProjectByDomain($task_info['data']['domain'] ?? '');
if(!$project){
//是否有关联的域名
$relate_domain = InquiryRelateDomain::where('from_domain', $task_info['data']['domain'] ?? '')->value('to_domain');
$relate_domain = InquiryRelateDomain::getRelateDomain($task_info['data']['domain'] ?? '');
if(!$relate_domain){
throw new \Exception('项目不存在1');
}
... ...
... ... @@ -3,7 +3,12 @@
namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Models\Base;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
/**
* Class InquiryRelateDomain
... ... @@ -17,5 +22,39 @@ class InquiryRelateDomain extends Base
//设置关联表名
protected $table = 'gl_inquiry_relate_domain';
/**
* 获取关联域名
* @throws \Exception
* @author zbj
* @date 2025/4/12
*/
public static function getRelateDomain($domain){
$list_cache_key = 'RelateDomainList';
$data = Cache::get($list_cache_key);
if(!$data){
$data = [];
$page = 1;
while (true) {
try {
$res = HttpUtils::get('https://www.cmer.site/api/globalso_site', ['pagesite' => 100, 'page' => $page]);
if($res) {
$res = Arr::s2a($res);
$arr = [];
foreach ($res['data']['data'] as $item){
$arr[$item['domain']] = $item['globalso_domain'];
}
$data = array_merge($data, $arr);
if ($res['data']['last_page'] == $page) {
break;
}
}
$page++;
} catch (\Exception | GuzzleException $e) {
throw new \Exception('关联域名接口错误' . $e->getMessage());
}
}
Cache::put($list_cache_key, $data, 3600);
}
return $data[$domain]??'';
}
}
... ...