From 75e20ed49063feac161beca13aba24147424d5a7 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 17 九月 2026 18:43:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/main'
---
talent-card-server/src/test/java/com/talentcard/server/business/portal/PortalServiceTests.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/talent-card-server/src/test/java/com/talentcard/server/business/portal/PortalServiceTests.java b/talent-card-server/src/test/java/com/talentcard/server/business/portal/PortalServiceTests.java
index 7fe6235..06e3478 100644
--- a/talent-card-server/src/test/java/com/talentcard/server/business/portal/PortalServiceTests.java
+++ b/talent-card-server/src/test/java/com/talentcard/server/business/portal/PortalServiceTests.java
@@ -110,11 +110,11 @@
@SuppressWarnings("unchecked")
void merchantDetailHeaderTagsDriveListTags() throws Exception {
Method method = PortalService.class.getDeclaredMethod(
- "merchantBenefitTags", String.class, boolean.class, String.class, Map.class);
+ "merchantBenefitTags", Long.class, String.class, String.class, boolean.class, String.class, Map.class);
method.setAccessible(true);
- List<String> foodTags = (List<String>) method.invoke(service, "food", true, "8.8折", null);
- List<String> hotelTags = (List<String>) method.invoke(service, "hotel", true, "7折", Map.of(
+ List<String> foodTags = (List<String>) method.invoke(service, null, null, "food", true, "8.8折", null);
+ List<String> hotelTags = (List<String>) method.invoke(service, null, null, "hotel", true, "7折", Map.of(
"freeVoucherEnabled", true,
"freeVoucherTimes", "2",
"storeConsume", true,
@@ -123,7 +123,22 @@
"consumeDiscount", "8.5"));
assertThat(foodTags).containsExactly("券", "8.8折");
- assertThat(hotelTags).containsExactly("券", "免费2次", "8.5折");
+ // 酒店折扣同样取「团单折扣 7 折」与「商家权益到店消费折扣 8.5 折」中更低的一档。
+ assertThat(hotelTags).containsExactly("券", "免费2次", "7.0折");
+ }
+
+ @Test
+ void productFreeRightsProduceFreeTimesTag() throws Exception {
+ when(jdbc.queryForList(anyString(), any(Object[].class))).thenReturn(List.of(
+ Map.of("rightsConfig", "[{\"level\": \"卓越人才卡\", \"enabled\": true, \"free\": true,"
+ + " \"limitCount\": 10, \"exceedDiscount\": 7}]"),
+ Map.of("rightsConfig", "[{\"level\": \"卓越人才卡\", \"enabled\": true, \"free\": true,"
+ + " \"limitCount\": 1, \"exceedDiscount\": 6}]")));
+ Method method = PortalService.class.getDeclaredMethod("productFreeTimesTag", Long.class, String.class);
+ method.setAccessible(true);
+
+ assertThat((String) method.invoke(service, 83L, "卓越人才卡")).isEqualTo("免费10次");
+ assertThat((String) method.invoke(service, 83L, "杰出人才卡")).isEmpty();
}
@Test
@@ -144,4 +159,36 @@
assertThat(freeTags).containsExactly("免费");
assertThat(paidTags).containsExactly("8.5折");
}
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void merchantRightMatchingKeepsLocalAndOutsideRightsApart() throws Exception {
+ Method method = PortalService.class.getDeclaredMethod(
+ "matchingMerchantRight", List.class, String.class, String.class, boolean.class);
+ method.setAccessible(true);
+ List<Map<String, Object>> rights = List.of(
+ Map.of("level", "卓越人才卡(外地)", "tag", "卓越人才卡(外地)", "detail", "外地权益", "enabled", true),
+ Map.of("level", "卓越人才卡(本地)", "tag", "卓越人才卡(本地)", "detail", "本地权益", "enabled", true));
+
+ Map<String, Object> local = (Map<String, Object>) method.invoke(service, rights, "卓越人才卡", "LOCAL", true);
+ Map<String, Object> outside = (Map<String, Object>) method.invoke(service, rights, "卓越人才卡", "OUTSIDE", true);
+
+ assertThat(local.get("detail")).isEqualTo("本地权益");
+ assertThat(outside.get("detail")).isEqualTo("外地权益");
+ }
+
+ @Test
+ void merchantRightMatchingNeverFallsBackToAnotherAreaScope() throws Exception {
+ Method method = PortalService.class.getDeclaredMethod(
+ "matchingMerchantRight", List.class, String.class, String.class, boolean.class);
+ method.setAccessible(true);
+ // 只配了“(外地)”时,本地人才拿不到这份权益;不带地区后缀的配置两边都能用。
+ List<Map<String, Object>> outsideOnly = List.of(
+ Map.of("level", "卓越人才卡(外地)", "detail", "外地权益", "enabled", true));
+ List<Map<String, Object>> plain = List.of(Map.of("level", "卓越人才卡", "detail", "通用权益", "enabled", true));
+
+ assertThat(method.invoke(service, outsideOnly, "卓越人才卡", "LOCAL", true)).isNull();
+ assertThat(method.invoke(service, plain, "卓越人才卡", "LOCAL", true)).isNotNull();
+ assertThat(method.invoke(service, plain, "卓越人才卡", "OUTSIDE", true)).isNotNull();
+ }
}
--
Gitblit v1.7.1