TenantPaymentOrderMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. <mapper namespace="com.ym.mec.biz.dal.dao.TenantPaymentOrderDao">
  5. <resultMap type="com.ym.mec.biz.dal.entity.TenantPaymentOrder"
  6. id="TenantPaymentOrder">
  7. <result column="id_" property="id" />
  8. <result column="activities_id_" property="activitiesId" />
  9. <result column="user_id_" property="userId" />
  10. <result column="real_name_" property="user.username" />
  11. <result column="phone_" property="user.phone" />
  12. <result column="organ_id_" property="organId" />
  13. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  14. <result column="trans_minutes_" property="transMinutes" />
  15. <result column="give_minutes_" property="giveMinutes" />
  16. <result column="expect_amount_" property="expectAmount" />
  17. <result column="actual_amount_" property="actualAmount" />
  18. <result column="balance_payment_amount_" property="balancePaymentAmount" />
  19. <result column="com_amount_" property="comAmount" />
  20. <result column="per_amount_" property="perAmount" />
  21. <result column="remit_fee_" property="remitFee" />
  22. <result column="trans_no_" property="transNo" />
  23. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  24. <result column="memo_" property="memo" />
  25. <result column="payment_channel_" property="paymentChannel" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  26. <result column="payment_business_channel_" property="paymentBusinessChannel" />
  27. <result column="mer_nos_" property="merNos" />
  28. <result column="order_no_" property="orderNo" />
  29. <result column="pay_time_" property="payTime" />
  30. <result column="version_" property="version" />
  31. <result column="create_time_" property="createTime" />
  32. <result column="update_time_" property="updateTime" />
  33. </resultMap>
  34. <sql id="queryPaymentOrder">
  35. <where>
  36. <if test="organId != null">
  37. AND FIND_IN_SET(tpo.organ_id_,#{organId})
  38. </if>
  39. <if test="orderStartDate != null">
  40. AND DATE_FORMAT(tpo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  41. </if>
  42. <if test="orderEndDate != null">
  43. AND DATE_FORMAT(tpo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  44. </if>
  45. <if test="tenantPaymentType != null">
  46. AND tpo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  47. </if>
  48. <if test="userId != null">
  49. AND tpo.user_id_ = #{userId}
  50. </if>
  51. <if test="phone != null and phone != ''">
  52. AND su.phone_ = #{phone}
  53. </if>
  54. <if test="paymentChannel != null">
  55. AND tpo.payment_channel_ NOT IN (#{paymentChannel})
  56. </if>
  57. <if test="status != null">
  58. AND tpo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  59. </if>
  60. </where>
  61. </sql>
  62. <!-- 根据主键查询一条记录 -->
  63. <select id="get" resultMap="TenantPaymentOrder">
  64. SELECT * FROM tenant_payment_order WHERE id_ = #{id}
  65. </select>
  66. <!-- 全查询 -->
  67. <select id="findAll" resultMap="TenantPaymentOrder">
  68. SELECT * FROM tenant_payment_order ORDER BY id_
  69. </select>
  70. <!-- 向数据库增加一条记录 -->
  71. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.TenantPaymentOrder"
  72. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  73. <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
  74. AS ID FROM DUAL </selectKey> -->
  75. INSERT INTO tenant_payment_order
  76. (id_,activities_id_,user_id_,organ_id_,type_,trans_minutes_,give_minutes_,expect_amount_,actual_amount_,balance_payment_amount_,com_amount_,per_amount_,remit_fee_,trans_no_,status_,memo_,payment_channel_,payment_business_channel_,mer_nos_,order_no_,pay_time_,version_,create_time_,update_time_)
  77. VALUES(#{id},#{activitiesId},#{userId},#{organId},#{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{transMinutes},#{giveMinutes},#{expectAmount},#{actualAmount},#{balancePaymentAmount},#{comAmount},#{perAmount},#{remitFee},#{transNo},#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},#{paymentChannel},#{paymentBusinessChannel},#{merNos},#{orderNo},#{payTime},#{version},#{createTime},#{updateTime})
  78. </insert>
  79. <!-- 根据主键查询一条记录 -->
  80. <update id="update" parameterType="com.ym.mec.biz.dal.entity.TenantPaymentOrder">
  81. UPDATE tenant_payment_order
  82. <set>
  83. <if test="status != null">
  84. status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  85. </if>
  86. <if test="transMinutes != null">
  87. trans_minutes_ = #{transMinutes},
  88. </if>
  89. <if test="giveMinutes != null">
  90. give_minutes_ = #{giveMinutes},
  91. </if>
  92. <if test="organId != null">
  93. organ_id_ = #{organId},
  94. </if>
  95. <if test="activitiesId != null">
  96. activities_id_ = #{activitiesId},
  97. </if>
  98. <if test="comAmount != null">
  99. com_amount_ = #{comAmount},
  100. </if>
  101. <if test="orderNo != null">
  102. order_no_ = #{orderNo},
  103. </if>
  104. <if test="id != null">
  105. id_ = #{id},
  106. </if>
  107. <if test="perAmount != null">
  108. per_amount_ = #{perAmount},
  109. </if>
  110. <if test="expectAmount != null">
  111. expect_amount_ = #{expectAmount},
  112. </if>
  113. <if test="balancePaymentAmount != null">
  114. balance_payment_amount_ = #{balancePaymentAmount},
  115. </if>
  116. <if test="version != null">
  117. version_ = #{version},
  118. </if>
  119. <if test="memo != null">
  120. memo_ = #{memo},
  121. </if>
  122. <if test="paymentChannel != null">
  123. payment_channel_ = #{paymentChannel},
  124. </if>
  125. <if test="remitFee != null">
  126. remit_fee_ = #{remitFee},
  127. </if>
  128. <if test="createTime != null">
  129. create_time_ = #{createTime},
  130. </if>
  131. <if test="userId != null">
  132. user_id_ = #{userId},
  133. </if>
  134. <if test="paymentBusinessChannel != null">
  135. payment_business_channel_ = #{paymentBusinessChannel},
  136. </if>
  137. <if test="updateTime != null">
  138. update_time_ = #{updateTime},
  139. </if>
  140. <if test="transNo != null">
  141. trans_no_ = #{transNo},
  142. </if>
  143. <if test="actualAmount != null">
  144. actual_amount_ = #{actualAmount},
  145. </if>
  146. <if test="type != null">
  147. type_ = #{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  148. </if>
  149. <if test="merNos != null">
  150. mer_nos_ = #{merNos},
  151. </if>
  152. <if test="payTime != null">
  153. pay_time_ = #{payTime},
  154. </if>
  155. </set>
  156. WHERE id_ = #{id}
  157. </update>
  158. <!-- 根据主键删除一条记录 -->
  159. <delete id="delete">
  160. DELETE FROM tenant_payment_order WHERE id_ = #{id}
  161. </delete>
  162. <!-- 分页查询 -->
  163. <select id="queryPage" resultMap="TenantPaymentOrder"
  164. parameterType="map">
  165. SELECT tpo.*,su.real_name_,su.phone_ FROM tenant_payment_order tpo
  166. LEFT JOIN sys_user su ON su.id_ = tpo.user_id_
  167. <include refid="queryPaymentOrder"/>
  168. ORDER BY tpo.id_ desc
  169. <include refid="global.limit" />
  170. </select>
  171. <!-- 查询当前表的总记录数 -->
  172. <select id="queryCount" resultType="int">
  173. SELECT COUNT(tpo.id_) FROM tenant_payment_order tpo
  174. LEFT JOIN sys_user su ON su.id_ = tpo.user_id_
  175. <include refid="queryPaymentOrder"/>
  176. </select>
  177. <select id="queryByUserId" resultMap="TenantPaymentOrder">
  178. SELECT * FROM tenant_payment_order where user_id_ = #{userId} ORDER BY id_
  179. </select>
  180. <select id="queryByUserIdAndActivitiesId" resultMap="TenantPaymentOrder" parameterType="map">
  181. SELECT * FROM tenant_payment_order where user_id_ = #{userId} and activities_id_ = #{activitiesId} ORDER BY id_
  182. </select>
  183. <!-- 根据订单号查询订单 -->
  184. <select id="findOrderByOrderNo" resultMap="TenantPaymentOrder">
  185. SELECT * FROM tenant_payment_order WHERE order_no_ = #{orderNo}
  186. </select>
  187. <select id="findOrdersByStatus" resultMap="TenantPaymentOrder">
  188. SELECT * FROM tenant_payment_order
  189. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  190. AND payment_channel_ = #{paymentChannel}
  191. LIMIT 100
  192. </select>
  193. <select id="getOrderMoneyAmount" resultMap="TenantPaymentOrder">
  194. SELECT SUM(expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_ FROM tenant_payment_order tpo
  195. LEFT JOIN sys_user su ON su.id_ = tpo.user_id_
  196. <include refid="queryPaymentOrder"/>
  197. </select>
  198. </mapper>