| @@ -424,47 +424,61 @@ | |||||
| </update> | </update> | ||||
| <select id="userTradeList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeVo"> | <select id="userTradeList" parameterType="com.iformall.domain.po.WxMerchant" resultType="com.iformall.domain.vo.WxMerchantTradeVo"> | ||||
| select m.id,m.`img_url` cover,m.`name` merchantName,m.`link_person` linkName, | |||||
| (select count(*) from wx_coupon_order o | |||||
| left join wx_coupon co on(o.`coupon_id`=co.id) | |||||
| left join wx_coupon_merchant cm on(cm.product_id=co.id) | |||||
| inner join wx_merchant_b_user mb on(mb.id=o.b_user_id) | |||||
| where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id | |||||
| <if test="starttime != null"> | |||||
| and o.create_date >= #{starttime} | |||||
| </if> | |||||
| <if test="endtime != null"> | |||||
| and o.create_date <= #{endtime} | |||||
| </if> | |||||
| ) consumeCount, | |||||
| (select count(distinct mb.id) from wx_coupon_order o | |||||
| left join wx_coupon co on(o.`coupon_id`=co.id) | |||||
| left join wx_coupon_merchant cm on(cm.product_id=co.id) | |||||
| inner join wx_merchant_b_user mb on(mb.id=o.b_user_id) | |||||
| where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id | |||||
| <if test="starttime != null"> | |||||
| and o.create_date >= #{starttime} | |||||
| </if> | |||||
| <if test="endtime != null"> | |||||
| and o.create_date <= #{endtime} | |||||
| </if> | |||||
| ) consumeCountP, | |||||
| IFNULL((select sum(co.price) from wx_coupon_order o | |||||
| left join wx_coupon co on(o.`coupon_id`=co.id) | |||||
| left join wx_coupon_merchant cm on(cm.product_id=co.id) | |||||
| inner join wx_merchant_b_user mb on(mb.id=o.b_user_id) | |||||
| where cm.`merchant_id`=m.id and o.coupon_order_status=1 and mb.merchant_id=m.id | |||||
| SELECT m.id, m.`img_url` cover, m.`name` merchantName, m.`link_person` linkName, | |||||
| ifnull(consume.consumeCount,0) consumeCount,ifnull(consumePeople.consumeCountP,0),ifnull(price.tradeAmt,0) | |||||
| tradeAmt | |||||
| FROM wx_merchant m | |||||
| left join (SELECT count(*) as consumeCount,cm.merchant_id FROM wx_coupon_order o | |||||
| LEFT JOIN wx_coupon co ON (o.`coupon_id` = co.id) | |||||
| LEFT JOIN wx_coupon_merchant cm ON (cm.product_id = co.id) | |||||
| WHERE o.coupon_order_status = 1 | |||||
| <if test="tenantId != null"> | |||||
| and o.tenant_id = #{tenantId} | |||||
| </if> | |||||
| <if test="starttime != null"> | |||||
| and o.create_date >= #{starttime} | |||||
| </if> | |||||
| <if test="endtime != null"> | |||||
| and o.create_date <= #{endtime} | |||||
| </if> | |||||
| group by cm.merchant_id | |||||
| ) consume on consume.merchant_id=m.id | |||||
| left join (SELECT count(DISTINCT o.c_user_id) as consumeCountP,cm.merchant_id FROM wx_coupon_order o | |||||
| LEFT JOIN wx_coupon co ON (o.`coupon_id` = co.id) | |||||
| LEFT JOIN wx_coupon_merchant cm ON (cm.product_id = co.id) | |||||
| WHERE o.coupon_order_status = 1 | |||||
| <if test="tenantId != null"> | |||||
| and o.tenant_id = #{tenantId} | |||||
| </if> | |||||
| <if test="starttime != null"> | |||||
| and o.create_date >= #{starttime} | |||||
| </if> | |||||
| <if test="endtime != null"> | |||||
| and o.create_date <= #{endtime} | |||||
| </if> | |||||
| group by cm.merchant_id | |||||
| ) consumePeople on consumePeople.merchant_id=m.id | |||||
| left join (SELECT sum(o.coupon_price) as tradeAmt,cm.merchant_id FROM wx_coupon_order o | |||||
| LEFT JOIN wx_coupon co ON (o.`coupon_id` = co.id) | |||||
| LEFT JOIN wx_coupon_merchant cm ON (cm.product_id = co.id) | |||||
| INNER JOIN wx_merchant_b_user mb ON (mb.id = o.b_user_id) | |||||
| WHERE o.coupon_order_status = 1 | |||||
| <if test="tenantId != null"> | |||||
| and o.tenant_id = #{tenantId} | |||||
| </if> | |||||
| <if test="starttime != null"> | <if test="starttime != null"> | ||||
| and o.create_date >= #{starttime} | and o.create_date >= #{starttime} | ||||
| </if> | </if> | ||||
| <if test="endtime != null"> | <if test="endtime != null"> | ||||
| and o.create_date <= #{endtime} | and o.create_date <= #{endtime} | ||||
| </if> | </if> | ||||
| ),0) tradeAmt | |||||
| from wx_merchant m where m.status=1 | |||||
| group by cm.merchant_id | |||||
| ) price on price.merchant_id=m.id | |||||
| where m.status=1 | |||||
| <if test=" null != name and ''!=name "> | <if test=" null != name and ''!=name "> | ||||
| and `name` like concat('%', #{name},'%') | and `name` like concat('%', #{name},'%') | ||||