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

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