From 5267242ac94772fea114bac229e1a0aed56bdf8c Mon Sep 17 00:00:00 2001 From: gongbiao Date: Wed, 6 Nov 2019 13:20:59 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=95=86=E6=88=B7=E4=BC=9A=E5=91=98=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E5=88=97=E8=A1=A8][=E4=BF=AE=E6=94=B9][=E8=AF=A6?= =?UTF-8?q?=E6=83=85]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/WxMerchantMapper.xml | 59 +++++-------------- 1 file changed, 14 insertions(+), 45 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml index e74dbc0bf..8e3e5c180 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml @@ -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 - and o.tenant_id = #{tenantId} + and co.tenant_id = #{tenantId} - and o.create_date >= #{starttime} + and co.create_date >= #{starttime} - and o.create_date <= #{endtime} + and co.create_date <= #{endtime} - 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 - - and o.tenant_id = #{tenantId} - - - and o.create_date >= #{starttime} - - - and o.create_date <= #{endtime} - - 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 - - and o.tenant_id = #{tenantId} - - - and o.create_date >= #{starttime} - - - and o.create_date <= #{endtime} - - group by cm.merchant_id - ) price on price.merchant_id=m.id - where m.status=1 - and `name` like concat('%', #{name},'%') @@ -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} - and cm.`merchant_id` = #{id} + o.b_user_id in( + select id from wx_merchant_b_user where merchant_id=#{id} + )