StudentPaymentOrderMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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.StudentPaymentOrderDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" id="StudentPaymentOrder">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  12. <result column="expect_amount_" property="expectAmount"/>
  13. <result column="actual_amount_" property="actualAmount"/>
  14. <result column="trans_no_" property="transNo"/>
  15. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  16. <result column="memo_" property="memo"/>
  17. <result column="create_time_" property="createTime"/>
  18. <result column="update_time_" property="updateTime"/>
  19. <result column="payment_channel_" property="paymentChannel"/>
  20. <result column="payment_business_channel_" property="paymentBusinessChannel"/>
  21. <result column="payment_account_no_" property="paymentAccountNo"/>
  22. <result column="order_no_" property="orderNo"/>
  23. <result column="music_group_id_" property="musicGroupId"/>
  24. <result column="class_group_id_" property="classGroupId"/>
  25. <result column="pay_time_" property="payTime"/>
  26. <result column="version_" property="version"/>
  27. </resultMap>
  28. <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" extends="StudentPaymentOrder"
  29. id="PaymentOrderAndStudentInfo">
  30. <result column="username_" property="user.username"/>
  31. </resultMap>
  32. <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
  33. <result column="id_" property="id"/>
  34. <result column="goods_category_id_" property="goodsCategoryId"/>
  35. <result column="sn_" property="sn"/>
  36. <result column="name_" property="name"/>
  37. <result column="brand_" property="brand"/>
  38. <result column="specification_" property="specification"/>
  39. <result column="image_" property="image"/>
  40. <result column="stock_count_" property="stockCount"/>
  41. <result column="sell_count_" property="sellCount"/>
  42. <result column="market_price_" property="marketPrice"/>
  43. <result column="discount_price_" property="discountPrice"/>
  44. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  45. <result column="brief_" property="brief"/>
  46. <result column="desc_" property="desc"/>
  47. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  48. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  49. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  50. <result column="memo_" property="memo"/>
  51. <result column="publish_time_" property="publishTime"/>
  52. <result column="create_time_" property="createTime"/>
  53. <result column="update_time_" property="updateTime"/>
  54. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  55. </resultMap>
  56. <!-- 根据主键查询一条记录 -->
  57. <select id="get" resultMap="StudentPaymentOrder">
  58. SELECT * FROM student_payment_order WHERE id_ = #{id}
  59. </select>
  60. <!-- 全查询 -->
  61. <select id="findAll" resultMap="StudentPaymentOrder">
  62. SELECT *
  63. FROM student_payment_order
  64. ORDER BY id_
  65. </select>
  66. <!-- 向数据库增加一条记录 -->
  67. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
  68. keyColumn="id" keyProperty="id">
  69. INSERT INTO student_payment_order
  70. (id_,user_id_,type_,expect_amount_,actual_amount_,trans_no_,status_,memo_,create_time_,update_time_,payment_channel_,payment_business_channel_,payment_account_no_,order_no_,music_group_id_,class_group_id_)
  71. VALUES(#{id},#{userId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{expectAmount},#{actualAmount},#{transNo},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},now(),now(),#{paymentChannel},#{paymentBusinessChannel},#{paymentAccountNo},#{orderNo},#{musicGroupId},#{classGroupId})
  72. </insert>
  73. <!-- 根据主键查询一条记录 -->
  74. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  75. UPDATE student_payment_order
  76. <set>
  77. <if test="status != null">
  78. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  79. </if>
  80. <if test="orderNo != null">
  81. order_no_ = #{orderNo},
  82. </if>
  83. <if test="classGroupId != null">
  84. class_group_id_ = #{classGroupId},
  85. </if>
  86. <if test="expectAmount != null">
  87. expect_amount_ = #{expectAmount},
  88. </if>
  89. <if test="memo != null">
  90. memo_ = #{memo},
  91. </if>
  92. <if test="paymentChannel != null">
  93. payment_channel_ = #{paymentChannel},
  94. </if>
  95. <if test="userId != null">
  96. user_id_ = #{userId},
  97. </if>
  98. <if test="paymentAccountNo != null">
  99. payment_account_no_ = #{paymentAccountNo},
  100. </if>
  101. <if test="updateTime != null">
  102. update_time_ = NOW(),
  103. </if>
  104. <if test="paymentBusinessChannel != null">
  105. payment_business_channel_ = #{paymentBusinessChannel},
  106. </if>
  107. <if test="transNo != null">
  108. trans_no_ = #{transNo},
  109. </if>
  110. <if test="actualAmount != null">
  111. actual_amount_ = #{actualAmount},
  112. </if>
  113. <if test="type != null">
  114. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  115. </if>
  116. <if test="musicGroupId != null">
  117. music_group_id_ = #{musicGroupId},
  118. </if>
  119. <if test="payTime != null">
  120. pay_time_ = #{payTime},
  121. </if>
  122. <if test="version != null">
  123. version_ = version_+1,
  124. </if>
  125. </set>
  126. WHERE id_ = #{id} AND version_ = #{version}
  127. </update>
  128. <!-- 根据主键删除一条记录 -->
  129. <delete id="delete">
  130. DELETE FROM student_payment_order WHERE id_ = #{id}
  131. </delete>
  132. <!-- 分页查询 -->
  133. <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  134. SELECT spo.*,u.username_ FROM student_payment_order spo
  135. left join sys_user u on spo.user_id_ = u.id_
  136. <include refid="queryPaymentOrder"/>
  137. ORDER BY spo.id_
  138. <include refid="global.limit"/>
  139. </select>
  140. <!-- 查询当前表的总记录数 -->
  141. <select id="queryCount" resultType="int" parameterType="map">
  142. SELECT COUNT(spo.id_) FROM student_payment_order spo
  143. <include refid="queryPaymentOrder"/>
  144. </select>
  145. <sql id="queryPaymentOrder">
  146. <where>
  147. <if test="orderStartDate != null">
  148. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  149. </if>
  150. <if test="orderEndDate != null">
  151. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  152. </if>
  153. <if test="paymentType != null">
  154. AND spo.type_ = #{paymentType}
  155. </if>
  156. <if test="remark != null">
  157. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  158. </if>
  159. <if test="studentId != null">
  160. AND spo.user_id_ = #{studentId}
  161. </if>
  162. <if test="paymentStatus != null">
  163. AND spo.status_ = #{paymentStatus}
  164. </if>
  165. </where>
  166. </sql>
  167. <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
  168. select g.* from goods g where g.id_ in (SELECT spod.goods_id_list_ FROM student_payment_order spo left join
  169. student_payment_order_detail spod on spo.id_ = spod.payment_order_id_ where spo.music_group_id_ =
  170. #{musicGroupId} and spo.type_ = 'APPLY' and spod.type_ =
  171. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  172. </select>
  173. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  174. SELECT
  175. spo.*
  176. FROM
  177. student_vip_group_payment svgp
  178. LEFT JOIN student_payment_order spo ON svgp.student_payment_order_id_=spo.id_
  179. WHERE svgp.user_id_=#{userId}
  180. AND svgp.vip_group_id_=#{vipGroupId}
  181. AND spo.status_=#{status}
  182. and spo.type_ = 'SMALL_CLASS_TO_BUY'
  183. </select>
  184. <!-- 查询报名订单 -->
  185. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  186. SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND user_id_=#{userId} AND type_ =
  187. 'APPLY' AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  188. </select>
  189. <!-- 根据订单号查询订单 -->
  190. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  191. SELECT * FROM student_payment_order WHERE order_no_ = #{orderNo}
  192. </select>
  193. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  194. SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND type_ =
  195. #{type} AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  196. </select>
  197. <!-- 查找支付成功和支付中订单 -->
  198. <select id="findPayOrderNum" resultType="int">
  199. <![CDATA[
  200. SELECT COUNT(*)
  201. FROM student_payment_order
  202. WHERE status_ <= 2
  203. ]]>
  204. </select>
  205. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  206. <result column="goods_id_" property="goodsId"/>
  207. <collection property="goodsName" ofType="string">
  208. <result column="goods_name_"/>
  209. </collection>
  210. </resultMap>
  211. <select id="findGoodsIds" resultMap="userGoodsDto">
  212. SELECT g.id_ goods_id_,g.name_ goods_name_ FROM student_payment_order spo
  213. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  214. LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
  215. WHERE spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.goods_id_list_ IS NOT NULL
  216. AND spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId}
  217. </select>
  218. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  219. SELECT * FROM student_payment_order
  220. WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
  221. #{paymentChannel}
  222. </select>
  223. <!-- 查询支付中超时订单 -->
  224. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  225. SELECT * FROM student_payment_order WHERE order_no_ IN
  226. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  227. #{orderNo}
  228. </foreach>
  229. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  230. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  231. </select>
  232. </mapper>