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

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