|
|
@@ -1,6 +1,7 @@
|
|
|
package com.etotem.cfc.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
|
import com.etotem.cfc.entity.Product;
|
|
|
import com.etotem.cfc.entity.ProductOrder;
|
|
|
@@ -14,6 +15,7 @@ import org.junit.jupiter.api.Test;
|
|
|
import org.mockito.InjectMocks;
|
|
|
import org.mockito.Mock;
|
|
|
import org.mockito.MockitoAnnotations;
|
|
|
+import org.mockito.ArgumentCaptor;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -26,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
+import static org.mockito.Mockito.verify;
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
/**
|
|
|
@@ -178,6 +181,35 @@ class CommissionServiceTeamProductPerformanceTest {
|
|
|
assertEquals(2, result.get("maxLevel"));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void 查询条件与团队消费额口径一致() {
|
|
|
+ List<ReferralTree> tree = Collections.singletonList(treeNode(101L, 1));
|
|
|
+
|
|
|
+ invokeWith(1L, 7, tree, new ArrayList<ProductOrder>(), new ArrayList<Product>());
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ ArgumentCaptor<LambdaQueryWrapper<ProductOrder>> orderCaptor =
|
|
|
+ ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
|
|
+ verify(productOrderMapper).selectList(orderCaptor.capture());
|
|
|
+ LambdaQueryWrapper<ProductOrder> orderWrapper = orderCaptor.getValue();
|
|
|
+ String orderSql = orderWrapper.getSqlSegment();
|
|
|
+ assertTrue(orderSql.contains("buyer_id"), "订单查询必须按下级成员过滤:" + orderSql);
|
|
|
+ assertTrue(orderSql.contains("fulfill_status"), "订单查询必须过滤履约状态:" + orderSql);
|
|
|
+ assertTrue(orderWrapper.getParamNameValuePairs().containsValue("completed"),
|
|
|
+ "履约状态口径必须为 completed(与 /team/consumption 一致)");
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ ArgumentCaptor<LambdaQueryWrapper<ReferralTree>> treeCaptor =
|
|
|
+ ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
|
|
+ verify(referralTreeMapper).selectList(treeCaptor.capture());
|
|
|
+ LambdaQueryWrapper<ReferralTree> treeWrapper = treeCaptor.getValue();
|
|
|
+ String treeSql = treeWrapper.getSqlSegment();
|
|
|
+ assertTrue(treeSql.contains("parent_id"), "团队关系必须按 parentId 过滤:" + treeSql);
|
|
|
+ assertTrue(treeSql.contains("level"), "团队关系必须按 level 上限过滤:" + treeSql);
|
|
|
+ assertTrue(treeWrapper.getParamNameValuePairs().containsValue(7),
|
|
|
+ "maxLevel 应作为 level 上限参数参与查询");
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void maxLevel为空或超限时归一化() {
|
|
|
List<ReferralTree> tree = Collections.singletonList(treeNode(101L, 1));
|