|
|
|
@ -133,12 +133,24 @@ class OtherController extends CommonController
|
|
|
|
if ($validator->fails()) {
|
|
|
|
if ($validator->fails()) {
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$normalizedCompanyName = Company::normalizeCompanyName($all['company_name']);
|
|
|
|
|
|
|
|
$cache = CompanyDetailCache::query()
|
|
|
|
|
|
|
|
->where('normalized_company_name', $normalizedCompanyName)
|
|
|
|
|
|
|
|
->orWhere('normalized_enterprise_name', $normalizedCompanyName)
|
|
|
|
|
|
|
|
->orderByDesc('fetched_at')
|
|
|
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($cache && !empty($cache->payload)) {
|
|
|
|
|
|
|
|
$cache->last_matched_at = now();
|
|
|
|
|
|
|
|
$cache->save();
|
|
|
|
|
|
|
|
return $this->success($cache->payload);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$YuanheRepository = new YuanheRepository();
|
|
|
|
$YuanheRepository = new YuanheRepository();
|
|
|
|
$result = $YuanheRepository->companyInfo(['enterpriseName' => $all['company_name']]);
|
|
|
|
$result = $YuanheRepository->companyInfo(['enterpriseName' => $all['company_name']]);
|
|
|
|
if (empty($result)) {
|
|
|
|
if (empty($result)) {
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, '无数据']);
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, '无数据']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$normalizedCompanyName = Company::normalizeCompanyName($all['company_name']);
|
|
|
|
|
|
|
|
CompanyDetailCache::updateOrCreate(
|
|
|
|
CompanyDetailCache::updateOrCreate(
|
|
|
|
['normalized_company_name' => $normalizedCompanyName],
|
|
|
|
['normalized_company_name' => $normalizedCompanyName],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
|