StudentPaymentOrderDetailMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail" id="StudentPaymentOrderDetail">
  9. <result column="id_" property="id"/>
  10. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  11. <result column="goods_id_list_" property="goodsIdList"/>
  12. <result column="price_" property="price"/>
  13. <result column="create_time_" property="createTime"/>
  14. <result column="update_time_" property="updateTime"/>
  15. <result column="payment_order_id_" property="paymentOrderId"/>
  16. <result column="kit_group_purchase_type_" property="kitGroupPurchaseType"
  17. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  18. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  19. <result column="goods_id_" property="id"/>
  20. <result column="goods_name_" property="name"/>
  21. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  22. <result column="discount_price_" property="discountPrice"/>
  23. <result column="agree_cost_price_" property="agreeCostPrice"/>
  24. <result column="goods_type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  25. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  26. </collection>
  27. </resultMap>
  28. <!-- 根据主键查询一条记录 -->
  29. <select id="get" resultMap="StudentPaymentOrderDetail">
  30. SELECT *
  31. FROM student_payment_order_detail
  32. WHERE id_ = #{id}
  33. </select>
  34. <!-- 全查询 -->
  35. <select id="findAll" resultMap="StudentPaymentOrderDetail">
  36. SELECT *
  37. FROM student_payment_order_detail
  38. ORDER BY id_
  39. </select>
  40. <!-- 向数据库增加一条记录 -->
  41. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail" useGeneratedKeys="true"
  42. keyColumn="id" keyProperty="id">
  43. <!--
  44. <selectKey resultClass="int" keyProperty="id" >
  45. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  46. </selectKey>
  47. -->
  48. INSERT INTO student_payment_order_detail
  49. (id_,type_,goods_id_list_,price_,create_time_,update_time_,payment_order_id_,kit_group_purchase_type_)
  50. VALUES(#{id},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  51. #{goodsIdList},#{price},now(),now(),#{paymentOrderId},#{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  52. </insert>
  53. <!-- 根据主键查询一条记录 -->
  54. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  55. UPDATE student_payment_order_detail
  56. <set>
  57. <if test="price != null">
  58. price_ = #{price},
  59. </if>
  60. <if test="goodsIdList != null">
  61. goods_id_list_ = #{goodsIdList},
  62. </if>
  63. <if test="updateTime != null">
  64. update_time_ = NOW(),
  65. </if>
  66. <if test="paymentOrderId != null">
  67. payment_order_id_ = #{paymentOrderId},
  68. </if>
  69. <if test="kitGroupPurchaseType != null">
  70. kit_group_purchase_type_ =
  71. #{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  72. </if>
  73. <if test="type != null">
  74. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  75. </if>
  76. </set>
  77. WHERE id_ = #{id}
  78. </update>
  79. <!-- 根据主键删除一条记录 -->
  80. <delete id="delete">
  81. DELETE
  82. FROM student_payment_order_detail
  83. WHERE id_ = #{id}
  84. </delete>
  85. <!-- 分页查询 -->
  86. <select id="queryPage" resultMap="StudentPaymentOrderDetail" parameterType="map">
  87. SELECT * FROM student_payment_order_detail ORDER BY id_
  88. <include refid="global.limit"/>
  89. </select>
  90. <!-- 查询当前表的总记录数 -->
  91. <select id="queryCount" resultType="int">
  92. SELECT COUNT(*)
  93. FROM student_payment_order_detail
  94. </select>
  95. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
  96. INSERT INTO student_payment_order_detail
  97. (id_,type_,goods_id_list_,price_,remit_fee_,create_time_,update_time_,payment_order_id_,kit_group_purchase_type_)
  98. VALUES
  99. <foreach collection="studentPaymentOrderDetailList" item="orderDetail" separator=",">
  100. (#{orderDetail.id},#{orderDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  101. #{orderDetail.goodsIdList},#{orderDetail.price},#{orderDetail.remitFee},now(),now(),#{orderDetail.paymentOrderId},
  102. #{orderDetail.kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  103. </foreach>
  104. </insert>
  105. <!-- 查询注册订单详情 -->
  106. <select id="findApplyOrderSuccess" resultMap="StudentPaymentOrderDetail">
  107. SELECT spod.*
  108. FROM student_payment_order spo
  109. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  110. LEFT JOIN student_registration sr ON spo.user_id_ = sr.user_id_
  111. WHERE spo.music_group_id_ = #{musicGroupId}
  112. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  113. AND spo.type_ = 'APPLY'
  114. AND sr.music_group_id_ = #{musicGroupId}
  115. AND sr.music_group_status_ != 'QUIT'
  116. </select>
  117. <!-- 查询订单详情 -->
  118. <select id="findApplyOrderGoods" resultMap="StudentPaymentOrderDetail">
  119. SELECT *
  120. FROM student_payment_order_detail
  121. WHERE payment_order_id_ = #{orderId}
  122. </select>
  123. <!-- 查询用户注册订单详情 -->
  124. <select id="findUserApplyOrder" resultMap="StudentPaymentOrderDetail">
  125. SELECT spod.*
  126. FROM student_payment_order spo
  127. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  128. WHERE spo.user_id_ = #{userId}
  129. AND spo.music_group_id_ = #{musicGroupId}
  130. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  131. AND spo.type_ = 'APPLY'
  132. </select>
  133. <resultMap id="musicalListDetailDtoMap" type="com.ym.mec.biz.dal.dto.MusicalListDetailDto">
  134. <result property="paymentOrderId" column="payment_order_id_"/>
  135. <result property="username" column="username_"/>
  136. <result property="userId" column="user_id_"/>
  137. <result property="musicGroupName" column="muaic_group_name_"/>
  138. <result property="accessoriesAmount" column="accessories_amount_"/>
  139. <result property="courseAmount" column="course_amount_"/>
  140. <result property="kitGroupPurchaseTypeEnum" column="kit_group_purchase_type_"/>
  141. <result property="musicalAmount" column="musical_amount_"/>
  142. <result property="orderAmount" column="order_amount_"/>
  143. <result property="organName" column="organ_name_"/>
  144. <result property="goodsNames" column="goods_names_"/>
  145. </resultMap>
  146. <select id="getMusicalListDetail" resultMap="musicalListDetailDtoMap">
  147. SELECT MAX(spo.id_) payment_order_id_, spo.user_id_
  148. FROM student_payment_order spo
  149. LEFT JOIN student_registration sr ON spo.user_id_ = sr.user_id_
  150. WHERE spo.music_group_id_ = #{musicGroupId}
  151. <if test="userId != null">
  152. AND spo.user_id_ = #{userId}
  153. </if>
  154. AND spo.status_ = 'SUCCESS'
  155. AND sr.music_group_id_ = #{musicGroupId}
  156. AND sr.music_group_status_ != 'QUIT'
  157. GROUP BY spo.user_id_
  158. </select>
  159. <select id="queryGoodsNames" resultType="java.util.Map">
  160. SELECT spod.payment_order_id_ 'key',GROUP_CONCAT(g.name_) 'value'
  161. FROM student_payment_order_detail spod
  162. LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
  163. WHERE spod.payment_order_id_ IN
  164. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  165. #{item}
  166. </foreach>
  167. GROUP BY spod.payment_order_id_
  168. </select>
  169. <select id="queryGoodsPrice" resultType="java.util.Map">
  170. SELECT spod.payment_order_id_ 'key' ,SUM(price_) 'value' FROM student_payment_order_detail spod
  171. WHERE FIND_IN_SET(spod.type_,#{types})
  172. AND spod.payment_order_id_ IN
  173. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  174. #{item}
  175. </foreach>
  176. GROUP BY spod.payment_order_id_
  177. </select>
  178. <select id="findApplyOrderMusical" resultMap="StudentPaymentOrderDetail">
  179. SELECT *
  180. FROM student_payment_order_detail
  181. WHERE payment_order_id_ = #{orderId}
  182. AND type_ = 'MUSICAL'
  183. LIMIT 1
  184. </select>
  185. <select id="getOrderDetail" resultMap="StudentPaymentOrderDetail">
  186. SELECT spod.*,
  187. g.id_ goods_id_,
  188. g.name_ goods_name_,
  189. g.group_purchase_price_,
  190. g.discount_price_,
  191. g.agree_cost_price_,
  192. g.type_ goods_type_,
  193. g.complement_goods_id_list_
  194. FROM student_payment_order_detail spod
  195. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  196. WHERE spod.payment_order_id_ = #{orderId}
  197. AND spod.goods_id_list_ IS NOT NULL
  198. </select>
  199. <select id="getOrderDetailType" resultType="java.lang.String">
  200. SELECT DISTINCT type_
  201. FROM student_payment_order_detail
  202. WHERE payment_order_id_ = #{orderId}
  203. </select>
  204. <select id="getStudentApplyDetail" resultMap="StudentPaymentOrderDetail">
  205. SELECT spod.*,
  206. g.id_ goods_id_,
  207. g.name_ goods_name_,
  208. g.group_purchase_price_,
  209. g.discount_price_,
  210. g.agree_cost_price_,
  211. g.type_ goods_type_
  212. FROM student_payment_order_detail spod
  213. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  214. LEFT JOIN student_payment_order spo on spod.payment_order_id_ = spo.id_
  215. WHERE spo.user_id_ = #{studentId}
  216. AND spo.music_group_id_ = #{musicGroupId}
  217. AND spo.status_ = 'SUCCESS'
  218. AND spo.type_ = 'APPLY'
  219. AND spod.type_ IN ('MUSICAL', 'ACCESSORIES', 'TEACHING', 'OTHER', 'COURSE')
  220. </select>
  221. <select id="queryPurchaseTypeMap" resultType="java.util.Map">
  222. SELECT payment_order_id_ 'key',kit_group_purchase_type_ 'value'
  223. FROM student_payment_order_detail
  224. WHERE payment_order_id_ IN
  225. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  226. #{item}
  227. </foreach>
  228. AND type_='MUSICAL'
  229. </select>
  230. <select id="getOrderGoodies" resultMap="StudentPaymentOrderDetail">
  231. SELECT spod.*,
  232. g.id_ goods_id_,
  233. g.name_ goods_name_,
  234. g.group_purchase_price_,
  235. g.discount_price_,
  236. g.agree_cost_price_,
  237. g.type_ goods_type_,
  238. g.complement_goods_id_list_
  239. FROM student_payment_order_detail spod
  240. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  241. WHERE spod.payment_order_id_ IN
  242. <foreach collection="orderIds" open="(" close=")" separator="," item="orderId">
  243. #{orderId}
  244. </foreach>
  245. AND spod.goods_id_list_ IS NOT NULL
  246. </select>
  247. <select id="getWithIds" resultMap="StudentPaymentOrderDetail">
  248. SELECT * FROM student_payment_order_detail WHERE payment_order_id_ IN
  249. <foreach collection="paymentOrderIds" item="paymentOrderId" open="(" close=")" separator=",">
  250. #{paymentOrderId}
  251. </foreach>
  252. </select>
  253. <select id="getOrderDetailByType" resultMap="StudentPaymentOrderDetail">
  254. SELECT * FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId} AND type_ IN
  255. <foreach collection="orderDetailTypes" item="orderDetailType" open="(" close=")" separator=",">
  256. #{orderDetailType}
  257. </foreach>
  258. </select>
  259. <select id="getWithUserAndOrderType" resultMap="StudentPaymentOrderDetail">
  260. SELECT spod.* FROM student_payment_order_detail spod
  261. LEFT JOIN student_payment_order spo ON spo.id_=spod.payment_order_id_
  262. WHERE spo.user_id_= #{userId}
  263. AND spod.type_ = #{orderType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  264. AND spo.status_='SUCCESS'
  265. </select>
  266. <select id="getOrderDetailByOrderId" resultMap="StudentPaymentOrderDetail">
  267. SELECT * FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId}
  268. </select>
  269. </mapper>