Просмотр исходного кода

feat(backend): 活动详情支持游客浏览与会员价 - detail(id,userId) 解析会员价

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 месяц назад
Родитель
Сommit
74875d3476

+ 2 - 2
cfc-backend/src/main/java/com/etotem/cfc/dto/ActivityDTO.java

@@ -112,12 +112,12 @@ public class ActivityDTO {
 
     /**
      * Resolve final price based on membership level.
-     * Members (FAMILY/PROVIDER) get memberPrice if available, otherwise base price.
+     * Members (FAMILY/PREMIUM/PROVIDER) get memberPrice if available, otherwise base price.
      */
     public static Integer resolveMemberPrice(Integer basePrice, Integer memberPrice, String memberLevel) {
         if (basePrice == null) return null;
         // If user has member level and a memberPrice is set, use memberPrice
-        if (memberLevel != null && ("FAMILY".equals(memberLevel) || "PROVIDER".equals(memberLevel))) {
+        if (memberLevel != null && ("FAMILY".equals(memberLevel) || "PREMIUM".equals(memberLevel) || "PROVIDER".equals(memberLevel))) {
             if (memberPrice != null) {
                 return memberPrice;
             }

+ 7 - 5
cfc-backend/src/test/java/com/etotem/cfc/controller/ActivityControllerTest.java

@@ -141,6 +141,7 @@ public class ActivityControllerTest {
         Map<String, Object> params = new HashMap<>();
         params.put("page", 1);
         params.put("size", 10);
+        params.put("mine", true);
 
         // 登录用户可看到自己的私有活动(管理员视角:mine=true 时按发布者过滤)
         List<Activity> records = Collections.singletonList(
@@ -169,7 +170,7 @@ public class ActivityControllerTest {
     public void detail_Exists() {
         Activity activity = mockActivity(1L, "户外徒步", "published", "action");
 
-        when(activityService.detail(1L))
+        when(activityService.detail(1L, null))
             .thenReturn(new com.etotem.cfc.common.Result<ActivityDTO>() {{
                 setData(ActivityDTO.from(activity));
                 setCode(200);
@@ -178,14 +179,14 @@ public class ActivityControllerTest {
         Map<String, Object> params = new HashMap<>();
         params.put("id", 1);
 
-        Result<ActivityDTO> result = controller.detail(params);
+        Result<ActivityDTO> result = controller.detail(params, null);
         assertEquals(200, result.getCode());
         assertEquals("户外徒步", result.getData().getTitle());
     }
 
     @Test
     public void detail_NotFound() {
-        when(activityService.detail(999L))
+        when(activityService.detail(999L, null))
             .thenReturn(new com.etotem.cfc.common.Result<ActivityDTO>() {{
                 setData(null);
                 setCode(500);
@@ -195,14 +196,14 @@ public class ActivityControllerTest {
         Map<String, Object> params = new HashMap<>();
         params.put("id", 999);
 
-        Result<ActivityDTO> result = controller.detail(params);
+        Result<ActivityDTO> result = controller.detail(params, null);
         assertEquals(500, result.getCode());
     }
 
     @Test
     public void detail_MissingId() {
         Map<String, Object> params = new HashMap<>(); // no id
-        Result<ActivityDTO> result = controller.detail(params);
+        Result<ActivityDTO> result = controller.detail(params, null);
         assertEquals(500, result.getCode());
         assertTrue(result.getMessage().contains("不能为空"));
     }
@@ -230,6 +231,7 @@ public class ActivityControllerTest {
     @Test
     public void create_GuestNoVendorId() {
         Activity activity = mockActivity(null, "公开活动", "draft", "body");
+        activity.setVendorId(null); // 游客创建时不应有 vendorId
 
         when(activityService.create(any(Activity.class)))
             .thenReturn(new com.etotem.cfc.common.Result<ActivityDTO>() {{