You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

185 lines
6.5 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.iformall.mapper.WxCouponActionLogMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponActionLog">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  8. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
  9. <result column="channel_type" jdbcType="INTEGER" property="channelType" />
  10. <result column="channel_id" jdbcType="BIGINT" property="channelId" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. </resultMap>
  13. <sql id="allColumns">
  14. `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time`
  15. </sql>
  16. <sql id="dynamicWhereConditions">
  17. where 1 = 1
  18. <if test=" null != id ">
  19. and `id` = #{id}
  20. </if>
  21. <if test=" null != tenantId ">
  22. and `tenant_id` = #{tenantId}
  23. </if>
  24. <if test=" null != couponId ">
  25. and `coupon_id` = #{couponId}
  26. </if>
  27. <if test=" null != couponOrderId ">
  28. and `coupon_order_id` = #{couponOrderId}
  29. </if>
  30. <if test=" null != channelType ">
  31. and `channel_type` = #{channelType}
  32. </if>
  33. <if test=" null != channelId ">
  34. and `channel_id` = #{channelId}
  35. </if>
  36. <if test=" null != createTime ">
  37. and `create_time` = #{createTime}
  38. </if>
  39. <if test=" null != startTime ">
  40. and `create_time` &gt;= #{startTime}
  41. </if>
  42. <if test=" null != endTime ">
  43. and `create_time` &lt;= #{endTime}
  44. </if>
  45. <if test=" null != ids ">
  46. and id in
  47. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  48. #{idItem}
  49. </foreach>
  50. </if>
  51. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  52. </sql>
  53. <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap">
  54. select <include refid="allColumns" /> from wx_coupon_action_log
  55. <include refid="dynamicWhereConditions" />
  56. </select>
  57. <select id="findCountByDateLimit" resultType="java.lang.Integer">
  58. select COUNT(*) FROM wx_coupon_action_log
  59. where tenant_id = #{tenantId}
  60. and `channel_type` != 0
  61. and `channel_type` != 1
  62. and `create_time` &gt;= #{startTime}
  63. and `create_time` &lt;= #{endTime}
  64. </select>
  65. <select id="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  66. select DATE_FORMAT(create_time,'%m/%d') as xTime,
  67. (select Count(*) from wx_coupon_action_log c
  68. where DATE_FORMAT(create_time,'%m/%d')=xTime
  69. and c.channel_type=2
  70. and tenant_id=#{tenantId} ) as parkSendCount,
  71. (select Count(*) from wx_coupon_action_log c
  72. where DATE_FORMAT(create_time,'%m/%d')=xTime
  73. and c.channel_type=3
  74. and tenant_id=#{tenantId}) as verifySendCount,
  75. (select Count(*) from wx_coupon_action_log c
  76. where DATE_FORMAT(create_time,'%m/%d')=xTime
  77. and c.channel_type=4
  78. and tenant_id=#{tenantId}) as microPaySendCount,
  79. (select Count(*) from wx_coupon_action_log c
  80. where DATE_FORMAT(create_time,'%m/%d')=xTime
  81. and c.channel_type=5
  82. and tenant_id=#{tenantId}) as orderSendCount
  83. from wx_coupon_action_log
  84. where tenant_id=#{tenantId}
  85. and channel_type in (2,3,4,5)
  86. and create_time &gt;= #{startTime}
  87. and create_time &lt;= #{endTime}
  88. group by xTime
  89. order by xTime desc
  90. </select>
  91. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  92. select DATE_FORMAT(create_date,'%m/%d') AS xTime,COUNT(wx_coupon_order.id) as tempCount from wx_coupon_action_log
  93. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  94. where wx_coupon_action_log.tenant_id=#{tenantId}
  95. ----- and wx_coupon_order.coupon_order_status = 1 ----
  96. and wx_coupon_action_log.create_time &gt;= #{startTime}
  97. and wx_coupon_action_log.create_time &lt;= #{endTime}
  98. and wx_coupon_action_log.channel_type = #{channelType}
  99. group by xTime
  100. order by xTime desc
  101. </select>
  102. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  103. select DATE_FORMAT(create_time,'%Y-%m-%d') as xTime,
  104. (select Count(*) from wx_coupon_action_log c
  105. where DATE_FORMAT(create_time,'%Y-%m-%d')=xTime
  106. and c.channel_type=#{channelType}
  107. and tenant_id=#{tenantId} ) as sendCount
  108. from wx_coupon_action_log
  109. where tenant_id=#{tenantId}
  110. and channel_type=#{channelType}
  111. <if test=" null != startTime ">
  112. and create_time &gt;= #{startTime}
  113. </if>
  114. <if test=" null != endTime ">
  115. and create_time &lt;= #{endTime}
  116. </if>
  117. group by xTime
  118. order by xTime desc
  119. </select>
  120. <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  121. select DATE_FORMAT(create_date,'%Y-%m-%d') AS xTime,COUNT(wx_coupon_order.id) as tempCount from wx_coupon_action_log left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  122. where wx_coupon_action_log.tenant_id=#{tenantId}
  123. and wx_coupon_order.coupon_order_status = 1
  124. <if test=" null != startTime ">
  125. and wx_coupon_action_log.create_time &gt;= #{startTime}
  126. </if>
  127. <if test=" null != endTime ">
  128. and wx_coupon_action_log.create_time &lt;= #{endTime}
  129. </if>
  130. and wx_coupon_action_log.channel_type = #{channelType}
  131. group by xTime
  132. order by xTime desc
  133. </select>
  134. <select id="getCountByChannelId" resultType="java.lang.Integer">
  135. select COUNT(*) FROM wx_coupon_action_log
  136. where tenant_id = #{tenantId}
  137. and channel_type = #{channelType}
  138. and channel_id = #{channelId}
  139. </select>
  140. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  141. select COUNT(*)
  142. FROM wx_coupon_action_log a, wx_coupon_order o
  143. WHERE a.coupon_order_id = o.id
  144. AND a.tenant_id = #{tenantId}
  145. AND o.c_user_id = #{cUserId}
  146. AND date(a.create_time) = curdate()
  147. </select>
  148. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  149. select COUNT(*)
  150. FROM wx_coupon_action_log a, wx_coupon_order o
  151. WHERE a.coupon_order_id = o.id
  152. AND a.tenant_id = #{tenantId}
  153. AND o.c_user_id = #{cUserId}
  154. AND a.coupon_id = #{couponId}
  155. AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate()
  156. </select>
  157. </mapper>