|
|
|
@ -198,7 +198,6 @@
|
|
|
|
|
|
|
|
|
|
<select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount,
|
|
|
|
|
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) points,
|
|
|
|
|
COUNT(DISTINCT o.order_id) orders,max(t.clearing_amount) max_order
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.transaction_type>0)
|
|
|
|
@ -224,12 +223,11 @@
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY o.customer_id ORDER BY points desc
|
|
|
|
|
GROUP BY o.customer_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total_amount,
|
|
|
|
|
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) total_points
|
|
|
|
|
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total_amount
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.refund_id is not null)
|
|
|
|
|
<where>
|
|
|
|
|