StudentPaymentOrderDetailMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. </resultMap>
  18. <!-- 根据主键查询一条记录 -->
  19. <select id="get" resultMap="StudentPaymentOrderDetail">
  20. SELECT * FROM student_payment_order_detail WHERE id_ = #{id}
  21. </select>
  22. <!-- 全查询 -->
  23. <select id="findAll" resultMap="StudentPaymentOrderDetail">
  24. SELECT *
  25. FROM student_payment_order_detail
  26. ORDER BY id_
  27. </select>
  28. <!-- 向数据库增加一条记录 -->
  29. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail" useGeneratedKeys="true"
  30. keyColumn="id" keyProperty="id">
  31. <!--
  32. <selectKey resultClass="int" keyProperty="id" >
  33. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  34. </selectKey>
  35. -->
  36. INSERT INTO student_payment_order_detail
  37. (id_,type_,goods_id_list_,price_,create_time_,update_time_,payment_order_id_,kit_group_purchase_type_)
  38. VALUES(#{id},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  39. #{goodsIdList},#{price},now(),now(),#{paymentOrderId},#{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  43. UPDATE student_payment_order_detail
  44. <set>
  45. <if test="price != null">
  46. price_ = #{price},
  47. </if>
  48. <if test="goodsIdList != null">
  49. goods_id_list_ = #{goodsIdList},
  50. </if>
  51. <if test="updateTime != null">
  52. update_time_ = NOW(),
  53. </if>
  54. <if test="paymentOrderId != null">
  55. payment_order_id_ = #{paymentOrderId},
  56. </if>
  57. <if test="kitGroupPurchaseType != null">
  58. kit_group_purchase_type_ = #{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  59. </if>
  60. <if test="type != null">
  61. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  62. </if>
  63. </set>
  64. WHERE id_ = #{id}
  65. </update>
  66. <!-- 根据主键删除一条记录 -->
  67. <delete id="delete">
  68. DELETE FROM student_payment_order_detail WHERE id_ = #{id}
  69. </delete>
  70. <!-- 分页查询 -->
  71. <select id="queryPage" resultMap="StudentPaymentOrderDetail" parameterType="map">
  72. SELECT * FROM student_payment_order_detail ORDER BY id_
  73. <include refid="global.limit"/>
  74. </select>
  75. <!-- 查询当前表的总记录数 -->
  76. <select id="queryCount" resultType="int">
  77. SELECT COUNT(*)
  78. FROM student_payment_order_detail
  79. </select>
  80. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
  81. INSERT INTO student_payment_order_detail
  82. (id_,type_,goods_id_list_,price_,create_time_,update_time_,payment_order_id_,kit_group_purchase_type_)
  83. VALUES
  84. <foreach collection="studentPaymentOrderDetailList" item="orderDetail" separator=",">
  85. (#{orderDetail.id},#{orderDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. #{orderDetail.goodsIdList},#{orderDetail.price},now(),now(),#{orderDetail.paymentOrderId},
  87. #{orderDetail.kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  88. </foreach>
  89. </insert>
  90. <!-- 查询注册订单详情 -->
  91. <select id="findApplyOrderSuccess" resultMap="StudentPaymentOrderDetail">
  92. SELECT spod.* FROM student_payment_order spo
  93. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  94. WHERE spo.music_group_id_ = #{musicGroupId}
  95. AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  96. AND spo.type_ = 'APPLY'
  97. </select>
  98. <!-- 查询订单详情 -->
  99. <select id="findApplyOrderGoods" resultMap="StudentPaymentOrderDetail">
  100. SELECT * FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId}
  101. </select>
  102. <!-- 查询用户注册订单详情 -->
  103. <select id="findUserApplyOrder" resultMap="StudentPaymentOrderDetail">
  104. SELECT spod.* FROM student_payment_order spo
  105. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  106. WHERE spo.user_id_ = #{userId}
  107. AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  108. AND spo.type_ = 'APPLY'
  109. </select>
  110. <resultMap id="musicalListDetailDtoMap" type="com.ym.mec.biz.dal.dto.musicalListDetailDto">
  111. <result property="paymentOrderId" column="payment_order_id_"/>
  112. <result property="username" column="username_"/>
  113. <result property="userId" column="user_id_"/>
  114. <result property="musicGroupName" column="muaic_group_name_"/>
  115. <result property="accessoriesAmount" column="accessories_amount_"/>
  116. <result property="courseAmount" column="course_amount_"/>
  117. <result property="kitGroupPurchaseTypeEnum" column="kit_group_purchase_type_"/>
  118. <result property="musicalAmount" column="musical_amount_"/>
  119. <result property="orderAmount" column="order_amount_"/>
  120. <result property="organName" column="organ_name_"/>
  121. <result property="goodsNames" column="goods_names_"/>
  122. </resultMap>
  123. <select id="getMusicalListDetail" resultMap="musicalListDetailDtoMap">
  124. SELECT MAX(spo.id_) payment_order_id_,spo.user_id_ FROM student_payment_order spo
  125. WHERE spo.music_group_id_ = #{musicGroupId}
  126. GROUP BY spo.user_id_
  127. </select>
  128. <select id="queryGoodsNames" resultType="java.util.Map">
  129. SELECT spod.payment_order_id_ 'key',GROUP_CONCAT(g.name_) 'value'
  130. FROM student_payment_order_detail spod
  131. LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
  132. WHERE spod.payment_order_id_ IN
  133. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  134. #{item}
  135. </foreach>
  136. GROUP BY spod.payment_order_id_
  137. </select>
  138. <select id="queryGoodsPrice" resultType="java.util.Map">
  139. SELECT spod.payment_order_id_ 'key' ,SUM(price_) 'value' FROM student_payment_order_detail spod
  140. WHERE spod.type_ = #{type} AND spod.payment_order_id_ IN
  141. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  142. #{item}
  143. </foreach>
  144. GROUP BY spod.payment_order_id_
  145. </select>
  146. <select id="findApplyOrderMusical" resultMap="StudentPaymentOrderDetail">
  147. SELECT * FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId} AND type_ = 'MUSICAL' LIMIT 1
  148. </select>
  149. </mapper>