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

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