From 2b0d36971a1b7aa8c504a62d4b83bc2e6e8512c3 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 26 Mar 2026 12:07:32 +0800 Subject: [PATCH] update --- .../Controllers/Mobile/OtherController.php | 14 +++++++ app/Models/CompanyDetailCache.php | 13 ++++++ ...000_create_company_detail_caches_table.php | 41 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 app/Models/CompanyDetailCache.php create mode 100644 database/migrations/2026_03_26_120000_create_company_detail_caches_table.php diff --git a/app/Http/Controllers/Mobile/OtherController.php b/app/Http/Controllers/Mobile/OtherController.php index 825bab7..826a66b 100755 --- a/app/Http/Controllers/Mobile/OtherController.php +++ b/app/Http/Controllers/Mobile/OtherController.php @@ -10,6 +10,7 @@ use App\Models\AppointmentConfig; use App\Models\AppointmentType; use App\Models\Banner; use App\Models\Company; +use App\Models\CompanyDetailCache; use App\Models\Config; use App\Models\CourseType; use App\Repositories\YuanheRepository; @@ -137,6 +138,19 @@ class OtherController extends CommonController if (empty($result)) { return $this->fail([ResponseCode::ERROR_PARAMETER, '无数据']); } + $normalizedCompanyName = Company::normalizeCompanyName($all['company_name']); + CompanyDetailCache::updateOrCreate( + ['normalized_company_name' => $normalizedCompanyName], + [ + 'query_company_name' => trim($all['company_name']), + 'enterprise_name' => $result['enterpriseName'] ?? null, + 'normalized_enterprise_name' => Company::normalizeCompanyName($result['enterpriseName'] ?? null), + 'credit_code' => $result['creditCode'] ?? null, + 'enterprise_id' => $result['enterpriseId'] ?? null, + 'payload' => $result, + 'fetched_at' => now(), + ] + ); return $this->success($result); } diff --git a/app/Models/CompanyDetailCache.php b/app/Models/CompanyDetailCache.php new file mode 100644 index 0000000..0876d5a --- /dev/null +++ b/app/Models/CompanyDetailCache.php @@ -0,0 +1,13 @@ + 'array', + 'fetched_at' => 'datetime', + 'last_matched_at' => 'datetime', + ]; +} diff --git a/database/migrations/2026_03_26_120000_create_company_detail_caches_table.php b/database/migrations/2026_03_26_120000_create_company_detail_caches_table.php new file mode 100644 index 0000000..68c4299 --- /dev/null +++ b/database/migrations/2026_03_26_120000_create_company_detail_caches_table.php @@ -0,0 +1,41 @@ +id(); + $table->string('query_company_name')->comment('前端查询公司名称'); + $table->string('normalized_company_name')->unique()->comment('标准化查询公司名称'); + $table->string('enterprise_name')->nullable()->comment('第三方返回企业名称'); + $table->string('normalized_enterprise_name')->nullable()->index()->comment('标准化企业名称'); + $table->string('credit_code')->nullable()->index()->comment('统一社会信用代码'); + $table->string('enterprise_id')->nullable()->index()->comment('企业ID'); + $table->json('payload')->comment('第三方公司详情暂存数据'); + $table->dateTime('fetched_at')->nullable()->comment('抓取时间'); + $table->dateTime('last_matched_at')->nullable()->comment('最近匹配使用时间'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('company_detail_caches'); + } +};