Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

330 rindas
11 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="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  9. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
  10. <result column="channel_type" jdbcType="INTEGER" property="channelType" />
  11. <result column="channel_id" jdbcType="BIGINT" property="channelId" />
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  13. </resultMap>
  14. <sql id="allColumns">
  15. `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time`
  16. </sql>
  17. <sql id="dynamicWhereConditions">
  18. where 1 = 1
  19. <if test=" null != id ">
  20. and `id` = #{id}
  21. </if>
  22. <if test=" null != tenantId and '' != tenantId">
  23. and `tenant_id` = #{tenantId}
  24. </if>
  25. <if test=" null != parentTenantId and '' != parentTenantId">
  26. and `parent_tenant_id` = #{parentTenantId}
  27. </if>
  28. <if test=" null != couponId ">
  29. and `coupon_id` = #{couponId}
  30. </if>
  31. <if test=" null != couponOrderId ">
  32. and `coupon_order_id` = #{couponOrderId}
  33. </if>
  34. <if test=" null != channelType ">
  35. and `channel_type` = #{channelType}
  36. </if>
  37. <if test=" null != channelId ">
  38. and `channel_id` = #{channelId}
  39. </if>
  40. <if test=" null != createTime ">
  41. and `create_time` = #{createTime}
  42. </if>
  43. <if test=" null != startTime ">
  44. and `create_time` &gt;= #{startTime}
  45. </if>
  46. <if test=" null != endTime ">
  47. and `create_time` &lt;= #{endTime}
  48. </if>
  49. <if test=" null != ids ">
  50. and id in
  51. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  52. #{idItem}
  53. </foreach>
  54. </if>
  55. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  56. </sql>
  57. <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap">
  58. select
  59. <include refid="allColumns"/>
  60. from wx_coupon_action_log
  61. <include refid="dynamicWhereConditions" />
  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. <if test=" null != tenantId and '' != tenantId">
  69. and `tenant_id` = #{tenantId}
  70. </if>
  71. <if test=" null != parentTenantId and '' != parentTenantId">
  72. and `parent_tenant_id` = #{parentTenantId}
  73. </if>
  74. ) as parkSendCount,
  75. (select Count(*) from wx_coupon_action_log c
  76. where DATE_FORMAT(create_time,'%m/%d')=xTime
  77. and c.channel_type=3
  78. <if test=" null != tenantId and '' != tenantId">
  79. and `tenant_id` = #{tenantId}
  80. </if>
  81. <if test=" null != parentTenantId and '' != parentTenantId">
  82. and `parent_tenant_id` = #{parentTenantId}
  83. </if>
  84. ) as verifySendCount,
  85. (select Count(*) from wx_coupon_action_log c
  86. where DATE_FORMAT(create_time,'%m/%d')=xTime
  87. and c.channel_type=4
  88. <if test=" null != tenantId and '' != tenantId">
  89. and `tenant_id` = #{tenantId}
  90. </if>
  91. <if test=" null != parentTenantId and '' != parentTenantId">
  92. and `parent_tenant_id` = #{parentTenantId}
  93. </if>
  94. ) as microPaySendCount,
  95. (select Count(*) from wx_coupon_action_log c
  96. where DATE_FORMAT(create_time,'%m/%d')=xTime
  97. and c.channel_type=5
  98. <if test=" null != tenantId and '' != tenantId">
  99. and `tenant_id` = #{tenantId}
  100. </if>
  101. <if test=" null != parentTenantId and '' != parentTenantId">
  102. and `parent_tenant_id` = #{parentTenantId}
  103. </if>
  104. ) as orderSendCount
  105. from wx_coupon_action_log
  106. where channel_type in (2,3,4,5)
  107. <if test=" null != tenantId and '' != tenantId">
  108. and `tenant_id` = #{tenantId}
  109. </if>
  110. <if test=" null != parentTenantId and '' != parentTenantId">
  111. and `parent_tenant_id` = #{parentTenantId}
  112. </if>
  113. and create_time &gt;= #{startTime}
  114. and create_time &lt;= #{endTime}
  115. group by xTime
  116. order by xTime desc
  117. </select>
  118. <select id="getSceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportTVo" parameterType="hashmap">
  119. select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count
  120. from wx_coupon_action_log
  121. where channel_type in (2,3,4,5)
  122. <if test=" null != tenantId and '' != tenantId">
  123. and `tenant_id` = #{tenantId}
  124. </if>
  125. <if test=" null != parentTenantId and '' != parentTenantId">
  126. and `parent_tenant_id` = #{parentTenantId}
  127. </if>
  128. and create_time &gt;= #{startTime}
  129. and create_time &lt;= #{endTime}
  130. group by create_time_md, channel_type
  131. order by create_time_md desc
  132. </select>
  133. <update id="updateCreateTimeMd" parameterType="hashmap">
  134. update wx_coupon_action_log
  135. set create_time_md = DATE_FORMAT(create_time,'%m/%d')
  136. where 1=1
  137. <if test=" null != tenantId and '' != tenantId">
  138. and `tenant_id` = #{tenantId}
  139. </if>
  140. <if test=" null != parentTenantId and '' != parentTenantId">
  141. and `parent_tenant_id` = #{parentTenantId}
  142. </if>
  143. </update>
  144. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  145. select DATE_FORMAT(create_time,'%m/%d') AS xTime,
  146. COUNT(wx_coupon_order.id) as tempCount
  147. from wx_coupon_action_log
  148. left join wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  149. where 1=1
  150. <if test=" null != tenantId and '' != tenantId">
  151. and wx_coupon_action_log.`tenant_id` = #{tenantId}
  152. </if>
  153. <if test=" null != parentTenantId and '' != parentTenantId">
  154. and wx_coupon_action_log.`parent_tenant_id` = #{parentTenantId}
  155. </if>
  156. and wx_coupon_action_log.create_time &gt;= #{startTime}
  157. and wx_coupon_action_log.create_time &lt;= #{endTime}
  158. and wx_coupon_action_log.channel_type = #{channelType}
  159. group by xTime
  160. order by xTime desc
  161. </select>
  162. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  163. select DATE_FORMAT(create_time,'%Y-%m-%d') as xtime,
  164. Count(*) as sendCount
  165. from wx_coupon_action_log
  166. where channel_type=#{channelType}
  167. <if test=" null != tenantId and '' != tenantId">
  168. and `tenant_id` = #{tenantId}
  169. </if>
  170. <if test=" null != parentTenantId and '' != parentTenantId">
  171. and `parent_tenant_id` = #{parentTenantId}
  172. </if>
  173. <if test=" null != startTime ">
  174. and create_time &gt;= #{startTime}
  175. </if>
  176. <if test=" null != endTime ">
  177. and create_time &lt;= #{endTime}
  178. </if>
  179. group by xtime
  180. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  181. <if test=" null == sortColumns">order by xtime desc</if>
  182. </select>
  183. <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo"
  184. parameterType="hashmap">
  185. select DATE_FORMAT(cal.create_time,'%Y-%m-%d') AS xTime,
  186. COUNT(co.id) as tempCount
  187. from wx_coupon_action_log cal
  188. left join wx_coupon_order co on cal.coupon_order_id=co.id
  189. where co.coupon_order_status = 1
  190. <if test=" null != tenantId and '' != tenantId">
  191. and cal.`tenant_id` = #{tenantId}
  192. </if>
  193. <if test=" null != parentTenantId and '' != parentTenantId">
  194. and cal.`parent_tenant_id` = #{parentTenantId}
  195. </if>
  196. <if test=" null != startTime ">
  197. and cal.create_time &gt;= #{startTime}
  198. </if>
  199. <if test=" null != endTime ">
  200. and cal.create_time &lt;= #{endTime}
  201. </if>
  202. and cal.channel_type = #{channelType}
  203. group by xTime
  204. order by xTime desc
  205. </select>
  206. <select id="getCountByDateLimit" resultType="java.lang.Integer">
  207. select COUNT(*) FROM wx_coupon_action_log
  208. where `channel_type` != 0
  209. and `channel_type` != 1
  210. <if test=" null != tenantId and '' != tenantId">
  211. and `tenant_id` = #{tenantId}
  212. </if>
  213. <if test=" null != parentTenantId and '' != parentTenantId">
  214. and `parent_tenant_id` = #{parentTenantId}
  215. </if>
  216. and `create_time` &gt;= #{startTime}
  217. and `create_time` &lt;= #{endTime}
  218. </select>
  219. <select id="getCountByChannelId" resultType="java.lang.Integer">
  220. select COUNT(*) FROM wx_coupon_action_log
  221. where channel_type = #{channelType}
  222. and channel_id = #{channelId}
  223. <if test=" null != tenantId and '' != tenantId">
  224. and `tenant_id` = #{tenantId}
  225. </if>
  226. <if test=" null != parentTenantId and '' != parentTenantId">
  227. and `parent_tenant_id` = #{parentTenantId}
  228. </if>
  229. </select>
  230. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  231. select COUNT(*)
  232. FROM wx_coupon_action_log a, wx_coupon_order o
  233. WHERE a.coupon_order_id = o.id
  234. <if test=" null != tenantId and '' != tenantId">
  235. and a.`tenant_id` = #{tenantId}
  236. </if>
  237. <if test=" null != parentTenantId and '' != parentTenantId">
  238. and a.`parent_tenant_id` = #{parentTenantId}
  239. </if>
  240. AND o.c_user_id = #{cUserId}
  241. AND date(a.create_time) = curdate()
  242. </select>
  243. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  244. select COUNT(*)
  245. FROM wx_coupon_action_log a, wx_coupon_order o
  246. WHERE a.coupon_order_id = o.id
  247. <if test=" null != tenantId and '' != tenantId">
  248. and a.`tenant_id` = #{tenantId}
  249. </if>
  250. <if test=" null != parentTenantId and '' != parentTenantId">
  251. and a.`parent_tenant_id` = #{parentTenantId}
  252. </if>
  253. AND o.c_user_id = #{cUserId}
  254. AND a.coupon_id = #{couponId}
  255. AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate()
  256. </select>
  257. <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
  258. select COUNT(*)
  259. FROM wx_coupon_action_log a, wx_coupon_order o
  260. WHERE a.coupon_order_id = o.id
  261. <if test=" null != tenantId and '' != tenantId">
  262. and a.`tenant_id` = #{tenantId}
  263. </if>
  264. <if test=" null != parentTenantId and '' != parentTenantId">
  265. and a.`parent_tenant_id` = #{parentTenantId}
  266. </if>
  267. AND o.c_user_id = #{cUserId}
  268. <if test=" null != couponId ">
  269. AND a.coupon_id = #{couponId}
  270. </if>
  271. AND a.channel_type = #{channelType}
  272. and a.create_time &gt;= #{startTime}
  273. and a.create_time &lt;= #{endTime}
  274. </select>
  275. <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo">
  276. SELECT cal.id AS actionId,
  277. cal.coupon_id AS couponId,
  278. cal.create_time AS createDate,
  279. cs.id AS couponSendId,
  280. c.title,
  281. cu.nick_name AS userName,
  282. cu.phone,
  283. mbu.NAME AS operator
  284. FROM wx_coupon_action_log cal
  285. LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id
  286. LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id
  287. LEFT JOIN wx_coupon c ON cal.coupon_id = c.id
  288. LEFT JOIN wx_c_user cu ON cu.id = co.c_user_id
  289. LEFT JOIN wx_merchant_b_user mbu ON concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id')
  290. WHERE cal.channel_type = #{channelType}
  291. AND cs.conditions -> '$.id' = concat(#{merchantId},'')
  292. <if test=" null != beginDate ">
  293. AND cal.create_time &gt;= #{beginDate}
  294. </if>
  295. <if test=" null != endDate ">
  296. AND cal.create_time &lt; #{endDate}
  297. </if>
  298. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  299. </select>
  300. </mapper>