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.
 
 
 
 
 

223 linhas
8.3 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="order_id" jdbcType="BIGINT" property="orderId"/>
  8. <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
  9. <result column="remain_people" jdbcType="INTEGER" property="remainPeople"/>
  10. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  11. <result column="update_date" jdbcType="TIMESTAMP" property="createDate"/>
  12. <result column="expired_date" jdbcType="TIMESTAMP" property="createDate"/>
  13. <result column="status" jdbcType="SMALLINT" property="status"/>
  14. <result column="user_id" jdbcType="BIGINT" property="userId"/>
  15. </resultMap>
  16. <sql id="allColumns">
  17. `id`,`tenant_id`,`order_id`,`coupon_id`,`remain_people`,`create_date`,`update_date`,`expired_date`,`status`,`user_id`
  18. </sql>
  19. <sql id="dynamicWhereConditions">
  20. where 1 = 1
  21. <if test=" null != id ">
  22. and `id` = #{id}
  23. </if>
  24. <if test=" null != tenantId ">
  25. and `tenant_id` = #{tenantId}
  26. </if>
  27. <if test=" null != orderId ">
  28. and `order_id` = #{orderId}
  29. </if>
  30. <if test=" null != userId ">
  31. and `coupon_id` = #{couponId}
  32. </if>
  33. <if test=" null != pressValue ">
  34. and `remain_people` = #{remainPeople}
  35. </if>
  36. <if test=" null != createDate ">
  37. and `create_date` = #{createDate}
  38. </if>
  39. <if test=" null != ids ">
  40. and id in
  41. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  42. #{idItem}
  43. </foreach>
  44. </if>
  45. <if test=" null != sortColumns">order by ${sortColumns}</if>
  46. </sql>
  47. <select id="queryRemainOne" parameterType="com.iformall.domain.po.WxOrderGroup" resultType="hashmap">
  48. select o.press_end_date expiredDate,o.order_group_id orderGroupId,c.nick_name nickName,
  49. c.avatar_url avatarUrl,o.id orderId,o.product_id couponId
  50. from wx_order o
  51. left join wx_c_user c on o.c_user_id=c.id
  52. where o.tenant_id=#{tenantId} and o.id=#{orderId}
  53. </select>
  54. <select id="queryOrderGroup" parameterType="com.iformall.domain.po.WxOrder" resultType="hashmap">
  55. select o.id orderId,o.order_status orderStatus,o.order_group_id orderGroupId,c.title,c.sub_title subTitle,
  56. c.sale_price salePrice,c.cover_img coverImg,g.remain_people remainPeople,c.id couponId,g.expired_date
  57. expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId,
  58. o.coupon_channel_id couponChannelId,c.press_limit_num pressLimitNum,
  59. (select status from wx_coupon_channel where id=o.coupon_channel_id) couponStatus
  60. from wx_order o
  61. left join wx_coupon c on o.product_id=c.id
  62. left join wx_order_group g on o.order_group_id=g.id
  63. left join wx_c_user u on o.c_user_id=u.id
  64. where o.tenant_id=#{tenantId} and c.type=9
  65. <if test=" null != cUserId ">
  66. and o.c_user_id=#{cUserId}
  67. </if>
  68. <if test=" null != id ">
  69. and o.id=#{id}
  70. </if>
  71. <if test=" null != orderGroupId ">
  72. and o.order_group_id=#{orderGroupId}
  73. </if>
  74. and o.order_status in(10,11,12,13,14,15,16)
  75. order by o.id desc,o.order_status
  76. </select>
  77. <update id="updateOrderGroup" parameterType="com.iformall.domain.po.WxOrderGroup">
  78. update wx_order_group set remain_people=remain_people-1,status=#{status},update_date=#{updateDate} where id=#{id} and remain_people>0
  79. </update>
  80. <select id="queryOrderGroupMarketingList" parameterType="com.iformall.domain.vo.WxOrderGroupMarketing"
  81. resultType="com.iformall.domain.vo.WxOrderGroupMarketing">
  82. select c.tenant_id,coupon_id,c.cover_img,title,c.price,c.sale_price,c.group_total_count,c.group_success_count,
  83. ROUND(IFNULL((c.group_success_count/c.group_total_count),0)*100)
  84. group_transfer_ratio,c.success_people,c.verify_count,
  85. ROUND(IFNULL((verify_count/success_people),0)*100) verify_ratio,c.total_people from(
  86. select tenant_id,id coupon_id,cover_img,title,ROUND(price/100,2) price,ROUND(sale_price/100,2) sale_price,
  87. (select count(*) total from wx_order_group where coupon_id=c.id) group_total_count,
  88. (select count(*) total from wx_order_group where status=11 and coupon_id=c.id) group_success_count,
  89. IFNULL((select count(*) from wx_order where order_status=11 and product_id=c.id),0) success_people,
  90. (select count(*) total
  91. from wx_coupon_order where coupon_type=9 and coupon_order_status=1 and coupon_id=c.id) verify_count,
  92. IFNULL((select count(*) from wx_order where order_group_id!=0 and product_id=c.id),0) total_people
  93. from wx_coupon c where type=9 order by c.status,c.id desc
  94. ) c
  95. <where>
  96. <if test=" null != tenantId">
  97. and c.tenant_id=#{tenantId}
  98. </if>
  99. <if test=" null != couponId and ''!=couponId">
  100. and c.coupon_id=#{couponId}
  101. </if>
  102. <if test=" null != title and ''!=title">
  103. and c.title like concat('%',#{title},'%')
  104. </if>
  105. </where>
  106. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  107. </select>
  108. <select id="queryOrderGroupSuccessCountAndTime" parameterType="hashmap" resultType="hashmap">
  109. select count(*) total,DATE_FORMAT(create_date,'%Y-%m-%d') time from wx_coupon_order
  110. where coupon_type=9
  111. <if test=" null != tenantId">
  112. and tenant_id=#{tenantId}
  113. </if>
  114. <if test=" null != startdate and null!=enddate ">
  115. and create_date BETWEEN #{startdate} and #{enddate}
  116. </if>
  117. <if test=" null != couponId ">
  118. and coupon_id=#{couponId}
  119. </if>
  120. group by time
  121. </select>
  122. <select id="queryOrderGroupVerifyCountAndTime" parameterType="hashmap" resultType="hashmap">
  123. select count(*) total,DATE_FORMAT(create_date,'%Y-%m-%d') time
  124. from wx_coupon_order where coupon_type=9 and coupon_order_status=1
  125. <if test=" null != tenantId">
  126. and tenant_id=#{tenantId}
  127. </if>
  128. <if test=" null != startdate and null!=enddate ">
  129. and create_date BETWEEN #{startdate} and #{enddate}
  130. </if>
  131. <if test=" null != couponId ">
  132. and coupon_id=#{couponId}
  133. </if>
  134. group by time
  135. </select>
  136. <select id="queryOrderGroupCount" parameterType="hashmap" resultType="long">
  137. select count(*) total from wx_order_group
  138. <where>
  139. <if test=" null != tenantId">
  140. and tenant_id=#{tenantId}
  141. </if>
  142. <if test=" null != startdate and null!=enddate ">
  143. and create_date BETWEEN #{startdate} and #{enddate}
  144. </if>
  145. </where>
  146. </select>
  147. <select id="queryOrderGroupCountHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.vo.WxCouponStatisVo">
  148. select DATE_FORMAT(create_date,'%Y-%m-%d') xtime,count(*) xcount
  149. from wx_order_group
  150. <where>
  151. <if test=" null != tenantId">
  152. and tenant_id=#{tenantId}
  153. </if>
  154. <if test=" null != startdate and null!=enddate ">
  155. and create_date BETWEEN #{startdate} and #{enddate}
  156. </if>
  157. </where>
  158. group by xtime
  159. </select>
  160. <select id="queryOrderGroupSuccessCount" parameterType="hashmap" resultType="long">
  161. select count(*) total from wx_order_group where status=11
  162. <if test=" null != tenantId">
  163. and tenant_id=#{tenantId}
  164. </if>
  165. <if test=" null != startdate and null!=enddate ">
  166. and create_date BETWEEN #{startdate} and #{enddate}
  167. </if>
  168. </select>
  169. <select id="queryOrderGroupPeopleCount" parameterType="hashmap" resultType="long">
  170. select count(*) from (select id from wx_order where order_group_id!=0
  171. <if test=" null != tenantId">
  172. and tenant_id=#{tenantId}
  173. </if>
  174. <if test=" null != startdate and null!=enddate ">
  175. and create_date BETWEEN #{startdate} and #{enddate}
  176. </if>
  177. ) g
  178. </select>
  179. <select id="queryOrderGroupVerifyCount" parameterType="hashmap" resultType="long">
  180. select count(*) total from wx_coupon_order where coupon_type=9 and coupon_order_status=1
  181. <if test=" null != tenantId">
  182. and tenant_id=#{tenantId}
  183. </if>
  184. <if test=" null != startdate and null!=enddate ">
  185. and create_date BETWEEN #{startdate} and #{enddate}
  186. </if>
  187. <if test=" null != couponId ">
  188. and coupon_id=#{couponId}
  189. </if>
  190. </select>
  191. <select id="queryOrderGroupSuccessPeopleCount" parameterType="hashmap" resultType="long">
  192. select count(*) from wx_order where order_status=11
  193. <if test=" null != tenantId">
  194. and tenant_id=#{tenantId}
  195. </if>
  196. <if test=" null != startdate and null!=enddate ">
  197. and create_date BETWEEN #{startdate} and #{enddate}
  198. </if>
  199. </select>
  200. </mapper>