|
@@ -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为窗口右界");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|