Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

200 lignes
6.9 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="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  58. select DATE_FORMAT(create_time,'%m/%d') as xTime,
  59. (select Count(*) from wx_coupon_action_log c
  60. where DATE_FORMAT(create_time,'%m/%d')=xTime
  61. and c.channel_type=2
  62. and tenant_id=#{tenantId} ) as parkSendCount,
  63. (select Count(*) from wx_coupon_action_log c
  64. where DATE_FORMAT(create_time,'%m/%d')=xTime
  65. and c.channel_type=3
  66. and tenant_id=#{tenantId}) as verifySendCount,
  67. (select Count(*) from wx_coupon_action_log c
  68. where DATE_FORMAT(create_time,'%m/%d')=xTime
  69. and c.channel_type=4
  70. and tenant_id=#{tenantId}) as microPaySendCount,
  71. (select Count(*) from wx_coupon_action_log c
  72. where DATE_FORMAT(create_time,'%m/%d')=xTime
  73. and c.channel_type=5
  74. and tenant_id=#{tenantId}) as orderSendCount
  75. from wx_coupon_action_log
  76. where tenant_id=#{tenantId}
  77. and channel_type in (2,3,4,5)
  78. and create_time &gt;= #{startTime}
  79. and create_time &lt;= #{endTime}
  80. group by xTime
  81. order by xTime desc
  82. </select>
  83. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  84. select DATE_FORMAT(create_date,'%m/%d') AS xTime,
  85. COUNT(wx_coupon_order.id) as tempCount
  86. from wx_coupon_action_log
  87. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  88. where wx_coupon_action_log.tenant_id=#{tenantId}
  89. ----- and wx_coupon_order.coupon_order_status = 1 ----
  90. and wx_coupon_action_log.create_time &gt;= #{startTime}
  91. and wx_coupon_action_log.create_time &lt;= #{endTime}
  92. and wx_coupon_action_log.channel_type = #{channelType}
  93. group by xTime
  94. order by xTime desc
  95. </select>
  96. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  97. select DATE_FORMAT(create_time,'%Y-%m-%d') as xTime,
  98. Count(*) as sendCount
  99. from wx_coupon_action_log
  100. where tenant_id=#{tenantId}
  101. and channel_type=#{channelType}
  102. <if test=" null != startTime ">
  103. and create_time &gt;= #{startTime}
  104. </if>
  105. <if test=" null != endTime ">
  106. and create_time &lt;= #{endTime}
  107. </if>
  108. group by xTime
  109. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  110. <if test=" null == sortColumns"> order by xTime desc </if>
  111. </select>
  112. <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  113. select DATE_FORMAT(create_date,'%Y-%m-%d') AS xTime,
  114. COUNT(wx_coupon_order.id) as tempCount
  115. from wx_coupon_action_log
  116. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  117. where wx_coupon_action_log.tenant_id=#{tenantId}
  118. and wx_coupon_order.coupon_order_status = 1
  119. <if test=" null != startTime ">
  120. and wx_coupon_action_log.create_time &gt;= #{startTime}
  121. </if>
  122. <if test=" null != endTime ">
  123. and wx_coupon_action_log.create_time &lt;= #{endTime}
  124. </if>
  125. and wx_coupon_action_log.channel_type = #{channelType}
  126. group by xTime
  127. order by xTime desc
  128. </select>
  129. <select id="getCountByDateLimit" resultType="java.lang.Integer">
  130. select COUNT(*) FROM wx_coupon_action_log
  131. where tenant_id = #{tenantId}
  132. and `channel_type` != 0
  133. and `channel_type` != 1
  134. and `create_time` &gt;= #{startTime}
  135. and `create_time` &lt;= #{endTime}
  136. </select>
  137. <select id="getCountByChannelId" resultType="java.lang.Integer">
  138. select COUNT(*) FROM wx_coupon_action_log
  139. where tenant_id = #{tenantId}
  140. and channel_type = #{channelType}
  141. and channel_id = #{channelId}
  142. </select>
  143. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  144. select COUNT(*)
  145. FROM wx_coupon_action_log a, wx_coupon_order o
  146. WHERE a.coupon_order_id = o.id
  147. AND a.tenant_id = #{tenantId}
  148. AND o.c_user_id = #{cUserId}
  149. AND date(a.create_time) = curdate()
  150. </select>
  151. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  152. select COUNT(*)
  153. FROM wx_coupon_action_log a, wx_coupon_order o
  154. WHERE a.coupon_order_id = o.id
  155. AND a.tenant_id = #{tenantId}
  156. AND o.c_user_id = #{cUserId}
  157. AND a.coupon_id = #{couponId}
  158. AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate()
  159. </select>
  160. <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
  161. select COUNT(*)
  162. FROM wx_coupon_action_log a, wx_coupon_order o
  163. WHERE a.coupon_order_id = o.id
  164. AND a.tenant_id = #{tenantId}
  165. AND o.c_user_id = #{cUserId}
  166. AND a.coupon_id = #{couponId}
  167. AND a.channel_type = #{channelType}
  168. and a.create_time &gt;= #{startTime}
  169. and a.create_time &lt;= #{endTime}
  170. </select>
  171. </mapper>