Add booking travel cities and member relation
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
This commit is contained in:
@@ -23,5 +23,47 @@ class BookingSchemaFix(
|
|||||||
logger.info("Adding booking.expected_guest_count column")
|
logger.info("Adding booking.expected_guest_count column")
|
||||||
jdbcTemplate.execute("alter table booking add column expected_guest_count integer")
|
jdbcTemplate.execute("alter table booking add column expected_guest_count integer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val hasFromCity = jdbcTemplate.queryForObject(
|
||||||
|
"""
|
||||||
|
select count(*)
|
||||||
|
from information_schema.columns
|
||||||
|
where table_name = 'booking'
|
||||||
|
and column_name = 'from_city'
|
||||||
|
""".trimIndent(),
|
||||||
|
Int::class.java
|
||||||
|
) ?: 0
|
||||||
|
if (hasFromCity == 0) {
|
||||||
|
logger.info("Adding booking.from_city column")
|
||||||
|
jdbcTemplate.execute("alter table booking add column from_city varchar")
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasToCity = jdbcTemplate.queryForObject(
|
||||||
|
"""
|
||||||
|
select count(*)
|
||||||
|
from information_schema.columns
|
||||||
|
where table_name = 'booking'
|
||||||
|
and column_name = 'to_city'
|
||||||
|
""".trimIndent(),
|
||||||
|
Int::class.java
|
||||||
|
) ?: 0
|
||||||
|
if (hasToCity == 0) {
|
||||||
|
logger.info("Adding booking.to_city column")
|
||||||
|
jdbcTemplate.execute("alter table booking add column to_city varchar")
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasMemberRelation = jdbcTemplate.queryForObject(
|
||||||
|
"""
|
||||||
|
select count(*)
|
||||||
|
from information_schema.columns
|
||||||
|
where table_name = 'booking'
|
||||||
|
and column_name = 'member_relation'
|
||||||
|
""".trimIndent(),
|
||||||
|
Int::class.java
|
||||||
|
) ?: 0
|
||||||
|
if (hasMemberRelation == 0) {
|
||||||
|
logger.info("Adding booking.member_relation column")
|
||||||
|
jdbcTemplate.execute("alter table booking add column member_relation varchar")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.android.trisolarisserver.db.repo.GuestDocumentRepo
|
|||||||
import com.android.trisolarisserver.db.repo.GuestRepo
|
import com.android.trisolarisserver.db.repo.GuestRepo
|
||||||
import com.android.trisolarisserver.db.repo.GuestRatingRepo
|
import com.android.trisolarisserver.db.repo.GuestRatingRepo
|
||||||
import com.android.trisolarisserver.models.booking.BookingStatus
|
import com.android.trisolarisserver.models.booking.BookingStatus
|
||||||
|
import com.android.trisolarisserver.models.booking.MemberRelation
|
||||||
import com.android.trisolarisserver.models.booking.TransportMode
|
import com.android.trisolarisserver.models.booking.TransportMode
|
||||||
import com.android.trisolarisserver.models.room.RoomStay
|
import com.android.trisolarisserver.models.room.RoomStay
|
||||||
import com.android.trisolarisserver.models.room.RateSource
|
import com.android.trisolarisserver.models.room.RateSource
|
||||||
@@ -82,6 +83,9 @@ class BookingFlow(
|
|||||||
val now = nowForProperty(property.timezone)
|
val now = nowForProperty(property.timezone)
|
||||||
val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() }
|
val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() }
|
||||||
val guest = resolveGuestForBooking(propertyId, property, actor, now, phone)
|
val guest = resolveGuestForBooking(propertyId, property, actor, now, phone)
|
||||||
|
val fromCity = request.fromCity?.trim()?.ifBlank { null }
|
||||||
|
val toCity = request.toCity?.trim()?.ifBlank { null }
|
||||||
|
val memberRelation = parseMemberRelation(request.memberRelation)
|
||||||
val hasGuestCounts = request.maleCount != null || request.femaleCount != null || request.childCount != null
|
val hasGuestCounts = request.maleCount != null || request.femaleCount != null || request.childCount != null
|
||||||
val adultCount = if (hasGuestCounts) {
|
val adultCount = if (hasGuestCounts) {
|
||||||
(request.maleCount ?: 0) + (request.femaleCount ?: 0)
|
(request.maleCount ?: 0) + (request.femaleCount ?: 0)
|
||||||
@@ -114,6 +118,9 @@ class BookingFlow(
|
|||||||
femaleCount = request.femaleCount,
|
femaleCount = request.femaleCount,
|
||||||
totalGuestCount = totalGuestCount,
|
totalGuestCount = totalGuestCount,
|
||||||
expectedGuestCount = request.expectedGuestCount,
|
expectedGuestCount = request.expectedGuestCount,
|
||||||
|
fromCity = fromCity,
|
||||||
|
toCity = toCity,
|
||||||
|
memberRelation = memberRelation,
|
||||||
notes = request.notes,
|
notes = request.notes,
|
||||||
createdBy = actor,
|
createdBy = actor,
|
||||||
updatedAt = now
|
updatedAt = now
|
||||||
@@ -536,6 +543,15 @@ class BookingFlow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun parseMemberRelation(value: String?): MemberRelation? {
|
||||||
|
if (value.isNullOrBlank()) return null
|
||||||
|
return try {
|
||||||
|
MemberRelation.valueOf(value.trim().uppercase())
|
||||||
|
} catch (_: IllegalArgumentException) {
|
||||||
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown member relation")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseRateSource(value: String?): RateSource? {
|
private fun parseRateSource(value: String?): RateSource? {
|
||||||
if (value.isNullOrBlank()) return null
|
if (value.isNullOrBlank()) return null
|
||||||
return try {
|
return try {
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ data class BookingCreateRequest(
|
|||||||
val expectedCheckInAt: String,
|
val expectedCheckInAt: String,
|
||||||
val expectedCheckOutAt: String,
|
val expectedCheckOutAt: String,
|
||||||
val guestPhoneE164: String? = null,
|
val guestPhoneE164: String? = null,
|
||||||
|
val fromCity: String? = null,
|
||||||
|
val toCity: String? = null,
|
||||||
|
val memberRelation: String? = null,
|
||||||
val transportMode: String? = null,
|
val transportMode: String? = null,
|
||||||
val childCount: Int? = null,
|
val childCount: Int? = null,
|
||||||
val maleCount: Int? = null,
|
val maleCount: Int? = null,
|
||||||
|
|||||||
@@ -74,6 +74,16 @@ class Booking(
|
|||||||
@Column(name = "expected_guest_count")
|
@Column(name = "expected_guest_count")
|
||||||
var expectedGuestCount: Int? = null,
|
var expectedGuestCount: Int? = null,
|
||||||
|
|
||||||
|
@Column(name = "from_city")
|
||||||
|
var fromCity: String? = null,
|
||||||
|
|
||||||
|
@Column(name = "to_city")
|
||||||
|
var toCity: String? = null,
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "member_relation")
|
||||||
|
var memberRelation: MemberRelation? = null,
|
||||||
|
|
||||||
var notes: String? = null,
|
var notes: String? = null,
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.android.trisolarisserver.models.booking
|
||||||
|
|
||||||
|
enum class MemberRelation {
|
||||||
|
FRIENDS,
|
||||||
|
FAMILY,
|
||||||
|
GROUP,
|
||||||
|
ALONE
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user