| @@ -429,57 +429,25 @@ | |||
| ifnull(consume.consumeCount,0) consumeCount,ifnull(consumePeople.consumeCountP,0) as consumeCountP, | |||
| 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 | |||
| left join (select count(co.c_user_id) AS consumeCount, | |||
| count(DISTINCT co.c_user_id) AS consumeCountP,sum(co.coupon_price) AS tradeAmt, m.id as merchant_id from | |||
| wx_coupon_order co | |||
| left join (select m.id,mbu.id as b_user_id from wx_merchant m | |||
| left join wx_merchant_b_user mbu on m.id=mbu.merchant_id) m | |||
| on o.b_user_id=m.b_user_id | |||
| WHERE co.coupon_order_status = 1 | |||
| <if test="tenantId != null"> | |||
| and o.tenant_id = #{tenantId} | |||
| and co.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test="starttime != null"> | |||
| and o.create_date >= #{starttime} | |||
| and co.create_date >= #{starttime} | |||
| </if> | |||
| <if test="endtime != null"> | |||
| and o.create_date <= #{endtime} | |||
| and co.create_date <= #{endtime} | |||
| </if> | |||
| group by cm.merchant_id | |||
| group by m.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"> | |||
| and o.create_date >= #{starttime} | |||
| </if> | |||
| <if test="endtime != null"> | |||
| and o.create_date <= #{endtime} | |||
| </if> | |||
| group by cm.merchant_id | |||
| ) price on price.merchant_id=m.id | |||
| where m.status=1 | |||
| <if test=" null != name and ''!=name "> | |||
| and `name` like concat('%', #{name},'%') | |||
| </if> | |||
| @@ -498,12 +466,13 @@ | |||
| co.price tradeAmt,o.create_date tradeDate | |||
| 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) | |||
| left join wx_c_user_basic_info cb on o.c_user_id=cb.id | |||
| where o.coupon_order_status=1 | |||
| and o.tenant_id=#{tenantId} | |||
| <if test=" null != id "> | |||
| and cm.`merchant_id` = #{id} | |||
| o.b_user_id in( | |||
| select id from wx_merchant_b_user where merchant_id=#{id} | |||
| ) | |||
| </if> | |||
| <if test=" null != userName "> | |||