SettlementDocumentaryFeesMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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="com.ydtech.modules.fnc.dao.SettlementDocumentaryFeesMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
  6. <id column="id" property="id" />
  7. <result column="total_orders" property="totalOrders"/>
  8. <result column="time_frame" property="timeFrame"/>
  9. <result column="total_amount" property="totalAmount"/>
  10. <result column="create_time" property="createTime"/>
  11. <result column="settlement_time" property="settlementTime"/>
  12. <result column="end_time" property="endTime"/>
  13. <result column="settlement_amount" property="settlementAmount"/>
  14. <result column="unsettled_amount" property="unsettledAmount"/>
  15. <result column="company_id" property="companyId"/>
  16. <result column="year" property="year"/>
  17. <result column="month" property="month"/>
  18. <result column="day" property="day"/>
  19. <result column="agree_ment_id" property="agreeMentId"/>
  20. <result column="invoice_id" property="invoiceId"/>
  21. <result column="is_not_car" property="isNotCar"/>
  22. <result column="partner_companies_id" property="partnerCompaniesId"/>
  23. <result column="invoicing_method" property="invoicingMethod"/>
  24. <result column="tax_points" property="taxPoints"/>
  25. <result column="expend_amount" property="expendAmount"/>
  26. <result column="parent_id" property="parentId"/>
  27. <result column="handling_fees_status" property="handlingFeesStatus"/>
  28. <result column="agreement_type" property="agreementType"/>
  29. <result column="settlement_status" property="settlementStatus"/>
  30. <result column="settlement_image_id" property="settlementImageId"/>
  31. <result column="task_id" property="taskId"/>
  32. </resultMap>
  33. <select id="querySettle" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
  34. select
  35. a.id as "id",
  36. a.total_orders as "totalOrders",
  37. a.time_frame as "timeFrame",
  38. a.total_amount as "totalAmount",
  39. a.create_time as "createTime",
  40. a.start_time as "startTime",
  41. a.end_time as "endTime",
  42. a.settlement_amount as "settlementAmount",
  43. a.agree_ment_id as "agreeMentId",
  44. a.partner_companies_id as "partnerCompaniesId",
  45. a.invoicing_method as "invoicingMethod",
  46. a.tax_points as "taxPoints",
  47. a.expend_amount as "expendAmount",
  48. a.parent_id as "parentId",
  49. a.handling_fees_status as "handlingFeesStatus",
  50. a.agreement_type as "agreementType",
  51. a.settlement_time as "settlementTime",
  52. a.settlement_image_id as "settlementImageId",
  53. a.task_id as "taskId",
  54. upf.url as "imageUrl",
  55. a.unsettled_amount as "unsettledAmount"
  56. from settlement_documentary_fees a
  57. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  58. <where>
  59. 1=1
  60. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  61. and a.partner_companies_id =#{partnerCompaniesId}
  62. </if>
  63. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  64. and a.handling_fees_status =#{handlingFeesStatus}
  65. </if>
  66. <if test="isNotCar !=null and isNotCar !=''">
  67. and a.is_not_car =#{isNotCar}
  68. </if>
  69. <if test="agreementType !=null and agreementType !=''">
  70. and a.agreement_type =#{agreementType}
  71. </if>
  72. <if test="parentId !=null and parentId !=''">
  73. and a.parent_id =#{parentId}
  74. </if>
  75. <if test="settlementStatus !=null and settlementStatus !=''">
  76. and a.settlement_status =#{settlementStatus}
  77. </if>
  78. </where>
  79. </select>
  80. <select id="getOtherSettldetail" resultType="java.util.HashMap">
  81. SELECT
  82. a.id as "id",
  83. a.create_time AS "invoicTime",
  84. a.invoice_id AS "invoicId",
  85. a.tax_points AS "taxPoints",
  86. a.partner_companies_id AS "partnerCompaniesId",
  87. a.agreement_type as "agreementType",
  88. IFNULL(settlement_amount ,0) "invoicCommissionFeevalue",
  89. a.invoicing_method as "invoicingMethod",
  90. a.task_id AS "taskId"
  91. FROM
  92. settlement_documentary_fees a
  93. left join (
  94. select a.parent_id as "parentId" ,sum(a.settlement_amount) as "settlementAmount" from
  95. settlement_documentary_fees a
  96. where a.settlement_status ='2' and a.parent_id is not null
  97. GROUP BY a.parent_id
  98. ) b on a.id=b.parentId
  99. <where>
  100. 1=1
  101. <choose>
  102. <when test="settlementStatus != null and settlementStatus!=''">
  103. and a.settlement_status =#{settlementStatus}
  104. </when>
  105. <otherwise>
  106. and a.settlement_status ='1'
  107. </otherwise>
  108. </choose>
  109. <if test="isSettlement !=null and isSettlement !=''">
  110. and a.settlement_amount - COALESCE(b.settlementAmount, 0) &lt;&gt; 0
  111. </if>
  112. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  113. and a.partner_companies_id =#{partnerCompaniesId}
  114. </if>
  115. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  116. and a.handling_fees_status =#{handlingFeesStatus}
  117. </if>
  118. <if test="isNotCar !=null and isNotCar !=''">
  119. and a.is_not_car =#{isNotCar}
  120. </if>
  121. <if test="invoiceIds !=null and invoiceIds !='' and invoiceIds.length>0">
  122. and a.id IN
  123. <foreach item="item" index="index" collection="invoiceIds" open="(" separator="," close=")">
  124. #{item}
  125. </foreach>
  126. </if>
  127. </where>
  128. </select>
  129. <update id="batchByInvoice" parameterType="java.util.HashMap">
  130. update settlement_documentary_fees
  131. <set>
  132. settlement_status = '2',
  133. settlement_time = NOW(),
  134. <if test="settlementAmount !=null and settlementAmount !=''">
  135. settlement_amount =#{settlementAmount}
  136. </if>
  137. </set>
  138. <where>
  139. <if test="ids !=null and ids!='' and ids.length>0">
  140. id in
  141. <foreach collection="ids" item="item" open="(" separator="," close=")">
  142. #{item}
  143. </foreach>
  144. </if>
  145. </where>
  146. </update>
  147. <select id="getInvoicIds" resultType="java.util.HashMap">
  148. SELECT
  149. a.id as "id",
  150. a.partner_companies_id AS "partnerCompaniesId"
  151. FROM settlement_documentary_fees a
  152. <where>
  153. a.settlement_status = '1'
  154. <if test="isNotCar !=null and isNotCar !=''">
  155. and a.is_not_car =#{isNotCar}
  156. </if>
  157. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  158. a.handling_fees_status=#{handlingFeesStatus}
  159. </if>
  160. </where>
  161. </select>
  162. <select id="getByParentSettlementAmount" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
  163. SELECT
  164. sum(a.settlement_amount) as "totalAmount"
  165. FROM settlement_documentary_fees a
  166. <where>
  167. a.settlement_status = '2'
  168. <if test="id !=null and id !=''">
  169. and a.parent_id =#{id}
  170. </if>
  171. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  172. and a.handling_fees_status =#{handlingFeesStatus}
  173. </if>
  174. </where>
  175. </select>
  176. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
  177. select
  178. a.id as "id",
  179. a.total_orders as "totalOrders",
  180. a.time_frame as "timeFrame",
  181. a.total_amount as "totalAmount",
  182. a.create_time as "createTime",
  183. a.start_time as "startTime",
  184. a.end_time as "endTime",
  185. a.settlement_amount as "settlementAmount",
  186. a.agree_ment_id as "agreeMentId",
  187. a.partner_companies_id as "partnerCompaniesId",
  188. a.invoicing_method as "invoicingMethod",
  189. a.tax_points as "taxPoints",
  190. a.expend_amount as "expendAmount",
  191. a.parent_id as "parentId",
  192. a.handling_fees_status as "handlingFeesStatus",
  193. a.agreement_type as "agreementType",
  194. a.settlement_time as "settlementTime",
  195. a.settlement_image_id as "settlementImageId",
  196. a.task_id as "taskId",
  197. upf.url as "imageUrl",
  198. a.unsettled_amount as "unsettledAmount"
  199. from settlement_documentary_fees a
  200. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  201. <where>
  202. 1=1
  203. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  204. and a.partner_companies_id =#{partnerCompaniesId}
  205. </if>
  206. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  207. and a.handling_fees_status =#{handlingFeesStatus}
  208. </if>
  209. <if test="isNotCar !=null and isNotCar !=''">
  210. and a.is_not_car =#{isNotCar}
  211. </if>
  212. <if test="agreementType !=null and agreementType !=''">
  213. and a.agreement_type =#{agreementType}
  214. </if>
  215. <if test="parentId !=null and parentId !=''">
  216. and a.parent_id =#{parentId}
  217. </if>
  218. <if test="settlementStatus !=null and settlementStatus !=''">
  219. and a.settlement_status =#{settlementStatus}
  220. </if>
  221. </where>
  222. </select>
  223. </mapper>