Browse Source

fix App 查询全部订单时主从分离 其他只查子订单

liub 1 week ago
parent
commit
9cd4ffdd1c

+ 5 - 4
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java

@@ -1110,15 +1110,16 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
 
         Page<OrderListVo> orderListVoPage;
         if (baseController.getUserSystemCode().equals("APP")) {
-            // 手动分页:以主订单为主,按车牌+状态分组去重,先统计总数再取当前页(避免 MP 自动 count 解析窗口函数报错)
+            // APP 端统一走手动分页:按车牌+状态分组去重(避免 MP 自动 count 解析窗口函数报错)。
+            // SQL 中根据 isLargeOrder 动态切换 parent_id 条件:大订单查主订单(parent_id='0'),否则只查从订单(parent_id!='0')
             Page<OrderListVo> page = insOrdersParam.getPage();
             long current = page.getCurrent();
             long size = page.getSize();
             long offset = (current - 1) * size;
             long total = insOrdersMapper.countOrderListDistinct(insOrdersParam);
             List<OrderListVo> records = insOrdersMapper.queryOrderListDistinct(insOrdersParam, offset, size);
-            // 以主订单为主:查询主订单下的从订单并挂载
-            if (CollUtil.isNotEmpty(records)) {
+            // 大订单:以主订单为主,查询主订单下的从订单并挂载
+            if (StringUtils.equals("1", insOrdersParam.getIsLargeOrder()) && CollUtil.isNotEmpty(records)) {
                 List<String> parentIds = records.stream().map(OrderListVo::getOrderNo).collect(Collectors.toList());
                 List<OrderListVo> childOrders = insOrdersMapper.queryChildOrderListByParentIds(parentIds, insOrdersParam);
                 if (CollUtil.isNotEmpty(childOrders)) {
@@ -1130,7 +1131,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             orderListVoPage = new Page<>(current, size, total);
             orderListVoPage.setRecords(records != null ? records : java.util.Collections.emptyList());
         } else {
-            // 非 APP 走原 MP 自动分页查询
+            // 非 APP 走原 MP 自动分页查询(queryOrderList 仅查询从订单 parent_id != '0',不查主订单)
             orderListVoPage = insOrdersMapper.queryOrderList(insOrdersParam.getPage(), insOrdersParam);
         }
         // modify by lipf, 2026年4月29日11:06:02 解决业务员类型缺失的问题

+ 20 - 2
tenant/insurance/quotation-summary/src/main/resources/mapper/InsOrdersMapper.xml

@@ -1428,7 +1428,16 @@
         ) x WHERE x.rn = 1
         ) ioa1 ON io.id = ioa1.order_no
         <where>
-            and io.is_delete = 0 and io.parent_id = '0' and sujis.type_attr NOT IN (1,2,3,4)
+            and io.is_delete = 0
+            <choose>
+                <when test="insOrdersParam.isLargeOrder != null and insOrdersParam.isLargeOrder == '1'">
+                    and io.parent_id = '0'
+                </when>
+                <otherwise>
+                    and io.parent_id != '0'
+                </otherwise>
+            </choose>
+            and sujis.type_attr NOT IN (1,2,3,4)
             <if test="insOrdersParam.jzgInfoId != null and insOrdersParam.jzgInfoId != ''">
                 and io.real_quote_user_id in (select bbb.mobile from sys_user bbb where bbb.id in ( select ss.user_id
                 from sys_user_jzg_info ss where 1 =1 and (ss.leader_id = #{insOrdersParam.jzgInfoId} or ss.id
@@ -1641,7 +1650,16 @@
             ) x WHERE x.rn = 1
             ) ioa1 ON io.id = ioa1.order_no
             <where>
-                and io.is_delete = 0 and io.parent_id = '0' and sujis.type_attr NOT IN (1,2,3,4)
+                and io.is_delete = 0
+                <choose>
+                    <when test="insOrdersParam.isLargeOrder != null and insOrdersParam.isLargeOrder == '1'">
+                        and io.parent_id = '0'
+                    </when>
+                    <otherwise>
+                        and io.parent_id != '0'
+                    </otherwise>
+                </choose>
+                and sujis.type_attr NOT IN (1,2,3,4)
                 <if test="insOrdersParam.jzgInfoId != null and insOrdersParam.jzgInfoId != ''">
                     and io.real_quote_user_id in (select bbb.mobile from sys_user bbb where bbb.id in ( select ss.user_id
                     from sys_user_jzg_info ss where 1 =1 and (ss.leader_id = #{insOrdersParam.jzgInfoId} or ss.id