|
|
@@ -0,0 +1,63 @@
|
|
|
+package com.etotem.cfc.service;
|
|
|
+
|
|
|
+import com.etotem.cfc.entity.CfDirectSalesTier;
|
|
|
+import com.etotem.cfc.mapper.*;
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.mockito.InjectMocks;
|
|
|
+import org.mockito.Mock;
|
|
|
+import org.mockito.MockitoAnnotations;
|
|
|
+
|
|
|
+import java.lang.reflect.Method;
|
|
|
+import java.util.*;
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+import static org.mockito.ArgumentMatchers.any;
|
|
|
+import static org.mockito.Mockito.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * TDD 契约(Task3):F03c 权重读冻结快照(旧5档),F03a 发放走新业绩口径,
|
|
|
+ * 常量 TEAM_DEPTH=8 与 F03A_WEIGHT_DEPTH=10 分离。
|
|
|
+ */
|
|
|
+class F03cSnapshotMatchTest {
|
|
|
+
|
|
|
+ @Mock private ReferralTreeMapper referralTreeMapper;
|
|
|
+ @Mock private UserMapper userMapper;
|
|
|
+ @Mock private CfRateTierMapper cfRateTierMapper;
|
|
|
+ @Mock private CfDirectSalesTierMapper cfDirectSalesTierMapper;
|
|
|
+ @Mock private CfIndirectSalesTierMapper cfIndirectSalesTierMapper;
|
|
|
+ @Mock private CfDirectSalesTierSnapshotMapper snapshotMapper;
|
|
|
+ @Mock private PpointConsumptionLogMapper ppointConsumptionLogMapper;
|
|
|
+
|
|
|
+ @InjectMocks private CfReferralService referralService;
|
|
|
+
|
|
|
+ @BeforeEach
|
|
|
+ void setUp() { MockitoAnnotations.openMocks(this); }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void f03c_snapshot_match_uses_old_tiers() {
|
|
|
+ // 旧口径:业绩 10000 → 新秀10%(不是新表业绩10000→新档位60%)
|
|
|
+ when(snapshotMapper.selectAllSnapshot()).thenAnswer(inv -> {
|
|
|
+ List<CfDirectSalesTier> all = new ArrayList<>();
|
|
|
+ all.add(tier("新秀", 10000, 10));
|
|
|
+ all.add(tier("小成", 50000, 25));
|
|
|
+ all.add(tier("至富", 1000000, 70));
|
|
|
+ return all;
|
|
|
+ });
|
|
|
+ CfDirectSalesTier t = referralService.matchDirectSalesTierFromSnapshot(10000);
|
|
|
+ assertNotNull(t);
|
|
|
+ assertEquals(10, t.getRatePercent(), "F03c快照业绩10000应得旧新秀10%(不受新表影响)");
|
|
|
+ assertNull(referralService.matchDirectSalesTierFromSnapshot(9999));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void depth_constants_are_separated() {
|
|
|
+ assertEquals(8, CfReferralService.DEFAULT_TEAM_DEPTH);
|
|
|
+ assertEquals(10, CfReferralService.F03A_WEIGHT_DEPTH);
|
|
|
+ }
|
|
|
+
|
|
|
+ private CfDirectSalesTier tier(String name, int min, int rate) {
|
|
|
+ CfDirectSalesTier t = new CfDirectSalesTier();
|
|
|
+ t.setTierName(name); t.setMinAnnualPpoints(min); t.setRatePercent(rate);
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+}
|