fix(original-series-calculate): 소지 유저별 정산 엑셀 시트 생성을 정리한다

This commit is contained in:
2026-04-21 19:16:34 +09:00
parent 72f49f2471
commit 49b1aa8f0c
2 changed files with 33 additions and 16 deletions

View File

@@ -22,14 +22,14 @@ class AdminOriginalSeriesCalculateService(
fun getSettlementDetails(
startDateStr: String,
endDateStr: String,
memberId: Long,
creatorId: Long,
offset: Long,
limit: Long
): GetAdminOriginalSeriesSettlementDetailListResponse {
val (startDate, endDate) = toDateRange(startDateStr, endDateStr)
val totalCount = repository.getSettlementDetailTotalCount(startDate, endDate, memberId)
val totalCount = repository.getSettlementDetailTotalCount(startDate, endDate, creatorId)
val items = repository
.getSettlementDetails(startDate, endDate, memberId, offset, limit)
.getSettlementDetails(startDate, endDate, creatorId, offset, limit)
.map { it.toResponse() }
return GetAdminOriginalSeriesSettlementDetailListResponse(totalCount, items)
@@ -43,18 +43,16 @@ class AdminOriginalSeriesCalculateService(
return StreamingResponseBody { outputStream ->
val workbook = SXSSFWorkbook(100)
try {
if (owners.isEmpty()) {
writeHeaders(workbook.createSheet("오리지널 시리즈 정산"))
} else {
if (owners.isNotEmpty()) {
owners.forEach { owner ->
val sheet = workbook.createSheet(toSheetName(owner))
writeHeaders(sheet)
val totalCount = repository.getSettlementDetailTotalCount(startDate, endDate, owner.memberId)
val totalCount = repository.getSettlementDetailTotalCount(startDate, endDate, owner.creatorId)
val items = if (totalCount == 0) {
emptyList()
} else {
repository.getSettlementDetails(startDate, endDate, owner.memberId, 0L, totalCount.toLong())
repository.getSettlementDetails(startDate, endDate, owner.creatorId, 0L, totalCount.toLong())
.map { it.toResponse() }
}
@@ -92,7 +90,7 @@ class AdminOriginalSeriesCalculateService(
}
private fun toSheetName(owner: GetAdminOriginalSeriesOwnerResponse): String {
return WorkbookUtil.createSafeSheetName("${owner.memberId}_${owner.nickname}")
return WorkbookUtil.createSafeSheetName(owner.nickname)
}
private fun toDateRange(startDateStr: String, endDateStr: String): Pair<LocalDateTime, LocalDateTime> {