Selaa lähdekoodia

fix(CommissionService): move familyId declaration before use

Xiaogang Liao 2 kuukautta sitten
vanhempi
sitoutus
8b98eb99b4

+ 6 - 4
cfc-backend/src/main/java/com/etotem/cfc/service/CommissionService.java

@@ -283,12 +283,11 @@ public class CommissionService {
 
         // 创建L1佣金记录(金额>0才创建)
         if (l1Amount > 0) {
+            Long familyId = l1Referrer.getFamilyId();
             createCommissionRecord(orderId, orderType, l1ReferrerId, buyerId, 
                 commissionType, orderAmount, 0, l1Amount,
-                1, "settled", new Date());
+                1, "settled", new Date(), familyId);
             
-            // 获取推荐人的家庭ID并更新家庭公共账户
-            Long familyId = l1Referrer.getFamilyId();
             if (familyId != null) {
                 try {
                     familyEarningsService.earn(familyId, (long) l1Amount, l1ReferrerId);
@@ -347,7 +346,7 @@ public class CommissionService {
     private void createCommissionRecord(Long orderId, String orderType, Long referrerId,
                                         Long buyerId, String commissionType, Integer orderAmount,
                                         Integer profitRate, Integer commissionAmount,
-                                        Integer level, String status, Date settledAt) {
+                                        Integer level, String status, Date settledAt, Long familyId) {
         CommissionRecord record = new CommissionRecord();
         record.setOrderId(orderId);
         record.setOrderType(orderType);
@@ -361,6 +360,9 @@ public class CommissionService {
         record.setStatus(status);
         record.setSettledAt(settledAt);
         record.setCreatedAt(new Date());
+        if (familyId != null) {
+            record.setFamilyId(familyId);
+        }
         commissionRecordMapper.insert(record);
     }