|
@@ -870,6 +870,7 @@
|
|
|
io.create_time,
|
|
io.create_time,
|
|
|
io.create_by,
|
|
io.create_by,
|
|
|
io.error_message,
|
|
io.error_message,
|
|
|
|
|
+ io.parent_id,
|
|
|
ioci.license_no,
|
|
ioci.license_no,
|
|
|
ioci.vin_no,
|
|
ioci.vin_no,
|
|
|
owner_u.name as owner_name,
|
|
owner_u.name as owner_name,
|
|
@@ -948,6 +949,9 @@
|
|
|
<if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
|
|
<if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
|
|
|
AND io.id = #{insOrdersParam.orderNo}
|
|
AND io.id = #{insOrdersParam.orderNo}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="insOrdersParam.parentId != null and insOrdersParam.parentId != ''">
|
|
|
|
|
+ AND io.parent_id = #{insOrdersParam.parentId}
|
|
|
|
|
+ </if>
|
|
|
<if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
|
|
<if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
|
|
|
AND ioci.license_no = #{insOrdersParam.licenseNo}
|
|
AND ioci.license_no = #{insOrdersParam.licenseNo}
|
|
|
</if>
|
|
</if>
|
|
@@ -1086,72 +1090,79 @@
|
|
|
ioa1.after_premium as adjustPremium
|
|
ioa1.after_premium as adjustPremium
|
|
|
FROM
|
|
FROM
|
|
|
ins_orders io
|
|
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_user_jzg_info_salesman sujis ON suji.id = sujis.sys_user_jzg_info_id AND sujis.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
|
|
|
|
|
|
|
+ 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_user_jzg_info_salesman sujis
|
|
|
|
|
+ ON suji.id = sujis.sys_user_jzg_info_id AND sujis.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
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 优化1: 替代原 ROW_NUMBER() 获取最新一条 adjust 记录 -->
|
|
|
|
|
+ LEFT JOIN ins_order_adjust ioa
|
|
|
|
|
+ ON ioa.id = (
|
|
|
|
|
+ SELECT t.id
|
|
|
|
|
+ FROM ins_order_adjust t
|
|
|
|
|
+ WHERE t.order_no = io.id AND t.is_delete = 0
|
|
|
|
|
+ ORDER BY t.create_time DESC, t.id DESC
|
|
|
|
|
+ LIMIT 1
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 优化2: 替代原 ROW_NUMBER() 获取 status=2 的最新一条 adjust 记录 -->
|
|
|
|
|
+ LEFT JOIN ins_order_adjust ioa1
|
|
|
|
|
+ ON ioa1.id = (
|
|
|
|
|
+ SELECT t.id
|
|
|
|
|
+ FROM ins_order_adjust t
|
|
|
|
|
+ WHERE t.order_no = io.id AND t.status = 2 AND t.is_delete = 0
|
|
|
|
|
+ ORDER BY t.create_time DESC, t.id DESC
|
|
|
|
|
+ LIMIT 1
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
<where>
|
|
<where>
|
|
|
and io.is_delete = 0 and sujis.type_attr NOT IN (1,2,3,4)
|
|
and io.is_delete = 0 and sujis.type_attr NOT IN (1,2,3,4)
|
|
|
|
|
+
|
|
|
<if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
|
|
<if test="insOrdersParam.orderNo != null and insOrdersParam.orderNo != ''">
|
|
|
AND io.id = #{insOrdersParam.orderNo}
|
|
AND io.id = #{insOrdersParam.orderNo}
|
|
|
</if>
|
|
</if>
|
|
|
-<!-- <if test="insOrdersParam.parentId != null">-->
|
|
|
|
|
-<!-- AND io.parent_id = #{insOrdersParam.parentId}-->
|
|
|
|
|
-<!-- </if>-->
|
|
|
|
|
<if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
|
|
<if test="insOrdersParam.licenseNo != null and insOrdersParam.licenseNo != ''">
|
|
|
AND ioci.license_no = #{insOrdersParam.licenseNo}
|
|
AND ioci.license_no = #{insOrdersParam.licenseNo}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="insOrdersParam.orderStatus!= null and insOrdersParam.orderStatus!= ''">
|
|
|
|
|
|
|
+ <if test="insOrdersParam.orderStatus != null and insOrdersParam.orderStatus != ''">
|
|
|
AND io.order_status = #{insOrdersParam.orderStatus}
|
|
AND io.order_status = #{insOrdersParam.orderStatus}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="insOrdersParam.adjustStatus!= null and insOrdersParam.adjustStatus!= ''">
|
|
|
|
|
|
|
+ <if test="insOrdersParam.adjustStatus != null and insOrdersParam.adjustStatus != ''">
|
|
|
AND ioa.status = #{insOrdersParam.adjustStatus}
|
|
AND ioa.status = #{insOrdersParam.adjustStatus}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="insOrdersParam.salesman!= null">
|
|
|
|
|
|
|
+ <if test="insOrdersParam.salesman != null">
|
|
|
AND io.real_quote_user_id = #{insOrdersParam.salesman}
|
|
AND io.real_quote_user_id = #{insOrdersParam.salesman}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="insOrdersParam.companyId != null and insOrdersParam.companyId != ''">
|
|
<if test="insOrdersParam.companyId != null and insOrdersParam.companyId != ''">
|
|
|
AND io.company_id = #{insOrdersParam.companyId}
|
|
AND io.company_id = #{insOrdersParam.companyId}
|
|
|
</if>
|
|
</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 test="insOrdersParam.startDate != null and insOrdersParam.startDate != ''">
|
|
|
|
|
+ AND io.create_time >= #{insOrdersParam.startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="insOrdersParam.endDate != null and insOrdersParam.endDate != ''">
|
|
|
|
|
+ AND io.create_time <= #{insOrdersParam.endDate}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="insOrdersParam.companyName != null and insOrdersParam.companyName != ''">
|
|
<if test="insOrdersParam.companyName != null and insOrdersParam.companyName != ''">
|
|
@@ -1232,11 +1243,21 @@
|
|
|
<if test="insOrdersParam.adjustPremium != null">
|
|
<if test="insOrdersParam.adjustPremium != null">
|
|
|
AND ioa1.after_premium = #{insOrdersParam.adjustPremium}
|
|
AND ioa1.after_premium = #{insOrdersParam.adjustPremium}
|
|
|
</if>
|
|
</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 test="insOrdersParam.startSigningTime != null and insOrdersParam.startSigningTime != ''">
|
|
|
|
|
+ AND io.signing_time >= #{insOrdersParam.startSigningTime}
|
|
|
</if>
|
|
</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 test="insOrdersParam.endSigningTime != null and insOrdersParam.endSigningTime != ''">
|
|
|
|
|
+ AND io.signing_time <= #{insOrdersParam.endSigningTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 支付时间范围优化 -->
|
|
|
|
|
+ <if test="insOrdersParam.startPayTime != null and insOrdersParam.startPayTime != ''">
|
|
|
|
|
+ AND io.pay_time >= #{insOrdersParam.startPayTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="insOrdersParam.endPayTime != null and insOrdersParam.endPayTime != ''">
|
|
|
|
|
+ AND io.pay_time <= #{insOrdersParam.endPayTime}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
order by io.create_time desc
|
|
order by io.create_time desc
|