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

fix(f03): 重命名PpointConsumptionLogMapper.sumPpointsSince重载为sumPpointsSinceUntil(避免MyBatis同名方法注册冲突导致asOf回放失效)

Xiaogang Liao 1 час назад
Родитель
Сommit
e9e5a901be

+ 1 - 1
cfc-backend/src/main/java/com/etotem/cfc/mapper/PpointConsumptionLogMapper.java

@@ -43,7 +43,7 @@ public interface PpointConsumptionLogMapper extends BaseMapper<PpointConsumption
             "<foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach>",
             "<foreach collection='userIds' item='uid' open='(' separator=',' close=')'>#{uid}</foreach>",
             "</script>"
             "</script>"
     })
     })
-    int sumPpointsSince(@Param("userIds") Collection<Long> userIds, @Param("since") Date since, @Param("until") Date until);
+    int sumPpointsSinceUntil(@Param("userIds") Collection<Long> userIds, @Param("since") Date since, @Param("until") Date until);
 
 
     /**
     /**
      * 按订单ID精确取该订单产生的 P 点(ppoint_consumption_log.order_id,存量重算基数)。
      * 按订单ID精确取该订单产生的 P 点(ppoint_consumption_log.order_id,存量重算基数)。

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

@@ -323,7 +323,7 @@ public class CfReferralService {
             List<Long> batch = userIds.subList(i, Math.min(i + USER_ID_BATCH_SIZE, userIds.size()));
             List<Long> batch = userIds.subList(i, Math.min(i + USER_ID_BATCH_SIZE, userIds.size()));
             total += until == null
             total += until == null
                     ? ppointConsumptionLogMapper.sumPpointsSince(batch, since)
                     ? ppointConsumptionLogMapper.sumPpointsSince(batch, since)
-                    : ppointConsumptionLogMapper.sumPpointsSince(batch, since, until);
+                    : ppointConsumptionLogMapper.sumPpointsSinceUntil(batch, since, until);
         }
         }
         return total;
         return total;
     }
     }

+ 5 - 5
cfc-backend/src/test/java/com/etotem/cfc/service/CfReferralWeightedPpointsTest.java

@@ -48,7 +48,7 @@ class CfReferralWeightedPpointsTest {
         when(referralTreeMapper.selectList(any())).thenReturn(Arrays.asList(
         when(referralTreeMapper.selectList(any())).thenReturn(Arrays.asList(
                 tree(1L, 101L, 1), tree(1L, 102L, 2), tree(1L, 110L, 10)));
                 tree(1L, 101L, 1), tree(1L, 102L, 2), tree(1L, 110L, 10)));
         // 按用户集合返回P点:用 thenAnswer 区分
         // 按用户集合返回P点:用 thenAnswer 区分
-        when(ppointConsumptionLogMapper.sumPpointsSince(anyCollection(), any(Date.class), any(Date.class)))
+        when(ppointConsumptionLogMapper.sumPpointsSinceUntil(anyCollection(), any(Date.class), any(Date.class)))
                 .thenAnswer(inv -> {
                 .thenAnswer(inv -> {
                     Collection<Long> ids = inv.getArgument(0);
                     Collection<Long> ids = inv.getArgument(0);
                     int sum = 0;
                     int sum = 0;
@@ -66,7 +66,7 @@ class CfReferralWeightedPpointsTest {
         // 同一后代 103 既在 L1 又在 L2(脏数据)→ 取 min(level)=1 权重0.9;本人1混入 → 排除
         // 同一后代 103 既在 L1 又在 L2(脏数据)→ 取 min(level)=1 权重0.9;本人1混入 → 排除
         when(referralTreeMapper.selectList(any())).thenReturn(Arrays.asList(
         when(referralTreeMapper.selectList(any())).thenReturn(Arrays.asList(
                 tree(1L, 103L, 1), tree(1L, 103L, 2), tree(1L, 1L, 1)));
                 tree(1L, 103L, 1), tree(1L, 103L, 2), tree(1L, 1L, 1)));
-        when(ppointConsumptionLogMapper.sumPpointsSince(anyCollection(), any(Date.class), any(Date.class)))
+        when(ppointConsumptionLogMapper.sumPpointsSinceUntil(anyCollection(), any(Date.class), any(Date.class)))
                 .thenReturn(10000);
                 .thenReturn(10000);
         assertEquals(9000, service.getWeightedTeamAnnualPpoints(1L, asOf));
         assertEquals(9000, service.getWeightedTeamAnnualPpoints(1L, asOf));
     }
     }
@@ -74,7 +74,7 @@ class CfReferralWeightedPpointsTest {
     @Test
     @Test
     void f03a_tier_ppoints_is_self_plus_weighted_once() {
     void f03a_tier_ppoints_is_self_plus_weighted_once() {
         // self=10000(用户1本人),团队加权=9000(用户101 L1 ×0.9)
         // self=10000(用户1本人),团队加权=9000(用户101 L1 ×0.9)
-        when(ppointConsumptionLogMapper.sumPpointsSince(anyCollection(), any(Date.class), any(Date.class)))
+        when(ppointConsumptionLogMapper.sumPpointsSinceUntil(anyCollection(), any(Date.class), any(Date.class)))
                 .thenAnswer(inv -> {
                 .thenAnswer(inv -> {
                     Collection<Long> ids = inv.getArgument(0);
                     Collection<Long> ids = inv.getArgument(0);
                     if (ids.size() == 1 && ids.contains(1L)) return 10000; // self
                     if (ids.size() == 1 && ids.contains(1L)) return 10000; // self
@@ -99,11 +99,11 @@ class CfReferralWeightedPpointsTest {
     void asOf_filters_ppoints_by_created_at() {
     void asOf_filters_ppoints_by_created_at() {
         // 验证 asOf 截止:mapper 应被调用时传入 asOf(滚动窗口右界=asOf)
         // 验证 asOf 截止:mapper 应被调用时传入 asOf(滚动窗口右界=asOf)
         when(referralTreeMapper.selectList(any())).thenReturn(Collections.singletonList(tree(1L, 101L, 1)));
         when(referralTreeMapper.selectList(any())).thenReturn(Collections.singletonList(tree(1L, 101L, 1)));
-        when(ppointConsumptionLogMapper.sumPpointsSince(anyCollection(), any(Date.class), any(Date.class)))
+        when(ppointConsumptionLogMapper.sumPpointsSinceUntil(anyCollection(), any(Date.class), any(Date.class)))
                 .thenReturn(10000);
                 .thenReturn(10000);
         service.getWeightedTeamAnnualPpoints(1L, asOf);
         service.getWeightedTeamAnnualPpoints(1L, asOf);
         org.mockito.ArgumentCaptor<Date> cap = org.mockito.ArgumentCaptor.forClass(Date.class);
         org.mockito.ArgumentCaptor<Date> cap = org.mockito.ArgumentCaptor.forClass(Date.class);
-        verify(ppointConsumptionLogMapper, atLeastOnce()).sumPpointsSince(anyCollection(), any(Date.class), cap.capture());
+        verify(ppointConsumptionLogMapper, atLeastOnce()).sumPpointsSinceUntil(anyCollection(), any(Date.class), cap.capture());
         assertTrue(cap.getAllValues().stream().anyMatch(d -> d.equals(asOf)), "应以订单时刻asOf为窗口右界");
         assertTrue(cap.getAllValues().stream().anyMatch(d -> d.equals(asOf)), "应以订单时刻asOf为窗口右界");
     }
     }
 }
 }