Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

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