ReportFeeStatisticsServiceDaoImplMapper.xml 53 KB

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