<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.tcm.training.admin.statistics.mapper.RevenueStatisticsMapper">
|
|
<select id="selectDailyStatistics" resultType="com.tcm.training.admin.statistics.row.RevenueStatisticsDailyRow">
|
SELECT
|
DATE(f.trade_time) AS statDate,
|
SUM(CASE
|
WHEN f.flow_type = 'PAYMENT' AND f.business_type = 'COURSE_PURCHASE' THEN f.transaction_amount
|
ELSE 0
|
END) AS healthIncome,
|
SUM(CASE
|
WHEN f.flow_type = 'PAYMENT' AND f.business_type = 'MEMBER_PURCHASE' THEN f.transaction_amount
|
ELSE 0
|
END) AS memberIncome,
|
SUM(CASE
|
WHEN f.flow_type = 'REFUND' AND f.business_type = 'COURSE_PURCHASE' THEN f.transaction_amount
|
ELSE 0
|
END) AS healthRefundAmount,
|
SUM(CASE
|
WHEN f.flow_type = 'REFUND' AND f.business_type = 'MEMBER_PURCHASE' THEN f.transaction_amount
|
ELSE 0
|
END) AS memberRefundAmount,
|
SUM(CASE
|
WHEN f.flow_type = 'REFUND' THEN f.transaction_amount
|
ELSE 0
|
END) AS refundAmount
|
FROM tcm_payment_flow f
|
WHERE f.deleted = 0
|
AND f.business_type IN ('COURSE_PURCHASE', 'MEMBER_PURCHASE')
|
AND f.trade_time <![CDATA[>=]]> #{startTime}
|
AND f.trade_time <![CDATA[<=]]> #{endTime}
|
<if test="businessType != null and businessType.trim() != ''">
|
AND f.business_type = #{businessType}
|
</if>
|
GROUP BY DATE(f.trade_time)
|
ORDER BY DATE(f.trade_time) ASC
|
</select>
|
|
</mapper>
|