BizPaymentMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. <mapper namespace="cn.ezhizao.project.business.payment.mapper.BizPaymentMapper">
  4. <!-- 基础的返回map 多表复杂的 自行组合 -->
  5. <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.payment.domain.BizPayment"/>
  6. <!--根据主表id,删除 为的是表单保存时,明细统一物理删除后,再统一插入-->
  7. <delete id="physicallyDelete">
  8. DELETE FROM
  9. biz_payment
  10. WHERE id > 0
  11. <if test="id != null">
  12. AND id = #{id}
  13. </if>
  14. <if test="paymentId != null">
  15. AND payment_id = #{paymentId}
  16. </if>
  17. </delete>
  18. <!--带条件的List查询-->
  19. <select id="getList" resultMap="BaseResultMap">
  20. <include refid="getListSql"/>
  21. order by id desc
  22. </select>
  23. <select id="getByIds" resultMap="BaseResultMap">
  24. SELECT * FROM biz_payment
  25. WHERE id IN <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
  26. #{id}
  27. </foreach>
  28. </select>
  29. <update id="removePaymentDetail">
  30. UPDATE biz_payment_detail set deleted = 1 FROM biz_payment_detail WHERE payment_id IN
  31. <foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
  32. #{id}
  33. </foreach>
  34. </update>
  35. <!--带条件的List查询 数据总条数-->
  36. <select id="getTotal" resultType="java.lang.Integer">
  37. SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
  38. </select>
  39. <sql id="getListSql">
  40. SELECT t1.id, t1.flow_no, t1.form_date, t1.subsidiary_id, t1.subsidiary, t1.subsidiary_name,
  41. t1.contract_id,
  42. t1.verify_date,
  43. t1.verify_comment,
  44. t1.subsidiary_bank_account
  45. , t1.subsidiary_bank_name, t1.company_id, case when b.id is null then t1.company_name else b.name end as
  46. company_name, t1.amount, t1.payment_cause_id, t1.payment_status
  47. , t1.payment_subject_id, t1.verify_status, t1.accept_account, t1.accept_account_type_id, t1.accept_account_no
  48. , t1.account_bank, t1.applier_id, t1.remark, t1.actually_date, t1.service_company_name
  49. , t1.create_time, t1.creator_id, t1.update_time, t1.updater_id, t1.deleted, t1.version
  50. , (select sum(payment_amount) from biz_payment_detail pd where pd.payment_id = t1.id and pd.deleted = 0)
  51. sum_amount
  52. , (select sum(deal_price) from biz_payment_detail pd where pd.payment_id = t1.id and pd.deleted = 0)
  53. sum_contract_amount
  54. , t2.name as payment_cause
  55. , t3.name as payment_subject
  56. , t5.nick_name as applier_name
  57. , t4.contract_no as form_no
  58. FROM biz_payment t1
  59. left join biz_company b on b.id = t1.company_id
  60. left join biz_payment_type t2 on t2.id = t1.payment_cause_id
  61. left join biz_payment_subject t3 on t3.id = t1.payment_subject_id
  62. left join biz_archive_input t4 on t4.id = t1.contract_id
  63. left join sys_user t5 on t5.user_id = t1.applier_id
  64. WHERE t1.deleted = 0
  65. <if test="id != null">
  66. AND t1.id = #{id}
  67. </if>
  68. <if test="tenantId != null">
  69. AND t1.tenant_id = #{tenantId}
  70. </if>
  71. <if test="contractId != null">
  72. AND t1.contract_id = #{contractId}
  73. </if>
  74. <if test="flowNo != null and flowNo != ''">
  75. AND t1.flow_no = #{flowNo}
  76. </if>
  77. <if test="formDate != null and formDate != ''">
  78. AND DATE_FORMAT(t1.form_date,'%Y-%m-%d') = #{formDate}
  79. </if>
  80. <if test="startDate != null and endDate != null">
  81. AND (
  82. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &gt;= #{startDate}
  83. AND
  84. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &lt;= #{endDate}
  85. )
  86. </if>
  87. <if test="verifyStartDate != null and verifyEndDate != null">
  88. AND exists (
  89. select 1 from work_flow_content where master_id = t1.id
  90. and master_table_name = 'biz_payment'
  91. and (
  92. DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= #{verifyStartDate}
  93. AND
  94. DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{verifyEndDate}
  95. ))
  96. </if>
  97. <if test="subsidiaryId != null">
  98. AND t1.subsidiary_id = #{subsidiaryId}
  99. </if>
  100. <if test="subsidiary != null and subsidiary != ''">
  101. AND t1.subsidiary = #{subsidiary}
  102. </if>
  103. <if test="subsidiaryName != null and subsidiaryName != ''">
  104. AND t1.subsidiary_name = #{subsidiaryName}
  105. </if>
  106. <if test="subsidiaryBankAccount != null and subsidiaryBankAccount != ''">
  107. AND t1.subsidiary_bank_account = #{subsidiaryBankAccount}
  108. </if>
  109. <if test="subsidiaryBankName != null and subsidiaryBankName != ''">
  110. AND t1.subsidiary_bank_name = #{subsidiaryBankName}
  111. </if>
  112. <if test="companyId != null">
  113. AND t1.company_id = #{companyId}
  114. </if>
  115. <if test="companyName != null and companyName != ''">
  116. AND t1.company_name = #{companyName}
  117. </if>
  118. <if test="amount != null">
  119. AND t1.amount = #{amount}
  120. </if>
  121. <if test="paymentCauseId != null">
  122. AND t1.payment_cause_id = #{paymentCauseId}
  123. </if>
  124. <if test="paymentSubjectId != null">
  125. AND t1.payment_subject_id = #{paymentSubjectId}
  126. </if>
  127. <if test="paymentStatus != null">
  128. AND t1.payment_status = #{paymentStatus}
  129. </if>
  130. <if test="verifyStatus != null">
  131. AND t1.verify_status = #{verifyStatus}
  132. </if>
  133. <if test="acceptAccount != null and acceptAccount != ''">
  134. AND t1.accept_account = #{acceptAccount}
  135. </if>
  136. <if test="applierId != null">
  137. AND t1.applier_id = #{applierId}
  138. </if>
  139. <if test="acceptAccountTypeId != null">
  140. AND t1.accept_account_type_id = #{acceptAccountTypeId}
  141. </if>
  142. <if test="acceptAccountNo != null">
  143. AND t1.accept_account_no = #{acceptAccountNo}
  144. </if>
  145. <if test="accountBank != null and accountBank != ''">
  146. AND t1.account_bank = #{accountBank}
  147. </if>
  148. <if test="remark != null and remark != ''">
  149. AND t1.remark = #{remark}
  150. </if>
  151. <if test="createTime != null">
  152. AND t1.create_time = #{createTime}
  153. </if>
  154. <if test="keyword != null">
  155. AND (t1.company_name like concat('%', #{keyword},'%') or b.name like concat('%', #{keyword},'%'))
  156. </if>
  157. <if test="creatorId != null">
  158. AND t1.creator_id = #{creatorId}
  159. </if>
  160. <if test="updateTime != null">
  161. AND t1.update_time = #{updateTime}
  162. </if>
  163. <if test="updaterId != null">
  164. AND t1.updater_id = #{updaterId}
  165. </if>
  166. <if test="deleted != null">
  167. AND t1.deleted = #{deleted}
  168. </if>
  169. <if test="version != null">
  170. AND t1.version = #{version}
  171. </if>
  172. </sql>
  173. </mapper>