Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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