After adding the option to grant commission for solo prediction2
This commit is contained in:
parent
ceafb8ee36
commit
da7c2f7866
@ -268,7 +268,7 @@ export async function listGrants(input: {
|
||||
g.credit_raw::text, g.status, COALESCE(g.bet_ids, '{}') AS bet_ids,
|
||||
COALESCE(g.candle_open_ms_list, '{}') AS candle_open_ms_list,
|
||||
g.wallet_type_id, g.granted_by, g.granted_at, g.created_at,
|
||||
u.email AS user_email
|
||||
u.email_encrypted AS user_email
|
||||
FROM solo_encouragement_grants g
|
||||
LEFT JOIN users u ON u.id = g.user_id
|
||||
${where}
|
||||
@ -294,7 +294,7 @@ export async function listActiveStreaks(input: {
|
||||
const items = await query<SoloEncouragementActiveStreakRow[]>(
|
||||
`SELECT s.user_id, s.consecutive_solo_count, s.loss_raw_sum::text,
|
||||
s.last_candle_open_ms::text, COALESCE(s.last_bet_ids, '{}') AS last_bet_ids,
|
||||
s.updated_at, u.email AS user_email
|
||||
s.updated_at, u.email_encrypted AS user_email
|
||||
FROM solo_encouragement_user_state s
|
||||
LEFT JOIN users u ON u.id = s.user_id
|
||||
WHERE s.consecutive_solo_count > 0
|
||||
|
||||
@ -9,6 +9,7 @@ import * as auditLogRepository from '../repositories/auditLogRepository';
|
||||
import * as transactionRepository from '../repositories/transactionRepository';
|
||||
import * as userSecurityNotificationRepository from '../repositories/userSecurityNotificationRepository';
|
||||
import { queueUserAdminStatsRefresh } from './userAdminStatsService';
|
||||
import { decrypt } from '../utils/crypto';
|
||||
|
||||
export class SoloEncouragementError extends Error {
|
||||
constructor(message: string) {
|
||||
@ -17,6 +18,15 @@ export class SoloEncouragementError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
function safeDecryptEmail(encrypted: string | null): string | null {
|
||||
if (!encrypted) return null;
|
||||
try {
|
||||
return decrypt(encrypted);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function formatUsdt(raw: string | bigint, decimals = 6): string {
|
||||
const s = typeof raw === 'bigint' ? raw.toString() : raw.trim() || '0';
|
||||
const neg = s.startsWith('-');
|
||||
@ -339,7 +349,7 @@ export async function listActiveStreaksForAdmin(limit = 50, offset = 0) {
|
||||
const projected = computeCreditRaw(lossRaw, Number(settings.refund_percent));
|
||||
return {
|
||||
userId: row.user_id,
|
||||
userEmail: row.user_email,
|
||||
userEmail: safeDecryptEmail(row.user_email),
|
||||
consecutiveSoloCount: row.consecutive_solo_count,
|
||||
lossRaw: row.loss_raw_sum,
|
||||
projectedCreditRaw: projected.toString(),
|
||||
@ -368,7 +378,7 @@ export async function listGrantsForAdmin(input: {
|
||||
items: items.map((g) => ({
|
||||
id: g.id,
|
||||
userId: g.user_id,
|
||||
userEmail: g.user_email,
|
||||
userEmail: safeDecryptEmail(g.user_email),
|
||||
streakCount: g.streak_count,
|
||||
lossRaw: g.loss_raw,
|
||||
refundPercent: Number(g.refund_percent),
|
||||
|
||||
@ -284,7 +284,14 @@ export function SoloEncouragementAdminPage() {
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
{!streaksQ.data?.items?.length && (
|
||||
{streaksQ.isError && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5}>
|
||||
<Alert severity="error">{t('admin.soloEncouragement.loadFailed')}</Alert>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{!streaksQ.isError && !streaksQ.data?.items?.length && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} sx={{ opacity: 0.7 }}>
|
||||
{t('admin.soloEncouragement.noStreaks')}
|
||||
@ -367,7 +374,14 @@ export function SoloEncouragementAdminPage() {
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
{!grantsQ.data?.items?.length && (
|
||||
{grantsQ.isError && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={7}>
|
||||
<Alert severity="error">{t('admin.soloEncouragement.loadFailed')}</Alert>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{!grantsQ.isError && !grantsQ.data?.items?.length && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={7} sx={{ opacity: 0.7 }}>
|
||||
{t('admin.soloEncouragement.noGrants')}
|
||||
|
||||
@ -1813,6 +1813,7 @@ export const en = {
|
||||
subtitle:
|
||||
'Reward players who keep placing real-money predictions alone on an interval chart (Main or Bonus wallet). Test Wallet stakes are ignored.',
|
||||
loading: 'Loading solo encouragement settings…',
|
||||
loadFailed: 'Failed to load data. Refresh the page or check API logs.',
|
||||
enableFeature: 'Enable solo encouragement tracking',
|
||||
minConsecutive: 'Min consecutive solo predictions',
|
||||
minConsecutiveHelper: 'e.g. 3 — user must play alone this many maturities in a row',
|
||||
|
||||
@ -1830,6 +1830,7 @@ export const fr = {
|
||||
subtitle:
|
||||
'Récompensez les joueurs qui continuent à placer des prédictions seuls sur un graphique d’intervalle avec des fonds réels (Main ou Bonus). Les mises Test sont ignorées.',
|
||||
loading: 'Chargement des paramètres d’encouragement solo…',
|
||||
loadFailed: 'Échec du chargement. Rafraîchissez la page ou vérifiez les logs API.',
|
||||
enableFeature: 'Activer le suivi d’encouragement solo',
|
||||
minConsecutive: 'Prédictions solo successives minimales',
|
||||
minConsecutiveHelper: 'ex. 3 — l’utilisateur doit jouer seul pendant autant d’échéances d’affilée',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user