from (select ci.`id`, ci.`tenant_id`, ci.`coupon_id`, ci.`transaction_id`, ci.`amount`, ci.`sale_amount`, ci.`remaining_amount`, ci.`service_fee_amount`, ci.`share_fee_amount`, ci.`remaining_share_fee_amount`, ci.`rate_amount`, ci.`create_date`, ci.`update_date` from wx_card_info ci where ci.`tenant_id` = #{tenantId}) ci
left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1
left join wx_coupon_action_log cal on co.id = cal.coupon_order_id and co.coupon_id = cal.coupon_id
-->
<!--
from (select wcm.product_id,wcm.merchant_id,count(1) as mc from wx_coupon_merchant wcm where status = 0 and wcm.tenant_id = #{tenantId} group by product_id) couc
right join (select co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price from wx_coupon_order co where co.tenant_id = #{tenantId}) co on co.coupon_id = couc.product_id
inner join wx_c_user cu on cu.id=co.c_user_id
left join wx_coupon c on c.id = co.coupon_id
left join wx_merchant m1 on m1.id = couc.merchant_id
left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1
left join wx_merchant_b_user mbu on mbu.id = co.b_user_id
left join wx_merchant m2 on m2.id = mbu.merchant_id
left join wx_coupon_action_log cal on cal.coupon_order_id = co.id and cal.coupon_id = co.coupon_id
where 1=1-->
FROM (
SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
FROM wx_coupon_merchant wcm
WHERE STATUS = 0 AND wcm.tenant_id = #{tenantId} GROUP BY product_id) couc