|
|
|
@ -193,10 +193,24 @@ class Company extends SoftDeletesModel
|
|
|
|
return ['success' => false, 'message' => '用户已有公司关联', 'company' => null];
|
|
|
|
return ['success' => false, 'message' => '用户已有公司关联', 'company' => null];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清理公司名称:去除首尾空格、换行符、制表符等异常字符
|
|
|
|
|
|
|
|
$cleanedCompanyName = trim($user->company_name);
|
|
|
|
|
|
|
|
// 去除换行符、回车符、制表符等空白字符
|
|
|
|
|
|
|
|
$cleanedCompanyName = preg_replace('/[\r\n\t]+/', '', $cleanedCompanyName);
|
|
|
|
|
|
|
|
// 将多个连续空格替换为单个空格
|
|
|
|
|
|
|
|
$cleanedCompanyName = preg_replace('/\s+/', ' ', $cleanedCompanyName);
|
|
|
|
|
|
|
|
// 再次去除首尾空格
|
|
|
|
|
|
|
|
$cleanedCompanyName = trim($cleanedCompanyName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果清理后为空,返回错误
|
|
|
|
|
|
|
|
if (empty($cleanedCompanyName)) {
|
|
|
|
|
|
|
|
return ['success' => false, 'message' => '公司名称无效', 'company' => null];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$YuanheRepository = new YuanheRepository();
|
|
|
|
$YuanheRepository = new YuanheRepository();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取公司详细信息
|
|
|
|
// 获取公司详细信息,使用清理后的公司名称
|
|
|
|
$result = $YuanheRepository->companyInfo(['enterpriseName' => $user->company_name]);
|
|
|
|
$result = $YuanheRepository->companyInfo(['enterpriseName' => $cleanedCompanyName]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$result) {
|
|
|
|
if (!$result) {
|
|
|
|
// 标识一下未匹配到公司,后续可以根据这个字段筛选出未匹配到公司的用户
|
|
|
|
// 标识一下未匹配到公司,后续可以根据这个字段筛选出未匹配到公司的用户
|
|
|
|
|