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

363 строки
14 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 (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  212. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  213. </foreach>) cal
  214. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  215. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  216. </foreach>) co on cal.coupon_order_id=co.id
  217. where co.coupon_order_status = 1
  218. <if test=" null != tenantId and '' != tenantId">
  219. and cal.`tenant_id` = #{tenantId}
  220. </if>
  221. <if test=" null != parentTenantId and '' != parentTenantId">
  222. and cal.`parent_tenant_id` = #{parentTenantId}
  223. </if>
  224. <if test=" null != startTime ">
  225. and cal.create_time &gt;= #{startTime}
  226. </if>
  227. <if test=" null != endTime ">
  228. and cal.create_time &lt;= #{endTime}
  229. </if>
  230. and cal.channel_type = #{channelType}
  231. group by xTime
  232. order by xTime desc
  233. </select>
  234. <select id="getCountByDateLimit" resultType="java.lang.Integer">
  235. select COUNT(*) FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  236. SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
  237. </foreach>) wx_coupon_action_log
  238. where `channel_type` != 0
  239. and `channel_type` != 1
  240. <if test=" null != tenantId and '' != tenantId">
  241. and `tenant_id` = #{tenantId}
  242. </if>
  243. <if test=" null != parentTenantId and '' != parentTenantId">
  244. and `parent_tenant_id` = #{parentTenantId}
  245. </if>
  246. and `create_time` &gt;= #{startTime}
  247. and `create_time` &lt;= #{endTime}
  248. </select>
  249. <select id="getCountByChannelId" resultType="java.lang.Integer">
  250. select COUNT(*) FROM wx_coupon_action_log
  251. where channel_type = #{channelType}
  252. and channel_id = #{channelId}
  253. <if test=" null != tenantId and '' != tenantId">
  254. and `tenant_id` = #{tenantId}
  255. </if>
  256. <if test=" null != parentTenantId and '' != parentTenantId">
  257. and `parent_tenant_id` = #{parentTenantId}
  258. </if>
  259. </select>
  260. <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
  261. select COUNT(*)
  262. FROM wx_coupon_action_log a, wx_coupon_order o
  263. WHERE a.coupon_order_id = o.id
  264. <if test=" null != tenantId and '' != tenantId">
  265. and a.`tenant_id` = #{tenantId}
  266. </if>
  267. <if test=" null != parentTenantId and '' != parentTenantId">
  268. and a.`parent_tenant_id` = #{parentTenantId}
  269. </if>
  270. AND o.c_user_id = #{cUserId}
  271. AND date(a.create_time) = curdate()
  272. </select>
  273. <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
  274. select COUNT(*)
  275. FROM wx_coupon_action_log a, wx_coupon_order o
  276. WHERE a.coupon_order_id = o.id
  277. <if test=" null != tenantId and '' != tenantId">
  278. and a.`tenant_id` = #{tenantId}
  279. </if>
  280. <if test=" null != parentTenantId and '' != parentTenantId">
  281. and a.`parent_tenant_id` = #{parentTenantId}
  282. </if>
  283. AND o.c_user_id = #{cUserId}
  284. AND a.coupon_id = #{couponId}
  285. AND date(a.create_time) between #{beginDate} and #{endDate}
  286. </select>
  287. <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
  288. select COUNT(*)
  289. FROM wx_coupon_action_log a, wx_coupon_order o
  290. WHERE a.coupon_order_id = o.id
  291. <if test=" null != tenantId and '' != tenantId">
  292. and a.`tenant_id` = #{tenantId}
  293. </if>
  294. <if test=" null != parentTenantId and '' != parentTenantId">
  295. and a.`parent_tenant_id` = #{parentTenantId}
  296. </if>
  297. AND o.c_user_id = #{cUserId}
  298. <if test=" null != couponId ">
  299. AND a.coupon_id = #{couponId}
  300. </if>
  301. AND a.channel_type = #{channelType}
  302. and a.create_time &gt;= #{startTime}
  303. and a.create_time &lt;= #{endTime}
  304. </select>
  305. <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo">
  306. SELECT cal.id AS actionId,
  307. cal.coupon_id AS couponId,
  308. cal.create_time AS createDate,
  309. cs.id AS couponSendId,
  310. c.title,
  311. cu.nick_name AS userName,
  312. cu.phone,
  313. mbu.NAME AS operator
  314. FROM wx_coupon_action_log cal
  315. LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id
  316. LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id
  317. LEFT JOIN wx_coupon c ON cal.coupon_id = c.id
  318. LEFT JOIN wx_c_user_basic_info cu ON cu.id = co.c_user_id
  319. LEFT JOIN wx_merchant_b_user mbu ON mbu.id = cal.operator_id
  320. <!-- and concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id') -->
  321. WHERE cal.channel_type = #{channelType}
  322. AND cs.conditions -> '$.id' = concat(#{merchantId},'')
  323. <if test=" null != beginDate ">
  324. AND cal.create_time &gt;= #{beginDate}
  325. </if>
  326. <if test=" null != endDate ">
  327. AND cal.create_time &lt; #{endDate}
  328. </if>
  329. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  330. </select>
  331. </mapper>