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

chore: auto bump version and changelog [skip ci]

iwt 2 недель назад
Родитель
Сommit
08be1b9577

+ 5 - 6
cfc-backend/src/main/java/com/etotem/cfc/service/ActivityService.java

@@ -65,7 +65,7 @@ public class ActivityService extends ServiceImpl<ActivityMapper, Activity> {
     private UserMapper userMapper;
 
     @Resource
-    private PlatformPointsService platformPointsService;
+    private CfEarnDispatchService cfEarnDispatchService;
 
     public Result<Map<String, Object>> list(String dimensionCode, Integer page, Integer size, Long userId) {
         autoEndExpiredActivities();
@@ -413,14 +413,13 @@ public class ActivityService extends ServiceImpl<ActivityMapper, Activity> {
             log.warn("能量发放失败(不影响积分): childId={}, activityId={}, error={}",
                 task.getChildId(), activity.getId(), e.getMessage());
         }
-        // 活动下发 CF 值(平台积分)
+        // 活动下发 CF 值(F05 统一账本:数量取活动配置 activities.platform_points,幂等键:签到记录 ID)
         if (activity.getPlatformPoints() != null && activity.getPlatformPoints() > 0 && userId != null) {
             try {
-                platformPointsService.earn(userId, activity.getPlatformPoints(),
-                        "activity", activity.getId(), "活动签到: " + activity.getTitle());
+                cfEarnDispatchService.earnActivityCheckinCf(userId, task.getId(), activity.getPlatformPoints());
             } catch (Exception e) {
-                log.warn("活动CF值发放失败: userId={}, activityId={}, error={}",
-                        userId, activity.getId(), e.getMessage());
+                log.warn("活动CF值发放失败: userId={}, checkinId={}, error={}",
+                        userId, task.getId(), e.getMessage());
             }
         }
     }

+ 41 - 10
cfc-backend/src/main/java/com/etotem/cfc/service/GutHealthProjectService.java

@@ -2,6 +2,9 @@ package com.etotem.cfc.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.etotem.cfc.common.OrderNoGenerator;
+import com.etotem.cfc.config.ConfigService;
+import com.etotem.cfc.constant.CfConfigKeys;
+import com.etotem.cfc.dto.CfEarnResult;
 import com.etotem.cfc.dto.QuotaStatusDTO;
 import com.etotem.cfc.entity.*;
 import com.etotem.cfc.mapper.*;
@@ -30,8 +33,6 @@ import java.util.stream.Collectors;
 @Service
 public class GutHealthProjectService {
 
-    /** 默认项目价格(分) */
-    private static final int DEFAULT_PRICE = 1990;
     /** 任务列表默认总数(一周 7 天) */
     private static final int DEFAULT_TASK_TOTAL = 7;
 
@@ -48,11 +49,14 @@ public class GutHealthProjectService {
     private FamilyMembershipMapper familyMembershipMapper;
 
     @Resource
-    private PlatformPointsService platformPointsService;
+    private CfEarnDispatchService cfEarnDispatchService;
 
     @Resource
     private SysConfigService sysConfigService;
 
+    @Resource
+    private ConfigService configService;
+
     @Resource
     private MemberUpgradeRecordMapper memberUpgradeRecordMapper;
 
@@ -264,6 +268,14 @@ public class GutHealthProjectService {
         project.setUpdatedAt(new Date());
         projectMapper.insert(project);
 
+        // F02 消费返 CF:调研订单属消费订单(N6 所有消费都返),金额取订单实付(分)
+        try {
+            cfEarnDispatchService.earnConsumeCf(project.getUserId(), "gut_health", order.getId(), order.getAmount());
+        } catch (Exception e) {
+            log.error("调研订单返CF失败(F02): orderId={}, userId={}, error={}",
+                    order.getId(), project.getUserId(), e.getMessage());
+        }
+
         log.info("菌群健康项目创建成功: orderNo={}, projectId={}, userId={}, amount={}",
                 orderNo, project.getId(), project.getUserId(), order.getAmount());
         return true;
@@ -440,8 +452,13 @@ public class GutHealthProjectService {
             amount = getProjectPrice();
         }
         try {
-            platformPointsService.earn(project.getUserId(), amount, "GUT_HEALTH", project.getId(),
-                    "菌群健康调研一周打卡完成,返还CF值");
+            CfEarnResult result = cfEarnDispatchService.earnGutHealthRefundCf(
+                    project.getUserId(), project.getId(), amount);
+            if (result == null || !Boolean.TRUE.equals(result.getEarned())) {
+                log.warn("菌群健康项目CF返还未发放: userId={}, projectId={}, reason={}",
+                        project.getUserId(), project.getId(), result != null ? result.getReason() : "null");
+                return false;
+            }
             project.setCfRefunded(1);
             project.setUpdatedAt(new Date());
             projectMapper.updateById(project);
@@ -804,15 +821,29 @@ public class GutHealthProjectService {
         return project;
     }
 
+    /**
+     * 项目价格(分)。读取顺序:旧 sys_config.gut_health_project_price → service_config cf.product.gut_health_price
+     * (W0.2 已迁移,兜底 1990 分 = 19.9 元仅注册在 CfConfigKeys,代码内无硬编码常量)。
+     */
     private int getProjectPrice() {
-        String priceStr = sysConfigService.getValue("gut_health_project_price");
-        if (priceStr != null) {
+        String legacy = null;
+        try {
+            legacy = sysConfigService.getValue("gut_health_project_price");
+        } catch (Exception e) {
+            log.warn("读取 sys_config.gut_health_project_price 失败: {}", e.getMessage());
+        }
+        if (legacy != null && !legacy.trim().isEmpty()) {
             try {
-                return Integer.parseInt(priceStr);
-            } catch (NumberFormatException ignored) {
+                return Integer.parseInt(legacy.trim());
+            } catch (NumberFormatException e) {
+                log.warn("sys_config.gut_health_project_price 非整数:{}", legacy);
             }
         }
-        return DEFAULT_PRICE;
+        int price = configService.getIntConfig(CfConfigKeys.PRODUCT_GUT_HEALTH_PRICE, 0);
+        if (price <= 0) {
+            throw new IllegalStateException("缺少菌群健康项目价格配置: " + CfConfigKeys.PRODUCT_GUT_HEALTH_PRICE);
+        }
+        return price;
     }
 
     private Long getUserFamilyId(Long userId) {

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-85641058ce71093708a196ff689f35cb0ada30e5
+777f7da6d40ae71e7d75e70e1d397e3bd83caf66