Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

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