From bc51ed636d2dd4d28f5393aaf945d53dc1581942 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Tue, 11 Nov 2025 14:51:54 +0800 Subject: [PATCH] update --- app/Console/Commands/UpdateCompany.php | 19 ++++++--- ...025_11_11_140323_alert_companies_table.php | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2025_11_11_140323_alert_companies_table.php diff --git a/app/Console/Commands/UpdateCompany.php b/app/Console/Commands/UpdateCompany.php index fcdc305..3ebabfa 100755 --- a/app/Console/Commands/UpdateCompany.php +++ b/app/Console/Commands/UpdateCompany.php @@ -16,14 +16,14 @@ class UpdateCompany extends Command * * @var string */ - protected $signature = 'update_company {--user_id=}'; + protected $signature = 'update_company {--user_id=} {--address=0}'; /** * The console command description. * * @var string */ - protected $description = '批量公司信息'; + protected $description = '批量更新公司信息'; /** * Create a new command instance. @@ -43,10 +43,13 @@ class UpdateCompany extends Command public function handle() { $user_id = $this->option('user_id'); + $updateLocal = (int) $this->option('address'); // 更新公司信息 $this->compnay($user_id); - // 更新经纬度信息 - $this->local($user_id); + // 更新经纬度信息(可选) + if ($updateLocal) { + $this->local($user_id); + } return $this->info('全部更新完成'); } @@ -60,7 +63,7 @@ class UpdateCompany extends Command $users = User::where('id', $user_id)->get(); } else { // 批量更新 - $users = User::whereDoesntHave('company')->whereNotNull('company_name')->get(); + $users = User::whereNotNull('company_name')->get(); } $YuanheRepository = new YuanheRepository(); foreach ($users as $user) { @@ -102,6 +105,12 @@ class UpdateCompany extends Command 'stock_number' => $result['stockNumber'], 'stock_type' => $result['stockType'], 'company_tag' => implode(',', $result['tagList']), + // 更新日期 + 'update_date' => $result['updatedDate'], + // 管理平台 + 'group_name' => ($result['projectUsers'][0]['groupName'] ?? null), + // 项目经理 + 'user_name' => ($result['projectUsers'][0]['userName'] ?? null), ]; $company = Company::updateOrCreate($where, $data); // 更新用户关联 diff --git a/database/migrations/2025_11_11_140323_alert_companies_table.php b/database/migrations/2025_11_11_140323_alert_companies_table.php new file mode 100644 index 0000000..591ead3 --- /dev/null +++ b/database/migrations/2025_11_11_140323_alert_companies_table.php @@ -0,0 +1,40 @@ +dateTime('update_date')->useCurrent()->comment('更新日期'); + // 管理平台 + $table->string('group_name')->nullable()->comment('管理平台'); + // 项目经理 + $table->string('user_name')->nullable()->comment('项目经理'); + + + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('companies', function (Blueprint $table) { + // + }); + } +};