Browse Source

[商户会员消费][修改][查询]

release_toaliyun_real
gongbiao 6 years ago
parent
commit
d85f011e3a
1 changed files with 49 additions and 35 deletions
  1. +49
    -35
      mallinkService/src/main/resources/mapper/WxMerchantMapper.xml

+ 49
- 35
mallinkService/src/main/resources/mapper/WxMerchantMapper.xml View File

@@ -424,47 +424,61 @@
</update>

<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 &gt;= #{starttime}
</if>
<if test="endtime != null">
and o.create_date &lt;= #{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 &gt;= #{starttime}
</if>
<if test="endtime != null">
and o.create_date &lt;= #{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 &gt;= #{starttime}
</if>
<if test="endtime != null">
and o.create_date &lt;= #{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 &gt;= #{starttime}
</if>
<if test="endtime != null">
and o.create_date &lt;= #{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 &gt;= #{starttime}
</if>
<if test="endtime != null">
and o.create_date &lt;= #{endtime}
</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 ">
and `name` like concat('%', #{name},'%')


Loading…
Cancel
Save