ReportFeeStatisticsServiceDaoImplMapper.xml 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  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. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  462. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  463. where
  464. 1=1
  465. and bu.floor_id = a.floor_id
  466. and t.status_cd = '0'
  467. and t.community_id= a.community_id
  468. and t.pay_fee_time &gt; #{startDate}
  469. and t.pay_fee_time &lt; #{endDate}
  470. and t.cur_month_time &gt;= #{endDate}
  471. <if test="configIds !=null ">
  472. and t.config_id in
  473. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  474. #{item}
  475. </foreach>
  476. </if>
  477. <if test="feeTypeCd != null and feeTypeCd != ''">
  478. and pf.fee_type_cd = #{feeTypeCd}
  479. </if>
  480. ) preReceivedFee,
  481. (
  482. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  483. from pay_fee_detail_month t
  484. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  485. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  486. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  487. where
  488. 1=1
  489. and bu.floor_id = a.floor_id
  490. and t.status_cd = '0'
  491. and t.community_id= a.community_id
  492. and t.detail_id = '-1'
  493. and t.cur_month_time &lt; #{startDate}
  494. <if test="configIds !=null ">
  495. and t.config_id in
  496. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  497. #{item}
  498. </foreach>
  499. </if>
  500. <if test="feeTypeCd != null and feeTypeCd != ''">
  501. and pf.fee_type_cd = #{feeTypeCd}
  502. </if>
  503. ) hisOweFee,
  504. (
  505. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  506. from pay_fee_detail_month t
  507. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  508. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  509. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  510. where
  511. 1=1
  512. and bu.floor_id = a.floor_id
  513. and t.status_cd = '0'
  514. and t.community_id= a.community_id
  515. and t.cur_month_time &gt;= #{startDate}
  516. and t.cur_month_time &lt; #{endDate}
  517. <if test="configIds !=null ">
  518. and t.config_id in
  519. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  520. #{item}
  521. </foreach>
  522. </if>
  523. <if test="feeTypeCd != null and feeTypeCd != ''">
  524. and pf.fee_type_cd = #{feeTypeCd}
  525. </if>
  526. ) curReceivableFee,
  527. (
  528. select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
  529. from pay_fee_detail_month t
  530. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  531. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  532. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  533. where
  534. 1=1
  535. and bu.floor_id = a.floor_id
  536. and t.status_cd = '0'
  537. and t.community_id= a.community_id
  538. and t.cur_month_time &gt;= #{startDate}
  539. and t.cur_month_time &lt; #{endDate}
  540. and t.detail_id != '-1'
  541. <if test="configIds !=null ">
  542. and t.config_id in
  543. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  544. #{item}
  545. </foreach>
  546. </if>
  547. <if test="feeTypeCd != null and feeTypeCd != ''">
  548. and pf.fee_type_cd = #{feeTypeCd}
  549. </if>
  550. ) curReceivedFee,
  551. (
  552. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  553. from pay_fee_detail_month t
  554. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  555. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  556. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  557. where
  558. 1=1
  559. and bu.floor_id = a.floor_id
  560. and t.status_cd = '0'
  561. and t.community_id= a.community_id
  562. and t.pay_fee_time &gt; #{startDate}
  563. and t.pay_fee_time &lt; #{endDate}
  564. and t.cur_month_time &lt; #{startDate}
  565. and t.detail_id != '-1'
  566. <if test="configIds !=null ">
  567. and t.config_id in
  568. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  569. #{item}
  570. </foreach>
  571. </if>
  572. <if test="feeTypeCd != null and feeTypeCd != ''">
  573. and pf.fee_type_cd = #{feeTypeCd}
  574. </if>
  575. ) hisReceivedFee
  576. from f_floor a
  577. where 1=1
  578. and a.status_cd = '0'
  579. and a.community_id = #{communityId}
  580. order by a.seq
  581. </select>
  582. <select id="getConfigFeeSummary" parameterType="Map" resultType="Map">
  583. select a.name,
  584. (
  585. select count(1) from (
  586. select pfc.fee_type_cd,t.payer_obj_id
  587. from report_owe_fee t
  588. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  589. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  590. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  591. where
  592. 1=1
  593. and t.payer_obj_type = '3333'
  594. and t.community_id= #{communityId}
  595. and t.end_time &lt;= #{endDate}
  596. and t.amount_owed != 0
  597. <if test="configIds !=null ">
  598. and t.config_id in
  599. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  600. #{item}
  601. </foreach>
  602. </if>
  603. <if test="feeTypeCd != null and feeTypeCd != ''">
  604. and pfc.fee_type_cd = #{feeTypeCd}
  605. </if>
  606. group by pfc.fee_type_cd,t.payer_obj_id
  607. ) b
  608. where b.fee_type_cd = a.status_cd
  609. ) oweRoomCount,
  610. (
  611. select count(1) from (
  612. select pf.fee_type_cd,t.payer_obj_id
  613. from report_owe_fee t
  614. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  615. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  616. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  617. where
  618. 1=1
  619. and t.payer_obj_type = '3333'
  620. and t.community_id= #{communityId}
  621. and pf.community_id= #{communityId}
  622. and t.end_time &lt;= #{endDate}
  623. <if test="configIds !=null ">
  624. and t.config_id in
  625. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  626. #{item}
  627. </foreach>
  628. </if>
  629. <if test="feeTypeCd != null and feeTypeCd != ''">
  630. and pf.fee_type_cd = #{feeTypeCd}
  631. </if>
  632. group by pf.fee_type_cd,t.payer_obj_id
  633. ) b
  634. where b.fee_type_cd = a.status_cd
  635. ) feeRoomCount,
  636. (
  637. select ifnull(sum(t.received_amount),0.0) receivedFee
  638. from pay_fee_detail t
  639. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  640. <if test="floorId != null and floorId != ''">
  641. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  642. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  643. </if>
  644. where
  645. 1=1
  646. <if test="floorId != null and floorId != ''">
  647. and bu.floor_id = #{floorId}
  648. </if>
  649. and t.status_cd = '0'
  650. and t.community_id= #{communityId}
  651. and t.create_time &gt; #{startDate}
  652. and t.create_time &lt; #{endDate}
  653. <if test="configIds !=null ">
  654. and pf.config_id in
  655. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  656. #{item}
  657. </foreach>
  658. </if>
  659. and pf.fee_type_cd = a.status_cd
  660. ) receivedFee,
  661. (
  662. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  663. from pay_fee_detail_month t
  664. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  665. <if test="floorId != null and floorId != ''">
  666. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  667. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  668. </if>
  669. where
  670. 1=1
  671. <if test="floorId != null and floorId != ''">
  672. and bu.floor_id = #{floorId}
  673. </if>
  674. and t.status_cd = '0'
  675. and t.community_id= #{communityId}
  676. and t.pay_fee_time &gt; #{startDate}
  677. and t.pay_fee_time &lt; #{endDate}
  678. and t.cur_month_time &gt;= #{endDate}
  679. and t.detail_id != '-1'
  680. <if test="configIds !=null ">
  681. and t.config_id in
  682. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  683. #{item}
  684. </foreach>
  685. </if>
  686. and pf.fee_type_cd = a.status_cd
  687. ) preReceivedFee,
  688. (
  689. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  690. from pay_fee_detail_month t
  691. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  692. <if test="floorId != null and floorId != ''">
  693. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  694. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  695. </if>
  696. where
  697. 1=1
  698. <if test="floorId != null and floorId != ''">
  699. and bu.floor_id = #{floorId}
  700. </if>
  701. and t.status_cd = '0'
  702. and t.community_id= #{communityId}
  703. and t.detail_id = '-1'
  704. and t.cur_month_time &lt; #{startDate}
  705. <if test="configIds !=null ">
  706. and t.config_id in
  707. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  708. #{item}
  709. </foreach>
  710. </if>
  711. and pf.fee_type_cd = a.status_cd
  712. ) hisOweFee,
  713. (
  714. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  715. from pay_fee_detail_month t
  716. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  717. <if test="floorId != null and floorId != ''">
  718. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  719. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  720. </if>
  721. where
  722. 1=1
  723. <if test="floorId != null and floorId != ''">
  724. and bu.floor_id = #{floorId}
  725. </if>
  726. and t.status_cd = '0'
  727. and t.community_id= #{communityId}
  728. and t.cur_month_time &gt;= #{startDate}
  729. and t.cur_month_time &lt; #{endDate}
  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 pf.fee_type_cd = a.status_cd
  737. ) curReceivableFee,
  738. (
  739. select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
  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. <if test="floorId != null and floorId != ''">
  743. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  744. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  745. </if>
  746. where
  747. 1=1
  748. <if test="floorId != null and floorId != ''">
  749. and bu.floor_id = #{floorId}
  750. </if>
  751. and t.status_cd = '0'
  752. and t.community_id= #{communityId}
  753. and t.cur_month_time &gt;= #{startDate}
  754. and t.cur_month_time &lt; #{endDate}
  755. and t.detail_id != '-1'
  756. <if test="configIds !=null ">
  757. and t.config_id in
  758. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  759. #{item}
  760. </foreach>
  761. </if>
  762. and pf.fee_type_cd = a.status_cd
  763. ) curReceivedFee,
  764. (
  765. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  766. from pay_fee_detail_month t
  767. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  768. <if test="floorId != null and floorId != ''">
  769. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  770. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  771. </if>
  772. where
  773. 1=1
  774. <if test="floorId != null and floorId != ''">
  775. and bu.floor_id = #{floorId}
  776. </if>
  777. and t.status_cd = '0'
  778. and t.community_id= #{communityId}
  779. and t.pay_fee_time &gt; #{startDate}
  780. and t.pay_fee_time &lt; #{endDate}
  781. and t.cur_month_time &lt; #{startDate}
  782. and t.detail_id != '-1'
  783. <if test="configIds !=null ">
  784. and t.config_id in
  785. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  786. #{item}
  787. </foreach>
  788. </if>
  789. and pf.fee_type_cd = a.status_cd
  790. ) hisReceivedFee
  791. from t_dict a
  792. where 1=1
  793. and a.table_name = 'pay_fee_config'
  794. and a.table_columns = 'fee_type_cd'
  795. </select>
  796. <select id="getObjFeeSummaryCount" parameterType="Map" resultType="Map">
  797. select count(1) feeRoomCount
  798. from
  799. (
  800. select t.payer_ob_id
  801. from report_owe_fee t
  802. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  803. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  804. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  805. where
  806. 1=1
  807. and t.payer_obj_type = '3333'
  808. and t.community_id= #{communityId}
  809. and pf.community_id= #{communityId}
  810. group by a.payer_ob_id
  811. ) b
  812. </select>
  813. <!-- 查询房屋费用明细表-->
  814. <select id="getObjFeeSummary" parameterType="Map" resultType="Map">
  815. select
  816. a.obj_id objId,pfc.fee_type_cd feeTypeCd,
  817. (
  818. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  819. from pay_fee_detail_month t
  820. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  821. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  822. where t.status_cd = '0'
  823. and t.detail_id = '-1'
  824. and t.community_id= a.community_id
  825. and t.obj_id = a.obj_id
  826. and pfc1.fee_type_cd = pfc.fee_type_cd
  827. and t.cur_month_time &lt; #{endDate}
  828. ) oweFee,
  829. (
  830. select ifnull(sum(t.received_amount),0.0) receivedFee
  831. from pay_fee_detail t
  832. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  833. inner join pay_fee_config pfc1 on pfc1.config_id = pf.config_id and pfc1.status_cd = '0'
  834. where pf.payer_obj_id = a.obj_id
  835. and t.status_cd = '0'
  836. and t.community_id= a.community_id
  837. and pfc1.fee_type_cd = pfc.fee_type_cd
  838. and t.create_time &gt; #{startDate}
  839. and t.create_time &lt; #{endDate}
  840. ) receivedFee
  841. from pay_fee_detail_month a
  842. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  843. where a.obj_id in
  844. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  845. #{item}
  846. </foreach>
  847. group by a.obj_id,pfc.fee_type_cd,a.community_id
  848. </select>
  849. <!-- 查询业主费用明细表 -->
  850. <select id="getOwnerFeeSummary" parameterType="Map" resultType="Map">
  851. select
  852. a.owner_id ownerId,GROUP_CONCAT(a.obj_name) objName,pfc.fee_type_cd feeTypeCd,
  853. (
  854. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  855. from pay_fee_detail_month t
  856. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  857. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  858. where 1=1
  859. and t.status_cd = '0'
  860. and t.detail_id = '-1'
  861. and t.community_id= a.community_id
  862. and t.owner_id = a.owner_id
  863. and pfc1.fee_type_cd = pfc.fee_type_cd
  864. and t.cur_month_time &lt; #{endDate}
  865. ) oweFee,
  866. (
  867. select ifnull(sum(t.received_amount),0.0) receivedFee
  868. from pay_fee_detail_month t
  869. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  870. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  871. where t.owner_id = a.owner_id
  872. and t.status_cd = '0'
  873. and t.community_id= a.community_id
  874. and pfc1.fee_type_cd = pfc.fee_type_cd
  875. and t.pay_fee_time &gt; #{startDate}
  876. and t.pay_fee_time &lt; #{endDate}
  877. ) receivedFee
  878. from pay_fee_detail_month a
  879. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  880. where a.owner_id in
  881. <foreach collection="ownerIds" item="item" index="index" open="(" close=")" separator=",">
  882. #{item}
  883. </foreach>
  884. group by a.owner_id,pfc.fee_type_cd,a.community_id
  885. </select>
  886. <!-- 优惠费用-->
  887. <select id="getDiscountFee" parameterType="Map" resultType="Map">
  888. select ifnull(SUM(t.discount_amount),0.0) discountFee
  889. from pay_fee_detail_month t
  890. where 1=1
  891. and t.status_cd = '0'
  892. and t.detail_id != '-1'
  893. and t.discount_amount &gt; 0
  894. and t.community_id= #{communityId}
  895. and t.cur_month_time &gt; #{startDate}
  896. and t.cur_month_time &lt; #{endDate}
  897. </select>
  898. <!-- 滞纳金费用-->
  899. <select id="getLateFee" parameterType="Map" resultType="Map">
  900. select ifnull(SUM(t.discount_price),0.0) lateFee
  901. from pay_fee_detail_discount t
  902. inner join fee_discount fd on t.discount_id = fd.discount_id
  903. where t.status_cd = '0'
  904. and fd.discount_type = '2002'
  905. and t.community_id = #{communityId}
  906. and t.create_time &gt; #{startDate}
  907. and t.create_time &lt; #{endDate}
  908. </select>
  909. <!-- 查询预存账户-->
  910. <select id="getPrestoreAccount" parameterType="Map" resultType="Map">
  911. select ifnull(SUM(t.amount),0.0) prestoreAccount
  912. from account_detail t
  913. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  914. where 1=1
  915. and t.obj_type = '6006'
  916. and ac.acct_type = '2003'
  917. and t.detail_type = '1001'
  918. and ac.part_id= #{communityId}
  919. and t.create_time &gt; #{startDate}
  920. and t.create_time &lt; #{endDate}
  921. </select>
  922. <!-- 查询账户扣款-->
  923. <select id="getWithholdAccount" parameterType="Map" resultType="Map">
  924. select ifnull(SUM(t.amount),0.0) withholdAccount
  925. from account_detail t
  926. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  927. where 1=1
  928. and t.obj_type = '6006'
  929. and ac.acct_type = '2003'
  930. and t.detail_type = '2002'
  931. and ac.part_id= #{communityId}
  932. and t.create_time &gt; #{startDate}
  933. and t.create_time &lt; #{endDate}
  934. </select>
  935. <!-- 查询临时车费 -->
  936. <select id="getTempCarFee" parameterType="Map" resultType="Map">
  937. select ifnull(sum(t.pay_charge),0.0) tempCarFee
  938. from car_inout_payment t
  939. where 1=1
  940. and t.community_id = #{communityId}
  941. and t.create_time &gt; #{startDate}
  942. and t.create_time &lt; #{endDate}
  943. and t.status_cd = '0'
  944. </select>
  945. <!-- 押金退款金额 -->
  946. <select id="geRefundDeposit" parameterType="Map" resultType="Map">
  947. select ifnull(sum(t.received_amount),0.0) refundDeposit from return_pay_fee t
  948. where t.fee_type_cd = '888800010006'
  949. and t.status_cd = '0'
  950. and t.state = '1001'
  951. and t.community_id = #{communityId}
  952. and t.create_time &gt; #{startDate}
  953. and t.create_time &lt; #{endDate}
  954. </select>
  955. <!-- 退款订单数 -->
  956. <select id="geRefundOrderCount" parameterType="Map" resultType="Map">
  957. select count(1) refundOrderCount from return_pay_fee t
  958. where t.status_cd = '0'
  959. and t.state = '1001'
  960. and t.community_id = #{communityId}
  961. and t.create_time &gt; #{startDate}
  962. and t.create_time &lt; #{endDate}
  963. </select>
  964. <!-- 退款金额 -->
  965. <select id="geRefundFee" parameterType="Map" resultType="Map">
  966. select ifnull(sum(t.received_amount),0.0) refundFee from return_pay_fee t
  967. where t.status_cd = '0'
  968. and t.state = '1001'
  969. and t.community_id = #{communityId}
  970. and t.create_time &gt; #{startDate}
  971. and t.create_time &lt; #{endDate}
  972. </select>
  973. <!-- 查询充电费用-->
  974. <select id="getChargeFee" parameterType="Map" resultType="Map">
  975. select ifnull(sum(t.amount),0.0) chargeFee
  976. from charge_machine_order t
  977. where t.status_cd = '0'
  978. and t.community_id = #{communityId}
  979. and t.create_time &gt; #{startDate}
  980. and t.create_time &lt; #{endDate}
  981. </select>
  982. <!-- 查询楼栋实收-->
  983. <select id="getReceivedFeeByFloor" parameterType="Map" resultType="Map">
  984. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  985. (
  986. select count(1)
  987. from building_room br
  988. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  989. where
  990. 1=1
  991. and a.status_cd = '0'
  992. and br.status_cd = '0'
  993. and bu.floor_id = a.floor_id
  994. ) roomCount,
  995. (
  996. select count(1) from (
  997. select bu.floor_id,br.room_id
  998. from pay_fee_detail t
  999. INNER JOIN pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.payer_obj_type='3333' and pf1.status_cd = '0'
  1000. inner JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  1001. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1002. where
  1003. 1=1
  1004. and t.status_cd = '0'
  1005. and t.community_id = #{communityId}
  1006. and t.create_time &gt; #{startDate}
  1007. and t.create_time &lt; #{endDate}
  1008. group by bu.floor_id,br.room_id
  1009. ) b
  1010. where b.floor_id = a.floor_id
  1011. ) feeRoomCount,
  1012. (
  1013. select ifnull(sum(t.received_amount),0.0) receivedFee
  1014. from pay_fee_detail t
  1015. INNER JOIN pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.payer_obj_type='3333' and pf1.status_cd = '0'
  1016. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  1017. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1018. where
  1019. 1=1
  1020. and bu.floor_id = a.floor_id
  1021. and t.status_cd = '0'
  1022. and t.community_id = #{communityId}
  1023. and t.create_time &gt; #{startDate}
  1024. and t.create_time &lt; #{endDate}
  1025. and pf1.fee_type_cd = td.status_cd
  1026. ) receivedFee
  1027. from f_floor a
  1028. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  1029. where 1=1
  1030. and a.status_cd = '0'
  1031. and a.community_id = #{communityId}
  1032. order by a.seq
  1033. </select>
  1034. <!-- 按缴费方式统计 -->
  1035. <select id="getReceivedFeeByPrimeRate" parameterType="Map" resultType="Map">
  1036. select td.`name`,td.status_cd primeRate,ifnull(SUM(t.received_amount),0) receivedAmount
  1037. from t_dict td
  1038. left join pay_fee_detail t on td.status_cd = t.prime_rate and t.status_cd = '0'
  1039. where
  1040. 1=1
  1041. and td.table_name = 'pay_fee_detail'
  1042. and td.table_columns = 'prime_rate'
  1043. and t.community_id = #{communityId}
  1044. and t.create_time &gt; #{startDate}
  1045. and t.create_time &lt; #{endDate}
  1046. group by td.status_cd,td.`name`
  1047. </select>
  1048. <!-- 按楼栋统计欠费 -->
  1049. <select id="getOweFeeByFloor" parameterType="Map" resultType="Map">
  1050. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  1051. (
  1052. select count(1)
  1053. from building_room br
  1054. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  1055. where
  1056. 1=1
  1057. and a.status_cd = '0'
  1058. and br.status_cd = '0'
  1059. and bu.floor_id = a.floor_id
  1060. ) roomCount,
  1061. (
  1062. select count(1) from (
  1063. select bu.floor_id,br.room_id
  1064. from report_owe_fee t
  1065. inner join pay_fee pf on pf.fee_id = t.fee_id and pf.status_cd = '0' and pf.state = '2008001'
  1066. inner join building_room br on t.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 t.payer_obj_type = '3333'
  1071. and t.community_id= #{communityId}
  1072. and pf.community_id= #{communityId}
  1073. and t.end_time &lt; #{endDate}
  1074. group by bu.floor_id,br.room_id
  1075. ) b
  1076. where b.floor_id = a.floor_id
  1077. ) feeRoomCount,
  1078. (
  1079. select count(1) from (
  1080. select bu.floor_id,br.room_id
  1081. from report_owe_fee t
  1082. inner join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
  1083. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1084. left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1085. where
  1086. 1=1
  1087. and t.payer_obj_type = '3333'
  1088. and t.community_id= #{communityId}
  1089. and t.end_time &lt; #{endDate}
  1090. and t.amount_owed != 0
  1091. group by bu.floor_id,br.room_id
  1092. ) b
  1093. where b.floor_id = a.floor_id
  1094. ) oweRoomCount,
  1095. (
  1096. select ifnull(sum(t.amount_owed),0.0) oweFee
  1097. from report_owe_fee t
  1098. left join pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.status_cd = '0'
  1099. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  1100. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1101. where
  1102. 1=1
  1103. and bu.floor_id = a.floor_id
  1104. and t.community_id = #{communityId}
  1105. and t.amount_owed > 0
  1106. and pf1.fee_type_cd = td.status_cd
  1107. ) oweFee
  1108. from f_floor a
  1109. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  1110. where 1=1
  1111. and a.status_cd = '0'
  1112. and a.community_id = #{communityId}
  1113. order by a.seq
  1114. </select>
  1115. <!-- 对象欠费 -->
  1116. <select id="getObjOweFee" parameterType="Map" resultType="Map">
  1117. select t.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,t.fee_name feeName,
  1118. DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,DATE_FORMAT(t.deadline_time,'%Y-%m-%d') deadlineTime,t.amount_owed amountOwed
  1119. from report_owe_fee t
  1120. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1121. where t.amount_owed > 0
  1122. and t.payer_obj_type = '3333'
  1123. and t.community_id = #{communityId}
  1124. and t.payer_obj_id in
  1125. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1126. #{item}
  1127. </foreach>
  1128. </select>
  1129. <!-- 对象实收 -->
  1130. <select id="getObjReceivedFee" parameterType="Map" resultType="Map">
  1131. select pf.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,pfc.fee_name feeName,
  1132. DATE_FORMAT(t.start_time,'%Y-%m-%d') startTime,DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,t.received_amount receivedAmount
  1133. from pay_fee_detail t
  1134. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1135. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1136. where 1=1
  1137. and pf.payer_obj_type = '3333'
  1138. and t.community_id = #{communityId}
  1139. and t.create_time &gt; #{startDate}
  1140. and t.create_time &lt; #{endDate}
  1141. and pf.payer_obj_id in
  1142. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1143. #{item}
  1144. </foreach>
  1145. </select>
  1146. <!-- 已收房屋数 -->
  1147. <select id="getReceivedRoomCount" parameterType="Map" resultType="Map">
  1148. select count(DISTINCT pf.payer_obj_id) count from pay_fee_detail t
  1149. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1150. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1151. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1152. where
  1153. 1=1
  1154. and bu.floor_id = #{floorId}
  1155. and t.community_id = #{communityId}
  1156. and pf.community_id= #{communityId}
  1157. and t.create_time &gt; #{startDate}
  1158. and t.create_time &lt; #{endDate}
  1159. <if test="feeTypeCd != null and feeTypeCd != ''">
  1160. and pf.fee_type_cd = #{feeTypeCd}
  1161. </if>
  1162. </select>
  1163. <!-- 已收房屋金额 -->
  1164. <select id="getReceivedRoomAmount" parameterType="Map" resultType="Map">
  1165. select ifnull(sum(t.received_amount),0) amount from pay_fee_detail t
  1166. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1167. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1168. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1169. where
  1170. bu.floor_id = #{floorId}
  1171. and t.community_id = #{communityId}
  1172. and pf.community_id= #{communityId}
  1173. and t.create_time &gt; #{startDate}
  1174. and t.create_time &lt; #{endDate}
  1175. <if test="feeTypeCd != null and feeTypeCd != ''">
  1176. and pf.fee_type_cd = #{feeTypeCd}
  1177. </if>
  1178. </select>
  1179. <!-- 欠费清缴户 -->
  1180. <select id="getHisOweReceivedRoomCount" parameterType="Map" resultType="Map">
  1181. select count(DISTINCT t.obj_id) count
  1182. from pay_fee_detail_month t
  1183. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1184. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1185. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1186. where 1=1
  1187. and bu.floor_id = #{floorId}
  1188. and t.community_id = #{communityId}
  1189. and pf.community_id= #{communityId}
  1190. and t.pay_fee_time &gt; #{startDate}
  1191. and t.pay_fee_time &lt; #{endDate}
  1192. and t.cur_month_time &lt; #{hisDate}
  1193. <if test="feeTypeCd != null and feeTypeCd != ''">
  1194. and pf.fee_type_cd = #{feeTypeCd}
  1195. </if>
  1196. and t.detail_id != '-1'
  1197. and t.status_cd = '0'
  1198. </select>
  1199. <!-- 欠费清缴金额 -->
  1200. <select id="getHisOweReceivedRoomAmount" parameterType="Map" resultType="Map">
  1201. select ifnull(sum(t.received_amount),0) amount
  1202. from pay_fee_detail_month t
  1203. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1204. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1205. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1206. where 1=1
  1207. and bu.floor_id = #{floorId}
  1208. and t.community_id = #{communityId}
  1209. and pf.community_id= #{communityId}
  1210. and t.pay_fee_time &gt; #{startDate}
  1211. and t.pay_fee_time &lt; #{endDate}
  1212. and t.cur_month_time &lt; #{hisDate}
  1213. <if test="feeTypeCd != null and feeTypeCd != ''">
  1214. and pf.fee_type_cd = #{feeTypeCd}
  1215. </if>
  1216. and t.detail_id != '-1'
  1217. and t.status_cd = '0'
  1218. </select>
  1219. <!-- 查询月收入数据 -->
  1220. <select id="getMonthReceivedDetailCount" parameterType="Map" resultType="Map">
  1221. select count(1) count
  1222. from pay_fee_detail_month t
  1223. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1224. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1225. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1226. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1227. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1228. 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'
  1229. where 1=1
  1230. and pfdm.month_id is null
  1231. and t.status_cd = '0'
  1232. and t.cur_month_time &gt;= #{startDate}
  1233. and t.cur_month_time &lt; #{endDate}
  1234. and t.detail_id != '-1'
  1235. and t.community_id = #{communityId}
  1236. and pf.community_id= #{communityId}
  1237. <if test="feeTypeCd != null and feeTypeCd != ''">
  1238. and pf.fee_type_cd = #{feeTypeCd}
  1239. </if>
  1240. <if test="floorId != null and floorId != ''">
  1241. and bu.floor_id = #{floorId}
  1242. </if>
  1243. <if test="objName != null and objName != ''">
  1244. and t.obj_name like concat('%',#{objName},'%')
  1245. </if>
  1246. <if test="ownerName != null and ownerName != ''">
  1247. and t.owner_name like concat('%',#{ownerName},'%')
  1248. </if>
  1249. <if test="link != null and link != ''">
  1250. and t.link = #{link}
  1251. </if>
  1252. </select>
  1253. <!-- 月实收 查询-->
  1254. <select id="getMonthReceivedDetailInfo" parameterType="Map" resultType="Map">
  1255. 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,
  1256. pfd.pay_order_id payOrderId,pfd.cashier_name cashierName,
  1257. t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfd.create_time createTime,concat(t.detail_year,'-',t.detail_month) curYearMonth
  1258. from pay_fee_detail_month t
  1259. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1260. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1261. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1262. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1263. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1264. 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'
  1265. where 1=1
  1266. and pfdm.month_id is null
  1267. and t.status_cd = '0'
  1268. and t.cur_month_time &gt;= #{startDate}
  1269. and t.cur_month_time &lt; #{endDate}
  1270. and t.detail_id != '-1'
  1271. and t.community_id = #{communityId}
  1272. and pf.community_id= #{communityId}
  1273. <if test="feeTypeCd != null and feeTypeCd != ''">
  1274. and pf.fee_type_cd = #{feeTypeCd}
  1275. </if>
  1276. <if test="floorId != null and floorId != ''">
  1277. and bu.floor_id = #{floorId}
  1278. </if>
  1279. <if test="objName != null and objName != ''">
  1280. and t.obj_name like concat('%',#{objName},'%')
  1281. </if>
  1282. <if test="ownerName != null and ownerName != ''">
  1283. and t.owner_name like concat('%',#{ownerName},'%')
  1284. </if>
  1285. <if test="link != null and link != ''">
  1286. and t.link = #{link}
  1287. </if>
  1288. order by t.obj_name,t.fee_name,t.detail_year,t.detail_month
  1289. <if test="page != -1 and page != null ">
  1290. limit #{page}, #{row}
  1291. </if>
  1292. </select>
  1293. <!-- 月实收总金额 查询-->
  1294. <select id="getMonthReceivedDetailAmount" parameterType="Map" resultType="Map">
  1295. select ifnull(sum(t.received_amount),0.0) amount
  1296. from pay_fee_detail_month t
  1297. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1298. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1299. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1300. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1301. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1302. where 1=1
  1303. and t.status_cd = '0'
  1304. and t.cur_month_time &gt;= #{startDate}
  1305. and t.cur_month_time &lt; #{endDate}
  1306. and t.detail_id != '-1'
  1307. and t.community_id = #{communityId}
  1308. and pf.community_id= #{communityId}
  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="getMonthOweDetailCount" parameterType="Map" resultType="Map">
  1327. select count(1) count
  1328. from pay_fee_detail_month t
  1329. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1330. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1331. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1332. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1333. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1334. where 1=1
  1335. and t.status_cd = '0'
  1336. and t.cur_month_time &gt;= #{startDate}
  1337. and t.cur_month_time &lt; #{endDate}
  1338. and t.detail_id = '-1'
  1339. and t.community_id = #{communityId}
  1340. and pf.community_id= #{communityId}
  1341. and t.receivable_amount &gt; 0
  1342. <if test="feeTypeCd != null and feeTypeCd != ''">
  1343. and pf.fee_type_cd = #{feeTypeCd}
  1344. </if>
  1345. <if test="floorId != null and floorId != ''">
  1346. and bu.floor_id = #{floorId}
  1347. </if>
  1348. <if test="objName != null and objName != ''">
  1349. and t.obj_name like concat('%',#{objName},'%')
  1350. </if>
  1351. <if test="ownerName != null and ownerName != ''">
  1352. and t.owner_name like concat('%',#{ownerName},'%')
  1353. </if>
  1354. <if test="link != null and link != ''">
  1355. and t.link = #{link}
  1356. </if>
  1357. </select>
  1358. <!-- 月实收 查询-->
  1359. <select id="getMonthOweDetailInfo" parameterType="Map" resultType="Map">
  1360. 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,
  1361. t.receivable_amount receivableAmount,t.received_amount receivedAmount,concat(t.detail_year,'-',t.detail_month) curYearMonth
  1362. from pay_fee_detail_month t
  1363. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1364. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1365. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1366. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1367. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1368. where 1=1
  1369. and t.status_cd = '0'
  1370. and t.cur_month_time &gt;= #{startDate}
  1371. and t.cur_month_time &lt; #{endDate}
  1372. and t.detail_id = '-1'
  1373. and t.receivable_amount &gt; 0
  1374. and t.community_id = #{communityId}
  1375. and pf.community_id= #{communityId}
  1376. <if test="feeTypeCd != null and feeTypeCd != ''">
  1377. and pf.fee_type_cd = #{feeTypeCd}
  1378. </if>
  1379. <if test="floorId != null and floorId != ''">
  1380. and bu.floor_id = #{floorId}
  1381. </if>
  1382. <if test="objName != null and objName != ''">
  1383. and t.obj_name like concat('%',#{objName},'%')
  1384. </if>
  1385. <if test="ownerName != null and ownerName != ''">
  1386. and t.owner_name like concat('%',#{ownerName},'%')
  1387. </if>
  1388. <if test="link != null and link != ''">
  1389. and t.link = #{link}
  1390. </if>
  1391. order by t.obj_name,t.fee_name,t.detail_year,t.detail_month
  1392. <if test="page != -1 and page != null ">
  1393. limit #{page}, #{row}
  1394. </if>
  1395. </select>
  1396. <!-- 月欠费总金额 查询-->
  1397. <select id="getMonthOweDetailAmount" parameterType="Map" resultType="Map">
  1398. select ifnull(sum(t.receivable_amount),0.0) amount
  1399. from pay_fee_detail_month t
  1400. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1401. left join pay_fee_detail pfd on t.detail_id = pfd.detail_id and pfd.status_cd = '0'
  1402. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1403. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1404. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1405. where 1=1
  1406. and t.status_cd = '0'
  1407. and t.cur_month_time &gt;= #{startDate}
  1408. and t.cur_month_time &lt; #{endDate}
  1409. and t.detail_id = '-1'
  1410. and t.community_id = #{communityId}
  1411. and pf.community_id= #{communityId}
  1412. and t.receivable_amount &gt; 0
  1413. <if test="feeTypeCd != null and feeTypeCd != ''">
  1414. and pf.fee_type_cd = #{feeTypeCd}
  1415. </if>
  1416. <if test="floorId != null and floorId != ''">
  1417. and bu.floor_id = #{floorId}
  1418. </if>
  1419. <if test="objName != null and objName != ''">
  1420. and t.obj_name like concat('%',#{objName},'%')
  1421. </if>
  1422. <if test="ownerName != null and ownerName != ''">
  1423. and t.owner_name like concat('%',#{ownerName},'%')
  1424. </if>
  1425. <if test="link != null and link != ''">
  1426. and t.link = #{link}
  1427. </if>
  1428. </select>
  1429. </mapper>