1.新增获取充值/提现配置接口/api/finance/depositWithdrawConfig

2.优化充值和提现方式
This commit is contained in:
2026-04-23 10:15:01 +08:00
parent 0f28c0fd2a
commit aa1299c018
55 changed files with 901 additions and 750 deletions

View File

@@ -10,9 +10,9 @@ use support\think\Db;
/**
* 充值支付渠道:优先读取 game_config.finance_cashier.channels无此键时回退 game_config.deposit_channel迁移期镜像
*
* 每项code须在代码/环境注册表内、sort、status(0/1)、tier_ids空=全部启用档位)
* 每项code须在代码/环境注册表内、sort、status(0/1)
*
* 渠道展示名以代码注册表为准;运营只配置开关排序、可用档位。
* 渠道展示名以代码注册表为准;运营只配置开关排序,默认兼容全部充值档位。
*/
final class DepositChannel
{
@@ -150,23 +150,11 @@ 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;
$tierIds = [];
if (isset($row['tier_ids']) && is_array($row['tier_ids'])) {
foreach ($row['tier_ids'] as $tid) {
if (is_string($tid)) {
$t = trim($tid);
if ($t !== '' && preg_match('/^[a-zA-Z0-9_\-]{1,32}$/', $t)) {
$tierIds[] = $t;
}
}
}
$tierIds = array_values(array_unique($tierIds));
}
$out[] = [
'code' => $code,
'sort' => $sort,
'status' => $status,
'tier_ids' => $tierIds,
'tier_ids' => [],
];
}
@@ -219,17 +207,8 @@ final class DepositChannel
*/
public static function isTierAllowed(array $overrideRow, string $tierId): bool
{
$ids = $overrideRow['tier_ids'] ?? [];
if (!is_array($ids) || $ids === []) {
return true;
}
foreach ($ids as $id) {
if (is_string($id) && $id === $tierId) {
return true;
}
}
return false;
// 渠道不再配置档位白名单:默认兼容全部充值档位。
return true;
}
/**
@@ -268,9 +247,6 @@ final class DepositChannel
if (!isset($registry[$code])) {
continue;
}
if (!self::isTierAllowed($row, $tierId)) {
continue;
}
$meta = $registry[$code];
$name = self::pickLangName($meta, $lang);
$sortRaw = $row['sort'] ?? 0;

View File

@@ -14,9 +14,9 @@ use InvalidArgumentException;
* - title : string档位中文名称必填前端中文环境展示
* - title_en : string档位英文名称可选前端英文环境展示为空时回退到 title
* - currency : string支付货币代码38 位大写字母,如 MYR、CNY
* - pay_amount : string玩家支付的法币/支付货币额度(4 位小数)
* - amount : string到账基础平台币4 位小数)
* - bonus_amount : string赠送平台币4 位小数,可为 0
* - pay_amount : string玩家支付的法币/支付货币额度(2 位小数)
* - amount : string到账基础平台币2 位小数)
* - bonus_amount : string赠送平台币2 位小数,可为 0
* - desc : string档位中文描述可空<=255
* - desc_en : string档位英文描述可空<=255为空时回退到 desc
* - sort : int排序权重小值在前
@@ -95,7 +95,7 @@ final class DepositTier
$payAmount = self::normalizeAmount($row['pay_amount'] ?? '');
$amount = self::normalizeAmount($row['amount'] ?? '');
$bonus = self::normalizeAmount($row['bonus_amount'] ?? '0');
if (bccomp($payAmount, '0', 4) <= 0 && bccomp($amount, '0', 4) > 0) {
if (bccomp($payAmount, '0', 2) <= 0 && bccomp($amount, '0', 2) > 0) {
// 历史数据仅有 amount平台币用占位同步 pay_amount运营应在后台改为真实支付额度
$payAmount = $amount;
}
@@ -187,17 +187,17 @@ final class DepositTier
}
$payAmount = self::normalizeAmount($row['pay_amount'] ?? '');
if (bccomp($payAmount, '0', 4) <= 0) {
if (bccomp($payAmount, '0', 2) <= 0) {
throw new InvalidArgumentException('第 ' . $no . ' 行支付货币额度必须大于 0');
}
$amount = self::normalizeAmount($row['amount'] ?? '');
if (bccomp($amount, '0', 4) <= 0) {
if (bccomp($amount, '0', 2) <= 0) {
throw new InvalidArgumentException('第 ' . $no . ' 行基础平台币到账必须大于 0');
}
$bonus = self::normalizeAmount($row['bonus_amount'] ?? '0');
if (bccomp($bonus, '0', 4) < 0) {
if (bccomp($bonus, '0', 2) < 0) {
throw new InvalidArgumentException('第 ' . $no . ' 行赠送金额不能为负数');
}
@@ -333,25 +333,25 @@ final class DepositTier
}
/**
* 将金额归一化为 4 位小数字符串;非法输入返回 '0.0000'
* 将金额归一化为 2 位小数字符串;非法输入返回 '0.00'
*/
public static function normalizeAmount($raw): string
{
if ($raw === null || $raw === '') {
return '0.0000';
return '0.00';
}
if (is_string($raw)) {
$s = trim($raw);
} elseif (is_int($raw) || is_float($raw)) {
$s = strval($raw);
} else {
return '0.0000';
return '0.00';
}
$s = str_replace(',', '.', $s);
if (!is_numeric($s)) {
return '0.0000';
return '0.00';
}
return bcadd($s, '0', 4);
return bcadd($s, '0', 2);
}
/**

View File

@@ -353,10 +353,10 @@ final class FinanceCashierConfig
$seenCodes[$code] = true;
$dep = $row['deposit_coins_per_fiat'] ?? '';
$wdr = $row['withdraw_coins_per_fiat'] ?? '';
if (!is_string($dep) || $dep === '' || !is_numeric($dep) || bccomp($dep, '0', 8) <= 0) {
if (!is_string($dep) || $dep === '' || !is_numeric($dep) || bccomp($dep, '0', 2) <= 0) {
throw new InvalidArgumentException('第 ' . ($idx + 1) . ' 行:充值汇率须为大于 0 的数字');
}
if (!is_string($wdr) || $wdr === '' || !is_numeric($wdr) || bccomp($wdr, '0', 8) <= 0) {
if (!is_string($wdr) || $wdr === '' || !is_numeric($wdr) || bccomp($wdr, '0', 2) <= 0) {
throw new InvalidArgumentException('第 ' . ($idx + 1) . ' 行:提现汇率须为大于 0 的数字');
}
}
@@ -379,7 +379,7 @@ final class FinanceCashierConfig
if (isset($p['withdraw_limits']) && is_array($p['withdraw_limits'])) {
foreach (['min_ewallet', 'min_bank'] as $k) {
$v = $p['withdraw_limits'][$k] ?? '0';
if (!is_string($v) || !is_numeric($v) || bccomp($v, '0', 4) < 0) {
if (!is_string($v) || !is_numeric($v) || bccomp($v, '0', 2) < 0) {
throw new InvalidArgumentException('提现最低限额须为不小于 0 的数字');
}
}

View File

@@ -147,7 +147,7 @@ final class StreakWinReward
}
/**
* 返回该注单适用的「赔率乘数」字符串(= 配置档位的 odds_factor供 bcmul(total_amount, ..., 4)。
* 返回该注单适用的「赔率乘数」字符串(= 配置档位的 odds_factor供 bcmul(total_amount, ..., 2)。
*/
public static function totalOddsMultiplierForStreakAtBet(int $streakAtBet): string
{
@@ -156,7 +156,7 @@ final class StreakWinReward
$factor = 1;
}
return bcadd((string) $factor, '0', 4);
return bcadd((string) $factor, '0', 2);
}
/**