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

refactor(activity): P1-1 拆分签到计数 currentParticipants 与报名计数口径

- Activity 新增 signedCount(签到人数),checkin 时 +1 替代原先误用 currentParticipants 的签到计数
- approvedCount 明确为报名口径;create 时 currentParticipants/approvedCount/signedCount 均初始化 0
- ContentRecommendService 参与热度改用 approvedCount(报名热度)
- ActivityDTO 暴露 approvedCount/signedCount;迁移 + schema.sql 同步 signed_count 列
E2E Test Bot 3 недель назад
Родитель
Сommit
44a41cbc68

+ 1 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -2213,6 +2213,7 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         // 2026-10-22 整改:报名审核开关 + 名额占用计数
         ensureColumn("activities", "require_review", "TINYINT DEFAULT 0 COMMENT '报名是否需要审核: 1=需要, 0=免审即报名通过'");
         ensureColumn("activities", "approved_count", "INT DEFAULT 0 COMMENT '已通过报名人数(名额占用统计)'");
+        ensureColumn("activities", "signed_count", "INT DEFAULT 0 COMMENT '签到人数(checkin 时 +1,区别于 approved_count 的报名口径)'");
         // 修正 require_checkin_review 默认值并归一化存量(该字段此前未被读取,无业务依赖,避免存量活动突然进入待审核)
         // 同时按已通过报名回填 approved_count,使名额统计与存量数据一致
         try {

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

@@ -23,6 +23,10 @@ public class ActivityDTO {
     private String location;
     private Integer maxParticipants;
     private Integer currentParticipants;
+    /** 已通过报名人数(名额占用统计,区别于 currentParticipants 的签到计数) */
+    private Integer approvedCount;
+    /** 签到人数(checkin 时 +1) */
+    private Integer signedCount;
     private Integer price;
     private String vendorName;
     private String priceLabel;
@@ -97,6 +101,8 @@ public class ActivityDTO {
         dto.setLocation(activity.getLocation());
         dto.setMaxParticipants(activity.getMaxParticipants());
         dto.setCurrentParticipants(activity.getCurrentParticipants());
+        dto.setApprovedCount(activity.getApprovedCount());
+        dto.setSignedCount(activity.getSignedCount());
         dto.setVendorName(activity.getVendorName());
         dto.setRequireRegistration(activity.getRequireRegistration());
         dto.setRequireCheckinReview(activity.getRequireCheckinReview());

+ 4 - 1
cfc-backend/src/main/java/com/etotem/cfc/entity/Activity.java

@@ -58,9 +58,12 @@ public class Activity implements Serializable {
 
     private Integer currentParticipants;
 
-    /** 已通过报名人数(名额占用统计,区别于 currentParticipants 的签到计数) */
+    /** 已通过报名人数(名额占用统计) */
     private Integer approvedCount;
 
+    /** 签到人数(checkin 时 +1,区别于 approvedCount 的报名口径) */
+    private Integer signedCount;
+
     private Integer price;
 
     /** 会员价(分) */

+ 4 - 2
cfc-backend/src/main/java/com/etotem/cfc/service/ActivityService.java

@@ -153,6 +153,8 @@ public class ActivityService extends ServiceImpl<ActivityMapper, Activity> {
     public Result<ActivityDTO> create(Activity activity, Long creatorId) {
         activity.setStatus("draft");
         activity.setCurrentParticipants(0);
+        activity.setApprovedCount(0);
+        activity.setSignedCount(0);
         activity.setCreatorId(creatorId);
         activity.setCreatedAt(new Date());
         activity.setUpdatedAt(new Date());
@@ -357,8 +359,8 @@ public class ActivityService extends ServiceImpl<ActivityMapper, Activity> {
 
         taskMapper.insert(task);
 
-        // 7. 签到计数(无论是否需审核都计入 currentParticipants)
-        activity.setCurrentParticipants(activity.getCurrentParticipants() != null ? activity.getCurrentParticipants() + 1 : 1);
+        // 7. 签到计数(无论是否需审核都计入 signedCount)
+        activity.setSignedCount(activity.getSignedCount() != null ? activity.getSignedCount() + 1 : 1);
         activity.setUpdatedAt(new Date());
         this.updateById(activity);
 

+ 1 - 1
cfc-backend/src/main/java/com/etotem/cfc/service/ContentRecommendService.java

@@ -413,7 +413,7 @@ private List<RecommendItemVO> recommendProducts(String dimensionCode, Long userI
             score += calcFreshnessScore(a.getCreatedAt(), 15);
 
             // 参与热度 (0-10)
-            int participants = a.getCurrentParticipants() != null ? a.getCurrentParticipants() : 0;
+            int participants = a.getApprovedCount() != null ? a.getApprovedCount() : 0;
             score += Math.min(10, participants);
             if (participants >= 20) reasons.add("热门");
 

+ 1 - 0
cfc-backend/src/main/resources/schema.sql

@@ -2631,6 +2631,7 @@ ALTER TABLE activities ADD COLUMN energy_penalty_unregistered INT DEFAULT 5 COMM
 -- 2026-10-22 整改:报名审核开关 + 名额占用计数
 ALTER TABLE activities ADD COLUMN require_review TINYINT DEFAULT 0 COMMENT '报名是否需要审核: 1=需要, 0=免审即报名通过';
 ALTER TABLE activities ADD COLUMN approved_count INT DEFAULT 0 COMMENT '已通过报名人数(名额占用统计)';
+ALTER TABLE activities ADD COLUMN signed_count INT DEFAULT 0 COMMENT '签到人数(checkin 时 +1,区别于 approved_count 的报名口径)';
 -- 修正打卡审核默认值与存量归一化(2026-10-22)
 ALTER TABLE activities MODIFY COLUMN require_checkin_review TINYINT DEFAULT 0 COMMENT '打卡是否需要审核: 1=需要, 0=免审直接通过';
 UPDATE activities SET require_checkin_review = 0 WHERE require_checkin_review = 1;