- api/agent: 정산 상세 조회 API 다수 추가(라이브/콘텐츠/커뮤니티/콘텐츠·채널 후원) - 공통 파라미터 빌더 및 1→0 기반 페이지 변환 유틸 도입으로 Spring Pageable 규약 준수 - 정산 상세 뷰(라이브/콘텐츠/커뮤니티/콘텐츠 후원/채널 후원): 닉네임 표시, 페이지·정렬 파라미터 적용 - 로딩/에러/빈 결과 초기화 처리 강화, 합계 초기화로 실패 시 데이터 오해 방지 - AgentList: 정산 상세 라우팅 시 닉네임 query 전달로 상단 타이틀 표시 개선
146 lines
5.4 KiB
JavaScript
146 lines
5.4 KiB
JavaScript
import Vue from 'vue'
|
|
|
|
// 공통: 페이지 파라미터 변환(1-based UI → 0-based Spring Pageable)
|
|
function toZeroBased(page) {
|
|
const p = Number(page || 1)
|
|
return Math.max(0, p - 1)
|
|
}
|
|
|
|
// 에이전트 리스트 조회
|
|
// 서버 스펙에 페이지네이션이 없다면 단순 GET으로 사용
|
|
// 추후 필요 시 params(page,size) 확장 가능
|
|
async function getAgentList() {
|
|
return Vue.axios.get('/admin/partner/agent/list')
|
|
}
|
|
|
|
// 에이전트 정산 비율 목록 조회
|
|
async function getAgentSettlementRatioList() {
|
|
return Vue.axios.get('/admin/partner/agent/ratio')
|
|
}
|
|
|
|
// 에이전트 정산 비율 등록
|
|
// payload: { memberId: number, settlementRatio: number, effectiveFrom: string(yyyy-MM-ddTHH:mm:ss) }
|
|
async function createAgentSettlementRatio(payload) {
|
|
return Vue.axios.post('/admin/partner/agent/ratio', payload)
|
|
}
|
|
|
|
// 에이전트 정산 비율 수정
|
|
// payload: { memberId: number, settlementRatio: number, effectiveFrom: string(yyyy-MM-ddTHH:mm:ss) }
|
|
async function updateAgentSettlementRatio(payload) {
|
|
return Vue.axios.post('/admin/partner/agent/ratio/update', payload)
|
|
}
|
|
|
|
// 에이전트 닉네임 검색
|
|
// 반환: [{ id, nickname }]
|
|
async function searchAgentByNickname(query) {
|
|
try {
|
|
const res = await Vue.axios.get('/admin/partner/agent/search-by-nickname', {
|
|
params: { nickname: query, search_word: query }
|
|
})
|
|
if (res && Array.isArray(res.data)) return res.data
|
|
if (res && res.data && Array.isArray(res.data.data)) return res.data.data
|
|
return []
|
|
} catch (e) {
|
|
return []
|
|
}
|
|
}
|
|
|
|
// 에이전트 소속 크리에이터 목록 조회
|
|
// GET /admin/partner/agent/{agentId}/creator/list
|
|
// params: { page, size }
|
|
async function getAgentAssignedCreatorList(agentId, page = 1, size = 20) {
|
|
// Spring Pageable은 일반적으로 0-based page index를 사용
|
|
const zeroBasedPage = Math.max(0, Number(page || 1) - 1)
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/creator/list`, {
|
|
params: { page: zeroBasedPage, size }
|
|
})
|
|
}
|
|
|
|
// 추가 가능한 크리에이터 검색
|
|
// GET /admin/partner/agent/creator/search?search_word=...
|
|
async function searchAdminAgentAssignableCreators(search_word) {
|
|
return Vue.axios.get('/admin/partner/agent/creator/search', {
|
|
params: { search_word }
|
|
})
|
|
}
|
|
|
|
// 에이전트에 크리에이터 소속 시키기
|
|
// POST /admin/partner/agent/assignment
|
|
// payload: { agentId, creatorId, assignedAt } // assignedAt: LocalDateTime string (yyyy-MM-ddTHH:mm:ss)
|
|
async function assignAgentCreator(payload) {
|
|
return Vue.axios.post('/admin/partner/agent/assignment', payload)
|
|
}
|
|
|
|
// 크리에이터 소속 해제
|
|
// POST /admin/partner/agent/assignment/remove
|
|
// payload: { creatorId, unassignedAt } // unassignedAt: LocalDateTime string
|
|
async function removeAgentCreator(payload) {
|
|
return Vue.axios.post('/admin/partner/agent/assignment/remove', payload)
|
|
}
|
|
|
|
// =========================
|
|
// 정산 상세 - 에이전트별(크리에이터 기준 집계)
|
|
// 공통 Request: startDateStr, endDateStr, Spring Pageable(page,size,sort)
|
|
// 공통 Response: ApiResponse<GetAgentSettlementByCreatorResponse>
|
|
// { success, message, data: { totalCount, total:{...}, items:[...] } }
|
|
|
|
function buildSettlementParams({ startDateStr, endDateStr, page = 1, size = 20, sort }) {
|
|
const params = {
|
|
startDateStr,
|
|
endDateStr,
|
|
page: toZeroBased(page),
|
|
size
|
|
}
|
|
if (sort) params.sort = sort
|
|
return params
|
|
}
|
|
|
|
async function getAgentLiveSettlementByCreator(agentId, { startDateStr, endDateStr, page = 1, size = 20, sort } = {}) {
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/calculate/live-by-creator`, {
|
|
params: buildSettlementParams({ startDateStr, endDateStr, page, size, sort })
|
|
})
|
|
}
|
|
|
|
async function getAgentContentSettlementByCreator(agentId, { startDateStr, endDateStr, page = 1, size = 20, sort } = {}) {
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/calculate/content-by-creator`, {
|
|
params: buildSettlementParams({ startDateStr, endDateStr, page, size, sort })
|
|
})
|
|
}
|
|
|
|
async function getAgentCommunitySettlementByCreator(agentId, { startDateStr, endDateStr, page = 1, size = 20, sort } = {}) {
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/calculate/community-by-creator`, {
|
|
params: buildSettlementParams({ startDateStr, endDateStr, page, size, sort })
|
|
})
|
|
}
|
|
|
|
async function getAgentContentDonationSettlementByCreator(agentId, { startDateStr, endDateStr, page = 1, size = 20, sort } = {}) {
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/calculate/content-donation-by-creator`, {
|
|
params: buildSettlementParams({ startDateStr, endDateStr, page, size, sort })
|
|
})
|
|
}
|
|
|
|
async function getAgentChannelDonationSettlementByCreator(agentId, { startDateStr, endDateStr, page = 1, size = 20, sort } = {}) {
|
|
return Vue.axios.get(`/admin/partner/agent/${agentId}/calculate/channel-donation-by-creator`, {
|
|
params: buildSettlementParams({ startDateStr, endDateStr, page, size, sort })
|
|
})
|
|
}
|
|
|
|
export {
|
|
getAgentList,
|
|
getAgentSettlementRatioList,
|
|
createAgentSettlementRatio,
|
|
updateAgentSettlementRatio,
|
|
searchAgentByNickname,
|
|
// 에이전트 상세 - 소속 크리에이터 관리
|
|
getAgentAssignedCreatorList,
|
|
searchAdminAgentAssignableCreators,
|
|
assignAgentCreator,
|
|
removeAgentCreator,
|
|
// 에이전트 정산 상세 (크리에이터 기준)
|
|
getAgentLiveSettlementByCreator,
|
|
getAgentContentSettlementByCreator,
|
|
getAgentCommunitySettlementByCreator,
|
|
getAgentContentDonationSettlementByCreator,
|
|
getAgentChannelDonationSettlementByCreator,
|
|
}
|