Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

269 wiersze
10 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.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="createDate"/>
  13. <result column="expired_date" jdbcType="TIMESTAMP" property="createDate"/>
  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="queryRemainOne" parameterType="com.iformall.domain.po.WxOrderGroup" resultType="hashmap">
  52. select o.press_end_date expiredDate,o.order_group_id orderGroupId,c.nick_name nickName,
  53. c.avatar_url avatarUrl,o.id orderId,o.product_id couponId
  54. from wx_order o
  55. left join wx_c_user_basic_info c on o.c_user_id=c.id
  56. where o.id=#{orderId}
  57. <if test=" null != tenantId and '' != tenantId">
  58. and o.`tenant_id` = #{tenantId}
  59. </if>
  60. <if test=" null != parentTenantId and '' != parentTenantId">
  61. and o.`parent_tenant_id` = #{parentTenantId}
  62. </if>
  63. </select>
  64. <select id="queryOrderGroup" parameterType="com.iformall.domain.po.WxOrder" resultType="hashmap">
  65. select o.id orderId,o.order_status orderStatus,o.order_group_id orderGroupId,c.title,c.sub_title subTitle,
  66. c.sale_price salePrice,c.cover_img coverImg,g.remain_people remainPeople,c.id couponId,g.expired_date
  67. expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId,o.parent_tenant_id parentTenantId,
  68. o.coupon_channel_id couponChannelId,c.press_limit_num pressLimitNum,
  69. (select status from wx_coupon_channel where id=o.coupon_channel_id) couponStatus
  70. from wx_order o
  71. left join wx_coupon c on o.product_id=c.id
  72. left join wx_order_group g on o.order_group_id=g.id
  73. left join wx_c_user_basic_info u on o.c_user_id=u.id
  74. where c.type=9
  75. <if test=" null != tenantId and '' != tenantId">
  76. and o.`tenant_id` = #{tenantId}
  77. </if>
  78. <if test=" null != parentTenantId and '' != parentTenantId">
  79. and o.`parent_tenant_id` = #{parentTenantId}
  80. </if>
  81. <if test=" null != cUserId ">
  82. and o.c_user_id=#{cUserId}
  83. </if>
  84. <if test=" null != id ">
  85. and o.id=#{id}
  86. </if>
  87. <if test=" null != orderGroupId ">
  88. and o.order_group_id=#{orderGroupId}
  89. </if>
  90. and o.order_status in(10,11,12,13,14,15,16)
  91. order by o.id desc,o.order_status
  92. </select>
  93. <update id="updateOrderGroup" parameterType="com.iformall.domain.po.WxOrderGroup">
  94. update wx_order_group set remain_people=remain_people-1,status=#{status},update_date=#{updateDate} where id=#{id} and remain_people>0
  95. </update>
  96. <select id="queryOrderGroupMarketingList" parameterType="com.iformall.domain.vo.WxOrderGroupMarketing"
  97. resultType="com.iformall.domain.vo.WxOrderGroupMarketing">
  98. SELECT c.tenant_id,c.parent_tenant_id, c.id, c.cover_img, c.title,
  99. IFNULL(og.group_total_count,0) as group_total_count,
  100. IFNULL(og2.group_success_count,0) as group_success_count,
  101. IFNULL(o.success_people,0) as success_people,
  102. IFNULL(co.verify_count,0) as verify_count,
  103. IFNULL(o2.total_people,0) as total_people,
  104. ROUND(IFNULL((og2.group_success_count / og.group_total_count), 0) * 100) group_transfer_ratio,
  105. ROUND(IFNULL((co.verify_count / o.success_people), 0) * 100) verify_ratio,
  106. ROUND(c.price / 100, 2) price,
  107. ROUND(c.sale_price / 100, 2) sale_price
  108. FROM wx_coupon c
  109. left join (SELECT count(*) group_total_count, coupon_id FROM wx_order_group group by coupon_id) og on og.coupon_id = c.id
  110. left join (SELECT count(*) group_success_count, coupon_id FROM wx_order_group WHERE status = 11 group by coupon_id) og2 on og2.coupon_id = c.id
  111. left join (SELECT count(*) success_people, product_id FROM wx_order WHERE order_status = 11 group by product_id ) o on o.product_id = c.id
  112. left join (SELECT count(*) verify_count, coupon_id FROM wx_coupon_order WHERE coupon_type = 9 AND coupon_order_status = 1 group by coupon_id ) co on co.coupon_id = c.id
  113. left join (SELECT count(*) total_people, product_id FROM wx_order WHERE order_group_id != 0 group by product_id ) o2 on o2.product_id = c.id
  114. WHERE type = 9
  115. <if test=" null != tenantId and '' != tenantId">
  116. and c.`tenant_id` = #{tenantId}
  117. </if>
  118. <if test=" null != parentTenantId and '' != parentTenantId">
  119. and c.`parent_tenant_id` = #{parentTenantId}
  120. </if>
  121. <if test=" null != couponId and ''!=couponId">
  122. and c.coupon_id=#{couponId}
  123. </if>
  124. <if test=" null != title and ''!=title">
  125. and c.title like concat('%',#{title},'%')
  126. </if>
  127. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  128. <if test=" null == sortColumns">order by c.status asc,c.create_date desc</if>
  129. </select>
  130. <select id="queryOrderGroupSuccessCountAndTime" parameterType="hashmap" resultType="hashmap">
  131. select count(*) total,DATE_FORMAT(create_date,'%Y-%m-%d') time from wx_coupon_order
  132. where coupon_type=9
  133. <if test=" null != tenantId and '' != tenantId">
  134. and `tenant_id` = #{tenantId}
  135. </if>
  136. <if test=" null != parentTenantId and '' != parentTenantId">
  137. and `parent_tenant_id` = #{parentTenantId}
  138. </if>
  139. <if test=" null != startdate and null!=enddate ">
  140. and create_date BETWEEN #{startdate} and #{enddate}
  141. </if>
  142. <if test=" null != couponId ">
  143. and coupon_id=#{couponId}
  144. </if>
  145. group by time
  146. </select>
  147. <select id="queryOrderGroupVerifyCountAndTime" parameterType="hashmap" resultType="hashmap">
  148. select count(*) total,DATE_FORMAT(create_date,'%Y-%m-%d') time
  149. from wx_coupon_order where coupon_type=9 and coupon_order_status=1
  150. <if test=" null != tenantId and '' != tenantId">
  151. and `tenant_id` = #{tenantId}
  152. </if>
  153. <if test=" null != parentTenantId and '' != parentTenantId">
  154. and `parent_tenant_id` = #{parentTenantId}
  155. </if>
  156. <if test=" null != startdate and null!=enddate ">
  157. and create_date BETWEEN #{startdate} and #{enddate}
  158. </if>
  159. <if test=" null != couponId ">
  160. and coupon_id=#{couponId}
  161. </if>
  162. group by time
  163. </select>
  164. <select id="queryOrderGroupCount" parameterType="hashmap" resultType="long">
  165. select count(*) total from wx_order_group
  166. <where>
  167. <if test=" null != tenantId and '' != tenantId">
  168. and `tenant_id` = #{tenantId}
  169. </if>
  170. <if test=" null != parentTenantId and '' != parentTenantId">
  171. and `parent_tenant_id` = #{parentTenantId}
  172. </if>
  173. <if test=" null != startdate and null!=enddate ">
  174. and create_date BETWEEN #{startdate} and #{enddate}
  175. </if>
  176. </where>
  177. </select>
  178. <select id="queryOrderGroupCountHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.vo.WxCouponStatisVo">
  179. select DATE_FORMAT(create_date,'%Y-%m-%d') xtime,count(*) xcount
  180. from wx_order_group
  181. <where>
  182. <if test=" null != tenantId and '' != tenantId">
  183. and `tenant_id` = #{tenantId}
  184. </if>
  185. <if test=" null != parentTenantId and '' != parentTenantId">
  186. and `parent_tenant_id` = #{parentTenantId}
  187. </if>
  188. <if test=" null != startdate and null!=enddate ">
  189. and create_date BETWEEN #{startdate} and #{enddate}
  190. </if>
  191. </where>
  192. group by xtime
  193. </select>
  194. <select id="queryOrderGroupSuccessCount" parameterType="hashmap" resultType="long">
  195. select count(*) total from wx_order_group where status=11
  196. <if test=" null != tenantId and '' != tenantId">
  197. and `tenant_id` = #{tenantId}
  198. </if>
  199. <if test=" null != parentTenantId and '' != parentTenantId">
  200. and `parent_tenant_id` = #{parentTenantId}
  201. </if>
  202. <if test=" null != startdate and null!=enddate ">
  203. and create_date BETWEEN #{startdate} and #{enddate}
  204. </if>
  205. </select>
  206. <select id="queryOrderGroupPeopleCount" parameterType="hashmap" resultType="long">
  207. select count(*) from (select id from wx_order where order_group_id!=0
  208. <if test=" null != tenantId and '' != tenantId">
  209. and `tenant_id` = #{tenantId}
  210. </if>
  211. <if test=" null != parentTenantId and '' != parentTenantId">
  212. and `parent_tenant_id` = #{parentTenantId}
  213. </if>
  214. <if test=" null != startdate and null!=enddate ">
  215. and create_date BETWEEN #{startdate} and #{enddate}
  216. </if>
  217. ) g
  218. </select>
  219. <select id="queryOrderGroupVerifyCount" parameterType="hashmap" resultType="long">
  220. select count(*) total from wx_coupon_order where coupon_type=9 and coupon_order_status=1
  221. <if test=" null != tenantId and '' != tenantId">
  222. and `tenant_id` = #{tenantId}
  223. </if>
  224. <if test=" null != parentTenantId and '' != parentTenantId">
  225. and `parent_tenant_id` = #{parentTenantId}
  226. </if>
  227. <if test=" null != startdate and null!=enddate ">
  228. and create_date BETWEEN #{startdate} and #{enddate}
  229. </if>
  230. <if test=" null != couponId ">
  231. and coupon_id=#{couponId}
  232. </if>
  233. </select>
  234. <select id="queryOrderGroupSuccessPeopleCount" parameterType="hashmap" resultType="long">
  235. select count(*) from wx_order where order_status=11
  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 != startdate and null!=enddate ">
  243. and create_date BETWEEN #{startdate} and #{enddate}
  244. </if>
  245. </select>
  246. </mapper>