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

处理app 订单数据重复的问题

lixiaolong 2 месяцев назад
Родитель
Сommit
a0b8115ef3

+ 10 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/mapper/InsOrdersMapper.java

@@ -43,6 +43,16 @@ public interface InsOrdersMapper extends BaseMapper<InsOrders> {
 
     List<OrderListVo> queryOrderListAll(@Param("insOrdersParam") InsOrdersParamVO insOrdersParam);
 
+    /**
+     * 手动分页版:按车牌+状态分组去重(每组取最新一条),返回当前页数据
+     */
+    List<OrderListVo> queryOrderListDistinct(@Param("insOrdersParam") InsOrdersParamVO insOrdersParam, @Param("offset") long offset, @Param("size") long size);
+
+    /**
+     * 手动分页版:统计按车牌+状态分组去重后的总条数
+     */
+    Long countOrderListDistinct(@Param("insOrdersParam") InsOrdersParamVO insOrdersParam);
+
     List<HistoryQuoteResultVo> getHistoryQuote(@Param("userName") String userName);
 
     Page<HistoryQuoteResultVo> getHistoryQuoteList(@Param("page") Page page, @Param("params") HistoryQuoteQueryVo historyQuoteQueryVo, @Param("userName") String userName);

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

@@ -80,6 +80,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 @RequiredArgsConstructor
@@ -1038,7 +1039,21 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             jzgInfoId = sysUserJzgInfo.getId();
             insOrdersParam.setJzgInfoId(jzgInfoId);
         }
-        Page<OrderListVo> orderListVoPage = insOrdersMapper.queryOrderList(insOrdersParam.getPage(), insOrdersParam);
+        Page<OrderListVo> orderListVoPage;
+        if (baseController.getUserSystemCode().equals("APP")) {
+            // 手动分页:按车牌+状态分组去重,先统计总数再取当前页(避免 MP 自动 count 解析窗口函数报错)
+            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);
+            orderListVoPage = new Page<>(current, size, total);
+            orderListVoPage.setRecords(records != null ? records : java.util.Collections.emptyList());
+        } else {
+            // 非 APP 走原 MP 自动分页查询
+            orderListVoPage = insOrdersMapper.queryOrderList(insOrdersParam.getPage(), insOrdersParam);
+        }
         // modify by lipf, 2026年4月29日11:06:02 解决业务员类型缺失的问题
         List<OrderListVo> records = orderListVoPage.getRecords();
         if (CollUtil.isNotEmpty(records)) {
@@ -1071,14 +1086,27 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         if (CollUtil.isEmpty(insOrders)) {
             return;
         }
+        Map<String, String> logoMap = new ConcurrentHashMap<>();
         for (OrderQuotationCompany insOrder : insOrders) {
-            HttpResult<EsmInsCompany> esmInsCompanyHttpResult = platformClient.findLogoById(insOrder.getCompanyId());
-            if (esmInsCompanyHttpResult.getCode() == 200) {
-                insOrder.setLogo(esmInsCompanyHttpResult.getData().getLogo());
+            String companyId = insOrder.getCompanyId();
+            if (StrUtil.isBlank(companyId)) {
+                continue;
+            }
+            String logo = logoMap.get(companyId);
+            if (StrUtil.isBlank(logo)) {
+                HttpResult<EsmInsCompany> result = platformClient.findLogoById(companyId);
+                if (result.getCode() == 200 && result.getData() != null) {
+                    logo = result.getData().getLogo();
+                    if (StrUtil.isNotBlank(logo)) {
+                        logoMap.put(companyId, logo);
+                    }
+                }
+            }
+            if (StrUtil.isNotBlank(logo)) {
+                insOrder.setLogo(logo);
             }
         }
 
-
         Map<String, Map<String, List<OrderQuotationCompany>>> groupMap = insOrders.stream().collect(Collectors.groupingBy(OrderQuotationCompany::getQuoteNo, Collectors.groupingBy(OrderQuotationCompany::getOrderStatus)));
         for (OrderListVo orders : orderList) {
             String orderNo = orders.getNo();

+ 405 - 0
tenant/insurance/quotation-summary/src/main/resources/mapper/InsOrdersMapper.xml

@@ -1233,6 +1233,411 @@
         order by io.create_time desc
     </select>
 
+    <!-- 手动分页版:按车牌+状态分组去重(每组取最新一条),返回当前页数据;不触发 MP 自动 count -->
+    <select id="queryOrderListDistinct" resultType="com.jzg.commons.entity.orders.vo.OrderListVo">
+        SELECT
+        io.id as order_no,
+        io.quote_no as no,
+        io.company_id,
+        io.company_name,
+        io.product_id as productCode,
+        io.product_name as productName,
+        io.order_status,
+        io.create_time,
+        io.create_by,
+        io.error_message,
+        ioci.license_no,
+        ioci.vin_no,
+        owner_u.name as owner_name,
+        owner_u.mobile as owner_mobile,
+        policy_u.name as policy_name,
+        policy_u.mobile as policy_mobile,
+        insur_u.name as insur_name,
+        insur_u.mobile as insur_mobile,
+        iorci.start_date as ci_start_date,
+        iorbi.start_date as bi_start_date,
+        iorco.sum_premium as sumPremium,
+        iorco.jq_premium as ciPremium,
+        iorco.sy_premium as biPremium,
+        iorco.jy_premium as niPremium,
+        iorco.tax_premium as vvTax,
+        su.username as recorder,
+        suji.name as salesmanInfo,
+        suji.id as jzgInfoId,
+        suji.type_attr as salesmanType,
+        pa.agreement_name as agreementName,
+        sd.name as deptName,
+        io.pay_link as paymentLink,
+        ioa.status as adjustStatus,
+        ioa.id as adjustId,
+        ioa1.after_premium as adjustPremium
+        FROM (
+            SELECT dedup.order_id
+            FROM (
+                SELECT
+                    io.id AS order_id,
+                    io.create_time,
+                    ROW_NUMBER() OVER(PARTITION BY COALESCE(ioci.license_no, io.id), io.order_status ORDER BY io.create_time DESC) AS rn
+                FROM
+                ins_orders io
+                LEFT JOIN ins_orders_car_info ioci ON ioci.order_no = io.id and ioci.is_delete = 0
+                LEFT JOIN
+                ins_orders_car_user_info owner_u on owner_u.order_no = io.id and owner_u.policy_person_type = 1 and owner_u.is_delete = 0
+                left JOIN
+                ins_orders_car_user_info policy_u on policy_u.order_no = io.id and policy_u.policy_person_type = 2 and policy_u.is_delete = 0
+                left JOIN
+                ins_orders_car_user_info insur_u on insur_u.order_no = io.id and insur_u.policy_person_type = 3 and insur_u.is_delete = 0
+                left join
+                ins_orders_risk iorci on iorci.order_no = io.id and iorci.risk_code = '0507' and iorci.is_delete = 0
+                left join
+                ins_orders_risk iorbi on iorbi.order_no = io.id and iorbi.risk_code = '0510' and iorbi.is_delete = 0
+                LEFT JOIN
+                ins_orders_costs iorco on iorco.order_no = io.id and iorco.is_delete = 0
+                left join
+                sys_user su on su.mobile = io.real_quote_user_id and su.is_delete = 0
+                left join
+                sys_user_jzg_info suji on suji.user_id = su.id and suji.system_code = #{insOrdersParam.systemCode} and suji.is_delete = 0
+                left join
+                sys_dept sd on sd.id = suji.dept_id and sd.is_delete = 0
+                left join
+                ptl_agreement pa on pa.id = io.agreement_id and pa.is_delete = 0
+                left join
+                (
+                SELECT *
+                FROM (
+                SELECT t.*,
+                ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+                FROM ins_order_adjust t where t.is_delete = 0
+                ) x WHERE x.rn = 1
+                ) ioa ON io.id = ioa.order_no
+                left join
+                (
+                SELECT *
+                FROM (
+                SELECT t.*,
+                ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+                FROM ins_order_adjust t where t.status = 2 and t.is_delete = 0
+                ) x WHERE x.rn = 1
+                ) ioa1 ON io.id = ioa1.order_no
+                <where>
+                    and io.is_delete = 0  and io.parent_id != '0'
+                    <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
+                        =#{insOrdersParam.jzgInfoId}) and ss.is_delete = 0 ) and bbb.is_delete = 0 )
+                    </if>
+                    <if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
+                        AND io.id = #{insOrdersParam.orderNo}
+                    </if>
+                    <if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
+                        AND ioci.license_no = #{insOrdersParam.licenseNo}
+                    </if>
+                    <if test="insOrdersParam.orderStatus!= null and insOrdersParam.orderStatus!= ''">
+                        AND io.order_status = #{insOrdersParam.orderStatus}
+                    </if>
+                    <if test="insOrdersParam.adjustStatus!= null and insOrdersParam.adjustStatus!= ''">
+                        AND ioa.status = #{insOrdersParam.adjustStatus}
+                    </if>
+                    <if test="insOrdersParam.salesman!= null">
+                        AND io.real_quote_user_id = #{insOrdersParam.salesman}
+                    </if>
+                    <if test="insOrdersParam.companyId != null and insOrdersParam.companyId != ''">
+                        AND io.company_id = #{insOrdersParam.companyId}
+                    </if>
+                    <if test="insOrdersParam.startDate != null and insOrdersParam.startDate != ''and insOrdersParam.endDate != null and insOrdersParam.endDate != ''">
+                        AND io.create_time BETWEEN #{insOrdersParam.startDate} and #{insOrdersParam.endDate}
+                    </if>
+                    <if test="insOrdersParam.companyName != null and insOrdersParam.companyName != ''">
+                        AND io.company_name = #{insOrdersParam.companyName}
+                    </if>
+                    <if test="insOrdersParam.productCode != null and insOrdersParam.productCode != ''">
+                        AND io.product_id = #{insOrdersParam.productCode}
+                    </if>
+                    <if test="insOrdersParam.productName != null and insOrdersParam.productName != ''">
+                        AND io.product_name = #{insOrdersParam.productName}
+                    </if>
+                    <if test="insOrdersParam.vinNo != null and insOrdersParam.vinNo != ''">
+                        AND ioci.vin_no = #{insOrdersParam.vinNo}
+                    </if>
+                    <if test="insOrdersParam.ownerName != null and insOrdersParam.ownerName != ''">
+                        AND owner_u.name = #{insOrdersParam.ownerName}
+                    </if>
+                    <if test="insOrdersParam.ownerMobile != null and insOrdersParam.ownerMobile != ''">
+                        AND owner_u.mobile = #{insOrdersParam.ownerMobile}
+                    </if>
+                    <if test="insOrdersParam.policyName != null and insOrdersParam.policyName != ''">
+                        AND policy_u.name = #{insOrdersParam.policyName}
+                    </if>
+                    <if test="insOrdersParam.policyMobile != null and insOrdersParam.policyMobile != ''">
+                        AND policy_u.mobile = #{insOrdersParam.policyMobile}
+                    </if>
+                    <if test="insOrdersParam.insurName != null and insOrdersParam.insurName != ''">
+                        AND insur_u.name = #{insOrdersParam.insurName}
+                    </if>
+                    <if test="insOrdersParam.insurMobile != null and insOrdersParam.insurMobile != ''">
+                        AND insur_u.mobile = #{insOrdersParam.insurMobile}
+                    </if>
+                    <if test="insOrdersParam.ciStartDate != null">
+                        AND iorci.start_date = #{insOrdersParam.ciStartDate}
+                    </if>
+                    <if test="insOrdersParam.biStartDate != null">
+                        AND iorbi.start_date = #{insOrdersParam.biStartDate}
+                    </if>
+                    <if test="insOrdersParam.sumPremium != null">
+                        AND iorco.sum_premium = #{insOrdersParam.sumPremium}
+                    </if>
+                    <if test="insOrdersParam.ciPremium != null">
+                        AND iorco.jq_premium = #{insOrdersParam.ciPremium}
+                    </if>
+                    <if test="insOrdersParam.biPremium != null">
+                        AND iorco.sy_premium = #{insOrdersParam.biPremium}
+                    </if>
+                    <if test="insOrdersParam.niPremium != null">
+                        AND iorco.jy_premium = #{insOrdersParam.niPremium}
+                    </if>
+                    <if test="insOrdersParam.vvTax != null">
+                        AND iorco.tax_premium = #{insOrdersParam.vvTax}
+                    </if>
+                    <if test="insOrdersParam.salesmanInfo != null and insOrdersParam.salesmanInfo != ''">
+                        AND su.username = #{insOrdersParam.salesmanInfo}
+                    </if>
+                    <if test="insOrdersParam.salesmanType != null and insOrdersParam.salesmanType != ''">
+                        AND suji.type_attr = #{insOrdersParam.salesmanType}
+                    </if>
+                    <if test="insOrdersParam.agreementName != null and insOrdersParam.agreementName != ''">
+                        AND pa.agreement_name = #{insOrdersParam.agreementName}
+                    </if>
+                    <if test="insOrdersParam.deptId != null and insOrdersParam.deptId != ''">
+                        AND sd.id = #{insOrdersParam.deptId}
+                    </if>
+                    <if test="insOrdersParam.deptName != null and insOrdersParam.deptName != ''">
+                        AND sd.name = #{insOrdersParam.deptName}
+                    </if>
+                    <if test="insOrdersParam.paymentLink != null and insOrdersParam.paymentLink != ''">
+                        AND io.pay_link = #{insOrdersParam.paymentLink}
+                    </if>
+                    <if test="insOrdersParam.adjustId != null">
+                        AND ioa.id = #{insOrdersParam.adjustId}
+                    </if>
+                    <if test="insOrdersParam.adjustPremium != null">
+                        AND ioa1.after_premium = #{insOrdersParam.adjustPremium}
+                    </if>
+                    <if test="insOrdersParam.startSigningTime != null and insOrdersParam.startSigningTime != ''and insOrdersParam.endSigningTime != null and insOrdersParam.endSigningTime != ''">
+                        AND io.signing_time BETWEEN #{insOrdersParam.startSigningTime} and #{insOrdersParam.endSigningTime}
+                    </if>
+                    <if test="insOrdersParam.startPayTime != null and insOrdersParam.startPayTime != ''and insOrdersParam.endPayTime != null and insOrdersParam.endPayTime != ''">
+                        AND io.pay_time BETWEEN #{insOrdersParam.startPayTime} and #{insOrdersParam.endPayTime}
+                    </if>
+                </where>
+            ) dedup
+            WHERE dedup.rn = 1
+            ORDER BY dedup.create_time DESC
+            LIMIT #{offset}, #{size}
+        ) p
+        JOIN ins_orders io ON io.id = p.order_id
+        LEFT JOIN ins_orders_car_info ioci ON ioci.order_no = io.id and ioci.is_delete = 0
+        LEFT JOIN
+        ins_orders_car_user_info owner_u on owner_u.order_no = io.id and owner_u.policy_person_type = 1 and owner_u.is_delete = 0
+        left JOIN
+        ins_orders_car_user_info policy_u on policy_u.order_no = io.id and policy_u.policy_person_type = 2 and policy_u.is_delete = 0
+        left JOIN
+        ins_orders_car_user_info insur_u on insur_u.order_no = io.id and insur_u.policy_person_type = 3 and insur_u.is_delete = 0
+        left join
+        ins_orders_risk iorci on iorci.order_no = io.id and iorci.risk_code = '0507' and iorci.is_delete = 0
+        left join
+        ins_orders_risk iorbi on iorbi.order_no = io.id and iorbi.risk_code = '0510' and iorbi.is_delete = 0
+        LEFT JOIN
+        ins_orders_costs iorco on iorco.order_no = io.id and iorco.is_delete = 0
+        left join
+        sys_user su on su.mobile = io.real_quote_user_id and su.is_delete = 0
+        left join
+        sys_user_jzg_info suji on suji.user_id = su.id and suji.system_code = #{insOrdersParam.systemCode} and suji.is_delete = 0
+        left join
+        sys_dept sd on sd.id = suji.dept_id and sd.is_delete = 0
+        left join
+        ptl_agreement pa on pa.id = io.agreement_id and pa.is_delete = 0
+        left join
+        (
+        SELECT *
+        FROM (
+        SELECT t.*,
+        ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+        FROM ins_order_adjust t where t.is_delete = 0
+        ) x WHERE x.rn = 1
+        ) ioa ON io.id = ioa.order_no
+        left join
+        (
+        SELECT *
+        FROM (
+        SELECT t.*,
+        ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+        FROM ins_order_adjust t where t.status = 2 and t.is_delete = 0
+        ) x WHERE x.rn = 1
+        ) ioa1 ON io.id = ioa1.order_no
+        order by io.create_time desc
+    </select>
+
+    <!-- 手动分页版:统计按车牌+状态分组去重后的总条数 -->
+    <select id="countOrderListDistinct" resultType="java.lang.Long">
+        SELECT COUNT(*) FROM (
+            SELECT
+                io.id AS order_id,
+                ROW_NUMBER() OVER(PARTITION BY COALESCE(ioci.license_no, io.id), io.order_status ORDER BY io.create_time DESC) AS rn
+            FROM
+            ins_orders io
+            LEFT JOIN ins_orders_car_info ioci ON ioci.order_no = io.id and ioci.is_delete = 0
+            LEFT JOIN
+            ins_orders_car_user_info owner_u on owner_u.order_no = io.id and owner_u.policy_person_type = 1 and owner_u.is_delete = 0
+            left JOIN
+            ins_orders_car_user_info policy_u on policy_u.order_no = io.id and policy_u.policy_person_type = 2 and policy_u.is_delete = 0
+            left JOIN
+            ins_orders_car_user_info insur_u on insur_u.order_no = io.id and insur_u.policy_person_type = 3 and insur_u.is_delete = 0
+            left join
+            ins_orders_risk iorci on iorci.order_no = io.id and iorci.risk_code = '0507' and iorci.is_delete = 0
+            left join
+            ins_orders_risk iorbi on iorbi.order_no = io.id and iorbi.risk_code = '0510' and iorbi.is_delete = 0
+            LEFT JOIN
+            ins_orders_costs iorco on iorco.order_no = io.id and iorco.is_delete = 0
+            left join
+            sys_user su on su.mobile = io.real_quote_user_id and su.is_delete = 0
+            left join
+            sys_user_jzg_info suji on suji.user_id = su.id and suji.system_code = #{insOrdersParam.systemCode} and suji.is_delete = 0
+            left join
+            sys_dept sd on sd.id = suji.dept_id and sd.is_delete = 0
+            left join
+            ptl_agreement pa on pa.id = io.agreement_id and pa.is_delete = 0
+            left join
+            (
+            SELECT *
+            FROM (
+            SELECT t.*,
+            ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+            FROM ins_order_adjust t where t.is_delete = 0
+            ) x WHERE x.rn = 1
+            ) ioa ON io.id = ioa.order_no
+            left join
+            (
+            SELECT *
+            FROM (
+            SELECT t.*,
+            ROW_NUMBER() OVER(PARTITION BY t.order_no ORDER BY t.create_time DESC) AS rn
+            FROM ins_order_adjust t where t.status = 2 and t.is_delete = 0
+            ) x WHERE x.rn = 1
+            ) ioa1 ON io.id = ioa1.order_no
+            <where>
+                and io.is_delete = 0  and io.parent_id != '0'
+                <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
+                    =#{insOrdersParam.jzgInfoId}) and ss.is_delete = 0 ) and bbb.is_delete = 0 )
+                </if>
+                <if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
+                    AND io.id = #{insOrdersParam.orderNo}
+                </if>
+                <if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
+                    AND ioci.license_no = #{insOrdersParam.licenseNo}
+                </if>
+                <if test="insOrdersParam.orderStatus!= null and insOrdersParam.orderStatus!= ''">
+                    AND io.order_status = #{insOrdersParam.orderStatus}
+                </if>
+                <if test="insOrdersParam.adjustStatus!= null and insOrdersParam.adjustStatus!= ''">
+                    AND ioa.status = #{insOrdersParam.adjustStatus}
+                </if>
+                <if test="insOrdersParam.salesman!= null">
+                    AND io.real_quote_user_id = #{insOrdersParam.salesman}
+                </if>
+                <if test="insOrdersParam.companyId != null and insOrdersParam.companyId != ''">
+                    AND io.company_id = #{insOrdersParam.companyId}
+                </if>
+                <if test="insOrdersParam.startDate != null and insOrdersParam.startDate != ''and insOrdersParam.endDate != null and insOrdersParam.endDate != ''">
+                    AND io.create_time BETWEEN #{insOrdersParam.startDate} and #{insOrdersParam.endDate}
+                </if>
+                <if test="insOrdersParam.companyName != null and insOrdersParam.companyName != ''">
+                    AND io.company_name = #{insOrdersParam.companyName}
+                </if>
+                <if test="insOrdersParam.productCode != null and insOrdersParam.productCode != ''">
+                    AND io.product_id = #{insOrdersParam.productCode}
+                </if>
+                <if test="insOrdersParam.productName != null and insOrdersParam.productName != ''">
+                    AND io.product_name = #{insOrdersParam.productName}
+                </if>
+                <if test="insOrdersParam.vinNo != null and insOrdersParam.vinNo != ''">
+                    AND ioci.vin_no = #{insOrdersParam.vinNo}
+                </if>
+                <if test="insOrdersParam.ownerName != null and insOrdersParam.ownerName != ''">
+                    AND owner_u.name = #{insOrdersParam.ownerName}
+                </if>
+                <if test="insOrdersParam.ownerMobile != null and insOrdersParam.ownerMobile != ''">
+                    AND owner_u.mobile = #{insOrdersParam.ownerMobile}
+                </if>
+                <if test="insOrdersParam.policyName != null and insOrdersParam.policyName != ''">
+                    AND policy_u.name = #{insOrdersParam.policyName}
+                </if>
+                <if test="insOrdersParam.policyMobile != null and insOrdersParam.policyMobile != ''">
+                    AND policy_u.mobile = #{insOrdersParam.policyMobile}
+                </if>
+                <if test="insOrdersParam.insurName != null and insOrdersParam.insurName != ''">
+                    AND insur_u.name = #{insOrdersParam.insurName}
+                </if>
+                <if test="insOrdersParam.insurMobile != null and insOrdersParam.insurMobile != ''">
+                    AND insur_u.mobile = #{insOrdersParam.insurMobile}
+                </if>
+                <if test="insOrdersParam.ciStartDate != null">
+                    AND iorci.start_date = #{insOrdersParam.ciStartDate}
+                </if>
+                <if test="insOrdersParam.biStartDate != null">
+                    AND iorbi.start_date = #{insOrdersParam.biStartDate}
+                </if>
+                <if test="insOrdersParam.sumPremium != null">
+                    AND iorco.sum_premium = #{insOrdersParam.sumPremium}
+                </if>
+                <if test="insOrdersParam.ciPremium != null">
+                    AND iorco.jq_premium = #{insOrdersParam.ciPremium}
+                </if>
+                <if test="insOrdersParam.biPremium != null">
+                    AND iorco.sy_premium = #{insOrdersParam.biPremium}
+                </if>
+                <if test="insOrdersParam.niPremium != null">
+                    AND iorco.jy_premium = #{insOrdersParam.niPremium}
+                </if>
+                <if test="insOrdersParam.vvTax != null">
+                    AND iorco.tax_premium = #{insOrdersParam.vvTax}
+                </if>
+                <if test="insOrdersParam.salesmanInfo != null and insOrdersParam.salesmanInfo != ''">
+                    AND su.username = #{insOrdersParam.salesmanInfo}
+                </if>
+                <if test="insOrdersParam.salesmanType != null and insOrdersParam.salesmanType != ''">
+                    AND suji.type_attr = #{insOrdersParam.salesmanType}
+                </if>
+                <if test="insOrdersParam.agreementName != null and insOrdersParam.agreementName != ''">
+                    AND pa.agreement_name = #{insOrdersParam.agreementName}
+                </if>
+                <if test="insOrdersParam.deptId != null and insOrdersParam.deptId != ''">
+                    AND sd.id = #{insOrdersParam.deptId}
+                </if>
+                <if test="insOrdersParam.deptName != null and insOrdersParam.deptName != ''">
+                    AND sd.name = #{insOrdersParam.deptName}
+                </if>
+                <if test="insOrdersParam.paymentLink != null and insOrdersParam.paymentLink != ''">
+                    AND io.pay_link = #{insOrdersParam.paymentLink}
+                </if>
+                <if test="insOrdersParam.adjustId != null">
+                    AND ioa.id = #{insOrdersParam.adjustId}
+                </if>
+                <if test="insOrdersParam.adjustPremium != null">
+                    AND ioa1.after_premium = #{insOrdersParam.adjustPremium}
+                </if>
+                <if test="insOrdersParam.startSigningTime != null and insOrdersParam.startSigningTime != ''and insOrdersParam.endSigningTime != null and insOrdersParam.endSigningTime != ''">
+                    AND io.signing_time BETWEEN #{insOrdersParam.startSigningTime} and #{insOrdersParam.endSigningTime}
+                </if>
+                <if test="insOrdersParam.startPayTime != null and insOrdersParam.startPayTime != ''and insOrdersParam.endPayTime != null and insOrdersParam.endPayTime != ''">
+                    AND io.pay_time BETWEEN #{insOrdersParam.startPayTime} and #{insOrdersParam.endPayTime}
+                </if>
+            </where>
+        ) dedup
+        WHERE dedup.rn = 1
+    </select>
+
     <select id="getHistoryQuote" resultType="com.jzg.commons.entity.orders.vo.HistoryQuoteResultVo">
         SELECT t.id as order_no,
                t.license_no