FeeDetailServiceDaoImplMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="feeDetailServiceDaoImpl">
  5. <!-- 保存费用明细信息 add by wuxw 2018-07-03 -->
  6. <insert id="saveBusinessFeeDetailInfo" parameterType="Map">
  7. insert into
  8. business_pay_fee_detail(
  9. operate,prime_rate,detail_id,
  10. receivable_amount,cycles,remark,
  11. received_amount,community_id,b_id,fee_id,state,start_time,end_time,payable_amount
  12. <if test="createTime != null">
  13. ,create_time
  14. </if>
  15. ) values (
  16. #{operate},#{primeRate},#{detailId},#{receivableAmount},
  17. #{cycles},#{remark},#{receivedAmount},#{communityId},#{bId},#{feeId},#{state},#{startTime},#{endTime},#{payableAmount}
  18. <if test="createTime != null">
  19. ,#{createTime}
  20. </if>
  21. )
  22. </insert>
  23. <!-- 查询费用明细信息(Business) add by wuxw 2018-07-03 -->
  24. <select id="getBusinessFeeDetailInfo" parameterType="Map" resultType="Map">
  25. select
  26. t.operate,t.prime_rate,t.prime_rate primeRate,t.detail_id,
  27. t.detail_id detailId,t.receivable_amount,
  28. t.receivable_amount receivableAmount,t.cycles,
  29. t.remark,t.received_amount,t.received_amount receivedAmount,
  30. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,
  31. t.fee_id,t.fee_id feeId,t.state,t.start_time,t.end_time,t.start_time startTime,t.end_time endTime,
  32. t.payable_amount,t.payable_amount payableAmount
  33. from business_pay_fee_detail t
  34. where 1 =1
  35. <if test="operate !=null and operate != ''">
  36. and t.operate= #{operate}
  37. </if>
  38. <if test="primeRate !=null and primeRate != ''">
  39. and t.prime_rate= #{primeRate}
  40. </if>
  41. <if test="detailId !=null and detailId != ''">
  42. and t.detail_id= #{detailId}
  43. </if>
  44. <if test="receivableAmount !=null and receivableAmount != ''">
  45. and t.receivable_amount= #{receivableAmount}
  46. </if>
  47. <if test="payableAmount !=null and payableAmount != ''">
  48. and t.payable_amount= #{payableAmount}
  49. </if>
  50. <if test="cycles !=null and cycles != ''">
  51. and t.cycles= #{cycles}
  52. </if>
  53. <if test="remark !=null and remark != ''">
  54. and t.remark= #{remark}
  55. </if>
  56. <if test="receivedAmount !=null and receivedAmount != ''">
  57. and t.received_amount= #{receivedAmount}
  58. </if>
  59. <if test="communityId !=null and communityId != ''">
  60. and t.community_id= #{communityId}
  61. </if>
  62. <if test="bId !=null and bId != ''">
  63. and t.b_id= #{bId}
  64. </if>
  65. <if test="feeId !=null and feeId != ''">
  66. and t.fee_id= #{feeId}
  67. </if>
  68. </select>
  69. <!-- 保存费用明细信息至 instance表中 add by wuxw 2018-07-03 -->
  70. <insert id="saveFeeDetailInfoInstance" parameterType="Map">
  71. insert into
  72. pay_fee_detail(
  73. prime_rate,detail_id,receivable_amount,cycles,remark,status_cd,received_amount,community_id,b_id,fee_id,state,start_time,end_time,create_time,payable_amount)
  74. select
  75. t.prime_rate,t.detail_id,t.receivable_amount,t.cycles,t.remark,'0',t.received_amount,t.community_id,t.b_id,t.fee_id,state,t.start_time,t.end_time,
  76. t.create_time,t.payable_amount
  77. from business_pay_fee_detail t where 1=1
  78. and t.operate= 'ADD'
  79. <if test="primeRate !=null and primeRate != ''">
  80. and t.prime_rate= #{primeRate}
  81. </if>
  82. <if test="detailId !=null and detailId != ''">
  83. and t.detail_id= #{detailId}
  84. </if>
  85. <if test="receivableAmount !=null and receivableAmount != ''">
  86. and t.receivable_amount= #{receivableAmount}
  87. </if>
  88. <if test="cycles !=null and cycles != ''">
  89. and t.cycles= #{cycles}
  90. </if>
  91. <if test="remark !=null and remark != ''">
  92. and t.remark= #{remark}
  93. </if>
  94. <if test="receivedAmount !=null and receivedAmount != ''">
  95. and t.received_amount= #{receivedAmount}
  96. </if>
  97. <if test="payableAmount !=null and payableAmount != ''">
  98. and t.payable_amount= #{payableAmount}
  99. </if>
  100. <if test="communityId !=null and communityId != ''">
  101. and t.community_id= #{communityId}
  102. </if>
  103. <if test="bId !=null and bId != ''">
  104. and t.b_id= #{bId}
  105. </if>
  106. <if test="feeId !=null and feeId != ''">
  107. and t.fee_id= #{feeId}
  108. </if>
  109. </insert>
  110. <!-- 查询费用明细信息 add by wuxw 2018-07-03 -->
  111. <select id="getFeeDetailInfo" parameterType="Map" resultType="Map">
  112. select
  113. t.prime_rate,t.prime_rate primeRate,
  114. t.detail_id,t.detail_id detailId,
  115. t.receivable_amount,t.receivable_amount receivableAmount,
  116. t.cycles,t.remark,t.status_cd,t.status_cd statusCd,t.received_amount,t.received_amount receivedAmount,
  117. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.fee_id,t.fee_id feeId ,t.create_time createTime,
  118. t.state,d.name stateName,t.start_time,t.end_time,t.start_time startTime,t.end_time endTime,pfa.`value`
  119. importFeeName,pfc.fee_name feeName,t.payable_amount,t.payable_amount payableAmount,
  120. mw.cur_degrees curDegrees,mw.pre_degrees preDegrees, mw.pre_reading_time preReadingTime,mw.cur_reading_time
  121. curReadingTime,t.pay_order_id payOrderId,pfc.config_id configId,td.`name` primeRateName,pfao1.`value` payerObjName,
  122. t.cashier_id cashierId,t.cashier_name cashierName,pfc.fee_flag feeFlag,fr.receipt_code receiptCode
  123. from pay_fee_detail t
  124. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  125. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  126. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  127. LEFT JOIN meter_water mw on t.fee_id = mw.fee_id and mw.status_cd = '0' and mw.community_id = t.community_id
  128. left join pay_fee_attrs pfao1 on pfao1.fee_id = t.fee_id and pfao1.spec_cd = '390012' and pfao1.status_cd = '0'
  129. <if test="ownerId != null and ownerId != ''">
  130. left join pay_fee_attrs pfao on pfao.fee_id = t.fee_id and pfao.spec_cd = '390007' and pfao.status_cd = '0'
  131. </if>
  132. left join t_dict d on t.state = d.status_cd and d.table_name = 'pay_fee_detail' and d.table_columns = 'state'
  133. left join t_dict td on t.prime_rate = td.status_cd and td.table_name = 'pay_fee_detail' and td.table_columns = 'prime_rate'
  134. left join fee_receipt_detail frd on t.detail_id = frd.detail_id and frd.status_cd = '0'
  135. left join fee_receipt fr on frd.receipt_id = fr.receipt_id and fr.status_cd = '0'
  136. where 1 =1
  137. <if test="configId != null and configId != ''">
  138. and pf.config_id = #{configId}
  139. </if>
  140. <if test="payerObjId != null and payerObjId != ''">
  141. and pf.payer_obj_id = #{payerObjId}
  142. </if>
  143. <if test="payerObjType != null and payerObjType != ''">
  144. and pf.payer_obj_type = #{payerObjType}
  145. </if>
  146. <if test="ownerId != null and ownerId != ''">
  147. and pfao.value = #{ownerId}
  148. </if>
  149. <if test="primeRate !=null and primeRate != ''">
  150. and t.prime_rate= #{primeRate}
  151. </if>
  152. <if test="detailId !=null and detailId != ''">
  153. and t.detail_id= #{detailId}
  154. </if>
  155. <if test="receivableAmount !=null and receivableAmount != ''">
  156. and t.receivable_amount= #{receivableAmount}
  157. </if>
  158. <if test="cycles !=null and cycles != ''">
  159. and t.cycles= #{cycles}
  160. </if>
  161. <if test="remark !=null and remark != ''">
  162. and t.remark= #{remark}
  163. </if>
  164. <if test="statusCd !=null and statusCd != ''">
  165. and t.status_cd= #{statusCd}
  166. </if>
  167. <if test="receivedAmount !=null and receivedAmount != ''">
  168. and t.received_amount= #{receivedAmount}
  169. </if>
  170. <if test="payableAmount !=null and payableAmount != ''">
  171. and t.payable_amount= #{payableAmount}
  172. </if>
  173. <if test="communityId !=null and communityId != ''">
  174. and t.community_id= #{communityId}
  175. </if>
  176. <if test="bId !=null and bId != ''">
  177. and t.b_id= #{bId}
  178. </if>
  179. <if test="feeId !=null and feeId != ''">
  180. and t.fee_id= #{feeId}
  181. </if>
  182. <if test="startTime !=null ">
  183. and t.create_time &gt;= #{startTime}
  184. </if>
  185. <if test="endTime !=null ">
  186. and t.create_time &lt;= #{endTime}
  187. </if>
  188. <if test="curYear != null and curYear != ''">
  189. and DATE_FORMAT(DATE_SUB(t.end_time,INTERVAL 1 DAY),'%Y') = #{curYear}
  190. </if>
  191. <if test="states != null">
  192. and t.state in
  193. <foreach collection="states" item="item" open="(" close=")" separator=",">
  194. #{item}
  195. </foreach>
  196. </if>
  197. <if test="state !=null and state != ''">
  198. and t.state= #{state}
  199. </if>
  200. <if test="cashierId !=null and cashierId != ''">
  201. and t.cashier_id= #{cashierId}
  202. </if>
  203. <if test="cashierName !=null and cashierName != ''">
  204. and t.cashier_name= #{cashierName}
  205. </if>
  206. order by pf.payer_obj_id, pfc.fee_name, t.end_time desc
  207. <if test="page != -1 and page != null ">
  208. limit #{page}, #{row}
  209. </if>
  210. </select>
  211. <!-- 修改费用明细信息 add by wuxw 2018-07-03 -->
  212. <update id="updateFeeDetailInfoInstance" parameterType="Map">
  213. update pay_fee_detail t set t.status_cd = #{statusCd}
  214. <if test="newBId != null and newBId != ''">
  215. ,t.b_id = #{newBId}
  216. </if>
  217. <if test="primeRate !=null and primeRate != ''">
  218. , t.prime_rate= #{primeRate}
  219. </if>
  220. <if test="receivableAmount !=null and receivableAmount != ''">
  221. , t.receivable_amount= #{receivableAmount}
  222. </if>
  223. <if test="cycles !=null and cycles != ''">
  224. , t.cycles= #{cycles}
  225. </if>
  226. <if test="remark !=null and remark != ''">
  227. , t.remark= #{remark}
  228. </if>
  229. <if test="receivedAmount !=null and receivedAmount != ''">
  230. , t.received_amount= #{receivedAmount}
  231. </if>
  232. <if test="payableAmount !=null and payableAmount != ''">
  233. , t.payable_amount= #{payableAmount}
  234. </if>
  235. <if test="communityId !=null and communityId != ''">
  236. , t.community_id= #{communityId}
  237. </if>
  238. <if test="state !=null and state != ''">
  239. , t.state= #{state}
  240. </if>
  241. <if test="feeId !=null and feeId != ''">
  242. , t.fee_id= #{feeId}
  243. </if>
  244. where 1=1
  245. <if test="detailId !=null and detailId != ''">
  246. and t.detail_id= #{detailId}
  247. </if>
  248. <if test="bId !=null and bId != ''">
  249. and t.b_id= #{bId}
  250. </if>
  251. </update>
  252. <!-- 查询费用明细数量 add by wuxw 2018-07-03 -->
  253. <select id="queryFeeDetailsCount" parameterType="Map" resultType="Map">
  254. select count(1) count
  255. from pay_fee_detail t
  256. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  257. <if test="ownerId != null and ownerId != ''">
  258. left join pay_fee_attrs pfa on pfa.fee_id = t.fee_id and pfa.spec_cd = '390007' and pfa.status_cd = '0'
  259. </if>
  260. where 1 =1
  261. <if test="configId != null and configId != ''">
  262. and pf.config_id = #{configId}
  263. </if>
  264. <if test="payerObjId != null and payerObjId != ''">
  265. and pf.payer_obj_id = #{payerObjId}
  266. </if>
  267. <if test="payerObjType != null and payerObjType != ''">
  268. and pf.payer_obj_type = #{payerObjType}
  269. </if>
  270. <if test="ownerId != null and ownerId != ''">
  271. and pfa.value = #{ownerId}
  272. </if>
  273. <if test="primeRate !=null and primeRate != ''">
  274. and t.prime_rate= #{primeRate}
  275. </if>
  276. <if test="detailId !=null and detailId != ''">
  277. and t.detail_id= #{detailId}
  278. </if>
  279. <if test="receivableAmount !=null and receivableAmount != ''">
  280. and t.receivable_amount= #{receivableAmount}
  281. </if>
  282. <if test="cycles !=null and cycles != ''">
  283. and t.cycles= #{cycles}
  284. </if>
  285. <if test="remark !=null and remark != ''">
  286. and t.remark= #{remark}
  287. </if>
  288. <if test="statusCd !=null and statusCd != ''">
  289. and t.status_cd= #{statusCd}
  290. </if>
  291. <if test="receivedAmount !=null and receivedAmount != ''">
  292. and t.received_amount= #{receivedAmount}
  293. </if>
  294. <if test="payableAmount !=null and payableAmount != ''">
  295. and t.payable_amount= #{payableAmount}
  296. </if>
  297. <if test="communityId !=null and communityId != ''">
  298. and t.community_id= #{communityId}
  299. </if>
  300. <if test="bId !=null and bId != ''">
  301. and t.b_id= #{bId}
  302. </if>
  303. <if test="feeId !=null and feeId != ''">
  304. and t.fee_id= #{feeId}
  305. </if>
  306. <if test="state !=null and state != ''">
  307. and t.state= #{state}
  308. </if>
  309. <if test="startTime !=null ">
  310. and t.create_time &gt;= #{startTime}
  311. </if>
  312. <if test="endTime !=null ">
  313. and t.create_time &lt;= #{endTime}
  314. </if>
  315. <if test="cashierId !=null and cashierId != ''">
  316. and t.cashier_id= #{cashierId}
  317. </if>
  318. <if test="cashierName !=null and cashierName != ''">
  319. and t.cashier_name= #{cashierName}
  320. </if>
  321. <if test="curYear != null and curYear != ''">
  322. and DATE_FORMAT(DATE_SUB(t.end_time,INTERVAL 1 DAY),'%Y') = #{curYear}
  323. </if>
  324. </select>
  325. <!-- 保存费用明细信息至 instance表中 add by wuxw 2018-07-03 -->
  326. <insert id="saveFeeDetail" parameterType="Map">
  327. insert into
  328. pay_fee_detail(
  329. prime_rate,detail_id,receivable_amount,cycles,remark,received_amount,community_id,fee_id,state,start_time,end_time,payable_amount
  330. <if test="createTime != null and createTime != ''">
  331. ,create_time
  332. </if>
  333. )
  334. values(#{primeRate},#{detailId},#{receivableAmount},#{cycles},#{remark},#{receivedAmount},#{communityId},#{feeId},#{state},
  335. #{startTime},#{endTime},#{payableAmount}
  336. <if test="createTime != null and createTime != ''">
  337. ,#{createTime}
  338. </if>
  339. )
  340. </insert>
  341. </mapper>