fix(prisma): regenerate client types, fix admin service and sync graphify

This commit is contained in:
parsa committed 2026-08-22 19:27:17 +03:30
1 parent 4e768d66a9
commit c35cff5671
229 files changed
+113729 -113225

No files matched your search

+16 -7
View File
@@ -615,7 +615,11 @@ export class AdminService {
});
}
async refundOrderToWallet(orderId: string, customAmount?: number, reason?: string) {
async refundOrderToWallet(
orderId: string,
customAmount?: number,
reason?: string,
) {
const order = await this.prisma.order.findUnique({
where: { id: orderId },
include: { user: true },
@@ -626,12 +630,15 @@ export class AdminService {
}
if (!order.userId || !order.user) {
throw new BadRequestException('این سفارش به کاربر ثبت‌نام‌شده‌ای متصل نیست');
throw new BadRequestException(
'این سفارش به کاربر ثبت‌نام‌شده‌ای متصل نیست',
);
}
const refundAmount = customAmount !== undefined && customAmount > 0
? customAmount
: Number(order.totalAmount || 0);
const refundAmount =
customAmount !== undefined && customAmount > 0
? customAmount
: Number(order.totalAmount || 0);
if (refundAmount <= 0) {
throw new BadRequestException('مبلغ استرداد باید بیشتر از صفر باشد');
@@ -653,7 +660,9 @@ export class AdminService {
amount: refundAmount,
type: 'deposit',
status: 'completed',
description: reason || `استرداد وجه سفارش لغو شده #${order.trackingNumber || order.id.slice(0, 8)} به کیف پول`,
description:
reason ||
`استرداد وجه سفارش لغو شده #${order.trackingNumber || order.id.slice(0, 8)} به کیف پول`,
},
});
@@ -812,7 +821,7 @@ export class AdminService {
update: { value: String(value) },
create: { key, value: String(value), category: 'general' },
});
} catch (e) {
} catch {
// ignore
}
}
+8 -2
View File
@@ -11,7 +11,10 @@ export class MenuService implements OnModuleInit {
try {
await this.seedIfEmpty();
} catch (err) {
console.warn('[MenuService] seedIfEmpty skipped during module init:', err?.message || err);
console.warn(
'[MenuService] seedIfEmpty skipped during module init:',
err?.message || err,
);
}
}
@@ -20,7 +23,10 @@ export class MenuService implements OnModuleInit {
const count = await this.prisma.menuItem.count();
if (count > 0) return;
} catch (err) {
console.warn('[MenuService] menuItem table not accessible yet:', err?.message || err);
console.warn(
'[MenuService] menuItem table not accessible yet:',
err?.message || err,
);
return;
}
+20 -9
View File
@@ -262,7 +262,11 @@ export class PaymentController {
@Post('admin/refund/inquiry')
@ApiOperation({ summary: 'استعلام وضعیت استرداد وجه' })
async inquireRefund(
@Body() body: { refundId?: string | number; transactionTrackId?: string | number },
@Body()
body: {
refundId?: string | number;
transactionTrackId?: string | number;
},
) {
return this.zibalService.inquireRefund(body);
}
@@ -290,7 +294,9 @@ export class PaymentController {
@Roles('Admin')
@ApiBearerAuth()
@Post('admin/gateway-report')
@ApiOperation({ summary: 'گزارش مستقیم تراکنش‌های درگاه زیبال از سرور زیبال' })
@ApiOperation({
summary: 'گزارش مستقیم تراکنش‌های درگاه زیبال از سرور زیبال',
})
async getGatewayReport(
@Body()
body: {
@@ -313,7 +319,9 @@ export class PaymentController {
@Roles('Admin')
@ApiBearerAuth()
@Post('admin/checkout-report')
@ApiOperation({ summary: 'گزارش تسویه‌ها و واریزی‌های درگاه و کیف‌پول زیبال' })
@ApiOperation({
summary: 'گزارش تسویه‌ها و واریزی‌های درگاه و کیف‌پول زیبال',
})
async getCheckoutReport(
@Body()
body: {
@@ -345,10 +353,7 @@ export class PaymentController {
@ApiBearerAuth()
@Get('admin/sub-merchants')
@ApiOperation({ summary: 'لیست ذی‌نفع‌های ثبت‌شده در زیبال' })
async getSubMerchants(
@Query('page') page = '1',
@Query('size') size = '20',
) {
async getSubMerchants(@Query('page') page = '1', @Query('size') size = '20') {
return this.zibalService.getSubMerchantList(Number(page), Number(size));
}
@@ -397,7 +402,10 @@ export class PaymentController {
@Query('accountId') accountId?: string,
@Query('update') update?: string,
) {
return this.zibalEBankService.getAccountBalance(accountId, update === 'true');
return this.zibalEBankService.getAccountBalance(
accountId,
update === 'true',
);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@@ -463,7 +471,10 @@ export class PaymentController {
async cancelEBankCheckout(
@Body() body: { checkoutIds: string[]; accountId?: string },
) {
return this.zibalEBankService.cancelCheckout(body.checkoutIds, body.accountId);
return this.zibalEBankService.cancelCheckout(
body.checkoutIds,
body.accountId,
);
}
@UseGuards(JwtAuthGuard, RolesGuard)
+25 -12
View File
@@ -93,7 +93,9 @@ export class ZibalEBankService {
): Promise<T> {
const token = await this.getAccessToken();
if (!token) {
throw new Error('توکن دسترسی بانکداری شرکتی زیبال (ZIBAL_EBANK_TOKEN) تنظیم نشده است.');
throw new Error(
'توکن دسترسی بانکداری شرکتی زیبال (ZIBAL_EBANK_TOKEN) تنظیم نشده است.',
);
}
let url = `${this.baseUrl}${endpoint}`;
@@ -131,7 +133,9 @@ export class ZibalEBankService {
return data as T;
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
this.logger.error(`[Zibal EBank API] Error requesting ${endpoint}: ${msg}`);
this.logger.error(
`[Zibal EBank API] Error requesting ${endpoint}: ${msg}`,
);
throw err;
} finally {
clearTimeout(timeoutId);
@@ -194,7 +198,9 @@ export class ZibalEBankService {
async getCheckoutList(filter: EBankCheckoutListFilter) {
const accountId = filter.accountId || (await this.getDefaultAccountId());
const now = new Date();
const defaultFrom = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000).toISOString();
const defaultFrom = new Date(
now.getTime() - 30 * 24 * 60 * 60 * 1000,
).toISOString();
const defaultTo = now.toISOString();
return this.request<any>('/ebank/v1/account/checkout/list/', {
@@ -260,7 +266,9 @@ export class ZibalEBankService {
async getStatementList(filter: EBankStatementFilter) {
const accountId = filter.accountId || (await this.getDefaultAccountId());
const now = new Date();
const defaultFrom = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString();
const defaultFrom = new Date(
now.getTime() - 7 * 24 * 60 * 60 * 1000,
).toISOString();
const defaultTo = now.toISOString();
return this.request<any>('/ebank/v1/account/statement/list/', {
@@ -286,7 +294,9 @@ export class ZibalEBankService {
async getIdentifiedPaymentList(filter: EBankIdentifiedPaymentFilter) {
const accountId = filter.accountId || (await this.getDefaultAccountId());
const now = new Date();
const defaultFrom = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000).toISOString();
const defaultFrom = new Date(
now.getTime() - 30 * 24 * 60 * 60 * 1000,
).toISOString();
const defaultTo = now.toISOString();
return this.request<any>('/ebank/v1/account/identified-payment/list/', {
@@ -311,14 +321,17 @@ export class ZibalEBankService {
accountId?: string,
) {
const targetAccountId = accountId || (await this.getDefaultAccountId());
return this.request<any>('/ebank/v1/account/identified-payment/change-status/', {
method: 'POST',
body: {
accountId: targetAccountId,
transactionId,
status,
return this.request<any>(
'/ebank/v1/account/identified-payment/change-status/',
{
method: 'POST',
body: {
accountId: targetAccountId,
transactionId,
status,
},
},
});
);
}
/**
+25 -8
View File
@@ -403,7 +403,9 @@ export class ZibalService implements IPaymentGateway {
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Zibal Lazy request HTTP ${response.status}: ${errorText}`);
throw new Error(
`Zibal Lazy request HTTP ${response.status}: ${errorText}`,
);
}
const data = (await response.json()) as ZibalRequestResponse;
@@ -417,7 +419,9 @@ export class ZibalService implements IPaymentGateway {
/**
* تایید پرداخت در حالت Lazy
*/
async verifyLazyPayment(trackId: string | number): Promise<ZibalVerifyResponse> {
async verifyLazyPayment(
trackId: string | number,
): Promise<ZibalVerifyResponse> {
const merchant = await this.getMerchant();
const payload = {
merchant,
@@ -440,7 +444,9 @@ export class ZibalService implements IPaymentGateway {
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Zibal verify Lazy HTTP ${response.status}: ${errorText}`);
throw new Error(
`Zibal verify Lazy HTTP ${response.status}: ${errorText}`,
);
}
const data = (await response.json()) as ZibalVerifyResponse;
@@ -531,7 +537,8 @@ export class ZibalService implements IPaymentGateway {
? {
...body,
// Ensure apiKey is set if not already present
apiKey: body.apiKey || (token && token !== 'zibal' ? token : apiKey),
apiKey:
body.apiKey || (token && token !== 'zibal' ? token : apiKey),
}
: body;
@@ -549,7 +556,9 @@ export class ZibalService implements IPaymentGateway {
});
const data = await res.json();
this.logger.log(`[Zibal Core API Response] ${endpoint} -> ${JSON.stringify(data)}`);
this.logger.log(
`[Zibal Core API Response] ${endpoint} -> ${JSON.stringify(data)}`,
);
return data as T;
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
@@ -587,7 +596,9 @@ export class ZibalService implements IPaymentGateway {
}) {
const merchant = await this.getMerchant();
const accountIdSetting = (
await this.prisma.uiText.findUnique({ where: { key: 'ZIBAL_EBANK_ACCOUNT_ID' } })
await this.prisma.uiText.findUnique({
where: { key: 'ZIBAL_EBANK_ACCOUNT_ID' },
})
)?.value;
const payload: Record<string, any> = {
@@ -709,13 +720,19 @@ export class ZibalService implements IPaymentGateway {
* گزارش صف تسویه‌های در انتظار
*/
async getCheckoutQueueReport(verbose = true) {
return this.apiRequest<any>('/v1/report/checkout/queue', 'POST', { verbose });
return this.apiRequest<any>('/v1/report/checkout/queue', 'POST', {
verbose,
});
}
/**
* استعلام تسویه مشخص با checkoutRequestId یا uniqueCode
*/
async inquireCheckoutReport(walletId: string, checkoutRequestId?: string, uniqueCode?: string) {
async inquireCheckoutReport(
walletId: string,
checkoutRequestId?: string,
uniqueCode?: string,
) {
return this.apiRequest<any>('/v1/report/checkout/inquire', 'POST', {
walletId,
checkoutRequestId,
+28 -4
View File
@@ -101,10 +101,34 @@ export const CANONICAL_ALIASES: Record<string, string[]> = {
charityRoundStep: ['CHARITY_ROUND_STEP', 'charity_round_step'],
// Zibal Gateway & Tokens
ZIBAL_EBANK_TOKEN: ['zibal_ebank_token', 'ZIBAL_API_KEY', 'zibal_api_key', 'ZIBAL_TOKEN', 'zibal_token'],
zibal_ebank_token: ['ZIBAL_EBANK_TOKEN', 'ZIBAL_API_KEY', 'zibal_api_key', 'ZIBAL_TOKEN', 'zibal_token'],
ZIBAL_API_KEY: ['ZIBAL_EBANK_TOKEN', 'zibal_ebank_token', 'zibal_api_key', 'ZIBAL_TOKEN', 'zibal_token'],
zibal_api_key: ['ZIBAL_EBANK_TOKEN', 'zibal_ebank_token', 'ZIBAL_API_KEY', 'ZIBAL_TOKEN', 'zibal_token'],
ZIBAL_EBANK_TOKEN: [
'zibal_ebank_token',
'ZIBAL_API_KEY',
'zibal_api_key',
'ZIBAL_TOKEN',
'zibal_token',
],
zibal_ebank_token: [
'ZIBAL_EBANK_TOKEN',
'ZIBAL_API_KEY',
'zibal_api_key',
'ZIBAL_TOKEN',
'zibal_token',
],
ZIBAL_API_KEY: [
'ZIBAL_EBANK_TOKEN',
'zibal_ebank_token',
'zibal_api_key',
'ZIBAL_TOKEN',
'zibal_token',
],
zibal_api_key: [
'ZIBAL_EBANK_TOKEN',
'zibal_ebank_token',
'ZIBAL_API_KEY',
'ZIBAL_TOKEN',
'zibal_token',
],
ZIBAL_MERCHANT: ['zibal_merchant', 'merchantId', 'merchant'],
zibal_merchant: ['ZIBAL_MERCHANT', 'merchantId', 'merchant'],
ZIBAL_EBANK_ACCOUNT_ID: ['zibal_ebank_account_id', 'accountId'],