ReportFeeStatisticsServiceDaoImplMapper.xml 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="reportFeeStatisticsServiceDaoImpl">
  6. <!-- 查询历史欠费 -->
  7. <select id="getHisMonthOweFee" parameterType="Map" resultType="Map">
  8. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  9. from pay_fee_detail_month t
  10. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  11. <if test="floorId != null and floorId != ''">
  12. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  13. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  14. </if>
  15. where
  16. 1=1
  17. <if test="floorId != null and floorId != ''">
  18. and bu.floor_id = #{floorId}
  19. </if>
  20. <if test="configId != null and configId != ''">
  21. and t.config_id = #{configId}
  22. </if>
  23. <if test="objName != null and objName != ''">
  24. and t.obj_name like concat('%',#{objName},'%')
  25. </if>
  26. <if test="ownerName != null and ownerName != ''">
  27. and t.owner_name like concat('%',#{ownerName},'%')
  28. </if>
  29. <if test="link != null and link != ''">
  30. and t.link = #{link}
  31. </if>
  32. <if test="configIds !=null ">
  33. and t.config_id in
  34. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  35. #{item}
  36. </foreach>
  37. </if>
  38. <if test="feeTypeCd != null and feeTypeCd != ''">
  39. and pf.fee_type_cd = #{feeTypeCd}
  40. </if>
  41. and t.status_cd = '0'
  42. and t.detail_id = '-1'
  43. and t.community_id= #{communityId}
  44. and t.cur_month_time &lt; #{startDate}
  45. </select>
  46. <!-- 查询单月欠费 -->
  47. <select id="getCurMonthOweFee" parameterType="Map" resultType="Map">
  48. select ifnull(sum(t.receivable_amount),0.0) curOweFee
  49. from pay_fee_detail_month t
  50. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  51. <if test="floorId != null and floorId != ''">
  52. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  53. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  54. </if>
  55. where
  56. 1=1
  57. <if test="floorId != null and floorId != ''">
  58. and bu.floor_id = #{floorId}
  59. </if>
  60. <if test="configId != null and configId != ''">
  61. and t.config_id = #{configId}
  62. </if>
  63. <if test="objName != null and objName != ''">
  64. and t.obj_name like concat('%',#{objName},'%')
  65. </if>
  66. <if test="ownerName != null and ownerName != ''">
  67. and t.owner_name like concat('%',#{ownerName},'%')
  68. </if>
  69. <if test="link != null and link != ''">
  70. and t.link = #{link}
  71. </if>
  72. <if test="configIds !=null ">
  73. and t.config_id in
  74. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  75. #{item}
  76. </foreach>
  77. </if>
  78. <if test="feeTypeCd != null and feeTypeCd != ''">
  79. and pf.fee_type_cd = #{feeTypeCd}
  80. </if>
  81. and t.status_cd = '0'
  82. and t.detail_id = '-1'
  83. and t.community_id= #{communityId}
  84. and t.cur_month_time &gt;= #{startDate}
  85. and t.cur_month_time &lt; #{endDate}
  86. </select>
  87. <select id="getOweFee" parameterType="Map" resultType="Map">
  88. select ifnull(sum(t.receivable_amount),0.0) oweFee
  89. from pay_fee_detail_month t
  90. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  91. <if test="floorId != null and floorId != ''">
  92. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  93. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  94. </if>
  95. where
  96. 1=1
  97. <if test="floorId != null and floorId != ''">
  98. and bu.floor_id = #{floorId}
  99. </if>
  100. <if test="configId != null and configId != ''">
  101. and t.config_id = #{configId}
  102. </if>
  103. <if test="objName != null and objName != ''">
  104. and t.obj_name like concat('%',#{objName},'%')
  105. </if>
  106. <if test="ownerName != null and ownerName != ''">
  107. and t.owner_name like concat('%',#{ownerName},'%')
  108. </if>
  109. <if test="link != null and link != ''">
  110. and t.link = #{link}
  111. </if>
  112. <if test="configIds !=null ">
  113. and t.config_id in
  114. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  115. #{item}
  116. </foreach>
  117. </if>
  118. <if test="feeTypeCd != null and feeTypeCd != ''">
  119. and pf.fee_type_cd = #{feeTypeCd}
  120. </if>
  121. and t.status_cd = '0'
  122. and t.detail_id = '-1'
  123. and t.community_id= #{communityId}
  124. and t.cur_month_time &lt; #{endDate}
  125. </select>
  126. <!-- 查询当月应收 -->
  127. <select id="getCurReceivableFee" parameterType="Map" resultType="Map">
  128. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  129. from pay_fee_detail_month t
  130. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  131. <if test="floorId != null and floorId != ''">
  132. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  133. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  134. </if>
  135. where
  136. 1=1
  137. <if test="floorId != null and floorId != ''">
  138. and bu.floor_id = #{floorId}
  139. </if>
  140. <if test="configId != null and configId != ''">
  141. and t.config_id = #{configId}
  142. </if>
  143. <if test="objName != null and objName != ''">
  144. and t.obj_name like concat('%',#{objName},'%')
  145. </if>
  146. <if test="ownerName != null and ownerName != ''">
  147. and t.owner_name like concat('%',#{ownerName},'%')
  148. </if>
  149. <if test="link != null and link != ''">
  150. and t.link = #{link}
  151. </if>
  152. <if test="configIds !=null ">
  153. and t.config_id in
  154. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="feeTypeCd != null and feeTypeCd != ''">
  159. and pf.fee_type_cd = #{feeTypeCd}
  160. </if>
  161. and t.status_cd = '0'
  162. and t.community_id= #{communityId}
  163. and t.cur_month_time &gt;= #{startDate}
  164. and t.cur_month_time &lt; #{endDate}
  165. </select>
  166. <!-- 查询欠费追回 -->
  167. <select id="getHisReceivedFee" parameterType="Map" resultType="Map">
  168. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  169. from pay_fee_detail_month t
  170. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  171. <if test="floorId != null and floorId != ''">
  172. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  173. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  174. </if>
  175. where
  176. 1=1
  177. <if test="floorId != null and floorId != ''">
  178. and bu.floor_id = #{floorId}
  179. </if>
  180. <if test="configId != null and configId != ''">
  181. and t.config_id = #{configId}
  182. </if>
  183. <if test="objName != null and objName != ''">
  184. and t.obj_name like concat('%',#{objName},'%')
  185. </if>
  186. <if test="ownerName != null and ownerName != ''">
  187. and t.owner_name like concat('%',#{ownerName},'%')
  188. </if>
  189. <if test="link != null and link != ''">
  190. and t.link = #{link}
  191. </if>
  192. <if test="configIds !=null ">
  193. and t.config_id in
  194. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  195. #{item}
  196. </foreach>
  197. </if>
  198. <if test="feeTypeCd != null and feeTypeCd != ''">
  199. and pf.fee_type_cd = #{feeTypeCd}
  200. </if>
  201. and t.status_cd = '0'
  202. and t.community_id= #{communityId}
  203. and t.pay_fee_time &gt; #{startDate}
  204. and t.pay_fee_time &lt; #{endDate}
  205. and t.cur_month_time &lt; #{startDate}
  206. </select>
  207. <!-- 查询 预交费用 -->
  208. <select id="getPreReceivedFee" parameterType="Map" resultType="Map">
  209. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  210. from pay_fee_detail_month t
  211. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  212. <if test="floorId != null and floorId != ''">
  213. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  214. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  215. </if>
  216. where
  217. 1=1
  218. <if test="floorId != null and floorId != ''">
  219. and bu.floor_id = #{floorId}
  220. </if>
  221. <if test="configId != null and configId != ''">
  222. and t.config_id = #{configId}
  223. </if>
  224. <if test="objName != null and objName != ''">
  225. and t.obj_name like concat('%',#{objName},'%')
  226. </if>
  227. <if test="ownerName != null and ownerName != ''">
  228. and t.owner_name like concat('%',#{ownerName},'%')
  229. </if>
  230. <if test="link != null and link != ''">
  231. and t.link = #{link}
  232. </if>
  233. <if test="configIds !=null ">
  234. and t.config_id in
  235. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  236. #{item}
  237. </foreach>
  238. </if>
  239. <if test="feeTypeCd != null and feeTypeCd != ''">
  240. and pf.fee_type_cd = #{feeTypeCd}
  241. </if>
  242. and t.status_cd = '0'
  243. and t.community_id= #{communityId}
  244. and t.pay_fee_time &gt; #{startDate}
  245. and t.pay_fee_time &lt; #{endDate}
  246. and t.cur_month_time &gt;= #{endDate}
  247. </select>
  248. <!-- 查询实收费用 -->
  249. <select id="getReceivedFee" parameterType="Map" resultType="Map">
  250. select ifnull(sum(t.received_amount),0.0) receivedFee
  251. from pay_fee_detail t
  252. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  253. left join pay_fee_attrs pfa on pf.fee_id = pfa.fee_id and pfa.status_cd = '0' and pfa.spec_cd = '390008'
  254. left join pay_fee_attrs pfa1 on pf.fee_id = pfa1.fee_id and pfa1.status_cd = '0' and pfa1.spec_cd = '390009'
  255. left join pay_fee_attrs pfa2 on pf.fee_id = pfa2.fee_id and pfa2.status_cd = '0' and pfa2.spec_cd = '390012'
  256. <if test="floorId != null and floorId != ''">
  257. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  258. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  259. </if>
  260. where
  261. 1=1
  262. <if test="floorId != null and floorId != ''">
  263. and bu.floor_id = #{floorId}
  264. </if>
  265. <if test="configId != null and configId != ''">
  266. and t.config_id = #{configId}
  267. </if>
  268. <if test="objName != null and objName != ''">
  269. and pfa2.value like concat('%',#{objName},'%')
  270. </if>
  271. <if test="ownerName != null and ownerName != ''">
  272. and pfa.value like concat('%',#{ownerName},'%')
  273. </if>
  274. <if test="link != null and link != ''">
  275. and pfa1.value = #{link}
  276. </if>
  277. <if test="configIds !=null ">
  278. and pf.config_id in
  279. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  280. #{item}
  281. </foreach>
  282. </if>
  283. <if test="feeTypeCd != null and feeTypeCd != ''">
  284. and pf.fee_type_cd = #{feeTypeCd}
  285. </if>
  286. and t.status_cd = '0'
  287. and t.community_id= #{communityId}
  288. and t.create_time &gt; #{startDate}
  289. and t.create_time &lt; #{endDate}
  290. </select>
  291. <!-- 查询欠费户数 -->
  292. <select id="getOweRoomCount" parameterType="Map" resultType="Map">
  293. select count(1) oweRoomCount
  294. from (
  295. select t.payer_obj_id
  296. from report_owe_fee t
  297. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  298. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  299. <if test="feeTypeCd != null and feeTypeCd != ''">
  300. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  301. </if>
  302. where
  303. 1=1
  304. and t.payer_obj_type = '3333'
  305. and t.community_id= #{communityId}
  306. and t.end_time &lt; #{endDate}
  307. and t.amount_owed != 0
  308. <if test="floorId != null and floorId != ''">
  309. and bu.floor_id = #{floorId}
  310. </if>
  311. <if test="configId != null and configId != ''">
  312. and t.config_id = #{configId}
  313. </if>
  314. <if test="objName != null and objName != ''">
  315. and t.payer_obj_name like concat('%',#{objName},'%')
  316. </if>
  317. <if test="ownerName != null and ownerName != ''">
  318. and t.owner_name like concat('%',#{ownerName},'%')
  319. </if>
  320. <if test="link != null and link != ''">
  321. and t.owner_tel = #{link}
  322. </if>
  323. <if test="configIds !=null ">
  324. and t.config_id in
  325. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  326. #{item}
  327. </foreach>
  328. </if>
  329. <if test="feeTypeCd != null and feeTypeCd != ''">
  330. and pfc.fee_type_cd = #{feeTypeCd}
  331. </if>
  332. group by t.payer_obj_id
  333. ) a
  334. </select>
  335. <!-- 查询收费户数 -->
  336. <select id="getFeeRoomCount" parameterType="Map" resultType="Map">
  337. select count(1) feeRoomCount
  338. from (
  339. select t.payer_obj_id
  340. from report_owe_fee t
  341. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  342. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  343. <if test="feeTypeCd != null and feeTypeCd != ''">
  344. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  345. </if>
  346. where
  347. 1=1
  348. and t.payer_obj_type = '3333'
  349. and t.community_id= #{communityId}
  350. and t.end_time &lt; #{endDate}
  351. <if test="floorId != null and floorId != ''">
  352. and bu.floor_id = #{floorId}
  353. </if>
  354. <if test="configId != null and configId != ''">
  355. and t.config_id = #{configId}
  356. </if>
  357. <if test="objName != null and objName != ''">
  358. and t.payer_obj_name like concat('%',#{objName},'%')
  359. </if>
  360. <if test="ownerName != null and ownerName != ''">
  361. and t.owner_name like concat('%',#{ownerName},'%')
  362. </if>
  363. <if test="link != null and link != ''">
  364. and t.owner_tel = #{link}
  365. </if>
  366. <if test="configIds !=null ">
  367. and t.config_id in
  368. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  369. #{item}
  370. </foreach>
  371. </if>
  372. <if test="feeTypeCd != null and feeTypeCd != ''">
  373. and pfc.fee_type_cd = #{feeTypeCd}
  374. </if>
  375. group by t.payer_obj_id
  376. ) a
  377. </select>
  378. <select id="getFloorFeeSummary" parameterType="Map" resultType="Map">
  379. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,
  380. (
  381. select count(1) from (
  382. select bu.floor_id,t.payer_obj_id
  383. from report_owe_fee t
  384. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  385. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  386. <if test="feeTypeCd != null and feeTypeCd != ''">
  387. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  388. </if>
  389. where
  390. 1=1
  391. and t.payer_obj_type = '3333'
  392. and t.community_id= #{communityId}
  393. and t.end_time &lt;= #{endDate}
  394. and t.amount_owed != 0
  395. <if test="configIds !=null ">
  396. and t.config_id in
  397. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  398. #{item}
  399. </foreach>
  400. </if>
  401. <if test="feeTypeCd != null and feeTypeCd != ''">
  402. and pfc.fee_type_cd = #{feeTypeCd}
  403. </if>
  404. group by bu.floor_id,t.payer_obj_id
  405. ) b
  406. where b.floor_id = a.floor_id
  407. ) oweRoomCount,
  408. (
  409. select count(1) from (
  410. select bu.floor_id,t.payer_obj_id
  411. from report_owe_fee t
  412. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  413. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  414. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  415. where
  416. 1=1
  417. and t.payer_obj_type = '3333'
  418. and t.community_id= #{communityId}
  419. and pf.community_id= #{communityId}
  420. and t.end_time &lt;= #{endDate}
  421. <if test="configIds !=null ">
  422. and t.config_id in
  423. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  424. #{item}
  425. </foreach>
  426. </if>
  427. <if test="feeTypeCd != null and feeTypeCd != ''">
  428. and pf.fee_type_cd = #{feeTypeCd}
  429. </if>
  430. group by bu.floor_id,t.payer_obj_id
  431. ) b
  432. where b.floor_id = a.floor_id
  433. ) feeRoomCount,
  434. (
  435. select ifnull(sum(t.received_amount),0.0) receivedFee
  436. from pay_fee_detail t
  437. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  438. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  439. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  440. where
  441. 1=1
  442. and bu.floor_id = a.floor_id
  443. and t.status_cd = '0'
  444. and t.community_id= a.community_id
  445. and t.create_time &gt; #{startDate}
  446. and t.create_time &lt; #{endDate}
  447. <if test="configIds !=null ">
  448. and pf.config_id in
  449. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  450. #{item}
  451. </foreach>
  452. </if>
  453. <if test="feeTypeCd != null and feeTypeCd != ''">
  454. and pf.fee_type_cd = #{feeTypeCd}
  455. </if>
  456. ) receivedFee,
  457. (
  458. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  459. from pay_fee_detail_month t
  460. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  461. where
  462. 1=1
  463. and t.obj_fpc_id = a.floor_id
  464. and t.status_cd = '0'
  465. and t.community_id= a.community_id
  466. and t.pay_fee_time &gt; #{startDate}
  467. and t.pay_fee_time &lt; #{endDate}
  468. and t.cur_month_time &gt;= #{endDate}
  469. <if test="configIds !=null ">
  470. and t.config_id in
  471. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  472. #{item}
  473. </foreach>
  474. </if>
  475. <if test="feeTypeCd != null and feeTypeCd != ''">
  476. and t.fee_type_cd = #{feeTypeCd}
  477. </if>
  478. ) preReceivedFee,
  479. (
  480. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  481. from pay_fee_detail_month t
  482. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  483. where
  484. 1=1
  485. and t.obj_fpc_id = a.floor_id
  486. and t.status_cd = '0'
  487. and t.community_id= a.community_id
  488. and t.detail_id = '-1'
  489. and t.cur_month_time &lt; #{startDate}
  490. <if test="configIds !=null ">
  491. and t.config_id in
  492. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  493. #{item}
  494. </foreach>
  495. </if>
  496. <if test="feeTypeCd != null and feeTypeCd != ''">
  497. and t.fee_type_cd = #{feeTypeCd}
  498. </if>
  499. ) hisOweFee,
  500. (
  501. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  502. from pay_fee_detail_month t
  503. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  504. where
  505. 1=1
  506. and t.obj_fpc_id = a.floor_id
  507. and t.status_cd = '0'
  508. and t.community_id= a.community_id
  509. and t.cur_month_time &gt;= #{startDate}
  510. and t.cur_month_time &lt; #{endDate}
  511. <if test="configIds !=null ">
  512. and t.config_id in
  513. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  514. #{item}
  515. </foreach>
  516. </if>
  517. <if test="feeTypeCd != null and feeTypeCd != ''">
  518. and t.fee_type_cd = #{feeTypeCd}
  519. </if>
  520. ) curReceivableFee,
  521. (
  522. select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
  523. from pay_fee_detail_month t
  524. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  525. where
  526. 1=1
  527. and t.obj_fpc_id = a.floor_id
  528. and t.status_cd = '0'
  529. and t.community_id= a.community_id
  530. and t.cur_month_time &gt;= #{startDate}
  531. and t.cur_month_time &lt; #{endDate}
  532. and t.detail_id != '-1'
  533. <if test="configIds !=null ">
  534. and t.config_id in
  535. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  536. #{item}
  537. </foreach>
  538. </if>
  539. <if test="feeTypeCd != null and feeTypeCd != ''">
  540. and t.fee_type_cd = #{feeTypeCd}
  541. </if>
  542. ) curReceivedFee,
  543. (
  544. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  545. from pay_fee_detail_month t
  546. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  547. where
  548. 1=1
  549. and t.obj_fpc_id = a.floor_id
  550. and t.status_cd = '0'
  551. and t.community_id= a.community_id
  552. and t.pay_fee_time &gt; #{startDate}
  553. and t.pay_fee_time &lt; #{endDate}
  554. and t.cur_month_time &lt; #{startDate}
  555. and t.detail_id != '-1'
  556. <if test="configIds !=null ">
  557. and t.config_id in
  558. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  559. #{item}
  560. </foreach>
  561. </if>
  562. <if test="feeTypeCd != null and feeTypeCd != ''">
  563. and t.fee_type_cd = #{feeTypeCd}
  564. </if>
  565. ) hisReceivedFee
  566. from f_floor a
  567. where 1=1
  568. and a.status_cd = '0'
  569. and a.community_id = #{communityId}
  570. order by a.seq
  571. </select>
  572. <select id="getConfigFeeSummary" parameterType="Map" resultType="Map">
  573. select a.name,
  574. (
  575. select count(1) from (
  576. select pfc.fee_type_cd,t.payer_obj_id
  577. from report_owe_fee t
  578. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  579. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  580. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  581. where
  582. 1=1
  583. and t.payer_obj_type = '3333'
  584. and t.community_id= #{communityId}
  585. and t.end_time &lt;= #{endDate}
  586. and t.amount_owed != 0
  587. <if test="configIds !=null ">
  588. and t.config_id in
  589. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  590. #{item}
  591. </foreach>
  592. </if>
  593. <if test="feeTypeCd != null and feeTypeCd != ''">
  594. and pfc.fee_type_cd = #{feeTypeCd}
  595. </if>
  596. group by pfc.fee_type_cd,t.payer_obj_id
  597. ) b
  598. where b.fee_type_cd = a.status_cd
  599. ) oweRoomCount,
  600. (
  601. select count(1) from (
  602. select pf.fee_type_cd,t.payer_obj_id
  603. from report_owe_fee t
  604. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  605. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  606. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  607. where
  608. 1=1
  609. and t.payer_obj_type = '3333'
  610. and t.community_id= #{communityId}
  611. and pf.community_id= #{communityId}
  612. and t.end_time &lt;= #{endDate}
  613. <if test="configIds !=null ">
  614. and t.config_id in
  615. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  616. #{item}
  617. </foreach>
  618. </if>
  619. <if test="feeTypeCd != null and feeTypeCd != ''">
  620. and pf.fee_type_cd = #{feeTypeCd}
  621. </if>
  622. group by pf.fee_type_cd,t.payer_obj_id
  623. ) b
  624. where b.fee_type_cd = a.status_cd
  625. ) feeRoomCount,
  626. (
  627. select ifnull(sum(t.received_amount),0.0) receivedFee
  628. from pay_fee_detail t
  629. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  630. <if test="floorId != null and floorId != ''">
  631. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  632. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  633. </if>
  634. where
  635. 1=1
  636. <if test="floorId != null and floorId != ''">
  637. and bu.floor_id = #{floorId}
  638. </if>
  639. and t.status_cd = '0'
  640. and t.community_id= #{communityId}
  641. and t.create_time &gt; #{startDate}
  642. and t.create_time &lt; #{endDate}
  643. <if test="configIds !=null ">
  644. and pf.config_id in
  645. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  646. #{item}
  647. </foreach>
  648. </if>
  649. and pf.fee_type_cd = a.status_cd
  650. ) receivedFee,
  651. (
  652. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  653. from pay_fee_detail_month t
  654. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  655. where
  656. 1=1
  657. <if test="floorId != null and floorId != ''">
  658. and t.obj_fpc_id = #{floorId}
  659. </if>
  660. and t.status_cd = '0'
  661. and t.community_id= #{communityId}
  662. and t.pay_fee_time &gt; #{startDate}
  663. and t.pay_fee_time &lt; #{endDate}
  664. and t.cur_month_time &gt;= #{endDate}
  665. and t.detail_id != '-1'
  666. <if test="configIds !=null ">
  667. and t.config_id in
  668. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  669. #{item}
  670. </foreach>
  671. </if>
  672. and t.fee_type_cd = a.status_cd
  673. ) preReceivedFee,
  674. (
  675. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  676. from pay_fee_detail_month t
  677. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  678. where
  679. 1=1
  680. <if test="floorId != null and floorId != ''">
  681. and t.obj_fpc_id = #{floorId}
  682. </if>
  683. and t.status_cd = '0'
  684. and t.community_id= #{communityId}
  685. and t.detail_id = '-1'
  686. and t.cur_month_time &lt; #{startDate}
  687. <if test="configIds !=null ">
  688. and t.config_id in
  689. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  690. #{item}
  691. </foreach>
  692. </if>
  693. and t.fee_type_cd = a.status_cd
  694. ) hisOweFee,
  695. (
  696. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  697. from pay_fee_detail_month t
  698. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  699. where
  700. 1=1
  701. <if test="floorId != null and floorId != ''">
  702. and t.obj_fpc_id = #{floorId}
  703. </if>
  704. and t.status_cd = '0'
  705. and t.community_id= #{communityId}
  706. and t.cur_month_time &gt;= #{startDate}
  707. and t.cur_month_time &lt; #{endDate}
  708. <if test="configIds !=null ">
  709. and t.config_id in
  710. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  711. #{item}
  712. </foreach>
  713. </if>
  714. and t.fee_type_cd = a.status_cd
  715. ) curReceivableFee,
  716. (
  717. select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
  718. from pay_fee_detail_month t
  719. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  720. where
  721. 1=1
  722. <if test="floorId != null and floorId != ''">
  723. and t.obj_fpc_id = #{floorId}
  724. </if>
  725. and t.status_cd = '0'
  726. and t.community_id= #{communityId}
  727. and t.cur_month_time &gt;= #{startDate}
  728. and t.cur_month_time &lt; #{endDate}
  729. and t.detail_id != '-1'
  730. <if test="configIds !=null ">
  731. and t.config_id in
  732. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  733. #{item}
  734. </foreach>
  735. </if>
  736. and t.fee_type_cd = a.status_cd
  737. ) curReceivedFee,
  738. (
  739. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  740. from pay_fee_detail_month t
  741. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  742. where
  743. 1=1
  744. <if test="floorId != null and floorId != ''">
  745. and t.obj_fpc_id = #{floorId}
  746. </if>
  747. and t.status_cd = '0'
  748. and t.community_id= #{communityId}
  749. and t.pay_fee_time &gt; #{startDate}
  750. and t.pay_fee_time &lt; #{endDate}
  751. and t.cur_month_time &lt; #{startDate}
  752. and t.detail_id != '-1'
  753. <if test="configIds !=null ">
  754. and t.config_id in
  755. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  756. #{item}
  757. </foreach>
  758. </if>
  759. and t.fee_type_cd = a.status_cd
  760. ) hisReceivedFee
  761. from t_dict a
  762. where 1=1
  763. and a.table_name = 'pay_fee_config'
  764. and a.table_columns = 'fee_type_cd'
  765. </select>
  766. <select id="getObjFeeSummaryCount" parameterType="Map" resultType="Map">
  767. select count(1) feeRoomCount
  768. from
  769. (
  770. select t.payer_ob_id
  771. from report_owe_fee t
  772. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  773. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  774. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  775. where
  776. 1=1
  777. and t.payer_obj_type = '3333'
  778. and t.community_id= #{communityId}
  779. and pf.community_id= #{communityId}
  780. group by a.payer_ob_id
  781. ) b
  782. </select>
  783. <!-- 查询房屋费用明细表-->
  784. <select id="getObjFeeSummary" parameterType="Map" resultType="Map">
  785. select
  786. a.obj_id objId,pfc.fee_type_cd feeTypeCd,
  787. (
  788. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  789. from pay_fee_detail_month t
  790. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  791. where t.status_cd = '0'
  792. and t.detail_id = '-1'
  793. and t.community_id= a.community_id
  794. and t.obj_id = a.obj_id
  795. and t.fee_type_cd = a.fee_type_cd
  796. and t.cur_month_time &lt; #{endDate}
  797. ) oweFee,
  798. (
  799. select ifnull(sum(t.received_amount),0.0) receivedFee
  800. from pay_fee_detail t
  801. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  802. inner join pay_fee_config pfc1 on pfc1.config_id = pf.config_id and pfc1.status_cd = '0'
  803. where pf.payer_obj_id = a.obj_id
  804. and t.status_cd = '0'
  805. and t.community_id= a.community_id
  806. and pfc1.fee_type_cd = pfc.fee_type_cd
  807. and t.create_time &gt; #{startDate}
  808. and t.create_time &lt; #{endDate}
  809. ) receivedFee
  810. from pay_fee_detail_month a
  811. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  812. where a.obj_id in
  813. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  814. #{item}
  815. </foreach>
  816. group by a.obj_id,pfc.fee_type_cd,a.community_id
  817. </select>
  818. <!-- 查询业主费用明细表 -->
  819. <select id="getOwnerFeeSummary" parameterType="Map" resultType="Map">
  820. select
  821. a.owner_id ownerId,GROUP_CONCAT(a.obj_name) objName,pfc.fee_type_cd feeTypeCd,
  822. (
  823. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  824. from pay_fee_detail_month t
  825. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  826. where 1=1
  827. and t.status_cd = '0'
  828. and t.detail_id = '-1'
  829. and t.community_id= a.community_id
  830. and t.owner_id = a.owner_id
  831. and t.fee_type_cd = a.fee_type_cd
  832. and t.cur_month_time &lt; #{endDate}
  833. ) oweFee,
  834. (
  835. select ifnull(sum(t.received_amount),0.0) receivedFee
  836. from pay_fee_detail_month t
  837. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  838. where t.owner_id = a.owner_id
  839. and t.status_cd = '0'
  840. and t.community_id= a.community_id
  841. and t.fee_type_cd = a.fee_type_cd
  842. and t.pay_fee_time &gt; #{startDate}
  843. and t.pay_fee_time &lt; #{endDate}
  844. ) receivedFee
  845. from pay_fee_detail_month a
  846. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  847. where a.owner_id in
  848. <foreach collection="ownerIds" item="item" index="index" open="(" close=")" separator=",">
  849. #{item}
  850. </foreach>
  851. group by a.owner_id,pfc.fee_type_cd,a.community_id
  852. </select>
  853. <!-- 优惠费用-->
  854. <select id="getDiscountFee" parameterType="Map" resultType="Map">
  855. select ifnull(SUM(t.discount_amount),0.0) discountFee
  856. from pay_fee_detail_month t
  857. where 1=1
  858. and t.status_cd = '0'
  859. and t.detail_id != '-1'
  860. and t.discount_amount &gt; 0
  861. and t.community_id= #{communityId}
  862. and t.cur_month_time &gt; #{startDate}
  863. and t.cur_month_time &lt; #{endDate}
  864. </select>
  865. <!-- 滞纳金费用-->
  866. <select id="getLateFee" parameterType="Map" resultType="Map">
  867. select ifnull(SUM(t.discount_price),0.0) lateFee
  868. from pay_fee_detail_discount t
  869. inner join fee_discount fd on t.discount_id = fd.discount_id
  870. where t.status_cd = '0'
  871. and fd.discount_type = '2002'
  872. and t.community_id = #{communityId}
  873. and t.create_time &gt; #{startDate}
  874. and t.create_time &lt; #{endDate}
  875. </select>
  876. <!-- 查询预存账户-->
  877. <select id="getPrestoreAccount" parameterType="Map" resultType="Map">
  878. select ifnull(SUM(t.amount),0.0) prestoreAccount
  879. from account_detail t
  880. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  881. where 1=1
  882. and t.obj_type = '6006'
  883. and ac.acct_type = '2003'
  884. and t.detail_type = '1001'
  885. and ac.part_id= #{communityId}
  886. and t.create_time &gt; #{startDate}
  887. and t.create_time &lt; #{endDate}
  888. </select>
  889. <!-- 查询账户扣款-->
  890. <select id="getWithholdAccount" parameterType="Map" resultType="Map">
  891. select ifnull(SUM(t.amount),0.0) withholdAccount
  892. from account_detail t
  893. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  894. where 1=1
  895. and t.obj_type = '6006'
  896. and ac.acct_type = '2003'
  897. and t.detail_type = '2002'
  898. and ac.part_id= #{communityId}
  899. and t.create_time &gt; #{startDate}
  900. and t.create_time &lt; #{endDate}
  901. </select>
  902. <!-- 查询临时车费 -->
  903. <select id="getTempCarFee" parameterType="Map" resultType="Map">
  904. select ifnull(sum(t.pay_charge),0.0) tempCarFee
  905. from car_inout_payment t
  906. where 1=1
  907. and t.community_id = #{communityId}
  908. and t.create_time &gt; #{startDate}
  909. and t.create_time &lt; #{endDate}
  910. and t.status_cd = '0'
  911. </select>
  912. <!-- 押金退款金额 -->
  913. <select id="geRefundDeposit" parameterType="Map" resultType="Map">
  914. select ifnull(sum(t.received_amount),0.0) refundDeposit from return_pay_fee t
  915. where t.fee_type_cd = '888800010006'
  916. and t.status_cd = '0'
  917. and t.state = '1001'
  918. and t.community_id = #{communityId}
  919. and t.create_time &gt; #{startDate}
  920. and t.create_time &lt; #{endDate}
  921. </select>
  922. <!-- 退款订单数 -->
  923. <select id="geRefundOrderCount" parameterType="Map" resultType="Map">
  924. select count(1) refundOrderCount from return_pay_fee t
  925. where t.status_cd = '0'
  926. and t.state = '1001'
  927. and t.community_id = #{communityId}
  928. and t.create_time &gt; #{startDate}
  929. and t.create_time &lt; #{endDate}
  930. </select>
  931. <!-- 退款金额 -->
  932. <select id="geRefundFee" parameterType="Map" resultType="Map">
  933. select ifnull(sum(t.received_amount),0.0) refundFee from return_pay_fee t
  934. where t.status_cd = '0'
  935. and t.state = '1001'
  936. and t.community_id = #{communityId}
  937. and t.create_time &gt; #{startDate}
  938. and t.create_time &lt; #{endDate}
  939. </select>
  940. <!-- 查询充电费用-->
  941. <select id="getChargeFee" parameterType="Map" resultType="Map">
  942. select ifnull(sum(t.amount),0.0) chargeFee
  943. from charge_machine_order t
  944. where t.status_cd = '0'
  945. and t.community_id = #{communityId}
  946. and t.create_time &gt; #{startDate}
  947. and t.create_time &lt; #{endDate}
  948. </select>
  949. <!-- 查询楼栋实收-->
  950. <select id="getReceivedFeeByFloor" parameterType="Map" resultType="Map">
  951. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  952. (
  953. select count(1)
  954. from building_room br
  955. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  956. where
  957. 1=1
  958. and a.status_cd = '0'
  959. and br.status_cd = '0'
  960. and bu.floor_id = a.floor_id
  961. ) roomCount,
  962. (
  963. select count(1) from (
  964. select bu.floor_id,br.room_id
  965. from pay_fee_detail t
  966. INNER JOIN pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.payer_obj_type='3333' and pf1.status_cd = '0'
  967. inner JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  968. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  969. where
  970. 1=1
  971. and t.status_cd = '0'
  972. and t.community_id = #{communityId}
  973. and t.create_time &gt; #{startDate}
  974. and t.create_time &lt; #{endDate}
  975. group by bu.floor_id,br.room_id
  976. ) b
  977. where b.floor_id = a.floor_id
  978. ) feeRoomCount,
  979. (
  980. select ifnull(sum(t.received_amount),0.0) receivedFee
  981. from pay_fee_detail t
  982. INNER JOIN pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.payer_obj_type='3333' and pf1.status_cd = '0'
  983. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  984. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  985. where
  986. 1=1
  987. and bu.floor_id = a.floor_id
  988. and t.status_cd = '0'
  989. and t.community_id = #{communityId}
  990. and t.create_time &gt; #{startDate}
  991. and t.create_time &lt; #{endDate}
  992. and pf1.fee_type_cd = td.status_cd
  993. ) receivedFee
  994. from f_floor a
  995. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  996. where 1=1
  997. and a.status_cd = '0'
  998. and a.community_id = #{communityId}
  999. order by a.seq
  1000. </select>
  1001. <!-- 按缴费方式统计 -->
  1002. <select id="getReceivedFeeByPrimeRate" parameterType="Map" resultType="Map">
  1003. select td.`name`,td.status_cd primeRate,ifnull(SUM(t.received_amount),0) receivedAmount
  1004. from t_dict td
  1005. left join pay_fee_detail t on td.status_cd = t.prime_rate and t.status_cd = '0'
  1006. where
  1007. 1=1
  1008. and td.table_name = 'pay_fee_detail'
  1009. and td.table_columns = 'prime_rate'
  1010. and t.community_id = #{communityId}
  1011. and t.create_time &gt; #{startDate}
  1012. and t.create_time &lt; #{endDate}
  1013. group by td.status_cd,td.`name`
  1014. </select>
  1015. <!-- 按楼栋统计欠费 -->
  1016. <select id="getOweFeeByFloor" parameterType="Map" resultType="Map">
  1017. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  1018. (
  1019. select count(1)
  1020. from building_room br
  1021. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  1022. where
  1023. 1=1
  1024. and a.status_cd = '0'
  1025. and br.status_cd = '0'
  1026. and bu.floor_id = a.floor_id
  1027. ) roomCount,
  1028. (
  1029. select count(1) from (
  1030. select bu.floor_id,br.room_id
  1031. from report_owe_fee t
  1032. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  1033. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  1034. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1035. where
  1036. 1=1
  1037. and t.payer_obj_type = '3333'
  1038. and t.community_id= #{communityId}
  1039. and pf.community_id= #{communityId}
  1040. and t.end_time &lt; #{endDate}
  1041. group by bu.floor_id,br.room_id
  1042. ) b
  1043. where b.floor_id = a.floor_id
  1044. ) feeRoomCount,
  1045. (
  1046. select count(1) from (
  1047. select bu.floor_id,br.room_id
  1048. from report_owe_fee t
  1049. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  1050. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1051. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1052. where
  1053. 1=1
  1054. and t.payer_obj_type = '3333'
  1055. and t.community_id= #{communityId}
  1056. and t.end_time &lt; #{endDate}
  1057. and t.amount_owed != 0
  1058. group by bu.floor_id,br.room_id
  1059. ) b
  1060. where b.floor_id = a.floor_id
  1061. ) oweRoomCount,
  1062. (
  1063. select ifnull(sum(t.amount_owed),0.0) oweFee
  1064. from report_owe_fee t
  1065. left join pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.status_cd = '0'
  1066. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  1067. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1068. where
  1069. 1=1
  1070. and bu.floor_id = a.floor_id
  1071. and t.community_id = #{communityId}
  1072. and t.amount_owed > 0
  1073. and pf1.fee_type_cd = td.status_cd
  1074. ) oweFee
  1075. from f_floor a
  1076. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  1077. where 1=1
  1078. and a.status_cd = '0'
  1079. and a.community_id = #{communityId}
  1080. order by a.seq
  1081. </select>
  1082. <!-- 对象欠费 -->
  1083. <select id="getObjOweFee" parameterType="Map" resultType="Map">
  1084. select t.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,t.fee_name feeName,
  1085. DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,DATE_FORMAT(t.deadline_time,'%Y-%m-%d') deadlineTime,t.amount_owed amountOwed
  1086. from report_owe_fee t
  1087. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1088. where t.amount_owed > 0
  1089. and t.payer_obj_type = '3333'
  1090. and t.community_id = #{communityId}
  1091. and t.payer_obj_id in
  1092. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1093. #{item}
  1094. </foreach>
  1095. </select>
  1096. <!-- 对象实收 -->
  1097. <select id="getObjReceivedFee" parameterType="Map" resultType="Map">
  1098. select pf.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,pfc.fee_name feeName,
  1099. DATE_FORMAT(t.start_time,'%Y-%m-%d') startTime,DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,t.received_amount receivedAmount
  1100. from pay_fee_detail t
  1101. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1102. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1103. where 1=1
  1104. and pf.payer_obj_type = '3333'
  1105. and t.community_id = #{communityId}
  1106. and t.create_time &gt; #{startDate}
  1107. and t.create_time &lt; #{endDate}
  1108. and pf.payer_obj_id in
  1109. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1110. #{item}
  1111. </foreach>
  1112. </select>
  1113. <!-- 已收房屋数 -->
  1114. <select id="getReceivedRoomCount" parameterType="Map" resultType="Map">
  1115. select count(DISTINCT pf.payer_obj_id) count from pay_fee_detail t
  1116. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1117. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1118. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1119. where
  1120. 1=1
  1121. and bu.floor_id = #{floorId}
  1122. and t.community_id = #{communityId}
  1123. and pf.community_id= #{communityId}
  1124. and t.create_time &gt; #{startDate}
  1125. and t.create_time &lt; #{endDate}
  1126. <if test="feeTypeCd != null and feeTypeCd != ''">
  1127. and pf.fee_type_cd = #{feeTypeCd}
  1128. </if>
  1129. </select>
  1130. <!-- 已收房屋金额 -->
  1131. <select id="getReceivedRoomAmount" parameterType="Map" resultType="Map">
  1132. select ifnull(sum(t.received_amount),0) amount from pay_fee_detail t
  1133. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1134. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1135. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1136. where
  1137. bu.floor_id = #{floorId}
  1138. and t.community_id = #{communityId}
  1139. and pf.community_id= #{communityId}
  1140. and t.create_time &gt; #{startDate}
  1141. and t.create_time &lt; #{endDate}
  1142. <if test="feeTypeCd != null and feeTypeCd != ''">
  1143. and pf.fee_type_cd = #{feeTypeCd}
  1144. </if>
  1145. </select>
  1146. <!-- 欠费清缴户 -->
  1147. <select id="getHisOweReceivedRoomCount" parameterType="Map" resultType="Map">
  1148. select count(DISTINCT t.obj_id) count
  1149. from pay_fee_detail_month t
  1150. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1151. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1152. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1153. where 1=1
  1154. and bu.floor_id = #{floorId}
  1155. and t.community_id = #{communityId}
  1156. and pf.community_id= #{communityId}
  1157. and t.pay_fee_time &gt; #{startDate}
  1158. and t.pay_fee_time &lt; #{endDate}
  1159. and t.cur_month_time &lt; #{hisDate}
  1160. <if test="feeTypeCd != null and feeTypeCd != ''">
  1161. and pf.fee_type_cd = #{feeTypeCd}
  1162. </if>
  1163. and t.detail_id != '-1'
  1164. and t.status_cd = '0'
  1165. </select>
  1166. <!-- 欠费清缴金额 -->
  1167. <select id="getHisOweReceivedRoomAmount" parameterType="Map" resultType="Map">
  1168. select ifnull(sum(t.received_amount),0) amount
  1169. from pay_fee_detail_month t
  1170. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1171. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1172. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1173. where 1=1
  1174. and bu.floor_id = #{floorId}
  1175. and t.community_id = #{communityId}
  1176. and pf.community_id= #{communityId}
  1177. and t.pay_fee_time &gt; #{startDate}
  1178. and t.pay_fee_time &lt; #{endDate}
  1179. and t.cur_month_time &lt; #{hisDate}
  1180. <if test="feeTypeCd != null and feeTypeCd != ''">
  1181. and pf.fee_type_cd = #{feeTypeCd}
  1182. </if>
  1183. and t.detail_id != '-1'
  1184. and t.status_cd = '0'
  1185. </select>
  1186. <!-- 查询月收入数据 -->
  1187. <select id="getMonthReceivedDetailCount" parameterType="Map" resultType="Map">
  1188. select count(1) count
  1189. from pay_fee_detail_month t
  1190. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1191. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1192. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1193. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1194. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1195. left join pay_fee_detail_month pfdm on t.fee_id = pfdm.fee_id and t.detail_year = pfdm.detail_year and t.detail_month = pfdm.detail_month and pfdm.detail_id = '-1'
  1196. where 1=1
  1197. and pfdm.month_id is null
  1198. and t.status_cd = '0'
  1199. and t.cur_month_time &gt;= #{startDate}
  1200. and t.cur_month_time &lt; #{endDate}
  1201. and t.detail_id != '-1'
  1202. and t.community_id = #{communityId}
  1203. and pf.community_id= #{communityId}
  1204. <if test="feeTypeCd != null and feeTypeCd != ''">
  1205. and pf.fee_type_cd = #{feeTypeCd}
  1206. </if>
  1207. <if test="floorId != null and floorId != ''">
  1208. and bu.floor_id = #{floorId}
  1209. </if>
  1210. <if test="objName != null and objName != ''">
  1211. and t.obj_name like concat('%',#{objName},'%')
  1212. </if>
  1213. <if test="ownerName != null and ownerName != ''">
  1214. and t.owner_name like concat('%',#{ownerName},'%')
  1215. </if>
  1216. <if test="link != null and link != ''">
  1217. and t.link = #{link}
  1218. </if>
  1219. </select>
  1220. <!-- 月实收 查询-->
  1221. <select id="getMonthReceivedDetailInfo" parameterType="Map" resultType="Map">
  1222. select concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) objName,t.owner_name ownerName,t.link,t.fee_name feeName, pfd.start_time startTime,pfd.end_time endTime,
  1223. pfd.pay_order_id payOrderId,pfd.cashier_name cashierName,
  1224. t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfd.create_time createTime,concat(t.detail_year,'-',t.detail_month) curYearMonth
  1225. from pay_fee_detail_month t
  1226. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1227. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1228. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1229. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1230. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1231. left join pay_fee_detail_month pfdm on t.fee_id = pfdm.fee_id and t.detail_year = pfdm.detail_year and t.detail_month = pfdm.detail_month and pfdm.detail_id = '-1'
  1232. where 1=1
  1233. and pfdm.month_id is null
  1234. and t.status_cd = '0'
  1235. and t.cur_month_time &gt;= #{startDate}
  1236. and t.cur_month_time &lt; #{endDate}
  1237. and t.detail_id != '-1'
  1238. and t.community_id = #{communityId}
  1239. and pf.community_id= #{communityId}
  1240. <if test="feeTypeCd != null and feeTypeCd != ''">
  1241. and pf.fee_type_cd = #{feeTypeCd}
  1242. </if>
  1243. <if test="floorId != null and floorId != ''">
  1244. and bu.floor_id = #{floorId}
  1245. </if>
  1246. <if test="objName != null and objName != ''">
  1247. and t.obj_name like concat('%',#{objName},'%')
  1248. </if>
  1249. <if test="ownerName != null and ownerName != ''">
  1250. and t.owner_name like concat('%',#{ownerName},'%')
  1251. </if>
  1252. <if test="link != null and link != ''">
  1253. and t.link = #{link}
  1254. </if>
  1255. order by t.obj_name,t.fee_name,t.detail_year,t.detail_month
  1256. <if test="page != -1 and page != null ">
  1257. limit #{page}, #{row}
  1258. </if>
  1259. </select>
  1260. <!-- 月实收总金额 查询-->
  1261. <select id="getMonthReceivedDetailAmount" parameterType="Map" resultType="Map">
  1262. select ifnull(sum(t.received_amount),0.0) amount
  1263. from pay_fee_detail_month t
  1264. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1265. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1266. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1267. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1268. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1269. where 1=1
  1270. and t.status_cd = '0'
  1271. and t.cur_month_time &gt;= #{startDate}
  1272. and t.cur_month_time &lt; #{endDate}
  1273. and t.detail_id != '-1'
  1274. and t.community_id = #{communityId}
  1275. and pf.community_id= #{communityId}
  1276. <if test="feeTypeCd != null and feeTypeCd != ''">
  1277. and pf.fee_type_cd = #{feeTypeCd}
  1278. </if>
  1279. <if test="floorId != null and floorId != ''">
  1280. and bu.floor_id = #{floorId}
  1281. </if>
  1282. <if test="objName != null and objName != ''">
  1283. and t.obj_name like concat('%',#{objName},'%')
  1284. </if>
  1285. <if test="ownerName != null and ownerName != ''">
  1286. and t.owner_name like concat('%',#{ownerName},'%')
  1287. </if>
  1288. <if test="link != null and link != ''">
  1289. and t.link = #{link}
  1290. </if>
  1291. </select>
  1292. <!-- 查询月欠费数据 -->
  1293. <select id="getMonthOweDetailCount" parameterType="Map" resultType="Map">
  1294. select count(1) count
  1295. from pay_fee_detail_month t
  1296. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1297. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1298. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1299. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1300. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1301. where 1=1
  1302. and t.status_cd = '0'
  1303. and t.cur_month_time &gt;= #{startDate}
  1304. and t.cur_month_time &lt; #{endDate}
  1305. and t.detail_id = '-1'
  1306. and t.community_id = #{communityId}
  1307. and pf.community_id= #{communityId}
  1308. and t.receivable_amount &gt; 0
  1309. <if test="feeTypeCd != null and feeTypeCd != ''">
  1310. and pf.fee_type_cd = #{feeTypeCd}
  1311. </if>
  1312. <if test="floorId != null and floorId != ''">
  1313. and bu.floor_id = #{floorId}
  1314. </if>
  1315. <if test="objName != null and objName != ''">
  1316. and t.obj_name like concat('%',#{objName},'%')
  1317. </if>
  1318. <if test="ownerName != null and ownerName != ''">
  1319. and t.owner_name like concat('%',#{ownerName},'%')
  1320. </if>
  1321. <if test="link != null and link != ''">
  1322. and t.link = #{link}
  1323. </if>
  1324. </select>
  1325. <!-- 月实收 查询-->
  1326. <select id="getMonthOweDetailInfo" parameterType="Map" resultType="Map">
  1327. select concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) objName,t.owner_name ownerName,t.link,t.fee_name feeName, pf.end_time startTime,t.deadline_time endTime,
  1328. t.receivable_amount receivableAmount,t.received_amount receivedAmount,concat(t.detail_year,'-',t.detail_month) curYearMonth
  1329. from pay_fee_detail_month t
  1330. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1331. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1332. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1333. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1334. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1335. where 1=1
  1336. and t.status_cd = '0'
  1337. and t.cur_month_time &gt;= #{startDate}
  1338. and t.cur_month_time &lt; #{endDate}
  1339. and t.detail_id = '-1'
  1340. and t.receivable_amount &gt; 0
  1341. and t.community_id = #{communityId}
  1342. and pf.community_id= #{communityId}
  1343. <if test="feeTypeCd != null and feeTypeCd != ''">
  1344. and pf.fee_type_cd = #{feeTypeCd}
  1345. </if>
  1346. <if test="floorId != null and floorId != ''">
  1347. and bu.floor_id = #{floorId}
  1348. </if>
  1349. <if test="objName != null and objName != ''">
  1350. and t.obj_name like concat('%',#{objName},'%')
  1351. </if>
  1352. <if test="ownerName != null and ownerName != ''">
  1353. and t.owner_name like concat('%',#{ownerName},'%')
  1354. </if>
  1355. <if test="link != null and link != ''">
  1356. and t.link = #{link}
  1357. </if>
  1358. order by t.obj_name,t.fee_name,t.detail_year,t.detail_month
  1359. <if test="page != -1 and page != null ">
  1360. limit #{page}, #{row}
  1361. </if>
  1362. </select>
  1363. <!-- 月欠费总金额 查询-->
  1364. <select id="getMonthOweDetailAmount" parameterType="Map" resultType="Map">
  1365. select ifnull(sum(t.receivable_amount),0.0) amount
  1366. from pay_fee_detail_month t
  1367. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1368. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1369. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1370. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1371. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1372. where 1=1
  1373. and t.status_cd = '0'
  1374. and t.cur_month_time &gt;= #{startDate}
  1375. and t.cur_month_time &lt; #{endDate}
  1376. and t.detail_id = '-1'
  1377. and t.community_id = #{communityId}
  1378. and pf.community_id= #{communityId}
  1379. and t.receivable_amount &gt; 0
  1380. <if test="feeTypeCd != null and feeTypeCd != ''">
  1381. and pf.fee_type_cd = #{feeTypeCd}
  1382. </if>
  1383. <if test="floorId != null and floorId != ''">
  1384. and bu.floor_id = #{floorId}
  1385. </if>
  1386. <if test="objName != null and objName != ''">
  1387. and t.obj_name like concat('%',#{objName},'%')
  1388. </if>
  1389. <if test="ownerName != null and ownerName != ''">
  1390. and t.owner_name like concat('%',#{ownerName},'%')
  1391. </if>
  1392. <if test="link != null and link != ''">
  1393. and t.link = #{link}
  1394. </if>
  1395. </select>
  1396. </mapper>