選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

358 行
13 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="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  58. select <include refid="allColumns"/> from wx_coupon_action_log where id = #{id} and tenant_id = #{tenantId}
  59. </select>
  60. <delete id="deleteById" parameterType="java.util.HashMap">
  61. delete from wx_coupon_action_log where id = #{id} and tenant_id = #{tenantId}
  62. </delete>
  63. <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap">
  64. select
  65. <include refid="allColumns"/>
  66. from wx_coupon_action_log
  67. <include refid="dynamicWhereConditions" />
  68. </select>
  69. <select id="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  70. select DATE_FORMAT(create_time,'%m/%d') as xTime,
  71. (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  72. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  73. </foreach>) c
  74. where DATE_FORMAT(create_time,'%m/%d')=xTime
  75. and c.channel_type=2
  76. <if test=" null != tenantId and '' != tenantId">
  77. and `tenant_id` = #{tenantId}
  78. </if>
  79. <if test=" null != parentTenantId and '' != parentTenantId">
  80. and `parent_tenant_id` = #{parentTenantId}
  81. </if>
  82. ) as parkSendCount,
  83. (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  84. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  85. </foreach>) c
  86. where DATE_FORMAT(create_time,'%m/%d')=xTime
  87. and c.channel_type=3
  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 verifySendCount,
  95. (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  96. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  97. </foreach>) c
  98. where DATE_FORMAT(create_time,'%m/%d')=xTime
  99. and c.channel_type=4
  100. <if test=" null != tenantId and '' != tenantId">
  101. and `tenant_id` = #{tenantId}
  102. </if>
  103. <if test=" null != parentTenantId and '' != parentTenantId">
  104. and `parent_tenant_id` = #{parentTenantId}
  105. </if>
  106. ) as microPaySendCount,
  107. (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  108. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  109. </foreach>) c
  110. where DATE_FORMAT(create_time,'%m/%d')=xTime
  111. and c.channel_type=5
  112. <if test=" null != tenantId and '' != tenantId">
  113. and `tenant_id` = #{tenantId}
  114. </if>
  115. <if test=" null != parentTenantId and '' != parentTenantId">
  116. and `parent_tenant_id` = #{parentTenantId}
  117. </if>
  118. ) as orderSendCount
  119. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  120. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  121. </foreach>) wx_coupon_action_log
  122. where channel_type in (2,3,4,5)
  123. <if test=" null != tenantId and '' != tenantId">
  124. and `tenant_id` = #{tenantId}
  125. </if>
  126. <if test=" null != parentTenantId and '' != parentTenantId">
  127. and `parent_tenant_id` = #{parentTenantId}
  128. </if>
  129. and create_time &gt;= #{startTime}
  130. and create_time &lt;= #{endTime}
  131. group by xTime
  132. order by xTime desc
  133. </select>
  134. <select id="getSceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportTVo" parameterType="hashmap">
  135. select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count
  136. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  137. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  138. </foreach>) wx_coupon_action_log
  139. where channel_type in (2,3,4,5)
  140. <if test=" null != tenantId and '' != tenantId">
  141. and `tenant_id` = #{tenantId}
  142. </if>
  143. <if test=" null != parentTenantId and '' != parentTenantId">
  144. and `parent_tenant_id` = #{parentTenantId}
  145. </if>
  146. and create_time &gt;= #{startTime}
  147. and create_time &lt;= #{endTime}
  148. group by create_time_md, channel_type
  149. order by create_time_md desc
  150. </select>
  151. <update id="updateCreateTimeMd" parameterType="hashmap">
  152. update wx_coupon_action_log
  153. set create_time_md = DATE_FORMAT(create_time,'%m/%d')
  154. where 1=1
  155. <if test=" null != tenantId and '' != tenantId">
  156. and `tenant_id` = #{tenantId}
  157. </if>
  158. <if test=" null != parentTenantId and '' != parentTenantId">
  159. and `parent_tenant_id` = #{parentTenantId}
  160. </if>
  161. </update>
  162. <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
  163. select DATE_FORMAT(create_time,'%m/%d') AS xTime,
  164. COUNT(wx_coupon_order.id) as tempCount
  165. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  166. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  167. </foreach>) wx_coupon_action_log
  168. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  169. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  170. </foreach>) wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
  171. where 1=1
  172. <if test=" null != tenantId and '' != tenantId">
  173. and wx_coupon_action_log.`tenant_id` = #{tenantId}
  174. </if>
  175. <if test=" null != parentTenantId and '' != parentTenantId">
  176. and wx_coupon_action_log.`parent_tenant_id` = #{parentTenantId}
  177. </if>
  178. and wx_coupon_action_log.create_time &gt;= #{startTime}
  179. and wx_coupon_action_log.create_time &lt;= #{endTime}
  180. and wx_coupon_action_log.channel_type = #{channelType}
  181. group by xTime
  182. order by xTime desc
  183. </select>
  184. <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="com.iformall.domain.dto.MarkingCouponDataReportDto">
  185. select DATE_FORMAT(create_time,'%Y-%m-%d') as xtime,
  186. Count(*) as sendCount
  187. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  188. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  189. </foreach>) wx_coupon_action_log
  190. where channel_type=#{channelType}
  191. <if test=" null != tenantId and '' != tenantId">
  192. and `tenant_id` = #{tenantId}
  193. </if>
  194. <if test=" null != parentTenantId and '' != parentTenantId">
  195. and `parent_tenant_id` = #{parentTenantId}
  196. </if>
  197. <if test=" null != startTime ">
  198. and create_time &gt;= #{startTime}
  199. </if>
  200. <if test=" null != endTime ">
  201. and create_time &lt;= #{endTime}
  202. </if>
  203. group by xtime
  204. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  205. <if test=" null == sortColumns">order by xtime desc</if>
  206. </select>
  207. <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo"
  208. parameterType="hashmap">
  209. select DATE_FORMAT(cal.create_time,'%Y-%m-%d') AS xTime,
  210. COUNT(co.id) as tempCount
  211. from wx_coupon_action_log cal
  212. left join wx_coupon_order co on cal.coupon_order_id=co.id
  213. where co.coupon_order_status = 1
  214. <if test=" null != tenantId and '' != tenantId">
  215. and cal.`tenant_id` = #{tenantId}
  216. </if>
  217. <if test=" null != parentTenantId and '' != parentTenantId">
  218. and cal.`parent_tenant_id` = #{parentTenantId}
  219. </if>
  220. <if test=" null != startTime ">
  221. and cal.create_time &gt;= #{startTime}
  222. </if>
  223. <if test=" null != endTime ">
  224. and cal.create_time &lt;= #{endTime}
  225. </if>
  226. and cal.channel_type = #{channelType}
  227. group by xTime
  228. order by xTime desc
  229. </select>
  230. <select id="getCountByDateLimit" resultType="java.lang.Integer">
  231. select COUNT(*) FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  232. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  233. </foreach>) wx_coupon_action_log
  234. where `channel_type` != 0
  235. and `channel_type` != 1
  236. <if test=" null != tenantId and '' != tenantId">
  237. and `tenant_id` = #{tenantId}
  238. </if>
  239. <if test=" null != parentTenantId and '' != parentTenantId">
  240. and `parent_tenant_id` = #{parentTenantId}
  241. </if>
  242. and `create_time` &gt;= #{startTime}
  243. and `create_time` &lt;= #{endTime}
  244. </select>
  245. <select id="getCountByChannelId" resultType="java.lang.Integer">
  246. select COUNT(*) FROM wx_coupon_action_log
  247. where channel_type = #{channelType}
  248. and channel_id = #{channelId}
  249. <if test=" null != tenantId and '' != tenantId">
  250. and `tenant_id` = #{tenantId}
  251. </if>
  252. <if test=" null != parentTenantId and '' != parentTenantId">
  253. and `parent_tenant_id` = #{parentTenantId}
  254. </if>
  255. </select>
  256. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  257. select COUNT(*)
  258. FROM wx_coupon_action_log a, wx_coupon_order o
  259. WHERE a.coupon_order_id = o.id
  260. <if test=" null != tenantId and '' != tenantId">
  261. and a.`tenant_id` = #{tenantId}
  262. </if>
  263. <if test=" null != parentTenantId and '' != parentTenantId">
  264. and a.`parent_tenant_id` = #{parentTenantId}
  265. </if>
  266. AND o.c_user_id = #{cUserId}
  267. AND date(a.create_time) = curdate()
  268. </select>
  269. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  270. select COUNT(*)
  271. FROM wx_coupon_action_log a, wx_coupon_order o
  272. WHERE a.coupon_order_id = o.id
  273. <if test=" null != tenantId and '' != tenantId">
  274. and a.`tenant_id` = #{tenantId}
  275. </if>
  276. <if test=" null != parentTenantId and '' != parentTenantId">
  277. and a.`parent_tenant_id` = #{parentTenantId}
  278. </if>
  279. AND o.c_user_id = #{cUserId}
  280. AND a.coupon_id = #{couponId}
  281. AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate()
  282. </select>
  283. <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
  284. select COUNT(*)
  285. FROM wx_coupon_action_log a, wx_coupon_order o
  286. WHERE a.coupon_order_id = o.id
  287. <if test=" null != tenantId and '' != tenantId">
  288. and a.`tenant_id` = #{tenantId}
  289. </if>
  290. <if test=" null != parentTenantId and '' != parentTenantId">
  291. and a.`parent_tenant_id` = #{parentTenantId}
  292. </if>
  293. AND o.c_user_id = #{cUserId}
  294. <if test=" null != couponId ">
  295. AND a.coupon_id = #{couponId}
  296. </if>
  297. AND a.channel_type = #{channelType}
  298. and a.create_time &gt;= #{startTime}
  299. and a.create_time &lt;= #{endTime}
  300. </select>
  301. <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo">
  302. SELECT cal.id AS actionId,
  303. cal.coupon_id AS couponId,
  304. cal.create_time AS createDate,
  305. cs.id AS couponSendId,
  306. c.title,
  307. cu.nick_name AS userName,
  308. cu.phone,
  309. mbu.NAME AS operator
  310. FROM wx_coupon_action_log cal
  311. LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id
  312. LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id
  313. LEFT JOIN wx_coupon c ON cal.coupon_id = c.id
  314. LEFT JOIN wx_c_user_basic_info cu ON cu.id = co.c_user_id
  315. LEFT JOIN wx_merchant_b_user mbu ON concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id')
  316. WHERE cal.channel_type = #{channelType}
  317. AND cs.conditions -> '$.id' = concat(#{merchantId},'')
  318. <if test=" null != beginDate ">
  319. AND cal.create_time &gt;= #{beginDate}
  320. </if>
  321. <if test=" null != endDate ">
  322. AND cal.create_time &lt; #{endDate}
  323. </if>
  324. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  325. </select>
  326. </mapper>