Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

243 строки
8.4 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="getSceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportTVo" parameterType="hashmap">
  84. select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count
  85. from wx_coupon_action_log
  86. where tenant_id=#{tenantId}
  87. and channel_type in (2,3,4,5)
  88. and create_time &gt;= #{startTime}
  89. and create_time &lt;= #{endTime}
  90. group by create_time_md, channel_type
  91. order by create_time_md desc
  92. </select>
  93. <update id="updateCreateTimeMd" parameterType="hashmap">
  94. update wx_coupon_action_log
  95. set create_time_md = DATE_FORMAT(create_time,'%m/%d') where tenant_id = #{tenantId};
  96. </update>
  97. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  98. select DATE_FORMAT(create_date,'%m/%d') AS xTime,
  99. COUNT(wx_coupon_order.id) as tempCount
  100. from wx_coupon_action_log
  101. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  102. where wx_coupon_action_log.tenant_id=#{tenantId}
  103. ----- and wx_coupon_order.coupon_order_status = 1 ----
  104. and wx_coupon_action_log.create_time &gt;= #{startTime}
  105. and wx_coupon_action_log.create_time &lt;= #{endTime}
  106. and wx_coupon_action_log.channel_type = #{channelType}
  107. group by xTime
  108. order by xTime desc
  109. </select>
  110. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  111. select DATE_FORMAT(create_time,'%Y-%m-%d') as xtime,
  112. Count(*) as sendCount
  113. from wx_coupon_action_log
  114. where tenant_id=#{tenantId}
  115. and channel_type=#{channelType}
  116. <if test=" null != startTime ">
  117. and create_time &gt;= #{startTime}
  118. </if>
  119. <if test=" null != endTime ">
  120. and create_time &lt;= #{endTime}
  121. </if>
  122. group by xtime
  123. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  124. <if test=" null == sortColumns">order by xtime desc</if>
  125. </select>
  126. <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  127. select DATE_FORMAT(create_date,'%Y-%m-%d') AS xTime,
  128. COUNT(wx_coupon_order.id) as tempCount
  129. from wx_coupon_action_log
  130. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  131. where wx_coupon_action_log.tenant_id=#{tenantId}
  132. and wx_coupon_order.coupon_order_status = 1
  133. <if test=" null != startTime ">
  134. and wx_coupon_action_log.create_time &gt;= #{startTime}
  135. </if>
  136. <if test=" null != endTime ">
  137. and wx_coupon_action_log.create_time &lt;= #{endTime}
  138. </if>
  139. and wx_coupon_action_log.channel_type = #{channelType}
  140. group by xTime
  141. order by xTime desc
  142. </select>
  143. <select id="getCountByDateLimit" resultType="java.lang.Integer">
  144. select COUNT(*) FROM wx_coupon_action_log
  145. where tenant_id = #{tenantId}
  146. and `channel_type` != 0
  147. and `channel_type` != 1
  148. and `create_time` &gt;= #{startTime}
  149. and `create_time` &lt;= #{endTime}
  150. </select>
  151. <select id="getCountByChannelId" resultType="java.lang.Integer">
  152. select COUNT(*) FROM wx_coupon_action_log
  153. where tenant_id = #{tenantId}
  154. and channel_type = #{channelType}
  155. and channel_id = #{channelId}
  156. </select>
  157. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  158. select COUNT(*)
  159. FROM wx_coupon_action_log a, wx_coupon_order o
  160. WHERE a.coupon_order_id = o.id
  161. AND a.tenant_id = #{tenantId}
  162. AND o.c_user_id = #{cUserId}
  163. AND date(a.create_time) = curdate()
  164. </select>
  165. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  166. select COUNT(*)
  167. FROM wx_coupon_action_log a, wx_coupon_order o
  168. WHERE a.coupon_order_id = o.id
  169. AND a.tenant_id = #{tenantId}
  170. AND o.c_user_id = #{cUserId}
  171. AND a.coupon_id = #{couponId}
  172. AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate()
  173. </select>
  174. <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
  175. select COUNT(*)
  176. FROM wx_coupon_action_log a, wx_coupon_order o
  177. WHERE a.coupon_order_id = o.id
  178. AND a.tenant_id = #{tenantId}
  179. AND o.c_user_id = #{cUserId}
  180. <if test=" null != couponId ">
  181. AND a.coupon_id = #{couponId}
  182. </if>
  183. AND a.channel_type = #{channelType}
  184. and a.create_time &gt;= #{startTime}
  185. and a.create_time &lt;= #{endTime}
  186. </select>
  187. <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo">
  188. SELECT cal.id AS actionId,
  189. cal.coupon_id AS couponId,
  190. cal.create_time AS createDate,
  191. cs.id AS couponSendId,
  192. c.title,
  193. cu.nick_name AS userName,
  194. cu.phone,
  195. mbu.NAME AS operator
  196. FROM wx_coupon_action_log cal
  197. LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id
  198. LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id
  199. LEFT JOIN wx_coupon c ON cal.coupon_id = c.id
  200. LEFT JOIN wx_c_user cu ON cu.id = co.c_user_id
  201. LEFT JOIN wx_merchant_b_user mbu ON concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id')
  202. WHERE cal.channel_type = #{channelType}
  203. AND cs.conditions -> '$.id' = concat(#{merchantId},'')
  204. <if test=" null != beginDate ">
  205. AND cal.create_time &gt;= #{beginDate}
  206. </if>
  207. <if test=" null != endDate ">
  208. AND cal.create_time &lt; #{endDate}
  209. </if>
  210. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  211. </select>
  212. </mapper>