[fix]红包关联globalpay_openid

master
hellolujian 6 years ago
parent c0ec8defea
commit aadf58d211

@ -52,12 +52,18 @@
</select> </select>
<select id="analysisLuckyMoney" resultType="com.alibaba.fastjson.JSONObject"> <select id="analysisLuckyMoney" resultType="com.alibaba.fastjson.JSONObject">
SELECT COUNT(red_packet_order_id) total_counts,sum(red_packet_amount) total_amount, SELECT COUNT(red_packet_order_id) total_counts,
ifnull(SUM(if(status=0 AND lock_key is null,1,0)),0) unsend_counts,SUM(if(status=0 AND lock_key is null,red_packet_amount,0)) unsend_amount, sum(red_packet_amount) total_amount,
sum(if(status!=0,1,0)) send_counts,SUM(if(status !=0 ,red_packet_amount,0)) send_amount, ifnull(SUM(if(status=0 AND lock_key is null,1,0)),0) unsend_counts,
sum(if(status=2,1,0)) fail_counts,SUM(if(status=2,red_packet_amount,0)) fail_amount, SUM(if(status=0 AND lock_key is null,red_packet_amount,0)) unsend_amount,
sum(if(status=1 or status=3,1,0)) receive_counts,SUM(if(status=1 or status=3,red_packet_amount,0)) receive_amount, sum(if(status!=0,1,0)) send_counts,
sum(if(status=4,1,0)) return_counts,SUM(if(status=4,red_packet_amount,0)) return_amount SUM(if(status !=0 ,red_packet_amount,0)) send_amount,
sum(if(status=2,1,0)) fail_counts,
SUM(if(status=2,red_packet_amount,0)) fail_amount,
sum(if(status=1 or status=3,1,0)) receive_counts,
SUM(if(status=1 or status=3,red_packet_amount,0)) receive_amount,
sum(if(status=4,1,0)) return_counts,
SUM(if(status=4,red_packet_amount,0)) return_amount
FROM act_red_packets_orders FROM act_red_packets_orders
<where> <where>
act_id = #{act_id} act_id = #{act_id}
@ -164,7 +170,11 @@
<select id="getRedPacketsByOpenid" resultType="int"> <select id="getRedPacketsByOpenid" resultType="int">
SELECT count(1) FROM act_red_packets_orders WHERE open_id=#{open_id} and date(event_time) = date(#{event_date}) and status !=0 and act_id = '2' SELECT count(1)
FROM act_red_packets_orders
WHERE open_id=#{open_id}
and date(event_time) = date(#{event_date})
and status !=0 and act_id = '2'
</select> </select>

@ -24,15 +24,19 @@
AND status != 0 AND act_id = #{act_id} AND status != 0 AND act_id = #{act_id}
</select> </select>
<!-- 由于在sys_customer_relation中新增了关联字段globalpay_openid
所以重新关联此字段再次left join, 选取其中不为null的
-->
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT
a.*, a.*,
b.client_moniker, b.client_moniker,
c.headimg, ifnull(c.headimg, c2.headimg) headimg,
c.nickname ifnull(c.nickname, c2.nickname) nickname
FROM act_red_packets_customer_orders a FROM act_red_packets_customer_orders a
INNER JOIN sys_clients b ON a.client_id = b.client_id INNER JOIN sys_clients b ON a.client_id = b.client_id
LEFT JOIN sys_customer_relation c ON c.wechat_openid = a.open_id LEFT JOIN sys_customer_relation c ON c.wechat_openid = a.open_id
LEFT JOIN sys_customer_relation c2 ON c2.globalpay_openid = a.open_id
WHERE act_id = #{actId} WHERE act_id = #{actId}
<if test="client_moniker != null"> <if test="client_moniker != null">
AND b.client_moniker = #{client_moniker} AND b.client_moniker = #{client_moniker}

Loading…
Cancel
Save