거래내역 엑셀 다운로드

This commit is contained in:
focp212@naver.com
2025-11-11 10:22:43 +09:00
parent 7c00077b6c
commit f72fcf0604
9 changed files with 150 additions and 16 deletions

View File

@@ -0,0 +1,39 @@
import axios from 'axios';
import { API_URL_TRANSACTION } from '@/shared/api/api-url-transaction';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
BillingExcelParams,
BillingExcelResponse
} from '../model/types';
import {
useMutation,
UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';
export const billingExcel = (params: BillingExcelParams) => {
let headerOptions = {
menuId: 34,
apiType: 'DOWNLOAD'
};
let options = {
headers: {
'X-User-Agent': getHeaderUserAgent(headerOptions)
}
};
return resultify(
axios.post<BillingExcelResponse>(API_URL_TRANSACTION.billingExcel(), params, options),
);
};
export const useBillingExcelMutation = (options?: UseMutationOptions<BillingExcelResponse, NiceAxiosError, BillingExcelParams>) => {
const mutation = useMutation<BillingExcelResponse, NiceAxiosError, BillingExcelParams>({
...options,
mutationFn: (params: BillingExcelParams) => billingExcel(params),
});
return {
...mutation,
};
};

View File

@@ -23,7 +23,7 @@ export const cashReceiptExcelDownload = (params: CashReceiptExcelDownloadParams)
} }
}; };
return resultify( return resultify(
axios.post<CashReceiptExcelDownloadResponse>(API_URL_TRANSACTION.cashReceiptReceiptDownload(), params, options), axios.post<CashReceiptExcelDownloadResponse>(API_URL_TRANSACTION.cashReceiptExcelDownload(), params, options),
); );
}; };

View File

@@ -12,7 +12,7 @@ import {
} from '@tanstack/react-query'; } from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url'; import { getHeaderUserAgent } from '@/shared/constants/url';
export const escrowDownloadExcelList = (params: EscrowDownloadExcelParams) => { export const escrowDownloadExcel = (params: EscrowDownloadExcelParams) => {
let headerOptions = { let headerOptions = {
menuId: 33, menuId: 33,
apiType: 'DOWNLOAD' apiType: 'DOWNLOAD'
@@ -23,14 +23,14 @@ export const escrowDownloadExcelList = (params: EscrowDownloadExcelParams) => {
} }
}; };
return resultify( return resultify(
axios.post<EscrowDownloadExcelResponse>(API_URL_TRANSACTION.escrowList(), params, options), axios.post<EscrowDownloadExcelResponse>(API_URL_TRANSACTION.escrowDownloadExcel(), params, options),
); );
}; };
export const useEscrowListMutation = (options?: UseMutationOptions<EscrowDownloadExcelResponse, NiceAxiosError, EscrowDownloadExcelParams>) => { export const useEscrowDownloadExcelMutation = (options?: UseMutationOptions<EscrowDownloadExcelResponse, NiceAxiosError, EscrowDownloadExcelParams>) => {
const mutation = useMutation<EscrowDownloadExcelResponse, NiceAxiosError, EscrowDownloadExcelParams>({ const mutation = useMutation<EscrowDownloadExcelResponse, NiceAxiosError, EscrowDownloadExcelParams>({
...options, ...options,
mutationFn: (params: EscrowDownloadExcelParams) => escrowDownloadExcelList(params), mutationFn: (params: EscrowDownloadExcelParams) => escrowDownloadExcel(params),
}); });
return { return {

View File

@@ -302,7 +302,7 @@ export interface CashReceiptExcelDownloadParams {
mid: string; mid: string;
startDate: string; startDate: string;
endDate: string; endDate: string;
dateType: CashReceiptDateType; dateType?: CashReceiptDateType;
purposeType: CashReceiptPurposeType; purposeType: CashReceiptPurposeType;
transactionType: CashReceiptTransactionType; transactionType: CashReceiptTransactionType;
processResult: CashReceiptProcessResult; processResult: CashReceiptProcessResult;
@@ -333,18 +333,30 @@ export interface EscrowDownloadExcelResponse {};
export interface BillingListParams { export interface BillingListParams {
mid?: string; mid?: string;
searchType?: string; searchType?: BillingSearchType;
searchKeyword?: string; searchKeyword?: string;
startDate?: string; startDate?: string;
endDate?: string; endDate?: string;
requestStatus?: string; requestStatus?: BillingRequestStatus;
processResult?: string; processResult?: BillingProcessResult;
paymentMethod?: string; paymentMethod?: BillingPaymentMethod;
minAmount?: number; minAmount?: number;
maxAmount?: number; maxAmount?: number;
page?: DefaultRequestPagination page?: DefaultRequestPagination
}; };
export interface BillingExcelParams {
email: string;
mid: string;
searchType: BillingSearchType;
startDate: string;
endDate: string;
requestStatus: BillingRequestStatus,
processResult: BillingProcessResult,
paymentMethod: BillingPaymentMethod
};
export interface BillingExcelResponse {};
export interface AllTransactionDetailParams { export interface AllTransactionDetailParams {
serviceCode?: string; serviceCode?: string;
tid?: string; tid?: string;

View File

@@ -224,6 +224,7 @@ export const AllTransactionListPage = () => {
}; };
transactionDownloadExcel(params).then((rs: TransactionDownloadExcelResponse) => { transactionDownloadExcel(params).then((rs: TransactionDownloadExcelResponse) => {
console.log(rs); console.log(rs);
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
}).catch((e: any) => { }).catch((e: any) => {
if(e.response?.data?.error?.message){ if(e.response?.data?.error?.message){
snackBar(e.response?.data?.error?.message); snackBar(e.response?.data?.error?.message);

View File

@@ -15,7 +15,8 @@ import {
ListItemProps, ListItemProps,
BillingListParams, BillingListParams,
BillingListResponse, BillingListResponse,
DetailData DetailData,
BillingExcelParams
} from '@/entities/transaction/model/types'; } from '@/entities/transaction/model/types';
import { useBillingListMutation } from '@/entities/transaction/api/use-billing-list-mutation'; import { useBillingListMutation } from '@/entities/transaction/api/use-billing-list-mutation';
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant'; import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
@@ -35,6 +36,7 @@ import { BillingDetail } from '@/entities/transaction/ui/detail/billing-detail';
import { showAlert } from '@/widgets/show-alert'; import { showAlert } from '@/widgets/show-alert';
import { checkGrant } from '@/shared/lib/check-grant'; import { checkGrant } from '@/shared/lib/check-grant';
import { snackBar } from '@/shared/lib'; import { snackBar } from '@/shared/lib';
import { useBillingExcelMutation } from '@/entities/transaction/api/use-billing-excel-mutation';
/* 빌링 34 */ /* 빌링 34 */
const menuId = 34; const menuId = 34;
@@ -72,6 +74,8 @@ export const BillingListPage = () => {
useSetFooterMode(false); useSetFooterMode(false);
const { mutateAsync: billingList } = useBillingListMutation(); const { mutateAsync: billingList } = useBillingListMutation();
const { mutateAsync: billingExcel } = useBillingExcelMutation();
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => { const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
entries.forEach((entry: IntersectionObserverEntry) => { entries.forEach((entry: IntersectionObserverEntry) => {
if(entry.isIntersecting){ if(entry.isIntersecting){
@@ -179,7 +183,29 @@ export const BillingListPage = () => {
selectedMode: DownloadSelectedMode, selectedMode: DownloadSelectedMode,
userEmail?: string userEmail?: string
) => { ) => {
if(selectedMode === DownloadSelectedMode.EMAIL
&& !!userEmail
){
let params: BillingExcelParams = {
email: userEmail,
mid: mid,
searchType: searchType,
startDate: startDate,
endDate: endDate,
requestStatus: requestStatus,
processResult: processResult,
paymentMethod: paymentMethod
};
billingExcel(params).then((rs) => {
console.log(rs);
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
}).catch((e: any) => {
if(e.response?.data?.error?.message){
snackBar(e.response?.data?.error?.message);
return;
}
});
}
}; };
const setDetailData = (detailData: DetailData) => { const setDetailData = (detailData: DetailData) => {

View File

@@ -16,7 +16,9 @@ import {
CashReceiptSummaryParams, CashReceiptSummaryParams,
CashReceiptListResponse, CashReceiptListResponse,
CashReceiptSummaryResponse, CashReceiptSummaryResponse,
DetailData DetailData,
CashReceiptExcelDownloadParams,
CashReceiptExcelDownloadResponse
} from '@/entities/transaction/model/types'; } from '@/entities/transaction/model/types';
import { useCashReceiptListMutation } from '@/entities/transaction/api/use-cash-receipt-list-mutation'; import { useCashReceiptListMutation } from '@/entities/transaction/api/use-cash-receipt-list-mutation';
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant'; import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
@@ -38,6 +40,7 @@ import { CashReceiptDetail } from '@/entities/transaction/ui/detail/cash-receit-
import { checkGrant } from '@/shared/lib/check-grant'; import { checkGrant } from '@/shared/lib/check-grant';
import { showAlert } from '@/widgets/show-alert'; import { showAlert } from '@/widgets/show-alert';
import { snackBar } from '@/shared/lib'; import { snackBar } from '@/shared/lib';
import { useCashReceiptExcelDownloadMutation } from '@/entities/transaction/api/use-cash-receipt-excel-download-mutation';
/* 현금영수증 32 */ /* 현금영수증 32 */
const menuId = 32; const menuId = 32;
@@ -80,6 +83,8 @@ export const CashReceiptListPage = () => {
const { mutateAsync: cashReceiptList } = useCashReceiptListMutation(); const { mutateAsync: cashReceiptList } = useCashReceiptListMutation();
const { mutateAsync: cashReceiptSummary } = useCashReceiptSummaryMutation(); const { mutateAsync: cashReceiptSummary } = useCashReceiptSummaryMutation();
const { mutateAsync: cashReceiptExcelDownload } = useCashReceiptExcelDownloadMutation();
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => { const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
entries.forEach((entry: IntersectionObserverEntry) => { entries.forEach((entry: IntersectionObserverEntry) => {
if(entry.isIntersecting){ if(entry.isIntersecting){
@@ -176,7 +181,29 @@ export const CashReceiptListPage = () => {
selectedMode: DownloadSelectedMode, selectedMode: DownloadSelectedMode,
userEmail?: string userEmail?: string
) => { ) => {
if(selectedMode === DownloadSelectedMode.EMAIL
&& !!userEmail
){
let params: CashReceiptExcelDownloadParams = {
email: userEmail,
mid: mid,
startDate: startDate,
endDate: endDate,
purposeType: purposeType,
transactionType: transactionType,
processResult: processResult
};
cashReceiptExcelDownload(params).then((rs: CashReceiptExcelDownloadResponse) => {
console.log(rs);
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
}).catch((e: any) => {
if(e.response?.data?.error?.message){
snackBar(e.response?.data?.error?.message);
return;
}
});
}
}; };

View File

@@ -14,7 +14,9 @@ import {
ListItemProps, ListItemProps,
EscrowListParams, EscrowListParams,
EscrowListResponse, EscrowListResponse,
DetailData DetailData,
EscrowDownloadExcelParams,
EscrowDownloadExcelResponse
} from '@/entities/transaction/model/types'; } from '@/entities/transaction/model/types';
import { useEscrowListMutation } from '@/entities/transaction/api/use-escrow-list-mutation'; import { useEscrowListMutation } from '@/entities/transaction/api/use-escrow-list-mutation';
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant'; import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
@@ -34,6 +36,7 @@ import { EscrowDetail } from '@/entities/transaction/ui/detail/escrow-detail';
import { checkGrant } from '@/shared/lib/check-grant'; import { checkGrant } from '@/shared/lib/check-grant';
import { showAlert } from '@/widgets/show-alert'; import { showAlert } from '@/widgets/show-alert';
import { snackBar } from '@/shared/lib'; import { snackBar } from '@/shared/lib';
import { useEscrowDownloadExcelMutation } from '@/entities/transaction/api/use-escrow-download-excel-mutation';
/* 에스크로 33 */ /* 에스크로 33 */
const menuId = 33; const menuId = 33;
@@ -72,6 +75,8 @@ export const EscrowListPage = () => {
useSetFooterMode(false); useSetFooterMode(false);
const { mutateAsync: escrowList } = useEscrowListMutation(); const { mutateAsync: escrowList } = useEscrowListMutation();
const { mutateAsync: escrowDownloadExcel } = useEscrowDownloadExcelMutation();
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => { const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
entries.forEach((entry: IntersectionObserverEntry) => { entries.forEach((entry: IntersectionObserverEntry) => {
if(entry.isIntersecting){ if(entry.isIntersecting){
@@ -162,7 +167,27 @@ export const EscrowListPage = () => {
selectedMode: DownloadSelectedMode, selectedMode: DownloadSelectedMode,
userEmail?: string userEmail?: string
) => { ) => {
if(selectedMode === DownloadSelectedMode.EMAIL
&& !!userEmail
){
let params: EscrowDownloadExcelParams = {
email: userEmail,
mid: mid,
startDate: startDate,
endDate: endDate,
deliveryStatus: deliveryStatus,
settlementStatus: settlementStatus
};
escrowDownloadExcel(params).then((rs: EscrowDownloadExcelResponse) => {
console.log(rs);
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
}).catch((e: any) => {
if(e.response?.data?.error?.message){
snackBar(e.response?.data?.error?.message);
return;
}
});
}
}; };
const setDetailData = (detailData: DetailData) => { const setDetailData = (detailData: DetailData) => {

View File

@@ -93,5 +93,9 @@ export const API_URL_TRANSACTION = {
// POST: 빌링 결제 신청 // POST: 빌링 결제 신청
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/billing/charge`; return `${API_BASE_URL}/api/v1/${API_URL_KEY}/billing/charge`;
}, },
billingExcel: () => {
// POST: 빌링 거래내역 엑셀 다운로드
return `${API_BASE_URL}/api/v1/${API_URL_KEY}/billing/excel`;
}
}; };