后台服务
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

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