1.新增充值档位配置

2.新增充值/提现配置
This commit is contained in:
2026-04-21 18:31:43 +08:00
parent aad00e10f8
commit 0f28c0fd2a
29 changed files with 3647 additions and 278 deletions

View File

@@ -10,11 +10,13 @@ use InvalidArgumentException;
* 充值档位game_config.deposit_tier仅存 JSON 数组
*
* 每一项字段mock/第三方支付模式,已不再保存收款账户信息;支持中英文双语):
* - id : string档位稳定 ID(如 t_xxxxxxxx
* - id : string档位稳定唯一标识(如 t_xxxxxxxx,移动端下单 tier_id / tier_key
* - title : string档位中文名称必填前端中文环境展示
* - title_en : string档位英文名称可选前端英文环境展示为空时回退到 title
* - amount : string充值金额4 位小数
* - bonus_amount : string赠送金额4 位小数,可为 0
* - currency : string支付货币代码38 位大写字母,如 MYR、CNY
* - pay_amount : string玩家支付的法币/支付货币额度4 位小数)
* - amount : string到账基础平台币4 位小数)
* - bonus_amount : string赠送平台币4 位小数,可为 0
* - desc : string档位中文描述可空<=255
* - desc_en : string档位英文描述可空<=255为空时回退到 desc
* - sort : int排序权重小值在前
@@ -33,6 +35,8 @@ final class DepositTier
* id: string,
* title: string,
* title_en: string,
* currency: string,
* pay_amount: string,
* amount: string,
* bonus_amount: string,
* desc: string,
@@ -83,8 +87,18 @@ final class DepositTier
}
$titleEn = self::stringField($row, 'title_en');
$currency = self::normalizeCurrency($row['currency'] ?? '');
if ($currency === '') {
$currency = 'CNY';
}
$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) {
// 历史数据仅有 amount平台币用占位同步 pay_amount运营应在后台改为真实支付额度
$payAmount = $amount;
}
$desc = self::stringField($row, 'desc');
if ($desc === '') {
@@ -100,6 +114,8 @@ final class DepositTier
'id' => $id,
'title' => $title,
'title_en' => $titleEn,
'currency' => $currency,
'pay_amount' => $payAmount,
'amount' => $amount,
'bonus_amount' => $bonus,
'desc' => $desc,
@@ -165,9 +181,19 @@ final class DepositTier
throw new InvalidArgumentException('第 ' . $no . ' 行英文充值名称过长');
}
$currency = self::normalizeCurrency($row['currency'] ?? '');
if ($currency === '') {
throw new InvalidArgumentException('第 ' . $no . ' 行支付货币不能为空');
}
$payAmount = self::normalizeAmount($row['pay_amount'] ?? '');
if (bccomp($payAmount, '0', 4) <= 0) {
throw new InvalidArgumentException('第 ' . $no . ' 行支付货币额度必须大于 0');
}
$amount = self::normalizeAmount($row['amount'] ?? '');
if (bccomp($amount, '0', 4) <= 0) {
throw new InvalidArgumentException('第 ' . $no . ' 行充值金额必须大于 0');
throw new InvalidArgumentException('第 ' . $no . ' 行基础平台币到账必须大于 0');
}
$bonus = self::normalizeAmount($row['bonus_amount'] ?? '0');
@@ -193,6 +219,8 @@ final class DepositTier
'id' => $id,
'title' => $title,
'title_en' => $titleEn,
'currency' => $currency,
'pay_amount' => $payAmount,
'amount' => $amount,
'bonus_amount' => $bonus,
'desc' => $desc,
@@ -340,6 +368,26 @@ final class DepositTier
return is_string($v) ? trim($v) : '';
}
/**
* 支付货币代码38 位字母,统一大写
*
* @param mixed $raw
*/
private static function normalizeCurrency($raw): string
{
if (!is_string($raw)) {
return '';
}
$s = strtoupper(trim($raw));
if ($s === '') {
return '';
}
if (!preg_match('/^[A-Z]{3,8}$/', $s)) {
return '';
}
return $s;
}
private static function isEnglishLang(string $lang): bool
{
$normalized = strtolower(str_replace('_', '-', trim($lang)));