Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

721 рядки
28 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.WxCouponOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponOrder">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  7. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  8. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  9. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  10. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  11. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  12. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  13. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  14. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  15. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  16. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  17. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  18. </resultMap>
  19. <sql id="allColumns">
  20. `id`,`tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`
  21. </sql>
  22. <sql id="dynamicWhereConditions">
  23. where 1 = 1
  24. <if test=" null != id ">
  25. and `id` = #{id}
  26. </if>
  27. <if test=" null != tenantId ">
  28. and `tenant_id` = #{tenantId}
  29. </if>
  30. <if test=" null != couponId ">
  31. and `coupon_id` = #{couponId}
  32. </if>
  33. <if test=" null != couponType ">
  34. and `coupon_type` = #{couponType}
  35. </if>
  36. <if test=" null != cUserId ">
  37. and `c_user_id` = #{cUserId}
  38. </if>
  39. <if test=" null != ownerId ">
  40. and `owner_id` = #{ownerId}
  41. </if>
  42. <if test=" null != bUserId ">
  43. and `b_user_id` = #{bUserId}
  44. </if>
  45. <if test=" null != orderId ">
  46. and `order_id` = #{orderId}
  47. </if>
  48. <if test=" null != expiredTime ">
  49. and `expired_time` = #{expiredTime}
  50. </if>
  51. <if test=" null != couponOrderStatus ">
  52. and `coupon_order_status` = #{couponOrderStatus}
  53. </if>
  54. <if test=" null != createDate ">
  55. and `create_date` = #{createDate}
  56. </if>
  57. <if test=" null != updateDate ">
  58. and `update_date` = #{updateDate}
  59. </if>
  60. <if test=" null != couponPrice ">
  61. and `coupon_price` = #{couponPrice}
  62. </if>
  63. <if test=" null != ids ">
  64. and id in
  65. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  66. #{idItem}
  67. </foreach>
  68. </if>
  69. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  70. </sql>
  71. <select id="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  72. select <include refid="allColumns" /> from wx_coupon_order
  73. <include refid="dynamicWhereConditions" />
  74. </select>
  75. <select id="countList" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
  76. select count(*) from wx_coupon_order
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <select id="findCountByDateLimit" resultType="java.lang.Integer">
  80. select COUNT(*) FROM wx_coupon_order
  81. where tenant_id = #{tenantId}
  82. and create_date &gt;= #{startTime}
  83. and create_date &lt;= #{endTime}
  84. </select>
  85. <select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  86. SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
  87. COUNT(DISTINCT c_user_id) as couponUserCount,
  88. count(*) as couponCount,
  89. (select Count(*)
  90. from wx_coupon_order c
  91. where coupon_order_status=1
  92. AND DATE_FORMAT(create_date,'%m/%d')=createTime
  93. AND tenant_id=#{tenantId}
  94. AND c.update_date &gt;= #{startTime}
  95. AND c.update_date &lt;= #{endTime}) as verifyCount,
  96. (select Count(DISTINCT c_user_id)
  97. from wx_coupon_order d
  98. where coupon_order_status=1
  99. AND DATE_FORMAT(create_date,'%m/%d')=createTime
  100. AND tenant_id=#{tenantId}
  101. AND d.update_date &gt;= #{startTime}
  102. AND d.update_date &lt;= #{endTime}) as verifyUserCount
  103. from wx_coupon_order
  104. where tenant_id=#{tenantId}
  105. AND create_date &gt;= #{startTime}
  106. AND create_date &lt;= #{endTime}
  107. GROUP BY createTime
  108. </select>
  109. <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  110. SELECT createTime,couponId,couponCount,couponUserCount,verifyCount,verifyUserCount
  111. from view_coupon_data
  112. where view_coupon_data.tenant_id=#{tenantId}
  113. <if test="startTime != null">
  114. and view_coupon_data.createTime &gt;= DATE_FORMAT(#{startTime},'%Y-%m-%d')
  115. </if>
  116. <if test="endTime != null">
  117. and view_coupon_data.createTime &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d')
  118. </if>
  119. <if test="couponType != null">
  120. and view_coupon_data.couponType = #{couponType}
  121. </if>
  122. <if test="couponTitle != null">
  123. and view_coupon_data.couponTitle like concat('%', #{couponTitle},'%')
  124. </if>
  125. order by view_coupon_data.createTime desc
  126. </select>
  127. <select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap">
  128. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
  129. ,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
  130. ,(select Count(*) from wx_coupon_order c
  131. where coupon_order_status=1
  132. and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
  133. and tenant_id=#{tenantId}
  134. <if test="startTime != null">
  135. and c.update_date &gt;= #{startTime}
  136. </if>
  137. <if test="endTime != null">
  138. and c.update_date &lt;= #{endTime}
  139. </if>
  140. )
  141. as verifyCount
  142. ,(select Count(DISTINCT c_user_id) from wx_coupon_order d
  143. where coupon_order_status=1
  144. and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
  145. and tenant_id=#{tenantId}
  146. <if test="startTime != null">
  147. and d.update_date &gt;= #{startTime}
  148. </if>
  149. <if test="endTime != null">
  150. and d.update_date &lt;= #{endTime}
  151. </if>
  152. )
  153. as verifyUserCount
  154. from wx_coupon_order
  155. where tenant_id=#{tenantId}
  156. <if test="startTime != null">
  157. AND create_date &gt;= #{startTime}
  158. </if>
  159. <if test="endTime != null">
  160. and create_date &lt;= #{endTime}
  161. </if>
  162. GROUP BY xTime
  163. order by xTime desc
  164. </select>
  165. <select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  166. select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
  167. from wx_coupon_order c
  168. where c.tenant_id = #{tenantId}
  169. and c.coupon_order_status = 1
  170. <if test=" null != startTime and null != endTime">
  171. and c.update_date BETWEEN #{startTime} and #{endTime}
  172. </if>
  173. group by xTime
  174. </select>
  175. <select id="queryForSceneRepotyHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  176. select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
  177. from wx_coupon_order c
  178. where c.tenant_id = #{tenantId}
  179. <if test=" null != startTime and null != endTime">
  180. and c.create_date BETWEEN #{startTime} and #{endTime}
  181. </if>
  182. group by xTime
  183. </select>
  184. <select id="findVerifiedCountByCUser" resultType="java.lang.Integer">
  185. select COUNT(*) FROM wx_coupon_order
  186. where c_user_id = #{cUserId}
  187. and update_date &gt;= #{startTime}
  188. and update_date &lt;= #{endTime}
  189. and coupon_order_status = 1
  190. </select>
  191. <select id="findOrderedCountByCUser" resultType="java.lang.Integer">
  192. select COUNT(*) FROM wx_coupon_order
  193. where c_user_id = #{cUserId}
  194. and create_date &gt;= #{startTime}
  195. and create_date &lt;= #{endTime}
  196. </select>
  197. <select id="findVerifiedCount" resultType="java.lang.Integer">
  198. select COUNT(*) FROM wx_coupon_order
  199. where tenant_id = #{tenantId}
  200. and update_date &gt;= #{startTime}
  201. and update_date &lt;= #{endTime}
  202. and coupon_order_status = 1
  203. </select>
  204. <select id="findOrderedCount" resultType="java.lang.Integer">
  205. select COUNT(*) FROM wx_coupon_order
  206. where tenant_id = #{tenantId}
  207. and create_date &gt;= #{startTime}
  208. and create_date &lt;= #{endTime}
  209. </select>
  210. <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
  211. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order
  212. where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime
  213. </select>
  214. <select id="queryPriceTotal" resultType="java.lang.Integer" >
  215. SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
  216. where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime}
  217. </select>
  218. <update id="offExpiredCouponOrderByValidDate">
  219. update wx_coupon_order SET coupon_order_status = 2, update_date = now()
  220. where expired_time &lt; now() and coupon_price = 0 and coupon_order_status = 0
  221. </update>
  222. <select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  223. select <include refid="allColumns" /> from wx_coupon_order
  224. where expired_time &lt; now() and coupon_price &gt; 0 and coupon_order_status = 0
  225. </select>
  226. <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo">
  227. <id column="id" jdbcType="BIGINT" property="id" />
  228. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  229. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  230. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  231. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  232. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  233. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  234. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  235. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  236. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  237. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  238. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  239. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  240. <result column="type" jdbcType="INTEGER" property="type" />
  241. <result column="title" jdbcType="VARCHAR" property="title" />
  242. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  243. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  244. <result column="price" jdbcType="INTEGER" property="price" />
  245. <result column="name" jdbcType="VARCHAR" property="bUserName" />
  246. <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
  247. <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
  248. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  249. <collection column="{productId=coupon_id}" property="merchantVoList"
  250. ofType="com.iformall.domain.vo.WxMerchantVo"
  251. javaType="java.util.List"
  252. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
  253. </collection>
  254. </resultMap>
  255. <sql id="allAdminCouponOrderListColumns">
  256. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  257. c.title,c.sale_price,c.use_price,c.price,c.unit,
  258. (case when com.mc=1 then
  259. (select m.name from wx_merchant m, wx_coupon_merchant cm
  260. where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name
  261. </sql>
  262. <sql id="allAdminCouponOrderDetailColumns">
  263. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  264. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
  265. bu.name, bu.phone as bphone,
  266. cu.phone,
  267. m.name as merchant_name
  268. </sql>
  269. <select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BVoResultMap">
  270. select <include refid="allAdminCouponOrderListColumns" />
  271. from
  272. wx_coupon_order co,
  273. wx_coupon c,
  274. (select tco.id as tcoid,
  275. (select count(*) from wx_coupon_merchant tcm
  276. where tcm.product_id = tco.coupon_id
  277. and tcm.status = 0) as mc
  278. from wx_coupon_order tco) com
  279. where com.tcoid = co.id
  280. and co.coupon_type &lt; 100
  281. and c.id = co.coupon_id
  282. <if test=" null != tenantId ">
  283. and co.tenant_id = #{tenantId}
  284. </if>
  285. <if test=" null != couponOrderStatus ">
  286. and co.coupon_order_status = #{couponOrderStatus}
  287. </if>
  288. <if test=" null != merchantName and merchantName!=''">
  289. and (case when com.mc=1
  290. then
  291. (select m.name from wx_merchant m, wx_coupon_merchant cm
  292. where m.id = cm.merchant_id
  293. and cm.product_id=co.coupon_id
  294. and cm.status = 0)
  295. else'[多商户通用]' end)
  296. like concat('%', #{merchantName},'%')
  297. </if>
  298. <if test="startDate != null">
  299. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  300. </if>
  301. <if test="endDate != null">
  302. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  303. </if>
  304. <if test=" null != id ">
  305. and co.id = #{id}
  306. </if>
  307. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  308. </select>
  309. <select id="findDetailOfAdmin" parameterType="java.lang.Long" resultMap="BVoResultMap">
  310. select <include refid="allAdminCouponOrderDetailColumns" />
  311. from
  312. wx_coupon c,
  313. wx_c_user cu,
  314. wx_coupon_order co
  315. left join wx_merchant_b_user bu on co.b_user_id = bu.id
  316. left join wx_merchant m on m.id = bu.merchant_id
  317. where co.id = #{id}
  318. and c.id = co.coupon_id
  319. and cu.id = co.c_user_id
  320. </select>
  321. <sql id="allBUserVerifiedCouponOrderColumns">
  322. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  323. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
  324. bu.name,
  325. cu.phone
  326. </sql>
  327. <sql id="allBUserOrderedCouponOrderColumns">
  328. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  329. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
  330. cu.phone
  331. </sql>
  332. <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  333. select <include refid="allBUserOrderedCouponOrderColumns" />
  334. from wx_coupon_order co,wx_coupon c,wx_c_user cu,wx_coupon_merchant cm,
  335. (select tco.id as tcoid,
  336. (select count(*) from wx_coupon_merchant tcm
  337. where tcm.product_id = tco.coupon_id
  338. and tcm.status = 0) as mc
  339. from wx_coupon_order tco) com
  340. where com.mc = 1
  341. and com.tcoid = co.id
  342. and cm.merchant_id = #{merchantId}
  343. and cm.product_id = c.id
  344. and cm.status = 0
  345. and co.coupon_id = c.id
  346. and cu.id = co.c_user_id
  347. <if test="startDate != null">
  348. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  349. </if>
  350. <if test="endDate != null">
  351. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  352. </if>
  353. order by co.create_date desc
  354. </select>
  355. <select id="findListOfVerifiedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  356. select <include refid="allBUserVerifiedCouponOrderColumns" />
  357. from wx_coupon_order co,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
  358. where co.coupon_id = c.id
  359. and cu.id = co.c_user_id
  360. and bu.id = co.b_user_id
  361. and bu.merchant_id = #{merchantId}
  362. <if test="startDate != null">
  363. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  364. </if>
  365. <if test="endDate != null">
  366. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  367. </if>
  368. AND co.coupon_order_status = '1'
  369. order by co.update_date desc
  370. </select>
  371. <sql id="allCouponOrderColumns">
  372. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price
  373. </sql>
  374. <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
  375. select <include refid="allCouponOrderColumns" />
  376. from wx_coupon_order co,wx_coupon_merchant cm,
  377. (select tco.id as tcoid,
  378. (select count(*) from wx_coupon_merchant tcm
  379. where tcm.product_id = tco.coupon_id
  380. and tcm.status = 0)
  381. as mc
  382. from wx_coupon_order tco) com
  383. where com.mc = 1
  384. and com.tcoid = co.id
  385. and cm.status = 0
  386. and cm.merchant_id = #{merchantId}
  387. and cm.product_id = co.coupon_id
  388. <if test="startDate != null">
  389. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  390. </if>
  391. <if test="endDate != null">
  392. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  393. </if>
  394. </select>
  395. <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
  396. select <include refid="allCouponOrderColumns" />
  397. from wx_coupon_order co, wx_merchant_b_user mbu
  398. where mbu.id = co.b_user_id
  399. and mbu.merchant_id = #{merchantId}
  400. <if test="startDate != null">
  401. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  402. </if>
  403. <if test="endDate != null">
  404. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  405. </if>
  406. AND co.coupon_order_status = '1'
  407. </select>
  408. <sql id="allCUserCouponOrderListColumns">
  409. co.id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  410. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
  411. cal.channel_type as send_channel_type
  412. </sql>
  413. <sql id="allCUserCouponOrderDetailColumns">
  414. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  415. c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark
  416. </sql>
  417. <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo">
  418. <id column="id" jdbcType="BIGINT" property="id" />
  419. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  420. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  421. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  422. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  423. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  424. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  425. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  426. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  427. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  428. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  429. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  430. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  431. <result column="type" jdbcType="INTEGER" property="type" />
  432. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  433. <result column="title" jdbcType="VARCHAR" property="title" />
  434. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  435. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  436. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  437. <result column="detail" jdbcType="VARCHAR" property="detail" />
  438. <result column="price" jdbcType="INTEGER" property="price" />
  439. <result column="unit" jdbcType="INTEGER" property="unit" />
  440. <result column="remark" jdbcType="VARCHAR" property="remark" />
  441. <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
  442. <collection column="{productId=coupon_id}" property="merchantVoList"
  443. ofType="com.iformall.domain.vo.WxMerchantVo"
  444. javaType="java.util.List"
  445. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  446. </collection>
  447. </resultMap>
  448. <select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
  449. select <include refid="allCUserCouponOrderListColumns" />
  450. from wx_coupon c,wx_coupon_order co
  451. left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
  452. where 1=1
  453. and co.coupon_id = c.id
  454. and co.coupon_type != 5
  455. and co.coupon_type &lt; 100
  456. <if test="cUserId != null">
  457. and co.c_user_id = #{cUserId}
  458. </if>
  459. <if test="ownerId != null">
  460. and co.owner_id = #{ownerId}
  461. </if>
  462. <if test="tenantId != null">
  463. and co.tenant_id = #{tenantId}
  464. </if>
  465. <if test="couponOrderStatus != null">
  466. AND co.coupon_order_status = #{couponOrderStatus}
  467. </if>
  468. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  469. </select>
  470. <select id="findDetailOfCUser" parameterType="java.lang.Long" resultMap="CVoResultMap">
  471. select <include refid="allCUserCouponOrderDetailColumns" />
  472. from wx_coupon_order co,wx_coupon c
  473. where co.coupon_id = c.id
  474. and co.id = #{id}
  475. </select>
  476. <sql id="allCUserCouponOrderCarListColumns">
  477. co.id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  478. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
  479. json_extract(car.vendor_params,'$.id') as coupon_free_id
  480. </sql>
  481. <resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo">
  482. <id column="id" jdbcType="BIGINT" property="id" />
  483. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  484. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  485. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  486. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  487. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  488. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  489. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  490. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  491. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  492. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  493. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  494. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  495. <result column="type" jdbcType="INTEGER" property="type" />
  496. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  497. <result column="title" jdbcType="VARCHAR" property="title" />
  498. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  499. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  500. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  501. <result column="detail" jdbcType="VARCHAR" property="detail" />
  502. <result column="price" jdbcType="INTEGER" property="price" />
  503. <result column="remark" jdbcType="VARCHAR" property="remark" />
  504. <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/>
  505. <collection column="{productId=coupon_id}" property="merchantVoList"
  506. ofType="com.iformall.domain.vo.WxMerchantVo"
  507. javaType="java.util.List"
  508. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  509. </collection>
  510. </resultMap>
  511. <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap">
  512. select <include refid="allCUserCouponOrderCarListColumns" />
  513. from wx_coupon_order co, wx_coupon c, wx_coupon_car car
  514. where co.coupon_id = c.id
  515. and co.coupon_id = car.id
  516. and c.type = 5
  517. <if test="cUserId != null">
  518. and co.c_user_id = #{cUserId}
  519. </if>
  520. <if test="tenantId != null">
  521. and co.tenant_id = #{tenantId}
  522. </if>
  523. <if test="id != null">
  524. and co.id = #{id}
  525. </if>
  526. <if test="couponOrderStatus != null">
  527. AND co.coupon_order_status = #{couponOrderStatus}
  528. </if>
  529. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  530. </select>
  531. <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo">
  532. <id column="id" jdbcType="BIGINT" property="id" />
  533. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  534. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  535. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  536. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  537. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  538. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  539. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  540. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  541. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  542. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  543. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  544. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  545. <result column="title" jdbcType="VARCHAR" property="title" />
  546. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  547. <result column="detail" jdbcType="VARCHAR" property="detail" />
  548. <result column="unit" jdbcType="INTEGER" property="unit" />
  549. <result column="remark" jdbcType="VARCHAR" property="remark" />
  550. <result column="amount" jdbcType="INTEGER" property="amount" />
  551. <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" />
  552. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  553. <collection column="{productId=coupon_id}" property="merchantVoList"
  554. ofType="com.iformall.domain.vo.WxMerchantVo"
  555. javaType="java.util.List"
  556. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  557. </collection>
  558. <collection column="{cardId=id}" property="cardSpendList"
  559. ofType="com.iformall.domain.vo.WxCardSpendVo"
  560. javaType="java.util.List"
  561. select="com.iformall.mapper.WxCardSpendMapper.findCardSpendVoList" >
  562. </collection>
  563. </resultMap>
  564. <sql id="allCUserCardListColumns">
  565. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,
  566. c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark,
  567. a.amount,a.remaining_amount,c.support_transfer
  568. </sql>
  569. <sql id="allCUserCardDetailColumns">
  570. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  571. c.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark,
  572. a.amount,a.remaining_amount,c.support_transfer
  573. </sql>
  574. <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap">
  575. select id,tenant_id,'0' coupon_id,'0' coupon_type,expired_time,`status`as
  576. coupon_order_status,create_date,update_date,
  577. '' cover_img,title,'' sub_title,'' detail,'0' unit,'' remark,amount,remain_amount as remaining_amount,'0'
  578. support_transfer
  579. from wx_card_transfer_info where 1=1
  580. <if test="tenantId != null">
  581. and tenant_id = #{tenantId}
  582. </if>
  583. <if test="ownerId != null">
  584. and from_user = #{ownerId}
  585. </if>
  586. <choose>
  587. <when test="couponOrderStatus != null">
  588. and status = #{couponOrderStatus}
  589. </when>
  590. <otherwise>
  591. and status=8
  592. </otherwise>
  593. </choose>
  594. union
  595. select <include refid="allCUserCardListColumns" />
  596. from wx_coupon_order co
  597. inner join wx_coupon c on co.coupon_id = c.id
  598. inner join wx_card_info a on co.id=a.id
  599. where 1=1
  600. and co.coupon_type = 100
  601. <if test="tenantId != null">
  602. and co.tenant_id = #{tenantId}
  603. </if>
  604. <if test="cUserId != null">
  605. and co.c_user_id = #{cUserId}
  606. </if>
  607. <if test="ownerId != null">
  608. and co.owner_id = #{ownerId}
  609. </if>
  610. <if test="couponOrderStatus != null">
  611. and co.coupon_order_status = #{couponOrderStatus}
  612. </if>
  613. <if test=" null != statusS ">
  614. and co.coupon_order_status in
  615. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  616. #{sItem}
  617. </foreach>
  618. </if>
  619. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  620. </select>
  621. <select id="findCardDetailOfCUser" parameterType="java.lang.Long" resultMap="CCardVoResultMap">
  622. select <include refid="allCUserCardDetailColumns" />
  623. from wx_coupon_order co,wx_coupon c, wx_card_info a
  624. where co.coupon_id = c.id and co.id = a.id
  625. and co.id = #{id}
  626. </select>
  627. </mapper>