toArray() : (array) $enterprise; $passageway = (string) ($e['passageway'] ?? 'alipay'); !isset(EnterpriseModel::PASSAGEWAY_CODE[$passageway]) && $passageway = 'alipay'; $conf['enterprise_id'] = (int) ($e['enterprise_id'] ?? 0); $conf['enterprise_name'] = (string) ($e['company_name'] ?? ''); $conf['business_license'] = (string) ($e['business_license'] ?? ''); $conf['passageway'] = $passageway; $conf['passageway_code'] = EnterpriseModel::PASSAGEWAY_CODE[$passageway]; $conf['passageway_name'] = EnterpriseModel::PASSAGEWAY_NAME[$passageway]; $conf['institution_id'] = (string) ($e['institution_id'] ?? ''); // 平安银行通道要求实名 $conf['require_id_card'] = $passageway === 'pingan'; // 以下留空则回落接入方级默认值 foreach (['app_id', 'no_prefix', 'voucher_name'] as $k) { $v = trim((string) ($e[$k] ?? '')); $v !== '' && $conf[$k] = $v; } return $conf; } /** * 取单项,支持点号:QytConfig::item('h5_base_url') * @param mixed $default * @return mixed */ public static function item(string $path, $default = null) { $node = self::get(); foreach (explode('.', $path) as $seg) { if (!is_array($node) || !array_key_exists($seg, $node)) { return $default; } $node = $node[$seg]; } return $node; } /** 清掉进程内缓存(单元测试 / 后台保存后使用) */ public static function flush(): void { self::$cache = null; self::$cacheAt = 0; } /** * 读后台设置。直接查表而不用 Setting 模型,是因为常驻命令行进程里 * BaseModel::$storeId 不会被初始化(只有 store/api 模块才赋值), * 走模型会查不到数据。本项目为单商城部署,取 store_id 最小的一条即可。 */ protected static function dbValues(): array { try { $json = Db::name('store_setting') ->where('key', SettingEnum::QYT) ->order('store_id', 'asc') ->value('values'); if (empty($json)) { return []; } $arr = json_decode((string) $json, true); return is_array($arr) ? $arr : []; } catch (\Throwable $e) { // 表不存在 / 库连不上时静默回落到 .env,不能因为读设置失败就中断发放 return []; } } }