OrderMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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.OrderMapper">
  6. <resultMap type="com.zhongzheng.modules.order.domain.Order" id="OrderResult">
  7. <result property="orderId" column="order_id"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderPrice" column="order_price"/>
  11. <result property="orderGeneral" column="order_general"/>
  12. <result property="orderStatus" column="order_status"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="payTime" column="pay_time"/>
  16. <result property="payType" column="pay_type"/>
  17. <result property="transid" column="transid"/>
  18. <result property="cancelTime" column="cancel_time"/>
  19. <result property="finishTime" column="finish_time"/>
  20. <result property="orderType" column="order_type"/>
  21. <result property="payPrice" column="pay_price"/>
  22. <result property="chargingType" column="charging_type"/>
  23. <result property="orderFrom" column="order_from"/>
  24. <result property="createUsername" column="create_username"/>
  25. <result property="createSysUserId" column="create_sys_user_id"/>
  26. <result property="inputOrderSn" column="input_order_sn"/>
  27. <result property="payStatus" column="pay_status"/>
  28. </resultMap>
  29. <resultMap type="com.zhongzheng.modules.order.vo.OrderListVo" id="OrderResultVo">
  30. <result property="orderId" column="order_id"/>
  31. <result property="orderSn" column="order_sn"/>
  32. <result property="userId" column="user_id"/>
  33. <result property="orderPrice" column="order_price"/>
  34. <result property="orderGeneral" column="order_general"/>
  35. <result property="orderStatus" column="order_status"/>
  36. <result property="createTime" column="create_time"/>
  37. <result property="payTime" column="pay_time"/>
  38. <result property="payType" column="pay_type"/>
  39. <result property="transid" column="transid"/>
  40. <result property="cancelTime" column="cancel_time"/>
  41. <result property="finishTime" column="finish_time"/>
  42. <result property="orderType" column="order_type"/>
  43. <result property="payPrice" column="pay_price"/>
  44. <result property="chargingType" column="charging_type"/>
  45. <result property="orderFrom" column="order_from"/>
  46. <result property="status" column="status"/>
  47. <result property="goodsName" column="goods_name"/>
  48. <result property="goodsId" column="goods_id"/>
  49. <result property="year" column="year"/>
  50. <result property="coverUrl" column="cover_url"/>
  51. <result property="code" column="code"/>
  52. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  53. <result property="educationName" column="education_name"/>
  54. <result property="projectName" column="project_name"/>
  55. <result property="businessName" column="business_name"/>
  56. <result property="schoolName" column="school_name"/>
  57. <result property="categoryName" column="category_name"/>
  58. <result property="goodsPrice" column="goods_price"/>
  59. <result property="goodsRealPrice" column="goods_real_price"/>
  60. <result property="idCard" column="id_card"/>
  61. <result property="telphone" column="telphone"/>
  62. <result property="realname" column="realname"/>
  63. <result property="goodsReceived" column="goods_received"/>
  64. <result property="refundStatus" column="refund_status"/>
  65. <result property="payStatus" column="pay_status"/>
  66. <result property="orderGoodsId" column="order_goods_id"/>
  67. <result property="periodPlush" column="period_plush"/>
  68. <result property="goodsPayStatus" column="goods_pay_status"/>
  69. <result property="goodsType" column="goods_type"/>
  70. <result property="invoiceStatus" column="invoice_status"/>
  71. </resultMap>
  72. <select id="getGradePeriod" parameterType="Map" resultType="integer">
  73. SELECT
  74. cgu.period_plush
  75. FROM
  76. order_goods og
  77. LEFT JOIN class_grade_user cgu ON og.grade_id = cgu.grade_id
  78. AND cgu.user_id = #{userId} where og.order_goods_id = #{orderGoodsId}
  79. </select>
  80. <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  81. SELECT
  82. o.*,
  83. g.goods_id,
  84. g.goods_name,
  85. g.year,
  86. g.cover_url,
  87. g.code,
  88. g.goods_type,
  89. og.goods_price,
  90. og.rebuy_order_goods_id,
  91. og.order_goods_id,
  92. og.goods_real_price,
  93. u.telphone,
  94. u.realname,
  95. u.id_card,
  96. cet.education_name,
  97. cpt.project_name,
  98. cb.business_name,
  99. s.school_name,
  100. m.category_name,
  101. og.goods_received,
  102. og.refund_status,
  103. og.pay_status as goods_pay_status,
  104. (select cgu.period_plush from class_grade_user cgu where cgu.grade_id = og.grade_id and cgu.user_id = o.user_id limit 1 ) period_plush,
  105. (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
  106. oio.order_goods_id = og.order_goods_id AND oi.period_status = 2) invoice_status
  107. FROM
  108. `order` o
  109. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  110. LEFT JOIN goods g ON og.goods_id = g.goods_id
  111. LEFT JOIN `user` u ON o.user_id = u.user_id
  112. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  113. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  114. LEFT JOIN course_business cb ON g.business_id = cb.id
  115. LEFT JOIN school s ON s.id = g.school_id
  116. LEFT JOIN major m ON g.major_id = m.id
  117. WHERE 1=1
  118. <if test="educationTypeId != null and educationTypeId != ''">
  119. AND g.education_type_id = #{educationTypeId}
  120. </if>
  121. <if test="businessId != null and businessId != ''">
  122. AND g.business_id = #{businessId}
  123. </if>
  124. <if test="schoolId != null and schoolId != ''">
  125. AND g.school_id = #{schoolId}
  126. </if>
  127. <if test="majorId != null and majorId != ''">
  128. AND g.major_id = #{majorId}
  129. </if>
  130. <if test="orderSn != null and orderSn != ''">
  131. AND o.order_sn = #{orderSn}
  132. </if>
  133. <if test="orderStatus != null ">
  134. AND o.order_status in
  135. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  136. #{item}
  137. </foreach>
  138. </if>
  139. <if test="status != null ">
  140. AND o.status in
  141. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. <if test="startTime != null">
  146. AND o.create_time >= #{startTime}
  147. </if>
  148. <if test="endTime != null">
  149. AND #{endTime} >= o.create_time
  150. </if>
  151. <if test="payStatus != null">
  152. AND og.pay_status = #{payStatus}
  153. </if>
  154. <if test="refundStatus != null">
  155. AND og.refund_status = #{refundStatus}
  156. </if>
  157. <if test="goodsType != null">
  158. AND g.goods_type = #{goodsType}
  159. </if>
  160. <if test="userId != null">
  161. AND u.user_id = #{userId}
  162. AND og.pay_status in (2,3)
  163. </if>
  164. <if test="inputOrderSn != null">
  165. AND o.input_order_sn = #{inputOrderSn}
  166. </if>
  167. <if test="searchKey != null and searchKey != ''">
  168. AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
  169. </if>
  170. <if test="orderGoodsIds != null ">
  171. AND og.order_goods_id in
  172. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  173. #{item}
  174. </foreach>
  175. </if>
  176. <if test="orderFroms != null ">
  177. AND o.order_from in
  178. <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
  179. #{item}
  180. </foreach>
  181. </if>
  182. ORDER BY o.order_id DESC
  183. </select>
  184. <select id="selectUserClass" parameterType="map" resultType="integer">
  185. SELECT
  186. COUNT(cg.grade_id)
  187. FROM
  188. class_grade_goods cgg
  189. LEFT JOIN class_grade_user cgu ON cgu.grade_id = cgg.grade_id
  190. LEFT JOIN class_grade cg ON cg.grade_id = cgg.grade_id
  191. WHERE cgg.goods_id =#{goodsId}
  192. and cgu.user_id=#{userId}
  193. and cg.`status` =1
  194. </select>
  195. <select id="selectListApp" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
  196. SELECT
  197. o.*
  198. FROM
  199. `order` o where 1=1
  200. <if test="userId != null">
  201. AND o.user_id = #{userId}
  202. </if>
  203. <if test="orderStatus != null">
  204. AND o.order_status in
  205. <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
  206. #{item}
  207. </foreach>
  208. </if>
  209. <if test="status != null">
  210. AND o.status in
  211. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  212. #{item}
  213. </foreach>
  214. </if>
  215. <if test="startTime != null">
  216. AND o.create_time >= #{startTime}
  217. </if>
  218. ORDER BY o.order_id DESC
  219. </select>
  220. <select id="queryByOrderSn" parameterType="String" resultType="Integer">
  221. SELECT order_status from `order` where order_sn = #{orderSn}
  222. </select>
  223. </mapper>