1.配置新版支付模块-菜单和接口都已重构

2.优化充值提现页面
3.菜单翻译问题
4.备份数据库
This commit is contained in:
2026-04-30 11:37:46 +08:00
parent e8c2b9d345
commit c7fc754573
23 changed files with 4042 additions and 400 deletions

View File

@@ -6,6 +6,7 @@ namespace app\admin\controller\config;
use app\common\controller\Backend;
use app\common\library\game\DepositChannel as DepositChannelLib;
use app\common\library\game\DepositTier as DepositTierLib;
use app\common\library\game\FinanceCashierConfig as FinanceCashierConfigLib;
use app\common\service\GameHotDataCoordinator;
use app\common\service\GameHotDataLock;
@@ -22,7 +23,7 @@ class FinanceCashierConfig extends Backend
{
protected bool $modelValidate = false;
protected array $noNeedPermission = ['index', 'save'];
protected array $noNeedPermission = ['index', 'save', 'tierList', 'tierSave'];
private function hasNodePermission(WebmanRequest $request, string $action): bool
{
@@ -109,6 +110,21 @@ class FinanceCashierConfig extends Backend
if (!is_array($payload)) {
return $this->error(__('Parameter %s can not be empty', ['']));
}
$pruneTierCurrencies = [];
if (isset($payload['prune_tier_currency_codes']) && is_array($payload['prune_tier_currency_codes'])) {
foreach ($payload['prune_tier_currency_codes'] as $c) {
if (!is_string($c)) {
continue;
}
$s = strtoupper(trim($c));
if ($s !== '') {
$pruneTierCurrencies[] = $s;
}
}
$pruneTierCurrencies = array_values(array_unique($pruneTierCurrencies));
}
unset($payload['prune_tier_currency_codes']);
try {
$json = FinanceCashierConfigLib::encodeForDb($payload);
} catch (InvalidArgumentException $e) {
@@ -162,11 +178,17 @@ class FinanceCashierConfig extends Backend
'update_time' => $now,
]);
}
if ($pruneTierCurrencies !== []) {
$this->pruneDepositTiersByCurrencies($pruneTierCurrencies, $now);
}
} catch (Throwable $e) {
return $this->error($e->getMessage());
}
GameHotDataCoordinator::afterGameConfigKeyCommitted(FinanceCashierConfigLib::CONFIG_KEY);
GameHotDataCoordinator::afterGameConfigKeyCommitted(DepositChannelLib::CONFIG_KEY);
if ($pruneTierCurrencies !== []) {
GameHotDataCoordinator::afterGameConfigKeyCommitted(DepositTierLib::CONFIG_KEY);
}
return $this->success(__('Saved successfully'));
} finally {
@@ -174,6 +196,83 @@ class FinanceCashierConfig extends Backend
}
}
public function tierList(WebmanRequest $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
if (!$this->hasNodePermission($request, 'tierList')) {
return $this->error(__('You have no permission'), [], 401);
}
if ($request->method() !== 'GET') {
return $this->error(__('Parameter error'));
}
$list = $this->loadDepositTierItems();
return $this->success('', ['list' => $list]);
}
public function tierSave(WebmanRequest $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
if (!$this->hasNodePermission($request, 'tierSave')) {
return $this->error(__('You have no permission'), [], 401);
}
if ($request->method() !== 'POST') {
return $this->error(__('Parameter error'));
}
$payload = $request->post();
if (!is_array($payload)) {
return $this->error(__('Parameter error'));
}
$items = $payload['items'] ?? null;
if (!is_array($items)) {
return $this->error(__('Items must be an array'));
}
try {
$clean = DepositTierLib::prepareItemsForSave(array_values($items));
$json = DepositTierLib::encodeForDb($clean);
} catch (InvalidArgumentException $e) {
return $this->error($e->getMessage());
}
$now = time();
$resourceKey = GameHotDataLock::safeResourceKeyForConfig(DepositTierLib::CONFIG_KEY);
$lock = GameHotDataLock::tryAcquire(GameHotDataLock::TYPE_GAME_CONFIG, $resourceKey);
if (!$lock['acquired']) {
return $this->error(__('This config is locked by another operation, please try again later'));
}
try {
$exists = Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->find();
if ($exists) {
Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->update([
'config_value' => $json,
'value_type' => 'json',
'update_time' => $now,
]);
} else {
Db::name('game_config')->insert([
'config_key' => DepositTierLib::CONFIG_KEY,
'config_value' => $json,
'value_type' => 'json',
'remark' => '充值档位 JSON 数组financeCashierConfig 统一维护)',
'create_time' => $now,
'update_time' => $now,
]);
}
GameHotDataCoordinator::afterGameConfigKeyCommitted(DepositTierLib::CONFIG_KEY);
return $this->success(__('Saved successfully'));
} catch (Throwable $e) {
return $this->error($e->getMessage());
} finally {
GameHotDataLock::release(GameHotDataLock::TYPE_GAME_CONFIG, $resourceKey, $lock['token'], $lock['redis_lock']);
}
}
/**
* @return array<string, array{name: string, name_en: string, sort: int}>
*/
@@ -194,4 +293,54 @@ class FinanceCashierConfig extends Backend
return $registryOut;
}
/**
* @return list<array<string, mixed>>
*/
private function loadDepositTierItems(): array
{
$row = Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->find();
return DepositTierLib::parseFromConfigValue(is_array($row) ? ($row['config_value'] ?? null) : null);
}
/**
* @param list<string> $currencyCodes
*/
private function pruneDepositTiersByCurrencies(array $currencyCodes, int $now): void
{
if ($currencyCodes === []) {
return;
}
$exists = Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->find();
$items = $this->loadDepositTierItems();
$filtered = [];
foreach ($items as $row) {
if (!is_array($row)) {
continue;
}
$currency = isset($row['currency']) && is_string($row['currency']) ? strtoupper(trim($row['currency'])) : '';
if ($currency !== '' && in_array($currency, $currencyCodes, true)) {
continue;
}
$filtered[] = $row;
}
$json = DepositTierLib::encodeForDb(DepositTierLib::prepareItemsForSave(array_values($filtered)));
if ($exists) {
Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->update([
'config_value' => $json,
'value_type' => 'json',
'update_time' => $now,
]);
} else {
Db::name('game_config')->insert([
'config_key' => DepositTierLib::CONFIG_KEY,
'config_value' => $json,
'value_type' => 'json',
'remark' => '充值档位 JSON 数组financeCashierConfig 统一维护)',
'create_time' => $now,
'update_time' => $now,
]);
}
}
}