-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from Nexters/feature/Boolti-235
Feature/boolti 235 티켓 N매 구현
- Loading branch information
Showing
28 changed files
with
1,142 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
data/src/main/java/com/nexters/boolti/data/network/response/TicketGroupDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.nexters.boolti.data.network.response | ||
|
||
|
||
import com.nexters.boolti.data.util.toLocalDateTime | ||
import com.nexters.boolti.domain.model.TicketGroup | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import java.time.LocalDateTime | ||
|
||
@Serializable | ||
internal data class TicketsDto( | ||
@SerialName("userId") | ||
val userId: String? = null, | ||
@SerialName("reservationId") | ||
val reservationId: String? = null, | ||
@SerialName("showName") | ||
val showName: String? = null, | ||
@SerialName("placeName") | ||
val placeName: String? = null, | ||
@SerialName("showDate") | ||
val showDate: String? = null, | ||
@SerialName("showImgPath") | ||
val showImgPath: String? = null, | ||
@SerialName("ticketType") | ||
val ticketType: String? = null, | ||
@SerialName("ticketName") | ||
val ticketName: String? = null, | ||
@SerialName("ticketCount") | ||
val ticketCount: Int? = null, | ||
) { | ||
fun toDomain(): TicketGroup = TicketGroup( | ||
userId = userId ?: "", | ||
showId = "", | ||
reservationId = reservationId ?: "", | ||
showName = showName ?: "", | ||
placeName = placeName ?: "", | ||
streetAddress = "", | ||
detailAddress = "", | ||
showDate = showDate?.toLocalDateTime() ?: LocalDateTime.now(), | ||
notice = "", | ||
ticketNotice = "", | ||
poster = showImgPath ?: "", | ||
ticketType = TicketGroup.TicketType.convert(ticketType), | ||
ticketName = ticketName ?: "", | ||
hostName = "", | ||
hostPhoneNumber = "", | ||
tickets = List(ticketCount ?: 0) { | ||
TicketGroup.Ticket( | ||
ticketId = "", | ||
entryCode = "", | ||
usedAt = null, | ||
ticketCreatedAt = LocalDateTime.MIN, | ||
csTicketId = "", | ||
showDate = LocalDateTime.MIN, | ||
) | ||
} | ||
) | ||
} | ||
|
||
@Serializable | ||
internal data class TicketGroupDto( | ||
@SerialName("detailAddress") | ||
val detailAddress: String? = null, | ||
@SerialName("hostName") | ||
val hostName: String? = null, | ||
@SerialName("hostPhoneNumber") | ||
val hostPhoneNumber: String? = null, | ||
@SerialName("notice") | ||
val notice: String? = null, | ||
@SerialName("placeName") | ||
val placeName: String? = null, | ||
@SerialName("reservationId") | ||
val reservationId: String? = null, | ||
@SerialName("showDate") | ||
val showDate: String? = null, | ||
@SerialName("showId") | ||
val showId: String? = null, | ||
@SerialName("showImgPath") | ||
val showImgPath: String? = null, | ||
@SerialName("showName") | ||
val showName: String? = null, | ||
@SerialName("streetAddress") | ||
val streetAddress: String? = null, | ||
@SerialName("ticketName") | ||
val ticketName: String? = null, | ||
@SerialName("ticketNotice") | ||
val ticketNotice: String? = null, | ||
@SerialName("ticketType") | ||
val ticketType: String? = null, | ||
@SerialName("tickets") | ||
val tickets: List<TicketDto>? = null, | ||
@SerialName("userId") | ||
val userId: String? = null, | ||
) { | ||
fun toDomain(): TicketGroup = TicketGroup( | ||
userId = userId ?: "", | ||
showId = showId ?: "", | ||
reservationId = reservationId ?: "", | ||
showName = showName ?: "", | ||
placeName = placeName ?: "", | ||
streetAddress = streetAddress ?: "", | ||
detailAddress = detailAddress ?: "", | ||
showDate = showDate?.toLocalDateTime() ?: LocalDateTime.MIN, | ||
notice = notice ?: "", | ||
ticketNotice = ticketNotice ?: "", | ||
poster = showImgPath ?: "", | ||
ticketType = TicketGroup.TicketType.convert(ticketType), | ||
ticketName = ticketName ?: "", | ||
hostName = hostName ?: "", | ||
hostPhoneNumber = hostPhoneNumber ?: "", | ||
tickets = tickets?.map { | ||
it.toDomain(showDate = showDate?.toLocalDateTime() ?: LocalDateTime.MIN) | ||
} ?: emptyList(), | ||
) | ||
|
||
@Serializable | ||
data class TicketDto( | ||
@SerialName("csTicketId") | ||
val csTicketId: String? = null, | ||
@SerialName("entryCode") | ||
val entryCode: String? = null, | ||
@SerialName("ticketCreatedAt") | ||
val ticketCreatedAt: String? = null, | ||
@SerialName("ticketId") | ||
val ticketId: String? = null, | ||
@SerialName("usedAt") | ||
val usedAt: String? = null, | ||
) { | ||
fun toDomain(showDate: LocalDateTime): TicketGroup.Ticket = TicketGroup.Ticket( | ||
ticketId = ticketId ?: "", | ||
entryCode = entryCode ?: "", | ||
usedAt = usedAt?.toLocalDateTime(), | ||
ticketCreatedAt = ticketCreatedAt?.toLocalDateTime() ?: LocalDateTime.MIN, | ||
csTicketId = csTicketId ?: "", | ||
showDate = showDate, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
domain/src/main/java/com/nexters/boolti/domain/model/LegacyTicket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.nexters.boolti.domain.model | ||
|
||
import java.time.LocalDateTime | ||
|
||
/** | ||
* @property userId | ||
* @property showId | ||
* @property ticketId | ||
* @property reservationId | ||
* @property salesTicketTypeId | ||
* @property showName | ||
* @property streetAddress | ||
* @property detailAddress | ||
* @property showDate | ||
* @property poster | ||
* @property isInviteTicket | ||
* @property ticketName | ||
* @property notice 공연 내용 (공연 상세에서 사용) | ||
* @property ticketNotice 안내사항 for 주최자 | ||
* @property placeName | ||
* @property entryCode QR 에 담길 정보 | ||
* @property usedAt | ||
* @property hostName | ||
* @property hostPhoneNumber | ||
*/ | ||
data class LegacyTicket( | ||
val userId: String = "", | ||
val showId: String = "", | ||
val ticketId: String = "", | ||
val reservationId: String = "", | ||
val salesTicketTypeId: String = "", | ||
val showName: String = "", | ||
val streetAddress: String = "", | ||
val detailAddress: String = "", | ||
val showDate: LocalDateTime = LocalDateTime.now(), | ||
val poster: String = "", | ||
val isInviteTicket: Boolean = false, | ||
val ticketName: String = "", | ||
val notice: String = "", | ||
val ticketNotice: String = "", | ||
val placeName: String = "", | ||
val entryCode: String = "", | ||
val usedAt: LocalDateTime? = null, | ||
val hostName: String = "", | ||
val hostPhoneNumber: String = "", | ||
val csReservationId: String = "", | ||
val csTicketId: String = "", | ||
) { | ||
val ticketState: TicketState | ||
get() = run { | ||
val now = LocalDateTime.now() | ||
when { | ||
usedAt != null && now > usedAt -> TicketState.Used | ||
now.toLocalDate() > showDate.toLocalDate() -> TicketState.Finished | ||
else -> TicketState.Ready | ||
} | ||
} | ||
} | ||
|
||
enum class TicketState { | ||
Ready, Used, Finished | ||
} |
Oops, something went wrong.