StudentApplyRefundsMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.StudentApplyRefundsDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentApplyRefunds" id="StudentApplyRefunds">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="order_no_" property="orderNo"/>
  12. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="expect_amount_" property="expectAmount"/>
  14. <result column="actual_amount_" property="actualAmount"/>
  15. <result column="create_time_" property="createTime"/>
  16. <result column="update_time_" property="updateTime"/>
  17. <result column="orig_payment_order_id_" property="origPaymentOrderId"/>
  18. <result column="remark_" property="remark"/>
  19. </resultMap>
  20. <resultMap type="com.ym.mec.biz.dal.entity.StudentApplyRefunds" extends="StudentApplyRefunds" id="StudentApplyRefundsListDTO">
  21. <result column="spo.expect_amount_" property="studentPaymentOrder.expectAmount"/>
  22. <result column="spo.actual_amount_" property="studentPaymentOrder.actualAmount"/>
  23. <result column="username_" property="user.username"/>
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="StudentApplyRefunds">
  27. SELECT * FROM student_apply_refunds WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="StudentApplyRefunds">
  31. SELECT * FROM student_apply_refunds ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentApplyRefunds" useGeneratedKeys="true"
  35. keyColumn="id" keyProperty="id">
  36. <!--
  37. <selectKey resultClass="int" keyProperty="id" >
  38. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  39. </selectKey>
  40. -->
  41. INSERT INTO student_apply_refunds
  42. (id_,user_id_,order_no_,status_,expect_amount_,actual_amount_,create_time_,update_time_,orig_payment_order_id_,remark_)
  43. VALUES(#{id},#{userId},#{orderNo},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{expectAmount},#{actualAmount},now(),now(),#{origPaymentOrderId},#{remark})
  44. </insert>
  45. <!-- 根据主键查询一条记录 -->
  46. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentApplyRefunds">
  47. UPDATE student_apply_refunds
  48. <set>
  49. <if test="status != null">
  50. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  51. </if>
  52. <if test="userId != null">
  53. user_id_ = #{userId},
  54. </if>
  55. <if test="orderNo != null">
  56. order_no_ = #{orderNo},
  57. </if>
  58. <if test="expectAmount != null">
  59. expect_amount_ = #{expectAmount},
  60. </if>
  61. <if test="updateTime != null">
  62. update_time_ = NOW(),
  63. </if>
  64. <if test="origPaymentOrderId != null">
  65. orig_payment_order_id_ = #{origPaymentOrderId},
  66. </if>
  67. <if test="actualAmount != null">
  68. actual_amount_ = #{actualAmount},
  69. </if>
  70. <if test="remark != null">
  71. remark_ = #{remark},
  72. </if>
  73. </set>
  74. WHERE id_ = #{id}
  75. </update>
  76. <!-- 根据主键删除一条记录 -->
  77. <delete id="delete">
  78. DELETE FROM student_apply_refunds WHERE id_ = #{id}
  79. </delete>
  80. <!-- 分页查询 -->
  81. <select id="queryPage" resultMap="StudentApplyRefundsListDTO" parameterType="map">
  82. SELECT sar.*,spo.expect_amount_,spo.actual_amount_,u.username_ FROM student_apply_refunds sar left join student_payment_order spo on sar.orig_payment_order_id_ = spo.id_ left join sys_user u on sar.user_id_ = u.id_
  83. where 1=1
  84. <if test="startTime != null">
  85. and sar.create_time_ &gt;= #{startTime}
  86. </if>
  87. <if test="endTime != null">
  88. and sar.create_time_ &lt;= #{endTime}
  89. </if>
  90. <if test="status!=null and status!=''">
  91. and sar.status_=#{status}
  92. </if>
  93. <if test="organId!=null and organId!=''">
  94. and u.organ_id_=#{organId}
  95. </if>
  96. ORDER BY sar.id_ <include refid="global.limit"/>
  97. </select>
  98. <!-- 查询当前表的总记录数 -->
  99. <select id="queryCount" resultType="int" parameterType="map">
  100. SELECT count(1) FROM student_apply_refunds sar left join student_payment_order spo on sar.orig_payment_order_id_ = spo.id_ left join sys_user u on sar.user_id_ = u.id_
  101. where 1=1
  102. <if test="startTime != null">
  103. and sar.create_time_ &gt;= #{startTime}
  104. </if>
  105. <if test="endTime != null">
  106. and sar.create_time_ &lt;= #{endTime}
  107. </if>
  108. <if test="status!=null and status!=''">
  109. and sar.status_=#{status}
  110. </if>
  111. <if test="organId!=null and organId!=''">
  112. and u.organ_id_=#{organId}
  113. </if>
  114. </select>
  115. <select id="checkIsApplyRefund" resultType="java.util.Map">
  116. SELECT
  117. DISTINCT spo.music_group_id_ AS 'key',
  118. sar.id_ IS NOT NULL AS 'value'
  119. FROM
  120. student_payment_order spo
  121. LEFT JOIN student_apply_refunds sar ON sar.orig_payment_order_id_ = spo.id_
  122. WHERE
  123. spo.status_ = 'SUCCESS'
  124. AND spo.user_id_=#{userId}
  125. AND spo.music_group_id_ IN
  126. <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
  127. #{musicGroupId}
  128. </foreach>
  129. </select>
  130. </mapper>