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.
 
 
 
 
 

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