TenantPaymentOrderMapper.xml 8.4 KB

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