调整Rooming List付款方式选项

This commit is contained in:
andy
2026-07-22 17:31:55 +07:00
parent 7e2cd8969f
commit 0de960372b
14 changed files with 74 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ package cn.nianxx.thhotel.workflows.reservation.common.request;
* @param hotelId 酒店 ID为空时按当前登录用户默认酒店解析
* @param peoplePerRoom 每间房人数
* @param roomType 目标 Excel 的 Room Type
* @param paymentType 目标 Excel 的 Payment Type当前默认和唯一允许值为 CA
* @param paymentType 目标 Excel 的 Payment Type默认 BTQR当前允许 BTQR 或 CA
* @param nationality 目标 Excel 的 Nationality当前只允许 KR 或 CHN
*/
public record ReservationRoomingListGenerationRequest(

View File

@@ -27,7 +27,9 @@ public class ReservationRoomingListGenerationServiceImpl implements ReservationR
private static final long MAX_SOURCE_FILE_BYTES = 20L * 1024L * 1024L;
private static final DateTimeFormatter FILE_TIMESTAMP_FORMATTER =
DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final String DEFAULT_PAYMENT_TYPE = "CA";
private static final String PAYMENT_TYPE_BTQR = "BTQR";
private static final String PAYMENT_TYPE_CA = "CA";
private static final String DEFAULT_PAYMENT_TYPE = PAYMENT_TYPE_BTQR;
private static final String NATIONALITY_KR = "KR";
private static final String NATIONALITY_CHN = "CHN";
@@ -132,8 +134,8 @@ public class ReservationRoomingListGenerationServiceImpl implements ReservationR
return DEFAULT_PAYMENT_TYPE;
}
String code = normalized.toUpperCase(java.util.Locale.ROOT);
if (!DEFAULT_PAYMENT_TYPE.equals(code)) {
errors.add("payment_type: 当前只允许 CA。");
if (!PAYMENT_TYPE_BTQR.equals(code) && !PAYMENT_TYPE_CA.equals(code)) {
errors.add("payment_type: 当前只允许 BTQR 或 CA。");
}
return code;
}

View File

@@ -89,7 +89,7 @@ class ReservationRoomingListGenerationControllerTest {
.param("hotel_id", "HOTEL-TEST")
.param("people_per_room", "2")
.param("room_type", "UG1")
.param("payment_type", "CA")
.param("payment_type", "BTQR")
.param("nationality", "CHN"))
.andExpect(status().isOk())
.andExpect(content().contentType(
@@ -109,7 +109,7 @@ class ReservationRoomingListGenerationControllerTest {
.andExpect(result -> assertThat(workbookCell(result.getResponse().getContentAsByteArray(), 1, 10))
.isEqualTo("0"))
.andExpect(result -> assertThat(workbookCell(result.getResponse().getContentAsByteArray(), 1, 11))
.isEqualTo("CA"))
.isEqualTo("BTQR"))
.andExpect(result -> assertThat(workbookCell(result.getResponse().getContentAsByteArray(), 1, 14))
.isEqualTo("CHN"))
.andExpect(content().string(not(containsString("P123456"))));

View File

@@ -67,7 +67,7 @@ class ReservationRoomingListGenerationServiceImplTest {
assertThat(cellText(firstRoom.getCell(8))).isEqualTo("1");
assertThat(cellText(firstRoom.getCell(9))).isEqualTo("3");
assertThat(cellText(firstRoom.getCell(10))).isEqualTo("0");
assertThat(cellText(firstRoom.getCell(11))).isEqualTo("CA");
assertThat(cellText(firstRoom.getCell(11))).isEqualTo("BTQR");
assertThat(cellText(firstRoom.getCell(13))).isEqualTo("ZHANG GAILI, LI HONG");
assertThat(cellText(firstRoom.getCell(14))).isEqualTo("CHN");
assertThat(cellText(firstRoom.getCell(15))).isEmpty();
@@ -88,6 +88,26 @@ class ReservationRoomingListGenerationServiceImplTest {
}
}
@Test
void shouldAcceptCaPaymentTypeForRoomingListWorkbook() throws Exception {
when(hotelContextService.requireAccessibleHotel("HOTEL-TEST")).thenReturn("HOTEL-TEST");
ReservationRoomingListGeneratedFile generatedFile = service.generate(
sourceFileWithTravelDate("2026-05-09 - 05-14", List.of("LI/CHUNHONG")),
new ReservationRoomingListGenerationRequest(
"HOTEL-TEST",
1,
"UG1",
"ca",
"CHN"),
actor());
try (XSSFWorkbook workbook = new XSSFWorkbook(new ByteArrayInputStream(generatedFile.content()))) {
Row firstRoom = workbook.getSheetAt(0).getRow(1);
assertThat(cellText(firstRoom.getCell(11))).isEqualTo("CA");
}
}
@Test
void shouldParseTravelDateWithNumericHyphenRange() throws Exception {
when(hotelContextService.requireAccessibleHotel("HOTEL-TEST")).thenReturn("HOTEL-TEST");
@@ -156,7 +176,7 @@ class ReservationRoomingListGenerationServiceImplTest {
assertThat(exception.getErrorCode()).isEqualTo("ROOMING_LIST_VALIDATION_FAILED");
assertThat(exception.getDetails())
.contains("payment_type: 当前只允许 CA。", "nationality: 当前只允许 KR 或 CHN。");
.contains("payment_type: 当前只允许 BTQR 或 CA。", "nationality: 当前只允许 KR 或 CHN。");
}
@Test