select res.*,IFNULL(round(sum_payment/sale_count*100,2),0) as payment_rate from (
select c.*,
(select count(wco.id) from wx_coupon_order wco where wco.coupon_id = c.id) as sale_count,
(select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
@@ -587,24 +591,27 @@
where wc.id = c.id) as sum_subsidy
from wx_coupon c where c.type not in(8,9,100)
) res
) la
<if test=" 1 == type ">
and c.sale_price > 0
and la.sale_price > 0
</if>
<if test=" 2 == type ">
and c.sale_price = 0
and la.sale_price = 0
</if>
<if test="title != null and title != ''">
and c.title like concat('%', #{title},'%')
and la.title like concat('%', #{title},'%')
</if>
<if test="id != null">
and c.id = #{id}
and la.id = #{id}
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
<if test=" null == sortColumns">order by c.status asc,c.create_date desc</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
<if test=" null == sortColumns">order by la.status asc,la.create_date desc</if>