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

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