Browse Source

feat(S-cfc-62): team.profit.hook 支付成功钩子接入 ProfitPoolService.settle

6 个支付成功调用点(5 个订单服务)在 CfCommissionService.settle/settleReferrerOnly 同点位并行调用 ProfitPoolService.settle,-D>0 才分润、uk_order 幂等,异常仅记录日志不阻断主链路;TeamProfitHookContractTest 7/7 绿。
E2E Test Bot 1 hour ago
parent
commit
07a29a3831

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/AssessmentOrderService.java

@@ -34,6 +34,10 @@ public class AssessmentOrderService extends ServiceImpl<AssessmentOrderMapper, A
     @Resource
     @Resource
     private CfCommissionService cfCommissionService;
     private CfCommissionService cfCommissionService;
 
 
+    /** team.profit.hook(§12-T3):支付成功钩子,与 CF 值分佣同点位并行结算利润池 */
+    @Resource
+    private ProfitPoolService profitPoolService;
+
     @Resource
     @Resource
     private AssessmentQuotaService assessmentQuotaService;
     private AssessmentQuotaService assessmentQuotaService;
 
 
@@ -90,6 +94,13 @@ public class AssessmentOrderService extends ServiceImpl<AssessmentOrderMapper, A
             cfCommissionService.settle(order.getId(), "assessment", order.getUserId(),
             cfCommissionService.settle(order.getId(), "assessment", order.getUserId(),
                     buyerFamilyId,
                     buyerFamilyId,
                     order.getActualPrice() != null ? order.getActualPrice().intValue() : 0, null);
                     order.getActualPrice() != null ? order.getActualPrice().intValue() : 0, null);
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断支付主链路
+            try {
+                profitPoolService.settle(order.getId(), "assessment", null,
+                        order.getActualPrice() != null ? order.getActualPrice().intValue() : 0, 0);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
             // 支付成功生成测评额度(SC-P-34/SC-P-35:额度过期不可用于预约)
             // 支付成功生成测评额度(SC-P-34/SC-P-35:额度过期不可用于预约)
             grantQuotaForPaidOrder(order);
             grantQuotaForPaidOrder(order);
         }
         }

+ 18 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/MemberSubscriptionService.java

@@ -32,6 +32,10 @@ public class MemberSubscriptionService {
     @Resource
     @Resource
     private CfCommissionService cfCommissionService;
     private CfCommissionService cfCommissionService;
 
 
+    /** team.profit.hook(§12-T3):支付成功钩子,与 CF 值分佣同点位并行结算利润池 */
+    @Resource
+    private ProfitPoolService profitPoolService;
+
     @Resource
     @Resource
     private ButlerService butlerService;
     private ButlerService butlerService;
 
 
@@ -165,6 +169,13 @@ public class MemberSubscriptionService {
         if (family != null && family.getCreatorId() != null) {
         if (family != null && family.getCreatorId() != null) {
             cfCommissionService.settleReferrerOnly(order.getId(), "subscription", family.getCreatorId(),
             cfCommissionService.settleReferrerOnly(order.getId(), "subscription", family.getCreatorId(),
                     family.getId(), amount);
                     family.getId(), amount);
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断主链路
+            try {
+                profitPoolService.settle(order.getId(), "subscription", null,
+                        amount != null ? amount : 0, 0);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
         }
         }
 
 
         return subscription;
         return subscription;
@@ -237,6 +248,13 @@ public class MemberSubscriptionService {
         if (family != null && family.getCreatorId() != null) {
         if (family != null && family.getCreatorId() != null) {
             cfCommissionService.settleReferrerOnly(order.getId(), "subscription", family.getCreatorId(),
             cfCommissionService.settleReferrerOnly(order.getId(), "subscription", family.getCreatorId(),
                     family.getId(), amount);
                     family.getId(), amount);
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断主链路
+            try {
+                profitPoolService.settle(order.getId(), "subscription", null,
+                        amount != null ? amount : 0, 0);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
         }
         }
 
 
         return current;
         return current;

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/MembershipService.java

@@ -55,6 +55,10 @@ public class MembershipService implements MembershipServiceInterface {
     @Lazy
     @Lazy
     private CfCommissionService cfCommissionService;
     private CfCommissionService cfCommissionService;
 
 
+    /** team.profit.hook(§12-T3):支付成功钩子,与 CF 值分佣同点位并行结算利润池 */
+    @Resource
+    private ProfitPoolService profitPoolService;
+
     @Resource
     @Resource
     private SysConfigService sysConfigService;
     private SysConfigService sysConfigService;
 
 
@@ -1005,6 +1009,13 @@ public class MembershipService implements MembershipServiceInterface {
             User buyer = userMapper.selectById(adminUserId);
             User buyer = userMapper.selectById(adminUserId);
             Long buyerFamilyId = (buyer != null) ? buyer.getFamilyId() : null;
             Long buyerFamilyId = (buyer != null) ? buyer.getFamilyId() : null;
             cfCommissionService.settleReferrerOnly(order.getId(), "membership", adminUserId, buyerFamilyId, order.getAmount());
             cfCommissionService.settleReferrerOnly(order.getId(), "membership", adminUserId, buyerFamilyId, order.getAmount());
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断主链路
+            try {
+                profitPoolService.settle(order.getId(), "membership", null,
+                        order.getAmount() != null ? order.getAmount() : 0, 0);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
 
 
             log.info("会员开通完成: orderNo={}, levelCode={}, amount={}, fromLevel={}",
             log.info("会员开通完成: orderNo={}, levelCode={}, amount={}, fromLevel={}",
                     order.getOrderNo(), order.getLevelCode(), order.getAmount(), fromLevel);
                     order.getOrderNo(), order.getLevelCode(), order.getAmount(), fromLevel);

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/PaymentService.java

@@ -67,6 +67,10 @@ public class PaymentService implements PaymentServiceInterface {
     @Resource
     @Resource
     private CfCommissionService cfCommissionService;
     private CfCommissionService cfCommissionService;
 
 
+    /** team.profit.hook(§12-T3):支付成功钩子,与 CF 值分佣同点位并行结算利润池 */
+    @Resource
+    private ProfitPoolService profitPoolService;
+
     @Lazy
     @Lazy
     @Resource
     @Resource
     private ProductOrderService productOrderService;
     private ProductOrderService productOrderService;
@@ -278,6 +282,13 @@ public class PaymentService implements PaymentServiceInterface {
         if (updated) {
         if (updated) {
             cfCommissionService.settle(order.getId(), "package", order.getUserId(),
             cfCommissionService.settle(order.getId(), "package", order.getUserId(),
                     order.getFamilyId(), order.getPrice(), null);
                     order.getFamilyId(), order.getPrice(), null);
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断支付主链路
+            try {
+                profitPoolService.settle(order.getId(), "package", null,
+                        order.getPrice() != null ? order.getPrice() : 0, 0);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
         }
         }
         return updated;
         return updated;
     }
     }

+ 10 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ProductOrderService.java

@@ -100,6 +100,10 @@ public class ProductOrderService {
     @Resource
     @Resource
     private CfCommissionService cfCommissionService;
     private CfCommissionService cfCommissionService;
 
 
+    /** team.profit.hook(§12-T3):支付成功钩子,与 CF 值分佣同点位并行结算利润池 */
+    @Resource
+    private ProfitPoolService profitPoolService;
+
     @Resource
     @Resource
     private PaymentService paymentService;
     private PaymentService paymentService;
 
 
@@ -1067,6 +1071,12 @@ public class ProductOrderService {
             cfCommissionService.settle(order.getId(), "product", order.getBuyerId(),
             cfCommissionService.settle(order.getId(), "product", order.getBuyerId(),
                     userMapper.selectById(order.getBuyerId()).getFamilyId(),
                     userMapper.selectById(order.getBuyerId()).getFamilyId(),
                     order.getTotalAmount(), order.getProductId(), paidCent);
                     order.getTotalAmount(), order.getProductId(), paidCent);
+            // team.profit.hook(§12-T3):同点位并行结算利润池,D>0 才分润、uk_order 幂等;不阻断支付主链路
+            try {
+                profitPoolService.settle(order.getId(), "product", order.getProductId(), (long) paidCent, 0L);
+            } catch (Exception e) {
+                log.error("利润池结算失败(hook): orderId={}, error={}", order.getId(), e.getMessage());
+            }
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("CF值分佣失败: orderId={}, error={}", order.getId(), e.getMessage());
             log.error("CF值分佣失败: orderId={}, error={}", order.getId(), e.getMessage());
         }
         }