后台服务
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

WxOrderGroupMapper.xml 13 KiB

hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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.WxOrderGroupMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOrderGroup">
  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="order_id" jdbcType="BIGINT" property="orderId"/>
  9. <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
  10. <result column="remain_people" jdbcType="INTEGER" property="remainPeople"/>
  11. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  12. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  13. <result column="expired_date" jdbcType="TIMESTAMP" property="expiredDate"/>
  14. <result column="status" jdbcType="SMALLINT" property="status"/>
  15. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  16. </resultMap>
  17. <sql id="allColumns">
  18. `id`,`tenant_id`,`parent_tenant_id`,`order_id`,`coupon_id`,`remain_people`,`create_date`,`update_date`,`expired_date`,`status`,`user_id`
  19. </sql>
  20. <sql id="dynamicWhereConditions">
  21. where 1 = 1
  22. <if test=" null != id ">
  23. and `id` = #{id}
  24. </if>
  25. <if test=" null != tenantId and '' != tenantId">
  26. and `tenant_id` = #{tenantId}
  27. </if>
  28. <if test=" null != parentTenantId and '' != parentTenantId">
  29. and `parent_tenant_id` = #{parentTenantId}
  30. </if>
  31. <if test=" null != orderId ">
  32. and `order_id` = #{orderId}
  33. </if>
  34. <if test=" null != userId ">
  35. and `coupon_id` = #{couponId}
  36. </if>
  37. <if test=" null != pressValue ">
  38. and `remain_people` = #{remainPeople}
  39. </if>
  40. <if test=" null != createDate ">
  41. and `create_date` = #{createDate}
  42. </if>
  43. <if test=" null != ids ">
  44. and id in
  45. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  46. #{idItem}
  47. </foreach>
  48. </if>
  49. <if test=" null != sortColumns">order by ${sortColumns}</if>
  50. </sql>
  51. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  52. select <include refid="allColumns"/> from wx_order_group where id = #{id} and tenant_id = #{tenantId}
  53. </select>
  54. <select id="queryRemainOne" parameterType="com.iformall.domain.po.WxOrderGroup" resultType="hashmap">
  55. select o.press_end_date expiredDate,o.order_group_id orderGroupId,o.id orderId,o.product_id couponId,o.c_user_id cUserId
  56. from wx_order o
  57. where o.id=#{orderId}
  58. <if test=" null != tenantId and '' != tenantId">
  59. and o.`tenant_id` = #{tenantId}
  60. </if>
  61. <if test=" null != parentTenantId and '' != parentTenantId">
  62. and o.`parent_tenant_id` = #{parentTenantId}
  63. </if>
  64. </select>
  65. <select id="queryOrderGroup" parameterType="com.iformall.domain.po.WxOrder" resultType="hashmap">
  66. select o.id orderId,o.order_status orderStatus,o.order_group_id orderGroupId,o.compose_order_id composeOrderId,c.title,c.sub_title subTitle,
  67. c.sale_price salePrice,c.cover_img coverImg,g.remain_people remainPeople,c.id couponId,g.expired_date
  68. expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId,o.parent_tenant_id parentTenantId,
  69. o.coupon_channel_id couponChannelId,c.press_limit_num pressLimitNum,
  70. (select status from wx_coupon_channel where id=o.coupon_channel_id) couponStatus,
  71. o.compose_order_type composeOrderType
  72. from wx_order o
  73. left join wx_coupon c on o.product_id=c.id
  74. left join wx_order_group g on o.order_group_id=g.id
  75. left join wx_c_user_basic_info u on o.c_user_id=u.id
  76. where c.type=9
  77. <if test=" null != tenantId and '' != tenantId">
  78. and o.`tenant_id` = #{tenantId}
  79. </if>
  80. <if test=" null != parentTenantId and '' != parentTenantId">
  81. and o.`parent_tenant_id` = #{parentTenantId}
  82. </if>
  83. <if test=" null != cUserId ">
  84. and o.c_user_id=#{cUserId}
  85. </if>
  86. <if test=" null != id ">
  87. and o.id=#{id}
  88. </if>
  89. <if test=" null != orderGroupId ">
  90. and o.order_group_id=#{orderGroupId}
  91. </if>
  92. and o.order_status in(10,11,12,13,14,15,16,98,99)
  93. order by o.id desc,o.order_status
  94. </select>
  95. <update id="updateOrderGroup" parameterType="com.iformall.domain.po.WxOrderGroup">
  96. update wx_order_group set remain_people=remain_people-1,status=#{status},update_date=#{updateDate} where id=#{id} and remain_people>0
  97. </update>
  98. <select id="queryOrderGroupMarketingList"
  99. resultType="com.iformall.domain.vo.WxOrderGroupMarketing">
  100. SELECT c.tenant_id,c.parent_tenant_id, c.id, c.cover_img, c.title,
  101. IFNULL(og.group_total_count,0) as group_total_count,
  102. IFNULL(og2.group_success_count,0) as group_success_count,
  103. IFNULL(o.success_people,0) as success_people,
  104. IFNULL(co.verify_count,0) as verify_count,
  105. IFNULL(o2.total_people,0) as total_people,
  106. ROUND(IFNULL((og2.group_success_count / og.group_total_count), 0) * 100) group_transfer_ratio,
  107. ROUND(IFNULL((co.verify_count / o.success_people), 0) * 100) verify_ratio,
  108. ROUND(c.price / 100, 2) price,
  109. ROUND(c.sale_price / 100, 2) sale_price
  110. FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  111. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  112. </foreach>) c
  113. left join (SELECT count(*) group_total_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  114. SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
  115. </foreach>) wx_order_group group by coupon_id) og on og.coupon_id = c.id
  116. left join (SELECT count(*) group_success_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  117. SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
  118. </foreach>) wx_order_group WHERE status = 11 group by coupon_id) og2 on og2.coupon_id = c.id
  119. left join (SELECT count(*) success_people, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  120. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  121. </foreach>) wx_order WHERE order_status = 11 group by product_id ) o on o.product_id = c.id
  122. left join (SELECT count(*) verify_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  123. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  124. </foreach>) wx_coupon_order WHERE coupon_type = 9 AND coupon_order_status = 1 group by coupon_id ) co on co.coupon_id = c.id
  125. left join (SELECT count(*) total_people, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  126. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  127. </foreach>) wx_order WHERE order_group_id != 0 group by product_id ) o2 on o2.product_id = c.id
  128. WHERE type = 9
  129. <if test=" null != marketing.tenantId and '' != marketing.tenantId">
  130. and c.`tenant_id` = #{marketing.tenantId}
  131. </if>
  132. <if test=" null != marketing.parentTenantId and '' != marketing.parentTenantId">
  133. and c.`parent_tenant_id` = #{marketing.parentTenantId}
  134. </if>
  135. <if test=" null != marketing.couponId and '' != marketing.couponId">
  136. and c.coupon_id=#{marketing.couponId}
  137. </if>
  138. <if test=" null != marketing.title and '' != marketing.title">
  139. and c.title like concat('%',#{marketing.title},'%')
  140. </if>
  141. <if test=" null != marketing.sortColumns"> order by ${marketing.sortColumns} </if>
  142. <if test=" null == marketing.sortColumns">order by c.status asc,c.create_date desc</if>
  143. </select>
  144. <select id="queryOrderGroupSuccessCountAndTime" parameterType="hashmap" resultType="hashmap">
  145. select count(1) total,DATE_FORMAT(create_date,'%Y-%m-%d') time from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  146. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  147. </foreach>) wx_coupon_order
  148. where coupon_type=9
  149. <if test=" null != tenantId and '' != tenantId">
  150. and `tenant_id` = #{tenantId}
  151. </if>
  152. <if test=" null != parentTenantId and '' != parentTenantId">
  153. and `parent_tenant_id` = #{parentTenantId}
  154. </if>
  155. <if test=" null != startdate and null!=enddate ">
  156. and create_date BETWEEN #{startdate} and #{enddate}
  157. </if>
  158. <if test=" null != couponId ">
  159. and coupon_id=#{couponId}
  160. </if>
  161. group by time
  162. </select>
  163. <select id="queryOrderGroupVerifyCountAndTime" parameterType="hashmap" resultType="hashmap">
  164. select count(1) total,DATE_FORMAT(create_date,'%Y-%m-%d') time
  165. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  166. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  167. </foreach>) wx_coupon_order where coupon_type=9 and coupon_order_status=1
  168. <if test=" null != tenantId and '' != tenantId">
  169. and `tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != parentTenantId and '' != parentTenantId">
  172. and `parent_tenant_id` = #{parentTenantId}
  173. </if>
  174. <if test=" null != startdate and null!=enddate ">
  175. and create_date BETWEEN #{startdate} and #{enddate}
  176. </if>
  177. <if test=" null != couponId ">
  178. and coupon_id=#{couponId}
  179. </if>
  180. group by time
  181. </select>
  182. <select id="queryOrderGroupCount" parameterType="hashmap" resultType="long">
  183. select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  184. SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
  185. </foreach>) wx_order_group
  186. <where>
  187. <if test=" null != tenantId and '' != tenantId">
  188. and `tenant_id` = #{tenantId}
  189. </if>
  190. <if test=" null != parentTenantId and '' != parentTenantId">
  191. and `parent_tenant_id` = #{parentTenantId}
  192. </if>
  193. <if test=" null != startdate and null!=enddate ">
  194. and create_date BETWEEN #{startdate} and #{enddate}
  195. </if>
  196. </where>
  197. </select>
  198. <select id="queryOrderGroupCountHistory" resultType="com.iformall.domain.vo.WxCouponStatisVo">
  199. select DATE_FORMAT(create_date,'%Y-%m-%d') xtime,count(*) xcount
  200. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  201. SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
  202. </foreach>) wx_order_group
  203. <where>
  204. <if test=" null != wxCoupon.startdate and null!= wxCoupon.enddate ">
  205. and create_date BETWEEN #{wxCoupon.startdate} and #{wxCoupon.enddate}
  206. </if>
  207. </where>
  208. group by xtime
  209. </select>
  210. <select id="queryOrderGroupSuccessCount" parameterType="hashmap" resultType="long">
  211. select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  212. SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
  213. </foreach>) wx_order_group where status=11
  214. <if test=" null != tenantId and '' != tenantId">
  215. and `tenant_id` = #{tenantId}
  216. </if>
  217. <if test=" null != parentTenantId and '' != parentTenantId">
  218. and `parent_tenant_id` = #{parentTenantId}
  219. </if>
  220. <if test=" null != startdate and null!=enddate ">
  221. and create_date BETWEEN #{startdate} and #{enddate}
  222. </if>
  223. </select>
  224. <select id="queryOrderGroupPeopleCount" parameterType="hashmap" resultType="long">
  225. select count(1) from (select id from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  226. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  227. </foreach>) wx_order where order_group_id!=0
  228. <if test=" null != tenantId and '' != tenantId">
  229. and `tenant_id` = #{tenantId}
  230. </if>
  231. <if test=" null != parentTenantId and '' != parentTenantId">
  232. and `parent_tenant_id` = #{parentTenantId}
  233. </if>
  234. <if test=" null != startdate and null!=enddate ">
  235. and create_date BETWEEN #{startdate} and #{enddate}
  236. </if>
  237. ) g
  238. </select>
  239. <select id="queryOrderGroupVerifyCount" parameterType="hashmap" resultType="long">
  240. select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  241. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  242. </foreach>) wx_coupon_order where coupon_type=9 and coupon_order_status=1
  243. <if test=" null != tenantId and '' != tenantId">
  244. and `tenant_id` = #{tenantId}
  245. </if>
  246. <if test=" null != parentTenantId and '' != parentTenantId">
  247. and `parent_tenant_id` = #{parentTenantId}
  248. </if>
  249. <if test=" null != startdate and null!=enddate ">
  250. and create_date BETWEEN #{startdate} and #{enddate}
  251. </if>
  252. <if test=" null != couponId ">
  253. and coupon_id=#{couponId}
  254. </if>
  255. </select>
  256. <select id="queryOrderGroupSuccessPeopleCount" parameterType="hashmap" resultType="long">
  257. select count(1) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  258. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  259. </foreach>) wx_order where order_status=11
  260. <if test=" null != tenantId and '' != tenantId">
  261. and `tenant_id` = #{tenantId}
  262. </if>
  263. <if test=" null != parentTenantId and '' != parentTenantId">
  264. and `parent_tenant_id` = #{parentTenantId}
  265. </if>
  266. <if test=" null != startdate and null!=enddate ">
  267. and create_date BETWEEN #{startdate} and #{enddate}
  268. </if>
  269. </select>
  270. </mapper>