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

723 рядки
27 KiB

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