OrderInputMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. </resultMap>
  18. <resultMap type="com.zhongzheng.modules.order.vo.OrderInputVo" id="OrderInputVoResult">
  19. <result property="id" column="id"/>
  20. <result property="inputOrderSn" column="input_order_sn"/>
  21. <result property="createUsername" column="create_username"/>
  22. <result property="status" column="status"/>
  23. <result property="createSysUserId" column="create_sys_user_id"/>
  24. <result property="createTime" column="create_time"/>
  25. <result property="educationTypeId" column="education_type_id"/>
  26. <result property="businessId" column="business_id"/>
  27. <result property="projectId" column="project_id"/>
  28. <result property="educationName" column="education_name"/>
  29. <result property="projectName" column="project_name"/>
  30. <result property="businessName" column="business_name"/>
  31. <result property="userNum" column="user_num"/>
  32. <result property="goodsNum" column="goods_num"/>
  33. <result property="goodsReceived" column="goods_received"/>
  34. <result property="orderPrice" column="order_price"/>
  35. <result property="payPrice" column="pay_price"/>
  36. <result property="realname" column="realname"/>
  37. <result property="idCard" column="id_card"/>
  38. <result property="goodsId" column="goods_id"/>
  39. <result property="goodsName" column="goods_name"/>
  40. <result property="orderSn" column="order_sn"/>
  41. <result property="userId" column="user_id"/>
  42. <result property="orderFrom" column="order_from"/>
  43. <result property="orderGoodsId" column="order_goods_id"/>
  44. <result property="goodsRefund" column="goods_refund"/>
  45. </resultMap>
  46. <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  47. SELECT u.input_order_sn,
  48. count( DISTINCT u.user_id ) user_num,
  49. count( DISTINCT og.goods_id ) goods_num,
  50. any_value ( cet.education_name ) education_name,
  51. any_value ( cpt.project_name ) project_name,
  52. any_value ( cb.business_name ) business_name,
  53. (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 = u.input_order_sn and og.refund_status = 2) goods_refund,
  54. sum( og.goods_received ) goods_received,
  55. sum(u.order_price ) order_price,
  56. sum(u.pay_price) pay_price,
  57. any_value ( u.create_username ) create_username,
  58. any_value ( u.create_time ) create_time FROM (SELECT
  59. oi.*,
  60. o.user_id,
  61. sum( o.order_price ) order_price,
  62. sum( o.pay_price ) pay_price,
  63. o.order_sn
  64. FROM
  65. order_input oi
  66. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  67. where 1=1
  68. <if test="businessId != null and businessId != ''">
  69. AND oi.business_id = #{businessId}
  70. </if>
  71. <if test="educationTypeId != null and educationTypeId != ''">
  72. AND oi.education_type_id = #{educationTypeId}
  73. </if>
  74. <if test="searchKey != null and searchKey != ''">
  75. AND (oi.create_username like concat('%', #{searchKey}, '%') or oi.input_order_sn = #{searchKey})
  76. </if>
  77. <if test="startTime != null and startTime != ''">
  78. AND oi.create_time >= #{startTime}
  79. </if>
  80. <if test="endTime != null and endTime != ''">
  81. AND #{endTime} >= oi.create_time
  82. </if>
  83. GROUP BY oi.id,o.order_sn,o.user_id)u LEFT JOIN order_goods og ON u.order_sn = og.order_sn
  84. LEFT JOIN course_education_type cet ON u.education_type_id = cet.id
  85. LEFT JOIN course_project_type cpt ON u.project_id = cpt.id
  86. LEFT JOIN course_business cb ON u.business_id = cb.id
  87. where 1=1
  88. GROUP BY
  89. u.input_order_sn
  90. ORDER BY create_time DESC
  91. </select>
  92. <select id="getInfo" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  93. SELECT
  94. oi.input_order_sn,
  95. count( DISTINCT o.user_id ) user_num,
  96. count( DISTINCT og.goods_id ) goods_num,
  97. any_value ( cet.education_name ) education_name,
  98. any_value ( cpt.project_name ) project_name,
  99. any_value ( cb.business_name ) business_name,
  100. (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,
  101. sum( og.goods_received ) goods_received,
  102. sum( o.order_price ) order_price,
  103. sum( o.pay_price ) pay_price,
  104. any_value ( oi.create_username ) create_username,
  105. any_value ( oi.create_time ) create_time,
  106. any_value ( oi.project_id ) project_id,
  107. any_value ( oi.business_id ) business_id,
  108. any_value ( oi.education_type_id ) education_type_id
  109. FROM
  110. order_input oi
  111. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  112. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  113. LEFT JOIN course_education_type cet ON oi.education_type_id = cet.id
  114. LEFT JOIN course_project_type cpt ON oi.project_id = cpt.id
  115. LEFT JOIN course_business cb ON oi.business_id = cb.id
  116. where 1=1
  117. AND oi.input_order_sn = #{inputOrderSn}
  118. GROUP BY
  119. oi.input_order_sn
  120. </select>
  121. <select id="getUserList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  122. SELECT
  123. o.user_id,
  124. u.realname,
  125. u.id_card
  126. FROM
  127. order_input oi
  128. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  129. LEFT JOIN `user` u ON o.user_id = u.user_id
  130. WHERE
  131. 1 = 1
  132. AND oi.input_order_sn = #{inputOrderSn}
  133. GROUP BY
  134. o.user_id
  135. </select>
  136. <select id="getUserGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
  137. SELECT
  138. o.user_id,
  139. g.goods_id,
  140. g.goods_name,
  141. o.order_sn,
  142. o.order_from,
  143. og.order_goods_id
  144. FROM
  145. order_input oi
  146. LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
  147. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  148. LEFT JOIN goods g ON og.goods_id = g.goods_id
  149. WHERE
  150. 1 = 1
  151. AND oi.input_order_sn = #{inputOrderSn}
  152. and o.user_id = #{userId}
  153. </select>
  154. </mapper>