Commit f153c166 by jianan

应付明细17

parent 90c649e0
...@@ -388,32 +388,34 @@ ...@@ -388,32 +388,34 @@
<select id="queryListStatistics" resultType="com.yd.csf.service.vo.ExpectedFortuneStatisticsVO"> <select id="queryListStatistics" resultType="com.yd.csf.service.vo.ExpectedFortuneStatisticsVO">
WITH filtered_data AS ( WITH filtered_data AS (
SELECT * SELECT
FROM expected_fortune ef.hkd_amount,
WHERE is_deleted = 0 ef.paid_amount,
AND is_part IN (0, 1) ef.unpaid_amount,
ef.policy_no,
ef.default_exchange_rate
FROM expected_fortune ef
WHERE ef.is_deleted = 0
AND ef.is_part IN (0, 1)
<if test="ew != null"> <if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''"> <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment} AND ${ew.sqlSegment}
</if> </if>
</if> </if>
), ),
policy_premium AS ( premium_total AS (
SELECT SELECT SUM(p.total_payment_premium * dp.default_exchange_rate) AS total_premium
policy_no, FROM (SELECT DISTINCT policy_no, default_exchange_rate FROM filtered_data) dp
MIN(p.total_payment_premium * default_exchange_rate) AS premium_amount INNER JOIN policy p ON p.policy_no = dp.policy_no
FROM filtered_data
INNER JOIN policy p USING(policy_no)
GROUP BY policy_no
) )
SELECT SELECT
COALESCE(SUM(fd.hkd_amount), 0) AS totalExpectedAmount, COALESCE(SUM(fd.hkd_amount), 0) AS totalExpectedAmount,
COALESCE(SUM(fd.paid_amount), 0) AS totalPaidAmount, COALESCE(SUM(fd.paid_amount), 0) AS totalPaidAmount,
COALESCE(SUM(fd.unpaid_amount), 0) AS totalUnpaidAmount, COALESCE(SUM(fd.unpaid_amount), 0) AS totalUnpaidAmount,
COALESCE(SUM(pp.premium_amount), 0) AS totalPremiumAmount, COALESCE(pt.total_premium, 0) AS totalPremiumAmount,
COUNT(DISTINCT fd.policy_no) AS totalPolicyCount COUNT(DISTINCT fd.policy_no) AS totalPolicyCount
FROM filtered_data fd FROM filtered_data fd
LEFT JOIN policy_premium pp USING(policy_no) CROSS JOIN premium_total pt
</select> </select>
<select id="queryListNewCount" resultType="java.lang.Long"> <select id="queryListNewCount" resultType="java.lang.Long">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment