From de3b9ab6bf2215244c047050472bf6cd0e0ad415 Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Thu, 23 Apr 2026 17:44:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BF=BB=E8=AF=91BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Channel.php | 51 ++++++++++++++++++- app/admin/controller/auth/Rule.php | 27 +++++++++- app/admin/library/Auth.php | 33 +++++++++--- app/common/lang/en/admin_rule_title.php | 2 + .../service/ChannelSettlementService.php | 4 +- web/src/api/backend/auth/group.ts | 3 ++ 6 files changed, 109 insertions(+), 11 deletions(-) diff --git a/app/admin/controller/Channel.php b/app/admin/controller/Channel.php index a489da2..2fd711c 100644 --- a/app/admin/controller/Channel.php +++ b/app/admin/controller/Channel.php @@ -283,8 +283,54 @@ class Channel extends Backend ->order($order) ->paginate($limit); + $items = $res->items(); + $channelIds = []; + foreach ($items as $item) { + $cid = intval($item['id'] ?? 0); + if ($cid > 0) { + $channelIds[] = $cid; + } + } + $channelIds = array_values(array_unique($channelIds)); + if ($channelIds !== []) { + $userCountMap = Db::name('user') + ->where('channel_id', 'in', $channelIds) + ->group('channel_id') + ->column('COUNT(*) AS c', 'channel_id'); + $now = time(); + foreach ($channelIds as $channelId) { + $latestCount = intval($userCountMap[$channelId] ?? 0); + Db::name('channel') + ->where('id', intval($channelId)) + ->update([ + 'user_count' => $latestCount, + 'update_time' => $now, + ]); + } + $profitMap = Db::name('bet_order') + ->where('channel_id', 'in', $channelIds) + ->where('status', 2) + ->group('channel_id') + ->column('SUM(total_amount - win_amount - jackpot_extra_amount) AS p', 'channel_id'); + foreach ($items as $k => $item) { + $cid = intval($item['id'] ?? 0); + if ($cid <= 0) { + continue; + } + $items[$k]['user_count'] = intval($userCountMap[$cid] ?? 0); + $profit = strval($profitMap[$cid] ?? '0.00'); + $items[$k]['profit_amount'] = bcadd($profit, '0', 2); + if (!isset($items[$k]['total_profit_amount']) || $items[$k]['total_profit_amount'] === null || $items[$k]['total_profit_amount'] === '') { + $items[$k]['total_profit_amount'] = $items[$k]['profit_amount']; + } + if (!isset($items[$k]['commission_pool_amount']) || $items[$k]['commission_pool_amount'] === null || $items[$k]['commission_pool_amount'] === '') { + $items[$k]['commission_pool_amount'] = '0.00'; + } + } + } + return $this->success('', [ - 'list' => $res->items(), + 'list' => $items, 'total' => $res->total(), 'remark' => get_route_remark(), ]); @@ -636,7 +682,8 @@ class Channel extends Backend if (!$this->auth->isSuperAdmin()) { return $this->error(__('You have no permission')); } - $res = ChannelSettlementService::settleAllDueChannels(intval($this->auth->id)); + // 批量按钮语义:手动触发“待结算渠道”结算,不受结算周期到点限制。 + $res = ChannelSettlementService::settleAllDueChannels(intval($this->auth->id), false); return $this->success('批量结算完成', $res); } diff --git a/app/admin/controller/auth/Rule.php b/app/admin/controller/auth/Rule.php index f9e17b8..aafc2a0 100644 --- a/app/admin/controller/auth/Rule.php +++ b/app/admin/controller/auth/Rule.php @@ -251,10 +251,11 @@ class Rule extends Backend ->select() ->toArray(); + $toEnglish = !$this->shouldForceMenuTitleZh($request) && $this->shouldTranslateMenuToEnglish(); foreach ($rules as $idx => $rule) { $title = $rule['title'] ?? ''; if (is_string($title) && $title !== '') { - $rules[$idx]['title'] = $this->menuTitleToZh($title); + $rules[$idx]['title'] = $toEnglish ? $this->menuTitleToEn($title) : $this->menuTitleToZh($title); } } @@ -272,6 +273,30 @@ class Rule extends Backend return isset($zhMap[$title]) && is_string($zhMap[$title]) ? $zhMap[$title] : $title; } + private function menuTitleToEn(string $title): string + { + static $enMap = null; + if (!is_array($enMap)) { + $mapFile = app_path() . '/common/lang/en/admin_rule_title.php'; + $loaded = is_file($mapFile) ? include $mapFile : []; + $enMap = is_array($loaded) ? $loaded : []; + } + return isset($enMap[$title]) && is_string($enMap[$title]) ? $enMap[$title] : $title; + } + + private function shouldTranslateMenuToEnglish(): bool + { + $lang = function_exists('locale') ? locale() : ''; + $normalized = is_string($lang) ? strtolower(str_replace('_', '-', trim($lang))) : ''; + return str_starts_with($normalized, 'en'); + } + + private function shouldForceMenuTitleZh(Request $request): bool + { + $flag = $request->get('force_menu_zh') ?? $request->post('force_menu_zh'); + return in_array($flag, [1, '1', true, 'true', 'yes', 'on'], true); + } + private function autoAssignPermission(int $id, int $pid): void { $groups = AdminGroup::where('rules', '<>', '*')->select(); diff --git a/app/admin/library/Auth.php b/app/admin/library/Auth.php index 12dc87b..be58992 100644 --- a/app/admin/library/Auth.php +++ b/app/admin/library/Auth.php @@ -278,24 +278,27 @@ class Auth extends \ba\Auth public function getMenus(int $uid = 0): array { $menus = parent::getMenus($uid ?: $this->id); - return $this->translateMenuRuleTitles($menus); + return $this->translateMenuRuleTitles($menus, $this->shouldTranslateMenuToEnglish()); } /** - * 菜单标题统一按中文显示(不随语言切换)。 - * 若 title 为英文动作名/英文菜单名,按中文映射表转换。 + * 菜单标题按当前语言展示: + * - 英文环境:中文标题映射为英文 + * - 其他环境:英文标题映射为中文 * * @param array> $menus * @return array> */ - private function translateMenuRuleTitles(array $menus): array + private function translateMenuRuleTitles(array $menus, bool $toEnglish): array { foreach ($menus as $k => $item) { if (isset($item['title']) && is_string($item['title']) && $item['title'] !== '') { - $menus[$k]['title'] = $this->menuTitleToZh($item['title']); + $menus[$k]['title'] = $toEnglish + ? $this->menuTitleToEn($item['title']) + : $this->menuTitleToZh($item['title']); } if (!empty($item['children']) && is_array($item['children'])) { - $menus[$k]['children'] = $this->translateMenuRuleTitles($item['children']); + $menus[$k]['children'] = $this->translateMenuRuleTitles($item['children'], $toEnglish); } } @@ -313,6 +316,24 @@ class Auth extends \ba\Auth return isset($zhMap[$title]) && is_string($zhMap[$title]) ? $zhMap[$title] : $title; } + private function menuTitleToEn(string $title): string + { + static $enMap = null; + if (!is_array($enMap)) { + $mapFile = app_path() . '/common/lang/en/admin_rule_title.php'; + $loaded = is_file($mapFile) ? include $mapFile : []; + $enMap = is_array($loaded) ? $loaded : []; + } + return isset($enMap[$title]) && is_string($enMap[$title]) ? $enMap[$title] : $title; + } + + private function shouldTranslateMenuToEnglish(): bool + { + $lang = function_exists('locale') ? locale() : ''; + $normalized = is_string($lang) ? strtolower(str_replace('_', '-', trim($lang))) : ''; + return str_starts_with($normalized, 'en'); + } + public function isSuperAdmin(): bool { return in_array('*', $this->getRuleIds()); diff --git a/app/common/lang/en/admin_rule_title.php b/app/common/lang/en/admin_rule_title.php index fc66862..6f49bc8 100644 --- a/app/common/lang/en/admin_rule_title.php +++ b/app/common/lang/en/admin_rule_title.php @@ -87,6 +87,8 @@ return [ '推送-用户私有频道' => 'Push: user private', '渠道管理' => 'Channel management', '管理员提现记录' => 'Admin withdraw records', + '管理员钱包' => 'Admin wallets', + '管理员钱包流水' => 'Admin wallet records', '一键批量结算待结算渠道' => 'Batch settle pending channels', '渠道结算统计' => 'Channel settlement statistics', diff --git a/app/common/service/ChannelSettlementService.php b/app/common/service/ChannelSettlementService.php index cd27f44..dae2b58 100644 --- a/app/common/service/ChannelSettlementService.php +++ b/app/common/service/ChannelSettlementService.php @@ -95,7 +95,7 @@ class ChannelSettlementService return ['ok' => false, 'msg' => '当前流程为超管结算后自动发放,渠道管理员无需二次结算']; } - public static function settleAllDueChannels(int $operatorAdminId): array + public static function settleAllDueChannels(int $operatorAdminId, bool $respectCycle = true): array { $channels = Db::name('channel')->where('status', 1)->select()->toArray(); $ok = 0; @@ -106,7 +106,7 @@ class ChannelSettlementService if ($channelId <= 0) { continue; } - if (!self::isChannelDueForAutoSettle($channel, $now)) { + if ($respectCycle && !self::isChannelDueForAutoSettle($channel, $now)) { continue; } $res = self::settleBySuperAdmin($channelId, $operatorAdminId, '周期自动结算', true); diff --git a/web/src/api/backend/auth/group.ts b/web/src/api/backend/auth/group.ts index 5612631..ed42107 100644 --- a/web/src/api/backend/auth/group.ts +++ b/web/src/api/backend/auth/group.ts @@ -4,5 +4,8 @@ export function getAdminRules() { return createAxios({ url: '/admin/auth.Rule/index', method: 'get', + params: { + force_menu_zh: 1, + }, }) }