OrderInputMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.order.mapper.OrderInputMapper">
  6. <resultMap type="com.zhongzheng.modules.order.domain.OrderInput" id="OrderInputResult">
  7. <result property="id" column="id"/>
  8. <result property="inputOrderSn" column="input_order_sn"/>
  9. <result property="createUsername" column="create_username"/>
  10. <result property="status" column="status"/>
  11. <result property="createSysUserId" column="create_sys_user_id"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. <result property="educationTypeId" column="education_type_id"/>
  15. <result property="businessId" column="business_id"/>
  16. <result property="projectId" column="project_id"/>
  17. <result property="oldOrderSn" column="old_order_sn"/>
  18. <result property="inputFrom" column="input_from"/>
  19. </resultMap>
  20. <resultMap type="com.zhongzheng.modules.order.vo.OrderInputVo" id="OrderInputVoResult">
  21. <result property="id" column="id"/>
  22. <result property="inputOrderSn" column="input_order_sn"/>
  23. <result property="createUsername" column="create_username"/>
  24. <result property="status" column="status"/>
  25. <result property="createSysUserId" column="create_sys_user_id"/>
  26. <result property="createTime" column="create_time"/>
  27. <result property="educationTypeId" column="education_type_id"/>
  28. <result property="businessId" column="business_id"/>
  29. <result property="projectId" column="project_id"/>
  30. <result property="educationName" column="education_name"/>
  31. <result property="projectName" column="project_name"/>
  32. <result property="businessName" column="business_name"/>
  33. <result property="userNum" column="user_num"/>
  34. <result property="goodsNum" column="goods_num"/>
  35. <result property="goodsReceived" column="goods_received"/>
  36. <result property="orderPrice" column="order_price"/>
  37. <result property="payPrice" column="pay_price"/>
  38. <result property="realname" column="realname"/>
  39. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  40. <result property="goodsId" column="goods_id"/>
  41. <result property="goodsName" column="goods_name"/>
  42. <result property="orderSn" column="order_sn"/>
  43. <result property="userId" column="user_id"/>
  44. <result property="orderFrom" column="order_from"/>
  45. <result property="orderGoodsId" column="order_goods_id"/>
  46. <result property="goodsRefund" column="goods_refund"/>
  47. <result property="goodsType" column="goods_type"/>
  48. <result property="goodsRealPrice" column="goods_real_price"/>
  49. <result property="oldOrderSn" column="old_order_sn"/>
  50. <result property="inputFrom" column="input_from"/>
  51. </resultMap>
  52. <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  53. SELECT u.input_order_sn,
  54. u.order_from,
  55. any_value (u.old_order_sn ) old_order_sn,
  56. any_value(g.goods_type) goods_type,
  57. count( DISTINCT u.user_id ) user_num,
  58. count( DISTINCT og.goods_id ) goods_num,
  59. any_value ( cet.education_name ) education_name,
  60. any_value ( cpt.project_name ) project_name,
  61. any_value ( cb.business_name ) business_name,
  62. (select IFNULL(sum(og.goods_received),0) from order_goods og LEFT JOIN `order` o on o.order_sn = og.order_sn
  63. where o.input_order_sn = u.input_order_sn and og.refund_status = 2) goods_refund,
  64. IFNULL(sum( og.goods_received ),0) goods_received,
  65. IFNULL(sum(og.goods_price ),0) order_price,
  66. IFNULL(sum(og.goods_real_price),0) pay_price,
  67. any_value ( u.create_username ) create_username,
  68. any_value ( u.create_time ) create_time FROM (SELECT
  69. oi.*,
  70. o.user_id,
  71. sum( o.order_price ) order_price,
  72. sum( o.pay_price ) pay_price,
  73. o.order_sn,
  74. any_value(o.order_from) order_from
  75. FROM
  76. order_input oi
  77. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  78. where 1=1
  79. <if test="orderFrom != null and orderFrom != ''">
  80. AND o.order_from = #{orderFrom}
  81. </if>
  82. <if test="businessId != null and businessId != ''">
  83. AND oi.business_id = #{businessId}
  84. </if>
  85. <if test="inputOrderSn != null and inputOrderSn != ''">
  86. AND oi.input_order_sn = #{inputOrderSn}
  87. </if>
  88. <if test="inputOrderSns != null and inputOrderSns.size()!=0">
  89. AND oi.input_order_sn in
  90. <foreach collection="inputOrderSns" item="item" index="index" open="(" close=")" separator=",">
  91. #{item}
  92. </foreach>
  93. </if>
  94. <if test="educationTypeId != null and educationTypeId != ''">
  95. AND oi.education_type_id = #{educationTypeId}
  96. </if>
  97. <if test="oldOrderSn != null and oldOrderSn != ''">
  98. AND oi.old_order_sn = #{oldOrderSn}
  99. </if>
  100. <if test="searchKey != null and searchKey != ''">
  101. AND (oi.create_username like concat('%', #{searchKey}, '%') or oi.input_order_sn = #{searchKey} or (select
  102. count(*) from `user` us where us.user_id = o.user_id AND us.realname like concat('%', #{searchKey}, '%')
  103. )>0)
  104. </if>
  105. <if test="startTime != null and startTime != ''">
  106. AND oi.create_time >= #{startTime}
  107. </if>
  108. <if test="endTime != null and endTime != ''">
  109. AND #{endTime} >= oi.create_time
  110. </if>
  111. GROUP BY oi.id,o.order_sn,o.user_id)u LEFT JOIN order_goods og ON u.order_sn = og.order_sn
  112. LEFT JOIN course_education_type cet ON u.education_type_id = cet.id
  113. LEFT JOIN course_project_type cpt ON u.project_id = cpt.id
  114. LEFT JOIN course_business cb ON u.business_id = cb.id
  115. LEFT JOIN goods g ON og.goods_id = g.goods_id
  116. where 1=1
  117. <if test="goodsType != null">
  118. AND g.goods_type = #{goodsType}
  119. </if>
  120. <if test="salesman != null and salesman != ''">
  121. AND og.salesman like concat('%', #{salesman}, '%')
  122. </if>
  123. GROUP BY
  124. u.input_order_sn
  125. ORDER BY create_time DESC
  126. </select>
  127. <select id="getInfo" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  128. SELECT
  129. oi.input_order_sn,
  130. count( DISTINCT o.user_id ) user_num,
  131. count( DISTINCT og.goods_id ) goods_num,
  132. any_value ( cet.education_name ) education_name,
  133. any_value ( cpt.project_name ) project_name,
  134. any_value ( cb.business_name ) business_name,
  135. (select IFNULL(sum(og.goods_received),0) from order_goods og LEFT JOIN `order` o on o.order_sn = og.order_sn where o.input_order_sn = oi.input_order_sn and og.refund_status = 2) goods_refund,
  136. IFNULL(sum( og.goods_received ),0) goods_received,
  137. IFNULL(sum( og.goods_real_price ),0) goods_real_price,
  138. IFNULL(sum( o.order_price ),0) order_price,
  139. IFNULL(sum( o.pay_price ),0) pay_price,
  140. any_value ( oi.create_username ) create_username,
  141. any_value ( oi.create_time ) create_time,
  142. any_value ( oi.project_id ) project_id,
  143. any_value ( oi.business_id ) business_id,
  144. any_value ( oi.education_type_id ) education_type_id
  145. FROM
  146. order_input oi
  147. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  148. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  149. LEFT JOIN course_education_type cet ON oi.education_type_id = cet.id
  150. LEFT JOIN course_project_type cpt ON oi.project_id = cpt.id
  151. LEFT JOIN course_business cb ON oi.business_id = cb.id
  152. where 1=1
  153. AND oi.input_order_sn = #{inputOrderSn}
  154. GROUP BY
  155. oi.input_order_sn
  156. </select>
  157. <select id="getUserList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  158. SELECT
  159. o.user_id,
  160. u.realname,
  161. u.id_card
  162. FROM
  163. order_input oi
  164. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  165. LEFT JOIN `user` u ON o.user_id = u.user_id
  166. WHERE
  167. 1 = 1
  168. AND oi.input_order_sn = #{inputOrderSn}
  169. GROUP BY
  170. o.user_id
  171. </select>
  172. <select id="getUserGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  173. SELECT
  174. o.user_id,
  175. g.goods_id,
  176. g.goods_name,
  177. o.order_sn,
  178. o.order_from,
  179. og.order_goods_id
  180. FROM
  181. order_input oi
  182. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  183. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  184. LEFT JOIN goods g ON og.goods_id = g.goods_id
  185. WHERE
  186. 1 = 1
  187. AND oi.input_order_sn = #{inputOrderSn}
  188. and o.user_id = #{userId}
  189. </select>
  190. </mapper>