feat(theme-4): sync inbox/announcements/presence/deposit from main
This commit is contained in:
@@ -7,6 +7,8 @@ import { FundsPostingService } from '../ledger/funds-posting.service';
|
||||
import { AgentCreditService } from '../agent/agent-credit.service';
|
||||
import { appBadRequest } from '../../shared/common/app-error';
|
||||
import { deleteUploadFileByUrl } from '../../shared/uploads/delete-upload-file';
|
||||
import { PlayerMessagesService } from '../player-messages/player-messages.service';
|
||||
import { SystemConfigService } from '../../shared/config/system-config.service';
|
||||
|
||||
function generateOrderNo(): string {
|
||||
const ts = Date.now().toString(36).toUpperCase();
|
||||
@@ -49,6 +51,8 @@ export class DepositService {
|
||||
private prisma: PrismaService,
|
||||
private funds: FundsPostingService,
|
||||
private credit: AgentCreditService,
|
||||
private playerMessages: PlayerMessagesService,
|
||||
private systemConfig: SystemConfigService,
|
||||
) {}
|
||||
|
||||
// ============ Payment Methods (Admin CRUD) ============
|
||||
@@ -254,6 +258,14 @@ export class DepositService {
|
||||
|
||||
// ============ Deposit Orders ============
|
||||
|
||||
private async getPlayerLocale(playerId: bigint, tx: Prisma.TransactionClient | PrismaService = this.prisma) {
|
||||
const user = await tx.user.findUnique({
|
||||
where: { id: playerId },
|
||||
select: { locale: true },
|
||||
});
|
||||
return user?.locale ?? 'en-US';
|
||||
}
|
||||
|
||||
private async recordDepositAudit(
|
||||
client: AuditLogWriter,
|
||||
data: {
|
||||
@@ -670,6 +682,10 @@ export class DepositService {
|
||||
};
|
||||
}
|
||||
|
||||
async countPendingDepositOrders(): Promise<number> {
|
||||
return this.prisma.depositOrder.count({ where: { status: 'PENDING' } });
|
||||
}
|
||||
|
||||
async approveDepositOrder(
|
||||
orderId: bigint,
|
||||
operatorId: bigint,
|
||||
@@ -722,6 +738,22 @@ export class DepositService {
|
||||
await this.credit.recalculateUsedCredit(parentAgentId, tx);
|
||||
}
|
||||
|
||||
const playerLocale = await this.getPlayerLocale(order.playerId, tx);
|
||||
const inboxNotify = await this.systemConfig.getInboxNotifySettings();
|
||||
if (inboxNotify.inboxEnabled && inboxNotify.deposit) {
|
||||
await this.playerMessages.createDepositApprovedMessage(
|
||||
order.playerId,
|
||||
{
|
||||
depositOrderId: orderId,
|
||||
orderNo: order.orderNo,
|
||||
amount: order.amount.toString(),
|
||||
approvedAmount: creditAmount.toString(),
|
||||
locale: playerLocale,
|
||||
},
|
||||
tx,
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
});
|
||||
}
|
||||
@@ -753,6 +785,18 @@ export class DepositService {
|
||||
remark: reason,
|
||||
});
|
||||
|
||||
const playerLocale = await this.getPlayerLocale(order.playerId);
|
||||
const inboxNotify = await this.systemConfig.getInboxNotifySettings();
|
||||
if (inboxNotify.inboxEnabled && inboxNotify.deposit) {
|
||||
await this.playerMessages.createDepositRejectedMessage(order.playerId, {
|
||||
depositOrderId: orderId,
|
||||
orderNo: order.orderNo,
|
||||
amount: order.amount.toString(),
|
||||
rejectReason: reason,
|
||||
locale: playerLocale,
|
||||
});
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user