|
|
|
@ -33,26 +33,11 @@
|
|
|
|
|
LEFT JOIN sys_clients sc
|
|
|
|
|
ON re.client_moniker = sc.client_moniker
|
|
|
|
|
<if test="start_amount != null || end_amount != null">
|
|
|
|
|
RIGHT JOIN(
|
|
|
|
|
SELECT distinct re.risk_id
|
|
|
|
|
FROM
|
|
|
|
|
risk_event re,
|
|
|
|
|
risk_event_help reh
|
|
|
|
|
<where>
|
|
|
|
|
reh.risk_event_help_id < (LENGTH(re.order_amounts) - LENGTH(REPLACE(re.order_amounts, ',' , ''))) + 1
|
|
|
|
|
<if test="start_amount != null">
|
|
|
|
|
AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) >= #{start_amount}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="end_amount != null">
|
|
|
|
|
AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) <= #{end_amount}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
) temp
|
|
|
|
|
on re.risk_id = temp.risk_id
|
|
|
|
|
RIGHT JOIN
|
|
|
|
|
(SELECT DISTINCT(risk_id) FROM risk_orders
|
|
|
|
|
WHERE #{start_amount} <= clearing_amount AND #{end_amount} > clearing_amount) ro
|
|
|
|
|
ON re.risk_id = ro.risk_id
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="bd_id != null">
|
|
|
|
|
INNER JOIN(
|
|
|
|
|
SELECT DISTINCT client_id
|
|
|
|
@ -184,25 +169,93 @@
|
|
|
|
|
LEFT JOIN sys_clients sc
|
|
|
|
|
ON re.client_moniker = sc.client_moniker
|
|
|
|
|
<if test="start_amount != null || end_amount != null">
|
|
|
|
|
RIGHT JOIN(
|
|
|
|
|
SELECT distinct re.risk_id
|
|
|
|
|
FROM
|
|
|
|
|
risk_event re,
|
|
|
|
|
risk_event_help reh
|
|
|
|
|
RIGHT JOIN
|
|
|
|
|
(SELECT DISTINCT(risk_id) FROM risk_orders
|
|
|
|
|
WHERE #{start_amount} <= clearing_amount AND #{end_amount} > clearing_amount) ro
|
|
|
|
|
ON re.risk_id = ro.risk_id
|
|
|
|
|
</if>
|
|
|
|
|
<where>
|
|
|
|
|
reh.risk_event_help_id < (LENGTH(re.order_amounts) - LENGTH(REPLACE(re.order_amounts, ',' , ''))) + 1
|
|
|
|
|
<if test="start_amount != null">
|
|
|
|
|
AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) >= #{start_amount}
|
|
|
|
|
<if test="risk_id != null">
|
|
|
|
|
AND re.risk_id = #{risk_id}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="end_amount != null">
|
|
|
|
|
AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) <= #{end_amount}
|
|
|
|
|
<if test="client_moniker != null">
|
|
|
|
|
AND re.client_moniker = #{client_moniker}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="is_send_client != null">
|
|
|
|
|
AND re.is_send_client = #{is_send_client}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="order_types != null">
|
|
|
|
|
<foreach collection="order_types" item="order_type_item" open="and re.order_type in (" close=")" separator=",">
|
|
|
|
|
#{order_type_item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="order_type != null">
|
|
|
|
|
AND re.order_type = #{order_type}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="result_types != null">
|
|
|
|
|
<foreach collection="result_types" item="result_type_item" open="AND re.result_type IN (" close=")" separator=",">
|
|
|
|
|
#{result_type_item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="result_type != null">
|
|
|
|
|
AND re.result_type = #{result_type}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="order_ids != null">
|
|
|
|
|
AND re.order_ids LIKE CONCAT('%', #{order_ids}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="sub_merchant_id != null">
|
|
|
|
|
AND sc.sub_merchant_id = #{sub_merchant_id}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="industry != null">
|
|
|
|
|
AND sc.industry = #{industry}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
) temp
|
|
|
|
|
on re.risk_id = temp.risk_id
|
|
|
|
|
<if test="receive_email_date_begin != null">
|
|
|
|
|
AND re.receive_email_date >= #{receive_email_date_begin}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="receive_email_date_end != null">
|
|
|
|
|
AND re.receive_email_date <= #{receive_email_date_end}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="reply_email_date_begin != null">
|
|
|
|
|
AND re.reply_email_date >= #{reply_email_date_begin}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="reply_email_date_end != null">
|
|
|
|
|
AND re.reply_email_date <= #{reply_email_date_begin}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="real_order_ids != null">
|
|
|
|
|
AND re.real_order_ids = #{real_order_ids}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY sc.industry
|
|
|
|
|
</select>
|
|
|
|
|
<select id="analysisByAmount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT
|
|
|
|
|
ELT(INTERVAL(ro.clearing_amount,0, 500, 1000, 1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,999999),
|
|
|
|
|
'0-500','500-1000','1000-1500','1500-2000','2000-2500','2500-3000','3000-3500','3500-4000','4000-4500','4500-5000','5000-5500','5500-6000',
|
|
|
|
|
'6000-6500','6500-7000','7000-7500','7500-8000','8000-8500','8500-9000','>9000') intervals,COUNT(ro.order_id) amount
|
|
|
|
|
FROM risk_event re
|
|
|
|
|
LEFT JOIN sys_clients sc
|
|
|
|
|
ON re.client_moniker = sc.client_moniker
|
|
|
|
|
RIGHT JOIN
|
|
|
|
|
(SELECT * FROM risk_orders
|
|
|
|
|
<if test="start_amount != null || end_amount != null">
|
|
|
|
|
WHERE #{start_amount} <= clearing_amount AND #{end_amount} > clearing_amount
|
|
|
|
|
</if>
|
|
|
|
|
) ro
|
|
|
|
|
ON re.risk_id = ro.risk_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="risk_id != null">
|
|
|
|
|
AND re.risk_id = #{risk_id}
|
|
|
|
@ -268,9 +321,9 @@
|
|
|
|
|
AND re.real_order_ids = #{real_order_ids}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY sc.industry
|
|
|
|
|
GROUP BY ELT(INTERVAL(ro.clearing_amount,0, 500, 1000, 1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,999999),
|
|
|
|
|
'0-500','500-1000','1000-1500','1500-2000','2000-2500','2500-3000','3000-3500','3500-4000','4000-4500','4500-5000','5000-5500','5500-6000',
|
|
|
|
|
'6000-6500','6500-7000','7000-7500','7500-8000','8000-8500','8500-9000','>9000')
|
|
|
|
|
ORDER BY intervals
|
|
|
|
|
</select>
|
|
|
|
|
<!--<select id="analysisByAmount" resultType="com.alibaba.fastjson.JSONObject">-->
|
|
|
|
|
|
|
|
|
|
<!--</select>-->
|
|
|
|
|
</mapper>
|
|
|
|
|