修复翻译BUG

This commit is contained in:
2026-04-23 17:44:10 +08:00
parent f2b4dab54f
commit de3b9ab6bf
6 changed files with 109 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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();