Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

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