FeeDetailServiceDaoImplMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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,open_invoice
  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},#{openInvoice}
  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`
  122. payerObjName,
  123. t.cashier_id cashierId,t.cashier_name cashierName,pfc.fee_flag feeFlag,fr.receipt_code
  124. receiptCode,t.open_invoice openInvoice
  125. from pay_fee_detail t
  126. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  127. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  128. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  129. LEFT JOIN meter_water mw on t.fee_id = mw.fee_id and mw.status_cd = '0' and mw.community_id = t.community_id
  130. left join pay_fee_attrs pfao1 on pfao1.fee_id = t.fee_id and pfao1.spec_cd = '390012' and pfao1.status_cd = '0'
  131. <if test="ownerId != null and ownerId != ''">
  132. left join pay_fee_attrs pfao on pfao.fee_id = t.fee_id and pfao.spec_cd = '390007' and pfao.status_cd = '0'
  133. </if>
  134. left join t_dict d on t.state = d.status_cd and d.table_name = 'pay_fee_detail' and d.table_columns = 'state'
  135. left join t_dict td on t.prime_rate = td.status_cd and td.table_name = 'pay_fee_detail' and td.table_columns =
  136. 'prime_rate'
  137. left join fee_receipt_detail frd on t.detail_id = frd.detail_id and frd.status_cd = '0'
  138. left join fee_receipt fr on frd.receipt_id = fr.receipt_id and fr.status_cd = '0'
  139. where 1 =1
  140. <if test="configId != null and configId != ''">
  141. and pf.config_id = #{configId}
  142. </if>
  143. <if test="payerObjId != null and payerObjId != ''">
  144. and pf.payer_obj_id = #{payerObjId}
  145. </if>
  146. <if test="payerObjType != null and payerObjType != ''">
  147. and pf.payer_obj_type = #{payerObjType}
  148. </if>
  149. <if test="ownerId != null and ownerId != ''">
  150. and pfao.value = #{ownerId}
  151. </if>
  152. <if test="primeRate !=null and primeRate != ''">
  153. and t.prime_rate= #{primeRate}
  154. </if>
  155. <if test="detailId !=null and detailId != ''">
  156. and t.detail_id= #{detailId}
  157. </if>
  158. <if test="detailIds !=null ">
  159. and t.detail_id in
  160. <foreach collection="detailIds" item="item" open="(" close=")" separator=",">
  161. #{item}
  162. </foreach>
  163. </if>
  164. <if test="receivableAmount !=null and receivableAmount != ''">
  165. and t.receivable_amount= #{receivableAmount}
  166. </if>
  167. <if test="cycles !=null and cycles != ''">
  168. and t.cycles= #{cycles}
  169. </if>
  170. <if test="remark !=null and remark != ''">
  171. and t.remark= #{remark}
  172. </if>
  173. <if test="statusCd !=null and statusCd != ''">
  174. and t.status_cd= #{statusCd}
  175. </if>
  176. <if test="receivedAmount !=null and receivedAmount != ''">
  177. and t.received_amount= #{receivedAmount}
  178. </if>
  179. <if test="payableAmount !=null and payableAmount != ''">
  180. and t.payable_amount= #{payableAmount}
  181. </if>
  182. <if test="communityId !=null and communityId != ''">
  183. and t.community_id= #{communityId}
  184. </if>
  185. <if test="bId !=null and bId != ''">
  186. and t.b_id= #{bId}
  187. </if>
  188. <if test="feeId !=null and feeId != ''">
  189. and t.fee_id= #{feeId}
  190. </if>
  191. <if test="startTime !=null ">
  192. and t.create_time &gt;= #{startTime}
  193. </if>
  194. <if test="endTime !=null ">
  195. and t.create_time &lt;= #{endTime}
  196. </if>
  197. <if test="curYear != null and curYear != ''">
  198. and DATE_FORMAT(DATE_SUB(t.end_time,INTERVAL 1 DAY),'%Y') = #{curYear}
  199. </if>
  200. <if test="states != null">
  201. and t.state in
  202. <foreach collection="states" item="item" open="(" close=")" separator=",">
  203. #{item}
  204. </foreach>
  205. </if>
  206. <if test="state !=null and state != ''">
  207. and t.state= #{state}
  208. </if>
  209. <if test="cashierId !=null and cashierId != ''">
  210. and t.cashier_id= #{cashierId}
  211. </if>
  212. <if test="cashierName !=null and cashierName != ''">
  213. and t.cashier_name= #{cashierName}
  214. </if>
  215. <if test="openInvoice !=null and openInvoice != ''">
  216. and t.open_invoice= #{openInvoice}
  217. </if>
  218. order by t.create_time desc,pf.payer_obj_id desc
  219. <if test="page != -1 and page != null ">
  220. limit #{page}, #{row}
  221. </if>
  222. </select>
  223. <!-- 修改费用明细信息 add by wuxw 2018-07-03 -->
  224. <update id="updateFeeDetailInfoInstance" parameterType="Map">
  225. update pay_fee_detail t set t.status_cd = #{statusCd}
  226. <if test="newBId != null and newBId != ''">
  227. ,t.b_id = #{newBId}
  228. </if>
  229. <if test="primeRate !=null and primeRate != ''">
  230. , t.prime_rate= #{primeRate}
  231. </if>
  232. <if test="receivableAmount !=null and receivableAmount != ''">
  233. , t.receivable_amount= #{receivableAmount}
  234. </if>
  235. <if test="cycles !=null and cycles != ''">
  236. , t.cycles= #{cycles}
  237. </if>
  238. <if test="remark !=null and remark != ''">
  239. , t.remark= #{remark}
  240. </if>
  241. <if test="receivedAmount !=null and receivedAmount != ''">
  242. , t.received_amount= #{receivedAmount}
  243. </if>
  244. <if test="payableAmount !=null and payableAmount != ''">
  245. , t.payable_amount= #{payableAmount}
  246. </if>
  247. <if test="communityId !=null and communityId != ''">
  248. , t.community_id= #{communityId}
  249. </if>
  250. <if test="state !=null and state != ''">
  251. , t.state= #{state}
  252. </if>
  253. <if test="feeId !=null and feeId != ''">
  254. , t.fee_id= #{feeId}
  255. </if>
  256. <if test="openInvoice !=null and openInvoice != ''">
  257. , t.open_invoice= #{openInvoice}
  258. </if>
  259. where 1=1
  260. <if test="detailId !=null and detailId != ''">
  261. and t.detail_id= #{detailId}
  262. </if>
  263. <if test="bId !=null and bId != ''">
  264. and t.b_id= #{bId}
  265. </if>
  266. </update>
  267. <!-- 查询费用明细数量 add by wuxw 2018-07-03 -->
  268. <select id="queryFeeDetailsCount" parameterType="Map" resultType="Map">
  269. select count(1) count
  270. from pay_fee_detail t
  271. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  272. <if test="ownerId != null and ownerId != ''">
  273. left join pay_fee_attrs pfa on pfa.fee_id = t.fee_id and pfa.spec_cd = '390007' and pfa.status_cd = '0'
  274. </if>
  275. where 1 =1
  276. <if test="configId != null and configId != ''">
  277. and pf.config_id = #{configId}
  278. </if>
  279. <if test="payerObjId != null and payerObjId != ''">
  280. and pf.payer_obj_id = #{payerObjId}
  281. </if>
  282. <if test="payerObjType != null and payerObjType != ''">
  283. and pf.payer_obj_type = #{payerObjType}
  284. </if>
  285. <if test="ownerId != null and ownerId != ''">
  286. and pfa.value = #{ownerId}
  287. </if>
  288. <if test="primeRate !=null and primeRate != ''">
  289. and t.prime_rate= #{primeRate}
  290. </if>
  291. <if test="detailId !=null and detailId != ''">
  292. and t.detail_id= #{detailId}
  293. </if>
  294. <if test="detailIds !=null ">
  295. and t.detail_id in
  296. <foreach collection="detailIds" item="item" open="(" close=")" separator=",">
  297. #{item}
  298. </foreach>
  299. </if>
  300. <if test="receivableAmount !=null and receivableAmount != ''">
  301. and t.receivable_amount= #{receivableAmount}
  302. </if>
  303. <if test="cycles !=null and cycles != ''">
  304. and t.cycles= #{cycles}
  305. </if>
  306. <if test="remark !=null and remark != ''">
  307. and t.remark= #{remark}
  308. </if>
  309. <if test="statusCd !=null and statusCd != ''">
  310. and t.status_cd= #{statusCd}
  311. </if>
  312. <if test="receivedAmount !=null and receivedAmount != ''">
  313. and t.received_amount= #{receivedAmount}
  314. </if>
  315. <if test="payableAmount !=null and payableAmount != ''">
  316. and t.payable_amount= #{payableAmount}
  317. </if>
  318. <if test="communityId !=null and communityId != ''">
  319. and t.community_id= #{communityId}
  320. </if>
  321. <if test="bId !=null and bId != ''">
  322. and t.b_id= #{bId}
  323. </if>
  324. <if test="feeId !=null and feeId != ''">
  325. and t.fee_id= #{feeId}
  326. </if>
  327. <if test="state !=null and state != ''">
  328. and t.state= #{state}
  329. </if>
  330. <if test="startTime !=null ">
  331. and t.create_time &gt;= #{startTime}
  332. </if>
  333. <if test="endTime !=null ">
  334. and t.create_time &lt;= #{endTime}
  335. </if>
  336. <if test="cashierId !=null and cashierId != ''">
  337. and t.cashier_id= #{cashierId}
  338. </if>
  339. <if test="cashierName !=null and cashierName != ''">
  340. and t.cashier_name= #{cashierName}
  341. </if>
  342. <if test="openInvoice !=null and openInvoice != ''">
  343. and t.open_invoice= #{openInvoice}
  344. </if>
  345. <if test="curYear != null and curYear != ''">
  346. and DATE_FORMAT(DATE_SUB(t.end_time,INTERVAL 1 DAY),'%Y') = #{curYear}
  347. </if>
  348. </select>
  349. <!-- 保存费用明细信息至 instance表中 add by wuxw 2018-07-03
  350. ,
  351. acct_amount,discount_amount,deduction_amount,late_amount,gift_amount
  352. ,
  353. #{acctAmount},#{discountAmount},#{deductionAmount},#{lateAmount},#{giftAmount}
  354. -->
  355. <insert id="saveFeeDetail" parameterType="Map">
  356. insert into
  357. pay_fee_detail(
  358. prime_rate,detail_id,receivable_amount,cycles,remark,received_amount,community_id,
  359. fee_id,state,start_time,end_time,payable_amount,cashier_name,cashier_id,open_invoice
  360. <if test="createTime != null and createTime != ''">
  361. ,create_time
  362. </if>
  363. )
  364. values(#{primeRate},#{detailId},#{receivableAmount},#{cycles},#{remark},#{receivedAmount},#{communityId},#{feeId},#{state},
  365. #{startTime},#{endTime},#{payableAmount},#{cashierName},#{cashierId},#{openInvoice}
  366. <if test="createTime != null and createTime != ''">
  367. ,#{createTime}
  368. </if>
  369. )
  370. </insert>
  371. </mapper>