Просмотр исходного кода

[BUG][1000749]:修复小程序营销数据的查询语句

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
c9945b9c2b
1 измененных файлов: 26 добавлений и 21 удалений
  1. +26
    -21
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 26
- 21
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -145,33 +145,38 @@
</select>

<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
,(select Count(coupon_id) from wx_coupon_order c
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,
wx_coupon_order.coupon_id as couponId
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
,(case when coupon_type &lt; 7 then
(select Count(coupon_id) from wx_coupon_order c
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and DATE_FORMAT(update_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and c.coupon_id=couponId
<if test="startTime != null">
and c.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and c.update_date &lt;= #{endTime}
</if>
) as verifyCount
,(select Count(DISTINCT c_user_id) from wx_coupon_order d
) else
(select Count(card_id) from wx_coupon_order c, wx_card_spend cs
where DATE_FORMAT(cs.create_date,'%Y-%m-%d')=createTime
and c.tenant_id=#{tenantId}
and c.coupon_id=couponId
and c.id=cs.card_id
) end)
as verifyCount
,(case when coupon_type &lt; 7 then
(select Count(DISTINCT c_user_id) from wx_coupon_order d
where coupon_order_status=1
and d.coupon_id=couponId
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and DATE_FORMAT(update_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and d.coupon_id=couponId
<if test="startTime != null">
and d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and d.update_date &lt;= #{endTime}
</if>
) as verifyUserCount
) else
(select Count(DISTINCT cs.owner_id) from wx_coupon_order c, wx_card_spend cs
where DATE_FORMAT(cs.create_date,'%Y-%m-%d')=createTime
and c.tenant_id=#{tenantId}
and c.coupon_id=couponId
and c.id=cs.card_id
) end)
as verifyUserCount
from wx_coupon_order
join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id
where wx_coupon_order.tenant_id=#{tenantId}
@@ -187,7 +192,7 @@
<if test="couponTitle != null">
and wx_coupon.title like concat('%', #{couponTitle},'%')
</if>
GROUP BY createTime,couponId
GROUP BY createTime,couponId,coupon_type
order by createTime desc
</select>



Загрузка…
Отмена
Сохранить