Files
MBTI_wang/api/app/common/SystemDefaultEnterprise.php
Ghost ef19f6860e feat: CRM 报告与双端结果页、管理端用户/设置与默认企业配置
1、修复了用户详情与人脸/DISC 展示、手机号与资料校验、相机页与测试选择等体验问题。

2、新增了 SystemDefaultEnterprise、discDisplay、管理端设置扩展接口;CrmReport/Test/Analyze 等 API 与路由能力补强。

3、优化了 resultFormat、descriptions、payment、企业上下文;海报与 PDP/DISC 文案;超管 Commerce/Users 与 admin Settings/Users。

Made-with: Cursor
2026-04-01 17:16:20 +08:00

41 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\common;
use app\model\Enterprise as EnterpriseModel;
use think\facade\Db;
/**
* 超管「系统基础配置」中的小程序默认企业,与 AppConfig 语义一致。
*/
class SystemDefaultEnterprise
{
/**
* 有效则返回企业 ID否则 null企业不存在或已软删时亦为 null
*/
public static function getId(): ?int
{
try {
$row = Db::name('system_config')->where('key', 'system')->where('enterprise_id', 0)->find();
if (!$row || empty($row['value'])) {
return null;
}
$raw = $row['value'];
$arr = is_string($raw) ? json_decode($raw, true) : $raw;
if (!is_array($arr) || !isset($arr['defaultEnterpriseId']) || $arr['defaultEnterpriseId'] === '' || $arr['defaultEnterpriseId'] === null) {
return null;
}
$de = (int) $arr['defaultEnterpriseId'];
if ($de <= 0) {
return null;
}
if (!EnterpriseModel::where('id', $de)->find()) {
return null;
}
return $de;
} catch (\Throwable $e) {
return null;
}
}
}