1.新增充值档位配置
2.新增充值/提现配置
This commit is contained in:
@@ -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,支付货币代码(3~8 位大写字母,如 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) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付货币代码:3~8 位字母,统一大写
|
||||
*
|
||||
* @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)));
|
||||
|
||||
Reference in New Issue
Block a user