ReportFeeStatisticsServiceDaoImplMapper.xml 60 KB

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