You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1046 lines
40 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. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />
  19. </resultMap>
  20. <sql id="allColumns">
  21. `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`, `auto_refund`
  22. </sql>
  23. <sql id="dynamicWhereConditions">
  24. where 1 = 1
  25. <if test=" null != id ">
  26. and `id` = #{id}
  27. </if>
  28. <if test=" null != tenantId ">
  29. and `tenant_id` = #{tenantId}
  30. </if>
  31. <if test=" null != couponId ">
  32. and `coupon_id` = #{couponId}
  33. </if>
  34. <if test=" null != couponType ">
  35. and `coupon_type` = #{couponType}
  36. </if>
  37. <if test=" null != cUserId ">
  38. and `c_user_id` = #{cUserId}
  39. </if>
  40. <if test=" null != ownerId ">
  41. and `owner_id` = #{ownerId}
  42. </if>
  43. <if test=" null != bUserId ">
  44. and `b_user_id` = #{bUserId}
  45. </if>
  46. <if test=" null != orderId ">
  47. and `order_id` = #{orderId}
  48. </if>
  49. <if test=" null != expiredTime ">
  50. and `expired_time` = #{expiredTime}
  51. </if>
  52. <if test=" null != couponOrderStatus ">
  53. and `coupon_order_status` = #{couponOrderStatus}
  54. </if>
  55. <if test=" null != createDate ">
  56. and `create_date` = #{createDate}
  57. </if>
  58. <if test=" null != updateDate ">
  59. and `update_date` = #{updateDate}
  60. </if>
  61. <if test=" null != couponPrice ">
  62. and `coupon_price` = #{couponPrice}
  63. </if>
  64. <if test=" null != autoRefund ">
  65. and `auto_refund` = #{autoRefund}
  66. </if>
  67. <if test=" null != ids ">
  68. and id in
  69. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  70. #{idItem}
  71. </foreach>
  72. </if>
  73. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  74. </sql>
  75. <select id="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  76. select <include refid="allColumns" /> from wx_coupon_order
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <update id="updateVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
  80. update wx_coupon_order
  81. set `coupon_order_status` = #{couponOrderStatus},
  82. `b_user_id` = #{bUserId},
  83. `update_date` = #{updateDate}
  84. where `tenant_id`=#{tenantId} and id=#{id} and `b_user_id` is null
  85. </update>
  86. <select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  87. SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
  88. COUNT(DISTINCT c_user_id) as couponUserCount,
  89. count(*) as couponCount,
  90. (select Count(*)
  91. from wx_coupon_order c
  92. where coupon_order_status=1
  93. AND DATE_FORMAT(create_date,'%m/%d')=createTime
  94. AND tenant_id=#{tenantId}
  95. AND c.update_date &gt;= #{startTime}
  96. AND c.update_date &lt;= #{endTime}) as verifyCount,
  97. (select Count(DISTINCT c_user_id)
  98. from wx_coupon_order d
  99. where coupon_order_status=1
  100. AND DATE_FORMAT(create_date,'%m/%d')=createTime
  101. AND tenant_id=#{tenantId}
  102. AND d.update_date &gt;= #{startTime}
  103. AND d.update_date &lt;= #{endTime}) as verifyUserCount
  104. from wx_coupon_order
  105. where tenant_id=#{tenantId}
  106. AND create_date &gt;= #{startTime}
  107. AND create_date &lt;= #{endTime}
  108. GROUP BY createTime
  109. </select>
  110. <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  111. SELECT createTime,couponId,couponCount,couponUserCount,verifyCount,verifyUserCount
  112. from view_coupon_data
  113. where view_coupon_data.tenant_id=#{tenantId}
  114. <if test="startTime != null">
  115. and view_coupon_data.createTime &gt;= DATE_FORMAT(#{startTime},'%Y-%m-%d')
  116. </if>
  117. <if test="endTime != null">
  118. and view_coupon_data.createTime &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d')
  119. </if>
  120. <if test="couponType != null">
  121. and view_coupon_data.couponType = #{couponType}
  122. </if>
  123. <if test="couponTitle != null">
  124. and view_coupon_data.couponTitle like concat('%', #{couponTitle},'%')
  125. </if>
  126. order by view_coupon_data.createTime desc
  127. </select>
  128. <select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="com.iformall.domain.dto.MarkingCouponDataReportDto">
  129. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
  130. ,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
  131. ,(select Count(*) from wx_coupon_order c
  132. where coupon_order_status=1
  133. and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
  134. and tenant_id=#{tenantId}
  135. <if test="startTime != null">
  136. and c.update_date &gt;= #{startTime}
  137. </if>
  138. <if test="endTime != null">
  139. and c.update_date &lt;= #{endTime}
  140. </if>
  141. )
  142. as verifyCount
  143. ,(select Count(DISTINCT c_user_id) from wx_coupon_order d
  144. where coupon_order_status=1
  145. and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
  146. and tenant_id=#{tenantId}
  147. <if test="startTime != null">
  148. and d.update_date &gt;= #{startTime}
  149. </if>
  150. <if test="endTime != null">
  151. and d.update_date &lt;= #{endTime}
  152. </if>
  153. )
  154. as verifyUserCount
  155. from wx_coupon_order
  156. where tenant_id=#{tenantId}
  157. <if test="startTime != null">
  158. AND create_date &gt;= #{startTime}
  159. </if>
  160. <if test="endTime != null">
  161. and create_date &lt;= #{endTime}
  162. </if>
  163. GROUP BY xTime
  164. order by xTime desc
  165. </select>
  166. <select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  167. select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
  168. from wx_coupon_order c
  169. where c.tenant_id = #{tenantId}
  170. and c.coupon_order_status = 1
  171. <if test=" null != startTime and null != endTime">
  172. and c.update_date BETWEEN #{startTime} and #{endTime}
  173. </if>
  174. group by xTime
  175. </select>
  176. <select id="queryForSceneRepotyHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  177. select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
  178. from wx_coupon_order c
  179. where c.tenant_id = #{tenantId}
  180. <if test=" null != startTime and null != endTime">
  181. and c.create_date BETWEEN #{startTime} and #{endTime}
  182. </if>
  183. group by xTime
  184. </select>
  185. <select id="queryPriceTotal" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer" >
  186. SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
  187. where 1=1
  188. <if test=" null != tenantId">
  189. and tenant_id = #{tenantId}
  190. </if>
  191. <if test=" null != couponOrderStatus">
  192. and coupon_order_status = #{couponOrderStatus}
  193. </if>
  194. <if test=" null != cUserId">
  195. and c_user_id = #{cUserId}
  196. </if>
  197. <if test=" null != couponId ">
  198. and coupon_id = #{couponId}
  199. </if>
  200. <if test=" null != couponType ">
  201. and coupon_type = #{couponType}
  202. </if>
  203. <if test=" null != startTime">
  204. and create_date &gt;= #{startTime}
  205. </if>
  206. <if test=" null != endTime">
  207. and create_date &lt;= #{endTime}
  208. </if>
  209. </select>
  210. <select id="findCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
  211. select COUNT(*) FROM wx_coupon_order co
  212. <if test=" null != businessId ">
  213. inner join wx_coupon c
  214. on c.id = co.coupon_id
  215. and c.business = #{businessId}
  216. <if test=" null != subBusinessId ">
  217. and c.sub_business = #{subBusinessId}
  218. </if>
  219. </if>
  220. where 1=1
  221. <if test=" null != tenantId">
  222. and co.tenant_id = #{tenantId}
  223. </if>
  224. <if test=" null != couponOrderStatus">
  225. and co.coupon_order_status = #{couponOrderStatus}
  226. </if>
  227. <if test=" null != cUserId">
  228. and co.c_user_id = #{cUserId}
  229. </if>
  230. <if test=" null != couponId ">
  231. and co.coupon_id = #{couponId}
  232. </if>
  233. <if test=" null != couponType ">
  234. and co.coupon_type = #{couponType}
  235. </if>
  236. <if test=" 1 == couponOrderStatus">
  237. <if test=" null != startTime">
  238. and co.update_date &gt;= #{startTime}
  239. </if>
  240. <if test=" null != endTime">
  241. and co.update_date &lt;= #{endTime}
  242. </if>
  243. <if test=" 0 == timeSlot">
  244. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  245. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  246. and date_format(co.update_date,'%w') in (1,2,3,4,5)
  247. </if>
  248. <if test=" 1 == timeSlot">
  249. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  250. and date_format(co.update_date,'%w') in (1,2,3,4))
  251. or
  252. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  253. and date_format(co.update_date,'%w') in (1,2,3,4,5)))
  254. </if>
  255. <if test=" 2 == timeSlot">
  256. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  257. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  258. and date_format(co.update_date,'%w') in (0,6)
  259. </if>
  260. <if test=" 3 == timeSlot">
  261. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  262. and date_format(co.update_date,'%w') in (5,6,0))
  263. or
  264. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  265. and date_format(co.update_date,'%w') in (6,0)))
  266. </if>
  267. </if>
  268. <if test=" 1 != couponOrderStatus">
  269. <if test=" null != startTime">
  270. and co.create_date &gt;= #{startTime}
  271. </if>
  272. <if test=" null != endTime">
  273. and co.create_date &lt;= #{endTime}
  274. </if>
  275. <if test=" 0 == timeSlot">
  276. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  277. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  278. and date_format(co.create_date,'%w') in (1,2,3,4,5)
  279. </if>
  280. <if test=" 1 == timeSlot">
  281. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  282. and date_format(co.create_date,'%w') in (1,2,3,4))
  283. or
  284. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  285. and date_format(co.create_date,'%w') in (1,2,3,4,5)))
  286. </if>
  287. <if test=" 2 == timeSlot">
  288. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  289. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  290. and date_format(co.create_date,'%w') in (0,6)
  291. </if>
  292. <if test=" 3 == timeSlot">
  293. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  294. and date_format(co.create_date,'%w') in (5,6,0))
  295. or
  296. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  297. and date_format(co.create_date,'%w') in (6,0)))
  298. </if>
  299. </if>
  300. </select>
  301. <select id="getCountByBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap">
  302. select c.business, COUNT(c.business) bu_count
  303. FROM wx_coupon_order co
  304. inner join wx_coupon c on c.id = co.coupon_id
  305. where 1=1
  306. <if test=" null != tenantId">
  307. and co.tenant_id = #{tenantId}
  308. </if>
  309. <if test=" null != couponOrderStatus">
  310. and co.coupon_order_status = #{couponOrderStatus}
  311. </if>
  312. <if test=" null != cUserId">
  313. and co.c_user_id = #{cUserId}
  314. </if>
  315. <if test=" null != couponId ">
  316. and co.coupon_id = #{couponId}
  317. </if>
  318. <if test=" null != couponType ">
  319. and co.coupon_type = #{couponType}
  320. </if>
  321. <if test=" 1 == couponOrderStatus">
  322. <if test=" null != startTime">
  323. and co.update_date &gt;= #{startTime}
  324. </if>
  325. <if test=" null != endTime">
  326. and co.update_date &lt;= #{endTime}
  327. </if>
  328. <if test=" 0 == timeSlot">
  329. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  330. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  331. and date_format(co.update_date,'%w') in (1,2,3,4,5)
  332. </if>
  333. <if test=" 1 == timeSlot">
  334. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  335. and date_format(co.update_date,'%w') in (1,2,3,4))
  336. or
  337. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  338. and date_format(co.update_date,'%w') in (1,2,3,4,5)))
  339. </if>
  340. <if test=" 2 == timeSlot">
  341. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  342. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  343. and date_format(co.update_date,'%w') in (0,6)
  344. </if>
  345. <if test=" 3 == timeSlot">
  346. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  347. and date_format(co.update_date,'%w') in (5,6,0))
  348. or
  349. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  350. and date_format(co.update_date,'%w') in (6,0)))
  351. </if>
  352. </if>
  353. <if test=" 1 != couponOrderStatus">
  354. <if test=" null != startTime">
  355. and co.create_date &gt;= #{startTime}
  356. </if>
  357. <if test=" null != endTime">
  358. and co.create_date &lt;= #{endTime}
  359. </if>
  360. <if test=" 0 == timeSlot">
  361. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  362. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  363. and date_format(co.create_date,'%w') in (1,2,3,4,5)
  364. </if>
  365. <if test=" 1 == timeSlot">
  366. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  367. and date_format(co.create_date,'%w') in (1,2,3,4))
  368. or
  369. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  370. and date_format(co.create_date,'%w') in (1,2,3,4,5)))
  371. </if>
  372. <if test=" 2 == timeSlot">
  373. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  374. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  375. and date_format(co.create_date,'%w') in (0,6)
  376. </if>
  377. <if test=" 3 == timeSlot">
  378. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  379. and date_format(co.create_date,'%w') in (5,6,0))
  380. or
  381. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  382. and date_format(co.create_date,'%w') in (6,0)))
  383. </if>
  384. </if>
  385. group by c.business
  386. </select>
  387. <select id="getCountBySubBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap">
  388. select c.sub_business, COUNT(c.sub_business) bu_count
  389. FROM wx_coupon_order co
  390. <if test=" null != businessId ">
  391. inner join wx_coupon c on c.id = co.coupon_id and c.business = #{businessId}
  392. </if>
  393. where 1=1
  394. <if test=" null != tenantId">
  395. and co.tenant_id = #{tenantId}
  396. </if>
  397. <if test=" null != couponOrderStatus">
  398. and co.coupon_order_status = #{couponOrderStatus}
  399. </if>
  400. <if test=" null != cUserId">
  401. and co.c_user_id = #{cUserId}
  402. </if>
  403. <if test=" null != couponId ">
  404. and co.coupon_id = #{couponId}
  405. </if>
  406. <if test=" null != couponType ">
  407. and co.coupon_type = #{couponType}
  408. </if>
  409. <if test=" 1 == couponOrderStatus">
  410. <if test=" null != startTime">
  411. and co.update_date &gt;= #{startTime}
  412. </if>
  413. <if test=" null != endTime">
  414. and co.update_date &lt;= #{endTime}
  415. </if>
  416. <if test=" 0 == timeSlot">
  417. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  418. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  419. and date_format(co.update_date,'%w') in (1,2,3,4,5)
  420. </if>
  421. <if test=" 1 == timeSlot">
  422. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  423. and date_format(co.update_date,'%w') in (1,2,3,4))
  424. or
  425. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  426. and date_format(co.update_date,'%w') in (1,2,3,4,5)))
  427. </if>
  428. <if test=" 2 == timeSlot">
  429. and date_format(co.update_date,'%H:%m') &gt;= '06:00'
  430. and date_format(co.update_date,'%H:%m') &lt; '18:00'
  431. and date_format(co.update_date,'%w') in (0,6)
  432. </if>
  433. <if test=" 3 == timeSlot">
  434. and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
  435. and date_format(co.update_date,'%w') in (5,6,0))
  436. or
  437. ((date_format(co.update_date,'%H:%m') &lt; '06:00')
  438. and date_format(co.update_date,'%w') in (6,0)))
  439. </if>
  440. </if>
  441. <if test=" 1 != couponOrderStatus">
  442. <if test=" null != startTime">
  443. and co.create_date &gt;= #{startTime}
  444. </if>
  445. <if test=" null != endTime">
  446. and co.create_date &lt;= #{endTime}
  447. </if>
  448. <if test=" 0 == timeSlot">
  449. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  450. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  451. and date_format(co.create_date,'%w') in (1,2,3,4,5)
  452. </if>
  453. <if test=" 1 == timeSlot">
  454. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  455. and date_format(co.create_date,'%w') in (1,2,3,4))
  456. or
  457. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  458. and date_format(co.create_date,'%w') in (1,2,3,4,5)))
  459. </if>
  460. <if test=" 2 == timeSlot">
  461. and date_format(co.create_date,'%H:%m') &gt;= '06:00'
  462. and date_format(co.create_date,'%H:%m') &lt; '18:00'
  463. and date_format(co.create_date,'%w') in (0,6)
  464. </if>
  465. <if test=" 3 == timeSlot">
  466. and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
  467. and date_format(co.create_date,'%w') in (5,6,0))
  468. or
  469. ((date_format(co.create_date,'%H:%m') &lt; '06:00')
  470. and date_format(co.create_date,'%w') in (6,0)))
  471. </if>
  472. </if>
  473. group by c.sub_business
  474. </select>
  475. <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
  476. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order
  477. where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime
  478. </select>
  479. <select id="findExpiredFreeCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  480. select <include refid="allColumns" /> from wx_coupon_order
  481. where expired_time &lt; now() and coupon_price = 0 and coupon_order_status = 0
  482. </select>
  483. <select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  484. select <include refid="allColumns" /> from wx_coupon_order
  485. where expired_time &lt; now() and coupon_price &gt; 0 and coupon_order_status = 0
  486. </select>
  487. <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo">
  488. <id column="id" jdbcType="BIGINT" property="id" />
  489. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  490. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  491. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  492. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  493. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  494. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  495. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  496. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  497. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  498. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  499. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  500. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  501. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  502. <result column="type" jdbcType="INTEGER" property="type" />
  503. <result column="title" jdbcType="VARCHAR" property="title" />
  504. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  505. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  506. <result column="price" jdbcType="INTEGER" property="price" />
  507. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />
  508. <result column="business" jdbcType="INTEGER" property="business"/>
  509. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  510. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  511. <result column="name" jdbcType="VARCHAR" property="bUserName" />
  512. <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
  513. <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
  514. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  515. <result column="verify_merchant_name" jdbcType="VARCHAR" property="verifyMerchantName"/>
  516. <collection column="{productId=coupon_id}" property="merchantVoList"
  517. ofType="com.iformall.domain.vo.WxMerchantVo"
  518. javaType="java.util.List"
  519. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
  520. </collection>
  521. </resultMap>
  522. <sql id="allAdminCouponOrderListColumns">
  523. 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,
  524. c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,c.subsidy_num,
  525. (case when com.mc=1 then
  526. (select m.name from wx_merchant m, wx_coupon_merchant cm
  527. where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name,
  528. (case when com.mc = 1 then (select m.id from wx_merchant m,
  529. wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id = co.coupon_id
  530. and cm.status = 0) else 0 end) as merchant_id,cu.phone,bu.verify_merchant_name,cal.channel_type
  531. </sql>
  532. <sql id="allAdminCouponOrderDetailColumns">
  533. 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,
  534. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,c.subsidy_num,
  535. bu.name, bu.phone as bphone,
  536. cu.phone,
  537. m.name as merchant_name,m.id as merchant_id
  538. </sql>
  539. <select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BVoResultMap">
  540. select <include refid="allAdminCouponOrderListColumns" />
  541. from
  542. wx_coupon_order co inner join wx_coupon c on c.id = co.coupon_id
  543. inner join (select tco.id as tcoid,
  544. (select count(*) from wx_coupon_merchant tcm
  545. where tcm.product_id = tco.coupon_id
  546. and tcm.status = 0) as mc
  547. from wx_coupon_order tco) com on com.tcoid = co.id
  548. inner join wx_c_user cu on cu.id=co.c_user_id
  549. left join (
  550. select bu.id as bu_id,m.name as verify_merchant_name
  551. from wx_merchant_b_user bu inner join wx_merchant m on bu.merchant_id=m.id
  552. where bu.tenant_id = #{tenantId}
  553. ) bu on bu.bu_id = co.b_user_id
  554. left join wx_coupon_action_log cal on co.id = cal.coupon_order_id and co.coupon_id = cal.coupon_id
  555. where 1=1
  556. <choose>
  557. <when test=" null != couponType">
  558. and co.coupon_type = #{couponType}
  559. </when>
  560. <otherwise>
  561. and co.coupon_type &lt; 100
  562. </otherwise>
  563. </choose>
  564. <if test=" null != tenantId ">
  565. and co.tenant_id = #{tenantId}
  566. </if>
  567. <if test=" null != couponOrderStatus ">
  568. and co.coupon_order_status = #{couponOrderStatus}
  569. </if>
  570. <if test=" null != merchantName and merchantName!=''">
  571. and (case when com.mc=1
  572. then
  573. (select m.name from wx_merchant m, wx_coupon_merchant cm
  574. where m.id = cm.merchant_id
  575. and cm.product_id=co.coupon_id
  576. and cm.status = 0)
  577. else'[多商户通用]' end)
  578. like concat('%', #{merchantName},'%')
  579. </if>
  580. <if test="startDate != null">
  581. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  582. </if>
  583. <if test="endDate != null">
  584. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  585. </if>
  586. <if test="verifyStartDate != null">
  587. AND co.update_date &gt; #{verifyStartDate,jdbcType=TIMESTAMP}
  588. </if>
  589. <if test="verifyEndDate != null">
  590. AND co.update_date &lt; #{verifyEndDate,jdbcType=TIMESTAMP}
  591. </if>
  592. <if test=" null != id ">
  593. and co.id = #{id}
  594. </if>
  595. <if test=" null != couponId ">
  596. and c.id = #{couponId}
  597. </if>
  598. <if test=" null != business ">
  599. and c.business = #{business}
  600. </if>
  601. <if test=" null != verifyMerchantName and ''!= verifyMerchantName ">
  602. and bu.verify_merchant_name = #{verifyMerchantName}
  603. </if>
  604. <if test="null!=building">
  605. and co.coupon_id in(
  606. select cm.product_id from wx_merchant_shop ms left join wx_merchant m on ms.merchant_id=m.id
  607. left join wx_shop s on ms.shop_id=s.id
  608. left join wx_coupon_merchant cm on ms.merchant_id=cm.merchant_id
  609. where ms.is_del=0 and s.building=#{building}
  610. <if test=" null != tenantId ">
  611. and ms.tenant_id=#{tenantId}
  612. </if>
  613. <if test="null!=floor">
  614. and s.floor=#{floor}
  615. </if>
  616. )
  617. </if>
  618. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  619. <if test=" null == sortColumns">order by co.create_date desc,co.id desc</if>
  620. </select>
  621. <select id="findDetailOfAdmin" parameterType="java.lang.Long" resultMap="BVoResultMap">
  622. select <include refid="allAdminCouponOrderDetailColumns" />
  623. from wx_coupon c, wx_coupon_order co
  624. left join wx_c_user cu on cu.id = co.c_user_id
  625. left join wx_merchant_b_user bu on co.b_user_id = bu.id
  626. left join wx_merchant m on m.id = bu.merchant_id
  627. where co.id = #{id}
  628. and c.id = co.coupon_id
  629. </select>
  630. <sql id="allBUserVerifiedCouponOrderColumns">
  631. 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,
  632. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
  633. bu.name,
  634. cu.phone
  635. </sql>
  636. <sql id="allBUserOrderedCouponOrderColumns">
  637. 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,
  638. c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
  639. cu.phone
  640. </sql>
  641. <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  642. select <include refid="allBUserOrderedCouponOrderColumns" />
  643. from wx_coupon_order co,wx_coupon c,wx_c_user cu,wx_coupon_merchant cm,
  644. (select tco.id as tcoid,
  645. (select count(*) from wx_coupon_merchant tcm
  646. where tcm.product_id = tco.coupon_id
  647. and tcm.status = 0) as mc
  648. from wx_coupon_order tco) com
  649. where com.mc = 1
  650. and com.tcoid = co.id
  651. and cm.merchant_id = #{merchantId}
  652. and cm.product_id = c.id
  653. and cm.status = 0
  654. and co.coupon_id = c.id
  655. and cu.id = co.c_user_id
  656. <if test="startDate != null">
  657. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  658. </if>
  659. <if test="endDate != null">
  660. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  661. </if>
  662. order by co.create_date desc
  663. </select>
  664. <select id="findListOfVerifiedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  665. select <include refid="allBUserVerifiedCouponOrderColumns" />
  666. from wx_coupon_order co,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
  667. where co.coupon_id = c.id
  668. and cu.id = co.c_user_id
  669. and bu.id = co.b_user_id
  670. and bu.merchant_id = #{merchantId}
  671. <if test="startDate != null">
  672. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  673. </if>
  674. <if test="endDate != null">
  675. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  676. </if>
  677. AND co.coupon_order_status = '1'
  678. order by co.update_date desc
  679. </select>
  680. <sql id="allCouponOrderColumns">
  681. 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
  682. </sql>
  683. <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
  684. select <include refid="allCouponOrderColumns" />
  685. from wx_coupon_order co,wx_coupon_merchant cm,
  686. (select tco.id as tcoid,
  687. (select count(*) from wx_coupon_merchant tcm
  688. where tcm.product_id = tco.coupon_id
  689. and tcm.status = 0)
  690. as mc
  691. from wx_coupon_order tco) com
  692. where com.mc = 1
  693. and com.tcoid = co.id
  694. and cm.status = 0
  695. and cm.merchant_id = #{merchantId}
  696. and cm.product_id = co.coupon_id
  697. <if test="startDate != null">
  698. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  699. </if>
  700. <if test="endDate != null">
  701. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  702. </if>
  703. </select>
  704. <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
  705. select <include refid="allCouponOrderColumns" />
  706. from wx_coupon_order co, wx_merchant_b_user mbu
  707. where mbu.id = co.b_user_id
  708. and mbu.merchant_id = #{merchantId}
  709. <if test="startDate != null">
  710. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  711. </if>
  712. <if test="endDate != null">
  713. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  714. </if>
  715. AND co.coupon_order_status = '1'
  716. </select>
  717. <sql id="allCUserCouponOrderListColumns">
  718. co.id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  719. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_start_date,c.valid_end_date,c.auto_refund,
  720. cal.channel_type as send_channel_type
  721. </sql>
  722. <sql id="allCUserCouponOrderDetailColumns">
  723. 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,
  724. c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.auto_refund
  725. </sql>
  726. <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo">
  727. <id column="id" jdbcType="BIGINT" property="id" />
  728. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  729. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  730. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  731. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  732. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  733. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  734. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  735. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  736. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  737. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  738. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  739. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  740. <result column="type" jdbcType="INTEGER" property="type" />
  741. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  742. <result column="title" jdbcType="VARCHAR" property="title" />
  743. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  744. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  745. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  746. <result column="detail" jdbcType="VARCHAR" property="detail" />
  747. <result column="price" jdbcType="INTEGER" property="price" />
  748. <result column="unit" jdbcType="INTEGER" property="unit" />
  749. <result column="remark" jdbcType="VARCHAR" property="remark" />
  750. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  751. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  752. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />
  753. <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
  754. <collection column="{productId=coupon_id}" property="merchantVoList"
  755. ofType="com.iformall.domain.vo.WxMerchantVo"
  756. javaType="java.util.List"
  757. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  758. </collection>
  759. </resultMap>
  760. <select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
  761. select <include refid="allCUserCouponOrderListColumns" />
  762. from wx_coupon c,wx_coupon_order co
  763. left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
  764. where 1=1
  765. and co.coupon_id = c.id
  766. and co.coupon_type != 5
  767. and co.coupon_type != 51
  768. and co.coupon_type &lt; 100
  769. <if test="cUserId != null">
  770. and co.c_user_id = #{cUserId}
  771. </if>
  772. <if test="ownerId != null">
  773. and co.owner_id = #{ownerId}
  774. </if>
  775. <if test="tenantId != null">
  776. and co.tenant_id = #{tenantId}
  777. </if>
  778. <if test="couponOrderStatus != null">
  779. AND co.coupon_order_status = #{couponOrderStatus}
  780. </if>
  781. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  782. </select>
  783. <select id="findDetailOfCUser" parameterType="java.lang.Long" resultMap="CVoResultMap">
  784. select <include refid="allCUserCouponOrderDetailColumns" />
  785. from wx_coupon_order co,wx_coupon c
  786. where co.coupon_id = c.id
  787. and co.id = #{id}
  788. </select>
  789. <sql id="allCUserCouponOrderCarListColumns">
  790. co.id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  791. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
  792. json_extract(car.vendor_params,'$.id') as coupon_free_id
  793. </sql>
  794. <resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo">
  795. <id column="id" jdbcType="BIGINT" property="id" />
  796. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  797. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  798. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  799. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  800. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  801. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  802. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  803. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  804. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  805. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  806. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  807. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  808. <result column="type" jdbcType="INTEGER" property="type" />
  809. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  810. <result column="title" jdbcType="VARCHAR" property="title" />
  811. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  812. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  813. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  814. <result column="detail" jdbcType="VARCHAR" property="detail" />
  815. <result column="price" jdbcType="INTEGER" property="price" />
  816. <result column="remark" jdbcType="VARCHAR" property="remark" />
  817. <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/>
  818. <collection column="{productId=coupon_id}" property="merchantVoList"
  819. ofType="com.iformall.domain.vo.WxMerchantVo"
  820. javaType="java.util.List"
  821. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  822. </collection>
  823. </resultMap>
  824. <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap">
  825. select <include refid="allCUserCouponOrderCarListColumns" />
  826. from wx_coupon_order co, wx_coupon c, wx_coupon_car car
  827. where co.coupon_id = c.id
  828. and co.coupon_id = car.id
  829. and c.type in (5,51)
  830. <if test="cUserId != null">
  831. and co.c_user_id = #{cUserId}
  832. </if>
  833. <if test="tenantId != null">
  834. and co.tenant_id = #{tenantId}
  835. </if>
  836. <if test="id != null">
  837. and co.id = #{id}
  838. </if>
  839. <if test="couponOrderStatus != null">
  840. AND co.coupon_order_status = #{couponOrderStatus}
  841. </if>
  842. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  843. </select>
  844. <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo">
  845. <id column="id" jdbcType="BIGINT" property="id" />
  846. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  847. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  848. <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
  849. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  850. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  851. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  852. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  853. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  854. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  855. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  856. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  857. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  858. <result column="title" jdbcType="VARCHAR" property="title" />
  859. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  860. <result column="detail" jdbcType="VARCHAR" property="detail" />
  861. <result column="unit" jdbcType="INTEGER" property="unit" />
  862. <result column="remark" jdbcType="VARCHAR" property="remark" />
  863. <result column="amount" jdbcType="INTEGER" property="amount" />
  864. <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" />
  865. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  866. <collection column="{productId=coupon_id}" property="merchantVoList"
  867. ofType="com.iformall.domain.vo.WxMerchantVo"
  868. javaType="java.util.List"
  869. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  870. </collection>
  871. <collection column="{cardId=id}" property="cardSpendList"
  872. ofType="com.iformall.domain.vo.WxCardSpendVo"
  873. javaType="java.util.List"
  874. select="com.iformall.mapper.WxCardSpendMapper.findCardSpendVoList" >
  875. </collection>
  876. </resultMap>
  877. <sql id="allCUserCardListColumns">
  878. co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,
  879. c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark,
  880. a.amount,a.remaining_amount,a.support_transfer
  881. </sql>
  882. <sql id="allCUserCardDetailColumns">
  883. 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,
  884. c.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark,
  885. a.amount,a.remaining_amount,a.support_transfer
  886. </sql>
  887. <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap">
  888. select c.* from (
  889. select id,tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as
  890. coupon_order_status,create_date,update_date,'' cover_img,title,'' sub_title,'' detail,0 unit,
  891. '' remark,amount,remain_amount as remaining_amount,0 support_transfer
  892. from wx_card_transfer_info where 1=1
  893. <if test="tenantId != null">
  894. and tenant_id = #{tenantId}
  895. </if>
  896. <if test="ownerId != null">
  897. and from_user = #{ownerId}
  898. </if>
  899. <choose>
  900. <when test="couponOrderStatus != null">
  901. and status = #{couponOrderStatus}
  902. </when>
  903. <otherwise>
  904. and status=8
  905. </otherwise>
  906. </choose>
  907. union
  908. select
  909. <include refid="allCUserCardListColumns"/>
  910. from wx_coupon_order co
  911. inner join wx_coupon c on co.coupon_id = c.id
  912. inner join wx_card_info a on co.id=a.id
  913. where 1=1
  914. and co.coupon_type = 100
  915. <if test="tenantId != null">
  916. and co.tenant_id = #{tenantId}
  917. </if>
  918. <if test="cUserId != null">
  919. and co.c_user_id = #{cUserId}
  920. </if>
  921. <if test="ownerId != null">
  922. and co.owner_id = #{ownerId}
  923. </if>
  924. <if test="couponOrderStatus != null">
  925. and co.coupon_order_status = #{couponOrderStatus}
  926. </if>
  927. <if test=" null != statusS ">
  928. and co.coupon_order_status in
  929. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  930. #{sItem}
  931. </foreach>
  932. </if>
  933. ) c
  934. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  935. </select>
  936. <select id="findCardDetailOfCUser" parameterType="java.lang.Long" resultMap="CCardVoResultMap">
  937. select <include refid="allCUserCardDetailColumns" />
  938. from wx_coupon_order co,wx_coupon c, wx_card_info a
  939. where co.coupon_id = c.id and co.id = a.id
  940. and co.id = #{id}
  941. </select>
  942. </mapper>