feat: 수수료 공식 갭 보완 + 8종 신규모듈 풀스택 (V116~V123)
수수료 공식 갭분석(5 병렬감사) 후 확정 버그 3건 수정 + 개념적으로 빠진 모듈 8종 풀스택 구현. [확정 버그 3건] - 1200% 누적한도(checkContractTotal)를 배치 CalcRecruitStep에 연결(기존 1차년 한도만 적용 → 두 한도 중 더 제한적인 값으로 clip+이연). +CalcRecruitStepTest - BatchInstallmentPlanGenerator planMonth 반영(하드코딩 1 제거, API판과 동일). +단위테스트 - PersistencyBonus 임계유지율 게이트 + FIXED 정액 룰 도출. +PersistencyBonusServiceTest [신규 모듈 8종] - MOD-1 도입수수료(recruiter/development) / MOD-2 선지급·차익정산 / MOD-3 환수 분할상환 - MOD-4 익월부활 재지급 / MOD-5 정산대사 입수 / MOD-6 환수 시효 / MOD-7 환수 감면 - MOD-8 채널별 수수료차등(sales_channel) 각 DB(테이블+메뉴+권한+공통코드)→VO/Mapper/Enum→Service/Controller→화면 풀스택. 배치 정산연계: AggregateStep에 도입/익월부활 가산(11종), 선지급 FIFO 상계(멱등 reverse), MOD-8 채널 우선 요율조회(NULL 폴백 하위호환). [검증] - 전체 ./gradlew build(전 모듈+전 테스트) GREEN - Flyway V116~V123 운영DB 적용(schema v115→v123) - 라이브 스모크 8 GET=200, MOD-1 RATE공식 50000 실측, 액션 POST 5xx 0건 - 적대적 코드리뷰 APPROVED(MOD-8 계산기 미연결 버그 발견·수정) 스펙: docs/DOMAIN_GAP_MOD1-8.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Form, Input, InputNumber, Modal, Select, Space, message } from 'antd';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ColDef } from '@ag-grid-community/core';
|
||||
import dayjs from 'dayjs';
|
||||
import PageContainer from '@/components/common/PageContainer';
|
||||
import SearchForm from '@/components/common/SearchForm';
|
||||
import DataGrid from '@/components/common/DataGrid';
|
||||
import PermissionButton from '@/components/common/PermissionButton';
|
||||
import {
|
||||
commissionApi,
|
||||
ChargebackWaiverRow,
|
||||
ChargebackWaiverSaveReq,
|
||||
CommissionSearchParam,
|
||||
} from '@/api/commission';
|
||||
import { GRAY, RADIUS, SHADOW } from '@/theme/tokens';
|
||||
|
||||
const fmt = (v: unknown) => (v as number)?.toLocaleString() ?? '-';
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: 'REQUESTED', label: '신청' },
|
||||
{ value: 'APPROVED', label: '승인' },
|
||||
{ value: 'REJECTED', label: '반려' },
|
||||
];
|
||||
|
||||
const COLS: ColDef<ChargebackWaiverRow>[] = [
|
||||
{ field: 'settleMonth', headerName: '정산월', width: 110, pinned: 'left' },
|
||||
{ field: 'agentName', headerName: '설계사', width: 130 },
|
||||
{ field: 'contractNo', headerName: '증권번호', width: 140 },
|
||||
{ field: 'originalChargeback', headerName: '원환수액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'waiverAmount', headerName: '감면액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'reason', headerName: '사유', flex: 1 },
|
||||
{ field: 'approvalStatus', headerName: '승인상태', width: 110 },
|
||||
{ field: 'approvedAt', headerName: '승인일시', width: 160 },
|
||||
];
|
||||
|
||||
export default function ChargebackWaiver() {
|
||||
const qc = useQueryClient();
|
||||
const [searchParams, setSearchParams] = useState<CommissionSearchParam & { approvalStatus?: string }>({
|
||||
settleMonth: dayjs().format('YYYYMM'), pageSize: 200,
|
||||
});
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [rejectTarget, setRejectTarget] = useState<ChargebackWaiverRow | null>(null);
|
||||
const [rejectReason, setRejectReason] = useState('');
|
||||
const [form] = Form.useForm<ChargebackWaiverSaveReq>();
|
||||
|
||||
const { data: listData, isLoading, isError } = useQuery({
|
||||
queryKey: ['chargebackWaiver', 'list', searchParams],
|
||||
queryFn: () => commissionApi.chargebackWaiverList(searchParams),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const rows = listData?.list ?? [];
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (body: ChargebackWaiverSaveReq) => commissionApi.chargebackWaiverCreate(body),
|
||||
onSuccess: () => {
|
||||
message.success('신청 완료');
|
||||
qc.invalidateQueries({ queryKey: ['chargebackWaiver', 'list'] });
|
||||
setCreateOpen(false);
|
||||
form.resetFields();
|
||||
},
|
||||
});
|
||||
|
||||
const approveMutation = useMutation({
|
||||
mutationFn: (requestId: number) => commissionApi.chargebackWaiverApprove(requestId),
|
||||
onSuccess: () => {
|
||||
message.success('승인 완료');
|
||||
qc.invalidateQueries({ queryKey: ['chargebackWaiver', 'list'] });
|
||||
},
|
||||
});
|
||||
|
||||
const rejectMutation = useMutation({
|
||||
mutationFn: ({ requestId, reason }: { requestId: number; reason: string }) =>
|
||||
commissionApi.chargebackWaiverReject(requestId, reason),
|
||||
onSuccess: () => {
|
||||
message.success('반려 완료');
|
||||
qc.invalidateQueries({ queryKey: ['chargebackWaiver', 'list'] });
|
||||
setRejectTarget(null);
|
||||
setRejectReason('');
|
||||
},
|
||||
});
|
||||
|
||||
const handleCreate = async () => {
|
||||
const values = await form.validateFields();
|
||||
createMutation.mutate(values);
|
||||
};
|
||||
|
||||
const handleApprove = (row: ChargebackWaiverRow) => Modal.confirm({
|
||||
title: '승인',
|
||||
content: `${row.agentName} 감면 신청(감면액: ${fmt(row.waiverAmount)})을 승인하시겠습니까?`,
|
||||
onOk: () => approveMutation.mutateAsync(row.requestId),
|
||||
});
|
||||
|
||||
const openReject = (row: ChargebackWaiverRow) => {
|
||||
setRejectTarget(row);
|
||||
setRejectReason('');
|
||||
};
|
||||
|
||||
const handleReject = () => {
|
||||
if (!rejectReason.trim()) { message.warning('반려 사유를 입력하세요'); return; }
|
||||
rejectMutation.mutate({ requestId: rejectTarget!.requestId, reason: rejectReason });
|
||||
};
|
||||
|
||||
const pinnedRow = rows.length > 0 ? {
|
||||
agentName: '합계',
|
||||
originalChargeback: rows.reduce((s, r) => s + (r.originalChargeback ?? 0), 0),
|
||||
waiverAmount: rows.reduce((s, r) => s + (r.waiverAmount ?? 0), 0),
|
||||
} as Partial<ChargebackWaiverRow> : undefined;
|
||||
|
||||
const cardStyle = { background: '#fff', borderRadius: RADIUS.lg, border: `1px solid ${GRAY[100]}`, boxShadow: SHADOW.sm };
|
||||
|
||||
return (
|
||||
<PageContainer title="환수감면신청" description="환수 감면 신청·승인·반려 워크플로">
|
||||
{isError && (
|
||||
<Alert type="warning" showIcon message="API 미응답" description="/api/chargeback-waivers 를 확인하세요." style={{ marginBottom: 16 }} />
|
||||
)}
|
||||
|
||||
<SearchForm
|
||||
conditions={[
|
||||
{ type: 'text', name: 'agentName', label: '설계사명', span: 6 },
|
||||
{ type: 'month', name: 'settleMonth', label: '정산월', span: 6 },
|
||||
{ type: 'code', name: 'approvalStatus', label: '승인상태', span: 6, groupCode: 'WAIVER_STATUS' },
|
||||
]}
|
||||
onSearch={(v) => setSearchParams({ ...v as typeof searchParams, pageSize: 200 })}
|
||||
onReset={() => setSearchParams({ settleMonth: dayjs().format('YYYYMM'), pageSize: 200 })}
|
||||
/>
|
||||
|
||||
<ProCard style={cardStyle}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<PermissionButton menuCode="CHARGEBACK_WAIVER" permCode="CREATE" type="primary" onClick={() => setCreateOpen(true)}>
|
||||
+ 감면 신청
|
||||
</PermissionButton>
|
||||
</div>
|
||||
<DataGrid<ChargebackWaiverRow>
|
||||
rows={rows}
|
||||
columns={[
|
||||
...COLS,
|
||||
{
|
||||
headerName: '액션', width: 180, pinned: 'right',
|
||||
cellRenderer: (p: { data: ChargebackWaiverRow }) => (
|
||||
<Space>
|
||||
<PermissionButton
|
||||
menuCode="CHARGEBACK_WAIVER" permCode="UPDATE" size="small"
|
||||
disabled={p.data.approvalStatus !== 'REQUESTED'}
|
||||
onClick={() => handleApprove(p.data)}
|
||||
>
|
||||
승인
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
menuCode="CHARGEBACK_WAIVER" permCode="UPDATE" size="small" danger
|
||||
disabled={p.data.approvalStatus !== 'REQUESTED'}
|
||||
onClick={() => openReject(p.data)}
|
||||
>
|
||||
반려
|
||||
</PermissionButton>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
loading={isLoading}
|
||||
height={520}
|
||||
rowKey="requestId"
|
||||
pinnedBottomRow={pinnedRow}
|
||||
/>
|
||||
</ProCard>
|
||||
|
||||
{/* 신청 모달 */}
|
||||
<Modal
|
||||
title="감면 신청"
|
||||
open={createOpen}
|
||||
onOk={handleCreate}
|
||||
onCancel={() => { setCreateOpen(false); form.resetFields(); }}
|
||||
okText="신청"
|
||||
cancelText="취소"
|
||||
confirmLoading={createMutation.isPending}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="contractId" label="계약 ID" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} />
|
||||
</Form.Item>
|
||||
<Form.Item name="agentId" label="설계사 ID" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} />
|
||||
</Form.Item>
|
||||
<Form.Item name="settleMonth" label="정산월(YYYYMM)" rules={[{ required: true }]}>
|
||||
<Input placeholder="예: 202601" />
|
||||
</Form.Item>
|
||||
<Form.Item name="originalChargeback" label="원 환수액" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={0} />
|
||||
</Form.Item>
|
||||
<Form.Item name="waiverAmount" label="감면 요청액" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={0} />
|
||||
</Form.Item>
|
||||
<Form.Item name="reason" label="사유">
|
||||
<Input.TextArea rows={3} placeholder="감면 사유를 입력하세요" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 반려 사유 모달 */}
|
||||
<Modal
|
||||
title="반려 사유 입력"
|
||||
open={!!rejectTarget}
|
||||
onOk={handleReject}
|
||||
onCancel={() => { setRejectTarget(null); setRejectReason(''); }}
|
||||
okText="반려"
|
||||
okButtonProps={{ danger: true }}
|
||||
cancelText="취소"
|
||||
confirmLoading={rejectMutation.isPending}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
placeholder="반려 사유를 입력하세요"
|
||||
value={rejectReason}
|
||||
onChange={(e) => setRejectReason(e.target.value)}
|
||||
/>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Form, Input, InputNumber, Modal, Space, message } from 'antd';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ColDef } from '@ag-grid-community/core';
|
||||
import PageContainer from '@/components/common/PageContainer';
|
||||
import SearchForm from '@/components/common/SearchForm';
|
||||
import DataGrid from '@/components/common/DataGrid';
|
||||
import PermissionButton from '@/components/common/PermissionButton';
|
||||
import {
|
||||
commissionApi,
|
||||
ClawbackInstallmentRow,
|
||||
ClawbackInstallmentGenerateReq,
|
||||
} from '@/api/commission';
|
||||
import { GRAY, RADIUS, SHADOW } from '@/theme/tokens';
|
||||
|
||||
const fmt = (v: unknown) => (v as number)?.toLocaleString() ?? '-';
|
||||
|
||||
interface SearchParam {
|
||||
receivableId?: number;
|
||||
dueMonth?: string;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
const COLS: ColDef<ClawbackInstallmentRow>[] = [
|
||||
{ field: 'receivableId', headerName: '채권ID', width: 110, pinned: 'left' },
|
||||
{ field: 'installmentNo', headerName: '회차', width: 80, type: 'numericColumn' },
|
||||
{ field: 'installmentAmount', headerName: '분할금액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'dueMonth', headerName: '납부월', width: 110 },
|
||||
{ field: 'status', headerName: '상태', width: 110 },
|
||||
{ field: 'recoveredAt', headerName: '회수일시', width: 160 },
|
||||
];
|
||||
|
||||
export default function ClawbackInstallment() {
|
||||
const qc = useQueryClient();
|
||||
const [searchParams, setSearchParams] = useState<SearchParam>({ pageSize: 200 });
|
||||
const [generateOpen, setGenerateOpen] = useState(false);
|
||||
const [form] = Form.useForm<ClawbackInstallmentGenerateReq>();
|
||||
|
||||
const { data: listData, isLoading, isError } = useQuery({
|
||||
queryKey: ['clawbackInstallment', 'list', searchParams],
|
||||
queryFn: () => commissionApi.clawbackInstallmentList(searchParams),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const rows = listData?.list ?? [];
|
||||
|
||||
const generateMutation = useMutation({
|
||||
mutationFn: (body: ClawbackInstallmentGenerateReq) =>
|
||||
commissionApi.clawbackInstallmentGenerate(body),
|
||||
onSuccess: (result) => {
|
||||
message.success(`분할 계획 ${result.length}건 생성 완료`);
|
||||
qc.invalidateQueries({ queryKey: ['clawbackInstallment', 'list'] });
|
||||
setGenerateOpen(false);
|
||||
form.resetFields();
|
||||
},
|
||||
});
|
||||
|
||||
const cancelMutation = useMutation({
|
||||
mutationFn: (planId: number) => commissionApi.clawbackInstallmentCancel(planId),
|
||||
onSuccess: () => {
|
||||
message.success('취소 완료');
|
||||
qc.invalidateQueries({ queryKey: ['clawbackInstallment', 'list'] });
|
||||
},
|
||||
});
|
||||
|
||||
const handleGenerate = async () => {
|
||||
const values = await form.validateFields();
|
||||
generateMutation.mutate(values);
|
||||
};
|
||||
|
||||
const handleCancel = (row: ClawbackInstallmentRow) => Modal.confirm({
|
||||
title: '회차 취소',
|
||||
content: `채권 ${row.receivableId} / ${row.installmentNo}회차를 취소하시겠습니까?`,
|
||||
onOk: () => cancelMutation.mutateAsync(row.planId),
|
||||
});
|
||||
|
||||
const pinnedRow = rows.length > 0 ? {
|
||||
installmentNo: undefined,
|
||||
installmentAmount: rows.reduce((s, r) => s + (r.installmentAmount ?? 0), 0),
|
||||
dueMonth: '합계',
|
||||
} as Partial<ClawbackInstallmentRow> : undefined;
|
||||
|
||||
const cardStyle = { background: '#fff', borderRadius: RADIUS.lg, border: `1px solid ${GRAY[100]}`, boxShadow: SHADOW.sm };
|
||||
|
||||
return (
|
||||
<PageContainer title="환수분할상환" description="대액 환수채권 분할 납부 계획 관리">
|
||||
{isError && (
|
||||
<Alert type="warning" showIcon message="API 미응답" description="/api/clawback-installments 를 확인하세요." style={{ marginBottom: 16 }} />
|
||||
)}
|
||||
|
||||
<SearchForm
|
||||
conditions={[
|
||||
{ type: 'text', name: 'receivableId', label: '채권ID', span: 6 },
|
||||
{ type: 'month', name: 'dueMonth', label: '납부월', span: 6 },
|
||||
]}
|
||||
onSearch={(v) => setSearchParams({ ...v as SearchParam, pageSize: 200 })}
|
||||
onReset={() => setSearchParams({ pageSize: 200 })}
|
||||
/>
|
||||
|
||||
<ProCard style={cardStyle}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<PermissionButton menuCode="CLAWBACK_INSTALLMENT" permCode="CREATE" type="primary" onClick={() => setGenerateOpen(true)}>
|
||||
+ 분할 계획 생성
|
||||
</PermissionButton>
|
||||
</div>
|
||||
<DataGrid<ClawbackInstallmentRow>
|
||||
rows={rows}
|
||||
columns={[
|
||||
...COLS,
|
||||
{
|
||||
headerName: '액션', width: 100, pinned: 'right',
|
||||
cellRenderer: (p: { data: ClawbackInstallmentRow }) => (
|
||||
<Space>
|
||||
<PermissionButton
|
||||
menuCode="CLAWBACK_INSTALLMENT" permCode="UPDATE" size="small" danger
|
||||
disabled={p.data.status !== 'SCHEDULED'}
|
||||
onClick={() => handleCancel(p.data)}
|
||||
>
|
||||
취소
|
||||
</PermissionButton>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
loading={isLoading}
|
||||
height={520}
|
||||
rowKey="planId"
|
||||
pinnedBottomRow={pinnedRow}
|
||||
/>
|
||||
</ProCard>
|
||||
|
||||
<Modal
|
||||
title="분할 계획 생성"
|
||||
open={generateOpen}
|
||||
onOk={handleGenerate}
|
||||
onCancel={() => { setGenerateOpen(false); form.resetFields(); }}
|
||||
okText="생성"
|
||||
cancelText="취소"
|
||||
confirmLoading={generateMutation.isPending}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="receivableId" label="채권 ID" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} placeholder="환수채권 ID" />
|
||||
</Form.Item>
|
||||
<Form.Item name="installmentCount" label="분할 회차수" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={2} max={60} placeholder="예: 12" />
|
||||
</Form.Item>
|
||||
<Form.Item name="startMonth" label="시작월(YYYYMM)" rules={[{ required: true }]}>
|
||||
<Input placeholder="예: 202602" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Form, Input, InputNumber, Modal, Select, Space, Tabs, message } from 'antd';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ColDef } from '@ag-grid-community/core';
|
||||
import dayjs from 'dayjs';
|
||||
import PageContainer from '@/components/common/PageContainer';
|
||||
import SearchForm from '@/components/common/SearchForm';
|
||||
import DataGrid from '@/components/common/DataGrid';
|
||||
import PermissionButton from '@/components/common/PermissionButton';
|
||||
import {
|
||||
commissionApi,
|
||||
LapsedReinstatementRow,
|
||||
LapsedReinstatementSaveReq,
|
||||
CommissionSearchParam,
|
||||
} from '@/api/commission';
|
||||
import { GRAY, RADIUS, SHADOW } from '@/theme/tokens';
|
||||
|
||||
const fmt = (v: unknown) => (v as number)?.toLocaleString() ?? '-';
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: 'PENDING', label: '대기' },
|
||||
{ value: 'REPAID', label: '재지급완료' },
|
||||
{ value: 'CANCELLED', label: '취소' },
|
||||
];
|
||||
|
||||
const COLS: ColDef<LapsedReinstatementRow>[] = [
|
||||
{ field: 'reinstatedMonth', headerName: '부활월', width: 110, pinned: 'left' },
|
||||
{ field: 'agentName', headerName: '설계사', width: 130 },
|
||||
{ field: 'contractNo', headerName: '증권번호', width: 140 },
|
||||
{ field: 'lapsedMonth', headerName: '실효월', width: 110 },
|
||||
{ field: 'withheldAmount', headerName: '보류액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'repaidAmount', headerName: '재지급액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'status', headerName: '상태', width: 110 },
|
||||
];
|
||||
|
||||
export default function LapsedReinstatement() {
|
||||
const qc = useQueryClient();
|
||||
const [searchParams, setSearchParams] = useState<CommissionSearchParam & { status?: string }>({
|
||||
settleMonth: dayjs().format('YYYYMM'), pageSize: 200,
|
||||
});
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [form] = Form.useForm<LapsedReinstatementSaveReq>();
|
||||
|
||||
const { data: listData, isLoading, isError } = useQuery({
|
||||
queryKey: ['lapsedReinstatement', 'list', searchParams],
|
||||
queryFn: () => commissionApi.lapsedReinstatementList(searchParams),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const rows = listData?.list ?? [];
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (body: LapsedReinstatementSaveReq) => commissionApi.lapsedReinstatementCreate(body),
|
||||
onSuccess: () => {
|
||||
message.success('등록 완료');
|
||||
qc.invalidateQueries({ queryKey: ['lapsedReinstatement', 'list'] });
|
||||
setCreateOpen(false);
|
||||
form.resetFields();
|
||||
},
|
||||
});
|
||||
|
||||
const repayMutation = useMutation({
|
||||
mutationFn: (recoveryId: number) => commissionApi.lapsedReinstatementRepay(recoveryId),
|
||||
onSuccess: () => {
|
||||
message.success('재지급 처리 완료');
|
||||
qc.invalidateQueries({ queryKey: ['lapsedReinstatement', 'list'] });
|
||||
},
|
||||
});
|
||||
|
||||
const cancelMutation = useMutation({
|
||||
mutationFn: (recoveryId: number) => commissionApi.lapsedReinstatementCancel(recoveryId),
|
||||
onSuccess: () => {
|
||||
message.success('취소 완료');
|
||||
qc.invalidateQueries({ queryKey: ['lapsedReinstatement', 'list'] });
|
||||
},
|
||||
});
|
||||
|
||||
const handleCreate = async () => {
|
||||
const values = await form.validateFields();
|
||||
createMutation.mutate(values);
|
||||
};
|
||||
|
||||
const handleRepay = (row: LapsedReinstatementRow) => Modal.confirm({
|
||||
title: '재지급 처리',
|
||||
content: `${row.agentName} 보류액 ${fmt(row.withheldAmount)}원을 재지급 처리하시겠습니까?`,
|
||||
onOk: () => repayMutation.mutateAsync(row.recoveryId),
|
||||
});
|
||||
|
||||
const handleCancel = (row: LapsedReinstatementRow) => Modal.confirm({
|
||||
title: '취소',
|
||||
content: '해당 부활 재지급 건을 취소하시겠습니까?',
|
||||
onOk: () => cancelMutation.mutateAsync(row.recoveryId),
|
||||
});
|
||||
|
||||
const pinnedRow = rows.length > 0 ? {
|
||||
agentName: '합계',
|
||||
withheldAmount: rows.reduce((s, r) => s + (r.withheldAmount ?? 0), 0),
|
||||
repaidAmount: rows.reduce((s, r) => s + (r.repaidAmount ?? 0), 0),
|
||||
} as Partial<LapsedReinstatementRow> : undefined;
|
||||
|
||||
const cardStyle = { background: '#fff', borderRadius: RADIUS.lg, border: `1px solid ${GRAY[100]}`, boxShadow: SHADOW.sm };
|
||||
|
||||
return (
|
||||
<PageContainer title="익월부활재지급" description="실효 계약 부활 시 보류 수수료 재지급 관리">
|
||||
{isError && (
|
||||
<Alert type="warning" showIcon message="API 미응답" description="/api/lapsed-reinstatements 를 확인하세요." style={{ marginBottom: 16 }} />
|
||||
)}
|
||||
|
||||
<SearchForm
|
||||
conditions={[
|
||||
{ type: 'text', name: 'agentName', label: '설계사명', span: 6 },
|
||||
{ type: 'month', name: 'settleMonth', label: '부활월', span: 6 },
|
||||
{ type: 'code', name: 'status', label: '상태', span: 6, groupCode: 'LAPSE_RECOVERY_STATUS' },
|
||||
]}
|
||||
onSearch={(v) => setSearchParams({ ...v as typeof searchParams, pageSize: 200 })}
|
||||
onReset={() => setSearchParams({ settleMonth: dayjs().format('YYYYMM'), pageSize: 200 })}
|
||||
/>
|
||||
|
||||
<ProCard style={cardStyle}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<PermissionButton menuCode="LAPSED_REINSTATEMENT" permCode="CREATE" type="primary" onClick={() => setCreateOpen(true)}>
|
||||
+ 부활 등록
|
||||
</PermissionButton>
|
||||
</div>
|
||||
<DataGrid<LapsedReinstatementRow>
|
||||
rows={rows}
|
||||
columns={[
|
||||
...COLS,
|
||||
{
|
||||
headerName: '액션', width: 180, pinned: 'right',
|
||||
cellRenderer: (p: { data: LapsedReinstatementRow }) => (
|
||||
<Space>
|
||||
<PermissionButton
|
||||
menuCode="LAPSED_REINSTATEMENT" permCode="UPDATE" size="small"
|
||||
disabled={p.data.status !== 'PENDING'}
|
||||
onClick={() => handleRepay(p.data)}
|
||||
>
|
||||
재지급
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
menuCode="LAPSED_REINSTATEMENT" permCode="UPDATE" size="small" danger
|
||||
disabled={p.data.status !== 'PENDING'}
|
||||
onClick={() => handleCancel(p.data)}
|
||||
>
|
||||
취소
|
||||
</PermissionButton>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
loading={isLoading}
|
||||
height={520}
|
||||
rowKey="recoveryId"
|
||||
pinnedBottomRow={pinnedRow}
|
||||
/>
|
||||
</ProCard>
|
||||
|
||||
<Modal
|
||||
title="부활 재지급 등록"
|
||||
open={createOpen}
|
||||
onOk={handleCreate}
|
||||
onCancel={() => { setCreateOpen(false); form.resetFields(); }}
|
||||
okText="등록"
|
||||
cancelText="취소"
|
||||
confirmLoading={createMutation.isPending}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="contractId" label="계약 ID" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} />
|
||||
</Form.Item>
|
||||
<Form.Item name="agentId" label="설계사 ID" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} />
|
||||
</Form.Item>
|
||||
<Form.Item name="lapsedMonth" label="실효월(YYYYMM)" rules={[{ required: true }]}>
|
||||
<Input placeholder="예: 202511" />
|
||||
</Form.Item>
|
||||
<Form.Item name="reinstatedMonth" label="부활월(YYYYMM)" rules={[{ required: true }]}>
|
||||
<Input placeholder="예: 202512" />
|
||||
</Form.Item>
|
||||
<Form.Item name="withheldAmount" label="보류액" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={0} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Form, Input, InputNumber, Modal, Select, Space, Tabs, message } from 'antd';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ColDef } from '@ag-grid-community/core';
|
||||
import dayjs from 'dayjs';
|
||||
import PageContainer from '@/components/common/PageContainer';
|
||||
import SearchForm from '@/components/common/SearchForm';
|
||||
import DataGrid from '@/components/common/DataGrid';
|
||||
import PermissionButton from '@/components/common/PermissionButton';
|
||||
import {
|
||||
commissionApi,
|
||||
RecruiterRuleRow,
|
||||
RecruiterLedgerRow,
|
||||
CommissionSearchParam,
|
||||
} from '@/api/commission';
|
||||
import { GRAY, RADIUS, SHADOW } from '@/theme/tokens';
|
||||
|
||||
const fmt = (v: unknown) => (v as number)?.toLocaleString() ?? '-';
|
||||
|
||||
const RECRUITER_TYPE_OPTIONS = [
|
||||
{ value: 'NEW_RECRUIT', label: '신인도입' },
|
||||
{ value: 'DEVELOPMENT', label: '육성' },
|
||||
{ value: 'TRAINING', label: '교육' },
|
||||
];
|
||||
|
||||
const RULE_COLS: ColDef<RecruiterRuleRow>[] = [
|
||||
{ field: 'recruiterType', headerName: '유형', width: 120 },
|
||||
{ field: 'calcType', headerName: '계산방식', width: 110 },
|
||||
{ field: 'commissionRate', headerName: '수수료율', width: 110, type: 'numericColumn' },
|
||||
{ field: 'fixedAmount', headerName: '정액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'effectiveFrom', headerName: '적용시작', width: 120 },
|
||||
{ field: 'effectiveTo', headerName: '적용종료', width: 120 },
|
||||
];
|
||||
|
||||
const LEDGER_COLS: ColDef<RecruiterLedgerRow>[] = [
|
||||
{ field: 'settleMonth', headerName: '정산월', width: 110, pinned: 'left' },
|
||||
{ field: 'recruiterAgentName', headerName: '도입자', width: 130 },
|
||||
{ field: 'recruitAgentName', headerName: '피도입자', width: 130 },
|
||||
{ field: 'recruiterType', headerName: '유형', width: 110 },
|
||||
{ field: 'baseAmount', headerName: '기준금액', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'commissionAmount', headerName: '수수료', flex: 1, type: 'numericColumn', valueFormatter: (p) => fmt(p.value) },
|
||||
{ field: 'status', headerName: '상태', width: 110 },
|
||||
];
|
||||
|
||||
export default function RecruiterCommission() {
|
||||
const qc = useQueryClient();
|
||||
const [ledgerParams, setLedgerParams] = useState<CommissionSearchParam>({
|
||||
settleMonth: dayjs().format('YYYYMM'), pageSize: 200,
|
||||
});
|
||||
const [ruleModalOpen, setRuleModalOpen] = useState(false);
|
||||
const [editingRule, setEditingRule] = useState<RecruiterRuleRow | null>(null);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const { data: rulesData, isLoading: rulesLoading, isError: rulesError } = useQuery({
|
||||
queryKey: ['recruiterCommission', 'rules'],
|
||||
queryFn: () => commissionApi.recruiterRules(),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const { data: ledgersData, isLoading: ledgersLoading } = useQuery({
|
||||
queryKey: ['recruiterCommission', 'ledgers', ledgerParams],
|
||||
queryFn: () => commissionApi.recruiterLedgers(ledgerParams),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const rules = rulesData?.list ?? [];
|
||||
const ledgers = ledgersData?.list ?? [];
|
||||
|
||||
const saveMutation = useMutation({
|
||||
mutationFn: async (values: Partial<RecruiterRuleRow>) => {
|
||||
if (editingRule) {
|
||||
return commissionApi.recruiterRuleUpdate(editingRule.ruleId, values);
|
||||
}
|
||||
return commissionApi.recruiterRuleCreate(values);
|
||||
},
|
||||
onSuccess: () => {
|
||||
message.success(editingRule ? '수정 완료' : '등록 완료');
|
||||
qc.invalidateQueries({ queryKey: ['recruiterCommission', 'rules'] });
|
||||
setRuleModalOpen(false);
|
||||
},
|
||||
});
|
||||
|
||||
const openCreate = () => { setEditingRule(null); form.resetFields(); setRuleModalOpen(true); };
|
||||
const openEdit = (row: RecruiterRuleRow) => { setEditingRule(row); form.setFieldsValue(row); setRuleModalOpen(true); };
|
||||
|
||||
const handleSave = async () => {
|
||||
const values = await form.validateFields();
|
||||
saveMutation.mutate(values);
|
||||
};
|
||||
|
||||
const handleDelete = (id: number) => Modal.confirm({
|
||||
title: '룰 삭제', content: '삭제하시겠습니까?',
|
||||
onOk: async () => {
|
||||
await commissionApi.recruiterRuleDelete(id);
|
||||
message.success('삭제 완료');
|
||||
qc.invalidateQueries({ queryKey: ['recruiterCommission', 'rules'] });
|
||||
},
|
||||
});
|
||||
|
||||
const pinnedLedger = ledgers.length > 0 ? {
|
||||
recruiterAgentName: '합계',
|
||||
baseAmount: ledgers.reduce((s, r) => s + (r.baseAmount ?? 0), 0),
|
||||
commissionAmount: ledgers.reduce((s, r) => s + (r.commissionAmount ?? 0), 0),
|
||||
} as Partial<RecruiterLedgerRow> : undefined;
|
||||
|
||||
const cardStyle = { background: '#fff', borderRadius: RADIUS.lg, border: `1px solid ${GRAY[100]}`, boxShadow: SHADOW.sm };
|
||||
|
||||
return (
|
||||
<PageContainer title="도입수수료" description="슈퍼바이저/도입수수료 룰 관리 및 원장 조회">
|
||||
{rulesError && (
|
||||
<Alert type="warning" showIcon message="API 미응답" description="/api/recruiter-commissions 를 확인하세요." style={{ marginBottom: 16 }} />
|
||||
)}
|
||||
|
||||
<Tabs
|
||||
defaultActiveKey="rules"
|
||||
items={[
|
||||
{
|
||||
key: 'rules',
|
||||
label: '도입 룰',
|
||||
children: (
|
||||
<ProCard style={cardStyle}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<PermissionButton menuCode="RECRUITER_COMM" permCode="CREATE" type="primary" onClick={openCreate}>
|
||||
+ 룰 등록
|
||||
</PermissionButton>
|
||||
</div>
|
||||
<DataGrid<RecruiterRuleRow>
|
||||
rows={rules}
|
||||
columns={[
|
||||
...RULE_COLS,
|
||||
{
|
||||
headerName: '액션', width: 160, pinned: 'right',
|
||||
cellRenderer: (p: { data: RecruiterRuleRow }) => (
|
||||
<Space>
|
||||
<PermissionButton menuCode="RECRUITER_COMM" permCode="UPDATE" size="small" onClick={() => openEdit(p.data)}>수정</PermissionButton>
|
||||
<PermissionButton menuCode="RECRUITER_COMM" permCode="DELETE" size="small" danger onClick={() => handleDelete(p.data.ruleId)}>삭제</PermissionButton>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
loading={rulesLoading}
|
||||
height={520}
|
||||
rowKey="ruleId"
|
||||
/>
|
||||
</ProCard>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'ledgers',
|
||||
label: '원장',
|
||||
children: (
|
||||
<>
|
||||
<SearchForm
|
||||
conditions={[
|
||||
{ type: 'text', name: 'agentName', label: '도입자명', span: 6 },
|
||||
{ type: 'month', name: 'settleMonth', label: '정산월', span: 6 },
|
||||
]}
|
||||
onSearch={(v) => setLedgerParams({ ...v as CommissionSearchParam, pageSize: 200 })}
|
||||
onReset={() => setLedgerParams({ settleMonth: dayjs().format('YYYYMM'), pageSize: 200 })}
|
||||
/>
|
||||
<ProCard style={cardStyle}>
|
||||
<DataGrid<RecruiterLedgerRow>
|
||||
rows={ledgers}
|
||||
columns={LEDGER_COLS}
|
||||
loading={ledgersLoading}
|
||||
height={520}
|
||||
rowKey="ledgerId"
|
||||
pinnedBottomRow={pinnedLedger}
|
||||
/>
|
||||
</ProCard>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={editingRule ? '룰 수정' : '룰 등록'}
|
||||
open={ruleModalOpen}
|
||||
onOk={handleSave}
|
||||
onCancel={() => setRuleModalOpen(false)}
|
||||
okText="저장"
|
||||
cancelText="취소"
|
||||
confirmLoading={saveMutation.isPending}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="recruiterType" label="유형" rules={[{ required: true }]}>
|
||||
<Select options={RECRUITER_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="calcType" label="계산방식" rules={[{ required: true }]}>
|
||||
<Select options={[{ value: 'RATE', label: '정률' }, { value: 'FIXED', label: '정액' }]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="commissionRate" label="수수료율(0~1)">
|
||||
<InputNumber style={{ width: '100%' }} min={0} max={1} step={0.0001} />
|
||||
</Form.Item>
|
||||
<Form.Item name="fixedAmount" label="정액">
|
||||
<InputNumber style={{ width: '100%' }} min={0} />
|
||||
</Form.Item>
|
||||
<Form.Item name="effectiveFrom" label="적용시작" rules={[{ required: true }]}>
|
||||
<Input placeholder="YYYY-MM-DD" />
|
||||
</Form.Item>
|
||||
<Form.Item name="effectiveTo" label="적용종료">
|
||||
<Input placeholder="YYYY-MM-DD" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Descriptions, Form, Input, InputNumber, Modal, Space, message } from 'antd';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ColDef } from '@ag-grid-community/core';
|
||||
import dayjs from 'dayjs';
|
||||
import PageContainer from '@/components/common/PageContainer';
|
||||
import DataGrid from '@/components/common/DataGrid';
|
||||
import PermissionButton from '@/components/common/PermissionButton';
|
||||
import { commissionApi, StatuteConfigRow } from '@/api/commission';
|
||||
import { GRAY, RADIUS, SHADOW } from '@/theme/tokens';
|
||||
|
||||
const COLS: ColDef<StatuteConfigRow>[] = [
|
||||
{ field: 'entityType', headerName: '대상유형', width: 200 },
|
||||
{ field: 'expirationMonths', headerName: '시효(개월)', width: 130, type: 'numericColumn' },
|
||||
{ field: 'isActive', headerName: '활성', width: 80 },
|
||||
];
|
||||
|
||||
export default function StatuteConfig() {
|
||||
const qc = useQueryClient();
|
||||
const [editTarget, setEditTarget] = useState<StatuteConfigRow | null>(null);
|
||||
const [expireMonth, setExpireMonth] = useState(dayjs().format('YYYYMM'));
|
||||
const [expireResult, setExpireResult] = useState<{ expiredCount: number } | null>(null);
|
||||
const [form] = Form.useForm<Partial<StatuteConfigRow>>();
|
||||
|
||||
const { data: configData, isLoading, isError } = useQuery({
|
||||
queryKey: ['statuteConfig', 'list'],
|
||||
queryFn: () => commissionApi.statuteConfigs(),
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const rows = configData?.list ?? [];
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: ({ configId, values }: { configId: number; values: Partial<StatuteConfigRow> }) =>
|
||||
commissionApi.statuteConfigUpdate(configId, values),
|
||||
onSuccess: () => {
|
||||
message.success('설정 수정 완료');
|
||||
qc.invalidateQueries({ queryKey: ['statuteConfig', 'list'] });
|
||||
setEditTarget(null);
|
||||
},
|
||||
});
|
||||
|
||||
const expireMutation = useMutation({
|
||||
mutationFn: (baseMonth: string) => commissionApi.statuteExpire(baseMonth),
|
||||
onSuccess: (result) => {
|
||||
setExpireResult(result);
|
||||
message.success(`만료 처리 완료 — ${result.expiredCount}건`);
|
||||
qc.invalidateQueries({ queryKey: ['statuteConfig', 'list'] });
|
||||
},
|
||||
});
|
||||
|
||||
const handleUpdate = async () => {
|
||||
const values = await form.validateFields();
|
||||
updateMutation.mutate({ configId: editTarget!.configId, values });
|
||||
};
|
||||
|
||||
const openEdit = (row: StatuteConfigRow) => {
|
||||
setEditTarget(row);
|
||||
form.setFieldsValue({
|
||||
expirationMonths: row.expirationMonths,
|
||||
isActive: row.isActive,
|
||||
});
|
||||
};
|
||||
|
||||
const handleExpire = () => Modal.confirm({
|
||||
title: '만료 실행',
|
||||
content: `기준월 ${expireMonth} 기준으로 시효 만료된 채권을 WRITTEN_OFF 처리합니다. 계속하시겠습니까?`,
|
||||
okType: 'danger',
|
||||
onOk: () => expireMutation.mutateAsync(expireMonth),
|
||||
});
|
||||
|
||||
const cardStyle = { background: '#fff', borderRadius: RADIUS.lg, border: `1px solid ${GRAY[100]}`, boxShadow: SHADOW.sm };
|
||||
|
||||
return (
|
||||
<PageContainer title="환수시효관리" description="환수채권 시효 설정 및 만료 실행">
|
||||
{isError && (
|
||||
<Alert type="warning" showIcon message="API 미응답" description="/api/statute 를 확인하세요." style={{ marginBottom: 16 }} />
|
||||
)}
|
||||
|
||||
<ProCard style={{ ...cardStyle, marginBottom: 16 }} title="시효 설정">
|
||||
<DataGrid<StatuteConfigRow>
|
||||
rows={rows}
|
||||
columns={[
|
||||
...COLS,
|
||||
{
|
||||
headerName: '액션', width: 100, pinned: 'right',
|
||||
cellRenderer: (p: { data: StatuteConfigRow }) => (
|
||||
<PermissionButton
|
||||
menuCode="STATUTE_CONFIG" permCode="UPDATE" size="small"
|
||||
onClick={() => openEdit(p.data)}
|
||||
>
|
||||
수정
|
||||
</PermissionButton>
|
||||
),
|
||||
},
|
||||
]}
|
||||
loading={isLoading}
|
||||
height={200}
|
||||
rowKey="configId"
|
||||
/>
|
||||
</ProCard>
|
||||
|
||||
<ProCard style={cardStyle} title="만료 실행">
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<span>기준월:</span>
|
||||
<Input
|
||||
value={expireMonth}
|
||||
onChange={(e) => setExpireMonth(e.target.value)}
|
||||
placeholder="YYYYMM"
|
||||
style={{ width: 120 }}
|
||||
/>
|
||||
<PermissionButton
|
||||
menuCode="STATUTE_CONFIG" permCode="UPDATE"
|
||||
type="primary" danger
|
||||
loading={expireMutation.isPending}
|
||||
onClick={handleExpire}
|
||||
>
|
||||
만료 실행
|
||||
</PermissionButton>
|
||||
</Space>
|
||||
{expireResult && (
|
||||
<Descriptions size="small" bordered>
|
||||
<Descriptions.Item label="처리 결과">
|
||||
{expireResult.expiredCount}건이 WRITTEN_OFF 처리되었습니다.
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)}
|
||||
</Space>
|
||||
</ProCard>
|
||||
|
||||
<Modal
|
||||
title="시효 설정 수정"
|
||||
open={!!editTarget}
|
||||
onOk={handleUpdate}
|
||||
onCancel={() => setEditTarget(null)}
|
||||
okText="저장"
|
||||
cancelText="취소"
|
||||
confirmLoading={updateMutation.isPending}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="expirationMonths" label="시효 개월수" rules={[{ required: true }]}>
|
||||
<InputNumber style={{ width: '100%' }} min={1} max={120} />
|
||||
</Form.Item>
|
||||
<Form.Item name="isActive" label="활성(Y/N)" rules={[{ required: true }]}>
|
||||
<Input placeholder="Y 또는 N" maxLength={1} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user