From d7c8736a737bff77b4527cb9217c4c7878f58623 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Fri, 26 Sep 2025 12:01:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E4=BC=98=E5=8C=96=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/UpdateCompany.php | 4 ++-- app/Http/functions.php | 28 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/UpdateCompany.php b/app/Console/Commands/UpdateCompany.php index f852fa5..90e00b3 100755 --- a/app/Console/Commands/UpdateCompany.php +++ b/app/Console/Commands/UpdateCompany.php @@ -87,7 +87,7 @@ class UpdateCompany extends Command 'logo' => $result['logo'], 'company_legal_representative' => $result['operName'], 'company_province' => $result['province'], - 'company_industry' => $result['qccIndustry'], + 'company_industry' => combineKeyValue($result['qccIndustry']), 'regist_amount' => $result['registAmount'], 'regist_capi_type' => $result['registCapiType'], 'company_date' => $result['startDate'], @@ -96,7 +96,7 @@ class UpdateCompany extends Command 'currency_type' => $result['currencyType'], 'stock_number' => $result['stockNumber'], 'stock_type' => $result['stockType'], - 'company_tag' => implode(',', $result['companyTag']), + 'company_tag' => implode(',', $result['tagList']), ]; $company = Company::updateOrCreate($where, $data); // 更新用户关联 diff --git a/app/Http/functions.php b/app/Http/functions.php index c57acd3..44676e3 100755 --- a/app/Http/functions.php +++ b/app/Http/functions.php @@ -718,3 +718,31 @@ function getDates($start, $end) } return $temp; // 返回data型数据 } + +/** + * 将JSON字符串或数组的键值对组合成"键:值,键:值"格式的字符串 + * + * @param string|array $data 可以是JSON字符串或关联数组 + * @return string 组合后的字符串 + */ +function combineKeyValue($data) +{ + // 如果输入是JSON字符串,则解析为数组 + if (is_string($data)) { + $data = json_decode($data, true); + } + + // 验证是否为数组 + if (!is_array($data)) { + return ''; + } + + // 拼接键值对 + $parts = []; + foreach ($data as $key => $value) { + $parts[] = "{$key}:{$value}"; + } + + // 用逗号连接 + return implode(',', $parts); +}