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.
 
 
 
 
 

177 lignes
6.2 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 `create_time` &gt;= #{startTime}
  61. and `create_time` &lt;= #{endTime}
  62. </select>
  63. <select id="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  64. select DATE_FORMAT(create_time,'%m/%d') as xTime,
  65. (select Count(*) from wx_coupon_action_log c
  66. where DATE_FORMAT(create_time,'%m/%d')=xTime
  67. and c.channel_type=2
  68. and tenant_id=#{tenantId} ) as parkSendCount,
  69. (select Count(*) from wx_coupon_action_log c
  70. where DATE_FORMAT(create_time,'%m/%d')=xTime
  71. and c.channel_type=3
  72. and tenant_id=#{tenantId}) as verifySendCount
  73. from wx_coupon_action_log
  74. where tenant_id=#{tenantId}
  75. and create_time &gt;= #{startTime}
  76. and create_time &lt;= #{endTime}
  77. group by xTime
  78. order by xTime desc
  79. </select>
  80. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  81. select DATE_FORMAT(create_date,'%m/%d') AS xTime,COUNT(wx_coupon_order.id) as tempCount from wx_coupon_action_log
  82. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  83. where wx_coupon_action_log.tenant_id=#{tenantId}
  84. and wx_coupon_order.coupon_order_status = 1
  85. and wx_coupon_action_log.create_time &gt;= #{startTime}
  86. and wx_coupon_action_log.create_time &lt;= #{endTime}
  87. and wx_coupon_action_log.channel_type = #{channelType}
  88. group by xTime
  89. order by xTime desc
  90. </select>
  91. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  92. select DATE_FORMAT(create_time,'%Y-%m-%d') as xTime,
  93. (select Count(*) from wx_coupon_action_log c
  94. where DATE_FORMAT(create_time,'%Y-%m-%d')=xTime
  95. and c.channel_type=2
  96. and tenant_id=#{tenantId} ) as parkSendCount,
  97. (select Count(*) from wx_coupon_action_log c
  98. where DATE_FORMAT(create_time,'%Y-%m-%d')=xTime
  99. and c.channel_type=3
  100. and tenant_id=#{tenantId}) as verifySendCount
  101. from wx_coupon_action_log
  102. where tenant_id=#{tenantId}
  103. <if test=" null != startTime ">
  104. and create_time &gt;= #{startTime}
  105. </if>
  106. <if test=" null != endTime ">
  107. and create_time &lt;= #{endTime}
  108. </if>
  109. group by xTime
  110. order by xTime desc
  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,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
  114. where wx_coupon_action_log.tenant_id=#{tenantId}
  115. and wx_coupon_order.coupon_order_status = 1
  116. <if test=" null != startTime ">
  117. and wx_coupon_action_log.create_time &gt;= #{startTime}
  118. </if>
  119. <if test=" null != endTime ">
  120. and wx_coupon_action_log.create_time &lt;= #{endTime}
  121. </if>
  122. and wx_coupon_action_log.channel_type = #{channelType}
  123. group by xTime
  124. order by xTime desc
  125. </select>
  126. <select id="getCountByChannelId" resultType="java.lang.Integer">
  127. select COUNT(*) FROM wx_coupon_action_log
  128. where tenant_id = #{tenantId}
  129. and channel_type = #{channelType}
  130. and channel_id = #{channelId}
  131. </select>
  132. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  133. select COUNT(*)
  134. FROM wx_coupon_action_log a, wx_coupon_order o
  135. WHERE a.coupon_order_id = o.id
  136. AND a.tenant_id = #{tenantId}
  137. AND o.c_user_id = #{cUserId}
  138. AND a.create_time between date_sub(now(),interval 1 day) and now()
  139. </select>
  140. <select id="getCountByUserAndCoupon" 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 a.coupon_id = #{couponId}
  147. AND a.create_time between date_sub(now(),interval #{dayNum} day) and now()
  148. </select>
  149. </mapper>