1.配置新版支付模块-菜单和接口都已重构
2.优化充值提现页面 3.菜单翻译问题 4.备份数据库
This commit is contained in:
@@ -10,9 +10,9 @@ use support\think\Db;
|
||||
/**
|
||||
* 充值支付渠道:优先读取 game_config.finance_cashier.channels;无此键时回退 game_config.deposit_channel(迁移期镜像)
|
||||
*
|
||||
* 每项:code(须在代码/环境注册表内)、sort、status(0/1)。
|
||||
* 每项:code(须在代码/环境注册表内)、sort、status(0/1)。**代码注册表当前仅内置 `ddpay`**(DDPay 网关)。
|
||||
*
|
||||
* 渠道展示名以代码注册表为准;运营只配置开关与排序,默认兼容全部充值档位。
|
||||
* 渠道展示名以代码注册表为准;运营只配置开关、排序与支持币种,默认兼容全部充值档位。
|
||||
*/
|
||||
final class DepositChannel
|
||||
{
|
||||
@@ -23,8 +23,9 @@ final class DepositChannel
|
||||
*/
|
||||
public static function codeRegistry(): array
|
||||
{
|
||||
// 仅保留 DDPay:充值/回调只走网关文档约定,不再提供模拟或其它渠道码
|
||||
$base = [
|
||||
'directpay' => ['name' => 'DirectPay', 'name_en' => 'DirectPay', 'sort' => 10],
|
||||
'ddpay' => ['name' => 'DDPay', 'name_en' => 'DDPay', 'sort' => 10],
|
||||
];
|
||||
$extra = self::registryFromEnv();
|
||||
foreach ($extra as $code => $meta) {
|
||||
@@ -150,17 +151,55 @@ final class DepositChannel
|
||||
$sort = isset($row['sort']) && is_numeric($row['sort']) ? intval($row['sort']) : 0;
|
||||
$status = isset($row['status']) && is_numeric($row['status']) ? intval($row['status']) : 1;
|
||||
$status = $status === 1 ? 1 : 0;
|
||||
$currencyCodes = null;
|
||||
if (array_key_exists('currency_codes', $row)) {
|
||||
if (is_array($row['currency_codes'])) {
|
||||
$currencyCodes = self::normalizeCurrencyCodes($row['currency_codes']);
|
||||
} else {
|
||||
$currencyCodes = null;
|
||||
}
|
||||
}
|
||||
$out[] = [
|
||||
'code' => $code,
|
||||
'sort' => $sort,
|
||||
'status' => $status,
|
||||
'tier_ids' => [],
|
||||
// null 表示“兼容全部充值币种”(历史配置默认行为)
|
||||
// 空数组 [] 表示“不支持任何充值币种”(运营可用作显式禁用某币种)
|
||||
'currency_codes' => $currencyCodes,
|
||||
];
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化为小写/去空并返回大写币种码列表(允许为空数组)。
|
||||
*
|
||||
* @param mixed $raw
|
||||
* @return list<string>
|
||||
*/
|
||||
private static function normalizeCurrencyCodes(mixed $raw): array
|
||||
{
|
||||
if (!is_array($raw)) {
|
||||
return [];
|
||||
}
|
||||
$out = [];
|
||||
foreach ($raw as $c) {
|
||||
if (!is_string($c) && !is_numeric($c)) {
|
||||
continue;
|
||||
}
|
||||
$s = is_string($c) ? trim($c) : strval($c);
|
||||
$s = strtoupper($s);
|
||||
if (!preg_match('/^[A-Z0-9]{2,12}$/', $s)) {
|
||||
continue;
|
||||
}
|
||||
$out[] = $s;
|
||||
}
|
||||
$out = array_values(array_unique($out));
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并注册表与运营覆盖;若库中无覆盖则对注册表内全部渠道启用默认行
|
||||
*
|
||||
@@ -187,6 +226,7 @@ final class DepositChannel
|
||||
'sort' => $sortVal,
|
||||
'status' => 1,
|
||||
'tier_ids' => [],
|
||||
'currency_codes' => null, // 默认兼容全部币种(历史行为)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -235,7 +275,7 @@ final class DepositChannel
|
||||
*
|
||||
* @return list<array{code: string, name: string, sort: int}>
|
||||
*/
|
||||
public static function channelsForTier(string $tierId, array $overrideRows, string $lang): array
|
||||
public static function channelsForTier(string $tierId, array $overrideRows, string $lang, string $fiatCurrencyCode = ''): array
|
||||
{
|
||||
$registry = self::codeRegistry();
|
||||
$out = [];
|
||||
@@ -247,6 +287,9 @@ final class DepositChannel
|
||||
if (!isset($registry[$code])) {
|
||||
continue;
|
||||
}
|
||||
if ($fiatCurrencyCode !== '' && !self::isCurrencyAllowedForRow($row, $fiatCurrencyCode)) {
|
||||
continue;
|
||||
}
|
||||
$meta = $registry[$code];
|
||||
$name = self::pickLangName($meta, $lang);
|
||||
$sortRaw = $row['sort'] ?? 0;
|
||||
@@ -268,6 +311,27 @@ final class DepositChannel
|
||||
return $out;
|
||||
}
|
||||
|
||||
private static function isCurrencyAllowedForRow(array $row, string $fiatCurrencyCode): bool
|
||||
{
|
||||
$normCurrency = strtoupper(trim($fiatCurrencyCode));
|
||||
if ($normCurrency === '') {
|
||||
return true;
|
||||
}
|
||||
$cc = $row['currency_codes'] ?? null;
|
||||
if ($cc === null) {
|
||||
// 历史/默认配置:不填则表示兼容全部币种
|
||||
return true;
|
||||
}
|
||||
if (!is_array($cc)) {
|
||||
return true;
|
||||
}
|
||||
// 显式空数组:不支持任何币种
|
||||
if ($cc === []) {
|
||||
return false;
|
||||
}
|
||||
return in_array($normCurrency, $cc, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $meta
|
||||
*/
|
||||
@@ -300,6 +364,22 @@ final class DepositChannel
|
||||
return self::isTierAllowed($row, $tierId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array{code: string, sort: int, status: int, tier_ids: list<string>, currency_codes: (list<string>|null)}> $effectiveRows
|
||||
*/
|
||||
public static function assertChannelAllowsCurrency(string $channelCode, string $fiatCurrencyCode, array $effectiveRows): bool
|
||||
{
|
||||
$row = self::findMergedByCode($effectiveRows, $channelCode);
|
||||
if ($row === null) {
|
||||
return false;
|
||||
}
|
||||
if (($row['status'] ?? 0) !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::isCurrencyAllowedForRow($row, $fiatCurrencyCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{code: string, sort: int, status: int, tier_ids: list<string>}> $effectiveRows
|
||||
*
|
||||
@@ -399,6 +479,7 @@ final class DepositChannel
|
||||
'sort' => $sortDefault,
|
||||
'status' => 1,
|
||||
'tier_ids' => [],
|
||||
'currency_codes' => null,
|
||||
];
|
||||
}
|
||||
usort($items, static function (array $a, array $b): int {
|
||||
|
||||
Reference in New Issue
Block a user