Add booking travel cities and member relation
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s

This commit is contained in:
androidlover5842
2026-01-29 13:55:17 +05:30
parent 5fe19cf54c
commit 4c0264cdbe
5 changed files with 79 additions and 0 deletions

View File

@@ -23,5 +23,47 @@ class BookingSchemaFix(
logger.info("Adding booking.expected_guest_count column")
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")
}
}
}

View File

@@ -17,6 +17,7 @@ import com.android.trisolarisserver.db.repo.GuestDocumentRepo
import com.android.trisolarisserver.db.repo.GuestRepo
import com.android.trisolarisserver.db.repo.GuestRatingRepo
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.room.RoomStay
import com.android.trisolarisserver.models.room.RateSource
@@ -82,6 +83,9 @@ class BookingFlow(
val now = nowForProperty(property.timezone)
val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() }
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 adultCount = if (hasGuestCounts) {
(request.maleCount ?: 0) + (request.femaleCount ?: 0)
@@ -114,6 +118,9 @@ class BookingFlow(
femaleCount = request.femaleCount,
totalGuestCount = totalGuestCount,
expectedGuestCount = request.expectedGuestCount,
fromCity = fromCity,
toCity = toCity,
memberRelation = memberRelation,
notes = request.notes,
createdBy = actor,
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? {
if (value.isNullOrBlank()) return null
return try {

View File

@@ -34,6 +34,9 @@ data class BookingCreateRequest(
val expectedCheckInAt: String,
val expectedCheckOutAt: String,
val guestPhoneE164: String? = null,
val fromCity: String? = null,
val toCity: String? = null,
val memberRelation: String? = null,
val transportMode: String? = null,
val childCount: Int? = null,
val maleCount: Int? = null,

View File

@@ -74,6 +74,16 @@ class Booking(
@Column(name = "expected_guest_count")
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,
@ManyToOne(fetch = FetchType.LAZY)

View File

@@ -0,0 +1,8 @@
package com.android.trisolarisserver.models.booking
enum class MemberRelation {
FRIENDS,
FAMILY,
GROUP,
ALONE
}