StudentPaymentOrderDetailMapper.xml 15 KB

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