ReportFeeStatisticsServiceDaoImplMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  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 a.room_id
  296. from building_room a
  297. left join pay_fee_detail_month t on t.obj_id = a.room_id
  298. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  299. <if test="floorId != null and floorId != ''">
  300. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  301. </if>
  302. where 1=1
  303. <if test="floorId != null and floorId != ''">
  304. and bu.floor_id = #{floorId}
  305. </if>
  306. <if test="configId != null and configId != ''">
  307. and t.config_id = #{configId}
  308. </if>
  309. <if test="objName != null and objName != ''">
  310. and t.obj_name like concat('%',#{objName},'%')
  311. </if>
  312. <if test="ownerName != null and ownerName != ''">
  313. and t.owner_name like concat('%',#{ownerName},'%')
  314. </if>
  315. <if test="link != null and link != ''">
  316. and t.link = #{link}
  317. </if>
  318. <if test="configIds !=null ">
  319. and t.config_id in
  320. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  321. #{item}
  322. </foreach>
  323. </if>
  324. <if test="feeTypeCd != null and feeTypeCd != ''">
  325. and pf.fee_type_cd = #{feeTypeCd}
  326. </if>
  327. and a.status_cd = '0'
  328. and pf.payer_obj_type = '3333'
  329. and t.community_id= #{communityId}
  330. and t.cur_month_time &lt; #{endDate}
  331. and t.detail_id = '-1'
  332. group by a.room_id
  333. ) a
  334. </select>
  335. <!-- 查询收费户数 -->
  336. <select id="getFeeRoomCount" parameterType="Map" resultType="Map">
  337. select count(1) feeRoomCount
  338. from (
  339. select a.room_id
  340. from building_room a
  341. left join pay_fee_detail_month t on t.obj_id = a.room_id
  342. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  343. <if test="floorId != null and floorId != ''">
  344. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  345. </if>
  346. where 1=1
  347. <if test="floorId != null and floorId != ''">
  348. and bu.floor_id = #{floorId}
  349. </if>
  350. <if test="configId != null and configId != ''">
  351. and t.config_id = #{configId}
  352. </if>
  353. <if test="objName != null and objName != ''">
  354. and t.obj_name like concat('%',#{objName},'%')
  355. </if>
  356. <if test="ownerName != null and ownerName != ''">
  357. and t.owner_name like concat('%',#{ownerName},'%')
  358. </if>
  359. <if test="link != null and link != ''">
  360. and t.link = #{link}
  361. </if>
  362. <if test="configIds !=null ">
  363. and t.config_id in
  364. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  365. #{item}
  366. </foreach>
  367. </if>
  368. <if test="feeTypeCd != null and feeTypeCd != ''">
  369. and pf.fee_type_cd = #{feeTypeCd}
  370. </if>
  371. and a.status_cd = '0'
  372. and pf.payer_obj_type = '3333'
  373. and t.community_id= #{communityId}
  374. and t.cur_month_time &lt; #{endDate}
  375. group by a.room_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,a.room_id
  383. from building_room a
  384. left join pay_fee_detail_month t on t.obj_id = a.room_id
  385. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  386. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  387. where
  388. 1=1
  389. and a.status_cd = '0'
  390. and pf.payer_obj_type = '3333'
  391. and t.community_id= a.community_id
  392. and t.cur_month_time &lt; #{endDate}
  393. and (t.receivable_amount - t.received_amount - t.discount_amount) > 0
  394. <if test="configIds !=null ">
  395. and t.config_id in
  396. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  397. #{item}
  398. </foreach>
  399. </if>
  400. <if test="feeTypeCd != null and feeTypeCd != ''">
  401. and pf.fee_type_cd = #{feeTypeCd}
  402. </if>
  403. group by bu.floor_id,t.obj_id
  404. ) b
  405. where b.floor_id = a.floor_id
  406. ) oweRoomCount,
  407. (
  408. select count(1) from (
  409. select bu.floor_id,a.room_id
  410. from building_room a
  411. left join pay_fee_detail_month t on t.obj_id = a.room_id
  412. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  413. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  414. where
  415. 1=1
  416. and a.status_cd = '0'
  417. and pf.payer_obj_type = '3333'
  418. and t.community_id= a.community_id
  419. and t.cur_month_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.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. from f_floor a
  527. where 1=1
  528. and a.status_cd = '0'
  529. and a.community_id = #{communityId}
  530. order by a.seq
  531. </select>
  532. <select id="getConfigFeeSummary" parameterType="Map" resultType="Map">
  533. select a.name,
  534. (
  535. select count(1) from (
  536. select pf.fee_type_cd,a.room_id
  537. from building_room a
  538. left join pay_fee_detail_month t on t.obj_id = a.room_id
  539. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  540. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  541. where
  542. 1=1
  543. and a.status_cd = '0'
  544. and pf.payer_obj_type = '3333'
  545. and t.community_id= a.community_id
  546. and t.cur_month_time &lt; #{endDate}
  547. and (t.receivable_amount - t.received_amount - t.discount_amount) > 0
  548. <if test="configIds !=null ">
  549. and t.config_id in
  550. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  551. #{item}
  552. </foreach>
  553. </if>
  554. <if test="feeTypeCd != null and feeTypeCd != ''">
  555. and pf.fee_type_cd = #{feeTypeCd}
  556. </if>
  557. group by pf.fee_type_cd,t.obj_id
  558. ) b
  559. where b.fee_type_cd = a.status_cd
  560. ) oweRoomCount,
  561. (
  562. select count(1) from (
  563. select pf.fee_type_cd,a.room_id
  564. from building_room a
  565. left join pay_fee_detail_month t on t.obj_id = a.room_id
  566. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  567. left join building_unit bu on a.unit_id = bu.unit_id and bu.status_cd = '0'
  568. where
  569. 1=1
  570. and a.status_cd = '0'
  571. and pf.payer_obj_type = '3333'
  572. and t.community_id= #{communityId}
  573. and t.cur_month_time &lt; #{endDate}
  574. <if test="configIds !=null ">
  575. and t.config_id in
  576. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  577. #{item}
  578. </foreach>
  579. </if>
  580. <if test="feeTypeCd != null and feeTypeCd != ''">
  581. and pf.fee_type_cd = #{feeTypeCd}
  582. </if>
  583. group by pf.fee_type_cd,t.obj_id
  584. ) b
  585. where b.fee_type_cd = a.status_cd
  586. ) feeRoomCount,
  587. (
  588. select ifnull(sum(t.received_amount),0.0) receivedFee
  589. from pay_fee_detail t
  590. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  591. <if test="floorId != null and floorId != ''">
  592. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  593. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  594. </if>
  595. where
  596. 1=1
  597. <if test="floorId != null and floorId != ''">
  598. and bu.floor_id = a.floor_id
  599. </if>
  600. and t.status_cd = '0'
  601. and t.community_id= #{communityId}
  602. and t.create_time &gt; #{startDate}
  603. and t.create_time &lt; #{endDate}
  604. <if test="configIds !=null ">
  605. and pf.config_id in
  606. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  607. #{item}
  608. </foreach>
  609. </if>
  610. and pf.fee_type_cd = a.status_cd
  611. ) receivedFee,
  612. (
  613. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  614. from pay_fee_detail_month t
  615. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  616. <if test="floorId != null and floorId != ''">
  617. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  618. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  619. </if>
  620. where
  621. 1=1
  622. <if test="floorId != null and floorId != ''">
  623. and bu.floor_id = a.floor_id
  624. </if>
  625. and t.status_cd = '0'
  626. and t.community_id= #{communityId}
  627. and t.pay_fee_time &gt; #{startDate}
  628. and t.pay_fee_time &lt; #{endDate}
  629. and t.cur_month_time &gt; #{endDate}
  630. <if test="configIds !=null ">
  631. and t.config_id in
  632. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  633. #{item}
  634. </foreach>
  635. </if>
  636. and pf.fee_type_cd = a.status_cd
  637. ) preReceivedFee,
  638. (
  639. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  640. from pay_fee_detail_month t
  641. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  642. <if test="floorId != null and floorId != ''">
  643. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  644. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  645. </if>
  646. where
  647. 1=1
  648. <if test="floorId != null and floorId != ''">
  649. and bu.floor_id = a.floor_id
  650. </if>
  651. and t.status_cd = '0'
  652. and t.community_id= #{communityId}
  653. and t.detail_id = '-1'
  654. and t.cur_month_time &lt; #{startDate}
  655. <if test="configIds !=null ">
  656. and t.config_id in
  657. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  658. #{item}
  659. </foreach>
  660. </if>
  661. and pf.fee_type_cd = a.status_cd
  662. ) hisOweFee,
  663. (
  664. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  665. from pay_fee_detail_month t
  666. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  667. <if test="floorId != null and floorId != ''">
  668. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  669. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  670. </if>
  671. where
  672. 1=1
  673. <if test="floorId != null and floorId != ''">
  674. and bu.floor_id = a.floor_id
  675. </if>
  676. and t.status_cd = '0'
  677. and t.community_id= #{communityId}
  678. and t.cur_month_time &gt; #{startDate}
  679. and t.cur_month_time &lt; #{endDate}
  680. <if test="configIds !=null ">
  681. and t.config_id in
  682. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  683. #{item}
  684. </foreach>
  685. </if>
  686. and pf.fee_type_cd = a.status_cd
  687. ) curReceivableFee
  688. from t_dict a
  689. where 1=1
  690. and a.table_name = 'pay_fee_config'
  691. and a.table_columns = 'fee_type_cd'
  692. </select>
  693. <select id="getObjFeeSummaryCount" parameterType="Map" resultType="Map">
  694. select count(1) feeRoomCount
  695. from
  696. (
  697. select a.obj_name objName,a.obj_id objId,a.owner_name ownerName,a.link
  698. from pay_fee_detail_month a
  699. where a.status_cd = '0'
  700. and a.community_id = #{communityId}
  701. group by a.obj_name,a.obj_id,a.owner_name,a.link
  702. ) b
  703. </select>
  704. <!-- 查询房屋费用明细表-->
  705. <select id="getObjFeeSummary" parameterType="Map" resultType="Map">
  706. select
  707. a.obj_id objId,pfc.fee_type_cd feeTypeCd,
  708. (
  709. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  710. from pay_fee_detail_month t
  711. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  712. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  713. where t.obj_id = a.obj_id
  714. and t.status_cd = '0'
  715. and t.detail_id = '-1'
  716. and t.community_id= a.community_id
  717. and t.obj_id = a.obj_id
  718. and pfc1.fee_type_cd = pfc.fee_type_cd
  719. and t.cur_month_time &lt; #{endDate}
  720. ) oweFee,
  721. (
  722. select ifnull(sum(t.received_amount),0.0) receivedFee
  723. from pay_fee_detail t
  724. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  725. inner join pay_fee_config pfc1 on pfc1.config_id = pf.config_id and pfc1.status_cd = '0'
  726. where pf.payer_obj_id = a.obj_id
  727. and t.status_cd = '0'
  728. and t.community_id= a.community_id
  729. and pfc1.fee_type_cd = pfc.fee_type_cd
  730. and t.create_time &gt; #{startDate}
  731. and t.create_time &lt; #{endDate}
  732. ) receivedFee
  733. from pay_fee_detail_month a
  734. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  735. where a.obj_id in
  736. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  737. #{item}
  738. </foreach>
  739. group by a.obj_id,pfc.fee_type_cd,a.community_id
  740. </select>
  741. <!-- 查询业主费用明细表 -->
  742. <select id="getOwnerFeeSummary" parameterType="Map" resultType="Map">
  743. select
  744. a.owner_id ownerId,GROUP_CONCAT(a.obj_name) objName,pfc.fee_type_cd feeTypeCd,
  745. (
  746. select ifnull(sum(t.receivable_amount),0.0) hisOweFee
  747. from pay_fee_detail_month t
  748. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  749. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  750. where 1=1
  751. and t.status_cd = '0'
  752. and t.detail_id = '-1'
  753. and t.community_id= a.community_id
  754. and t.owner_id = a.owner_id
  755. and pfc1.fee_type_cd = pfc.fee_type_cd
  756. and t.cur_month_time &lt; #{endDate}
  757. ) oweFee,
  758. (
  759. select ifnull(sum(t.received_amount),0.0) receivedFee
  760. from pay_fee_detail_month t
  761. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  762. inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
  763. where t.owner_id = a.owner_id
  764. and t.status_cd = '0'
  765. and t.community_id= a.community_id
  766. and pfc1.fee_type_cd = pfc.fee_type_cd
  767. and t.pay_fee_time &gt; #{startDate}
  768. and t.pay_fee_time &lt; #{endDate}
  769. ) receivedFee
  770. from pay_fee_detail_month a
  771. inner join pay_fee_config pfc on a.config_id = pfc.config_id and pfc.status_cd = '0'
  772. where a.owner_id in
  773. <foreach collection="ownerIds" item="item" index="index" open="(" close=")" separator=",">
  774. #{item}
  775. </foreach>
  776. group by a.owner_id,pfc.fee_type_cd,a.community_id
  777. </select>
  778. <!-- 优惠费用-->
  779. <select id="getDiscountFee" parameterType="Map" resultType="Map">
  780. select ifnull(SUM(t.discount_amount),0.0) discountFee
  781. from pay_fee_detail_month t
  782. where 1=1
  783. and t.status_cd = '0'
  784. and t.detail_id != '-1'
  785. and t.discount_amount &gt; 0
  786. and t.community_id= #{communityId}
  787. and t.cur_month_time &gt; #{startDate}
  788. and t.cur_month_time &lt; #{endDate}
  789. </select>
  790. <!-- 滞纳金费用-->
  791. <select id="getLateFee" parameterType="Map" resultType="Map">
  792. select ifnull(SUM(t.discount_amount),0.0) lateFee
  793. from pay_fee_detail_month t
  794. where 1=1
  795. and t.status_cd = '0'
  796. and t.detail_id != '-1'
  797. and t.discount_amount &lt; 0
  798. and t.community_id= #{communityId}
  799. and t.cur_month_time &gt; #{startDate}
  800. and t.cur_month_time &lt; #{endDate}
  801. </select>
  802. <!-- 查询预存账户-->
  803. <select id="getPrestoreAccount" parameterType="Map" resultType="Map">
  804. select ifnull(SUM(t.amount),0.0) prestoreAccount
  805. from account_detail t
  806. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  807. where 1=1
  808. and t.obj_type = '6006'
  809. and ac.acct_type = '2003'
  810. and t.detail_type = '1001'
  811. and ac.part_id= #{communityId}
  812. and t.create_time &gt; #{startDate}
  813. and t.create_time &lt; #{endDate}
  814. </select>
  815. <!-- 查询账户扣款-->
  816. <select id="getWithholdAccount" parameterType="Map" resultType="Map">
  817. select ifnull(SUM(t.amount),0.0) withholdAccount
  818. from account_detail t
  819. INNER JOIN account ac on t.acct_id = ac.acct_id and ac.status_cd = '0'
  820. where 1=1
  821. and t.obj_type = '6006'
  822. and ac.acct_type = '2003'
  823. and t.detail_type = '2002'
  824. and ac.part_id= #{communityId}
  825. and t.create_time &gt; #{startDate}
  826. and t.create_time &lt; #{endDate}
  827. </select>
  828. <!-- 查询临时车费 -->
  829. <select id="getTempCarFee" parameterType="Map" resultType="Map">
  830. select ifnull(sum(t.pay_charge),0.0) tempCarFee
  831. from car_inout_payment t
  832. where 1=1
  833. and t.community_id = #{communityId}
  834. and t.create_time &gt; #{startDate}
  835. and t.create_time &lt; #{endDate}
  836. and t.status_cd = '0'
  837. </select>
  838. <!-- 押金退款金额 -->
  839. <select id="geRefundDeposit" parameterType="Map" resultType="Map">
  840. select ifnull(sum(t.received_amount),0.0) refundDeposit from return_pay_fee t
  841. where t.fee_type_cd = '888800010006'
  842. and t.status_cd = '0'
  843. and t.state = '1001'
  844. and t.community_id = #{communityId}
  845. and t.create_time &gt; #{startDate}
  846. and t.create_time &lt; #{endDate}
  847. </select>
  848. <!-- 退款订单数 -->
  849. <select id="geRefundOrderCount" parameterType="Map" resultType="Map">
  850. select count(1) refundOrderCount from return_pay_fee t
  851. where t.status_cd = '0'
  852. and t.state = '1001'
  853. and t.community_id = #{communityId}
  854. and t.create_time &gt; #{startDate}
  855. and t.create_time &lt; #{endDate}
  856. </select>
  857. <!-- 退款金额 -->
  858. <select id="geRefundFee" parameterType="Map" resultType="Map">
  859. select ifnull(sum(t.received_amount),0.0) refundFee from return_pay_fee t
  860. where t.status_cd = '0'
  861. and t.state = '1001'
  862. and t.community_id = #{communityId}
  863. and t.create_time &gt; #{startDate}
  864. and t.create_time &lt; #{endDate}
  865. </select>
  866. <!-- 查询充电费用-->
  867. <select id="getChargeFee" parameterType="Map" resultType="Map">
  868. select ifnull(sum(t.amount),0.0) chargeFee
  869. from charge_machine_order t
  870. where t.status_cd = '0'
  871. and t.community_id = #{communityId}
  872. and t.create_time &gt; #{startDate}
  873. and t.create_time &lt; #{endDate}
  874. </select>
  875. <!-- 查询楼栋实收-->
  876. <select id="getReceivedFeeByFloor" parameterType="Map" resultType="Map">
  877. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  878. (
  879. select count(1)
  880. from building_room br
  881. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  882. where
  883. 1=1
  884. and a.status_cd = '0'
  885. and br.status_cd = '0'
  886. and bu.floor_id = a.floor_id
  887. ) roomCount,
  888. (
  889. select count(1) from (
  890. select bu.floor_id,br.room_id
  891. from building_room br
  892. INNER JOIN pay_fee pf on br.room_id = pf.payer_obj_id and pf.payer_obj_type = '3333' and pf.status_cd = '0'
  893. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  894. where
  895. 1=1
  896. and br.status_cd = '0'
  897. and br.community_id= #{communityId}
  898. group by bu.floor_id,br.room_id
  899. ) b
  900. where b.floor_id = a.floor_id
  901. ) feeRoomCount,
  902. (
  903. select ifnull(sum(t.received_amount),0.0) receivedFee
  904. from pay_fee_detail t
  905. INNER JOIN pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.payer_obj_type='3333' and pf1.status_cd = '0'
  906. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  907. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  908. where
  909. 1=1
  910. and bu.floor_id = a.floor_id
  911. and t.status_cd = '0'
  912. and t.community_id = #{communityId}
  913. and t.create_time &gt; #{startDate}
  914. and t.create_time &lt; #{endDate}
  915. and pf1.fee_type_cd = td.status_cd
  916. ) receivedFee
  917. from f_floor a
  918. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  919. where 1=1
  920. and a.status_cd = '0'
  921. and a.community_id = #{communityId}
  922. order by a.seq
  923. </select>
  924. <!-- 按缴费方式统计 -->
  925. <select id="getReceivedFeeByPrimeRate" parameterType="Map" resultType="Map">
  926. select td.`name`,td.status_cd primeRate,ifnull(SUM(t.received_amount),0) receivedAmount
  927. from t_dict td
  928. left join pay_fee_detail t on td.status_cd = t.prime_rate and t.status_cd = '0'
  929. where
  930. 1=1
  931. and td.table_name = 'pay_fee_detail'
  932. and td.table_columns = 'prime_rate'
  933. and t.community_id = #{communityId}
  934. and t.create_time &gt; #{startDate}
  935. and t.create_time &lt; #{endDate}
  936. group by td.status_cd,td.`name`
  937. </select>
  938. <!-- 按楼栋统计欠费 -->
  939. <select id="getOweFeeByFloor" parameterType="Map" resultType="Map">
  940. select a.floor_id floorId,a.floor_num floorNum,a.name floorName,td.status_cd feeTypeCd,
  941. (
  942. select count(1)
  943. from building_room br
  944. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  945. where
  946. 1=1
  947. and a.status_cd = '0'
  948. and br.status_cd = '0'
  949. and bu.floor_id = a.floor_id
  950. ) roomCount,
  951. (
  952. select count(1) from (
  953. select bu.floor_id,br.room_id
  954. from building_room br
  955. INNER JOIN pay_fee pf on br.room_id = pf.payer_obj_id and pf.payer_obj_type = '3333' and pf.status_cd = '0'
  956. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  957. where
  958. 1=1
  959. and br.status_cd = '0'
  960. and br.community_id= #{communityId}
  961. group by bu.floor_id,br.room_id
  962. ) b
  963. where b.floor_id = a.floor_id
  964. ) feeRoomCount,
  965. (
  966. select count(1) from (
  967. select bu.floor_id,br.room_id
  968. from building_room br
  969. INNER JOIN pay_fee_detail_month pf on br.room_id = pf.obj_id and pf.status_cd = '0'
  970. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  971. where
  972. 1=1
  973. and br.status_cd = '0'
  974. and br.community_id= #{communityId}
  975. and pf.detail_id = '-1'
  976. and pf.cur_month_time &lt; #{endDate}
  977. group by bu.floor_id,br.room_id
  978. ) b
  979. where b.floor_id = a.floor_id
  980. ) oweRoomCount,
  981. (
  982. select ifnull(sum(t.amount_owed),0.0) oweFee
  983. from report_owe_fee t
  984. left join pay_fee pf1 on t.fee_id = pf1.fee_id and pf1.status_cd = '0'
  985. LEFT JOIN building_room br on pf1.payer_obj_id = br.room_id and br.status_cd = '0'
  986. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  987. where
  988. 1=1
  989. and bu.floor_id = a.floor_id
  990. and t.community_id = #{communityId}
  991. and t.amount_owed > 0
  992. and pf1.fee_type_cd = td.status_cd
  993. ) oweFee
  994. from f_floor a
  995. left join t_dict td on td.table_name='pay_fee_config' and td.table_columns = 'fee_type_cd_show'
  996. where 1=1
  997. and a.status_cd = '0'
  998. and a.community_id = #{communityId}
  999. order by a.seq
  1000. </select>
  1001. <!-- 对象欠费 -->
  1002. <select id="getObjOweFee" parameterType="Map" resultType="Map">
  1003. select t.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,t.fee_name feeName,
  1004. DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,DATE_FORMAT(t.deadline_time,'%Y-%m-%d') deadlineTime,t.amount_owed amountOwed
  1005. from report_owe_fee t
  1006. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1007. where t.amount_owed > 0
  1008. and t.payer_obj_type = '3333'
  1009. and t.community_id = #{communityId}
  1010. and t.payer_obj_id in
  1011. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1012. #{item}
  1013. </foreach>
  1014. </select>
  1015. <!-- 对象实收 -->
  1016. <select id="getObjReceivedFee" parameterType="Map" resultType="Map">
  1017. select pf.payer_obj_id payerObjId, pf.fee_type_cd feeTypeCd,pfc.fee_name feeName,
  1018. DATE_FORMAT(t.start_time,'%Y-%m-%d') startTime,DATE_FORMAT(t.end_time,'%Y-%m-%d') endTime,t.received_amount receivedAmount
  1019. from pay_fee_detail t
  1020. left join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1021. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1022. where 1=1
  1023. and pf.payer_obj_type = '3333'
  1024. and t.community_id = #{communityId}
  1025. and t.create_time &gt; #{startDate}
  1026. and t.create_time &lt; #{endDate}
  1027. and pf.payer_obj_id in
  1028. <foreach collection="objIds" item="item" index="index" open="(" close=")" separator=",">
  1029. #{item}
  1030. </foreach>
  1031. </select>
  1032. <!-- 已收房屋数 -->
  1033. <select id="getReceivedRoomCount" parameterType="Map" resultType="Map">
  1034. select count(DISTINCT pf.payer_obj_id) count from pay_fee_detail t
  1035. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1036. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1037. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1038. where
  1039. bu.floor_id = #{floorId}
  1040. and t.community_id = #{communityId}
  1041. and t.create_time &gt; #{startDate}
  1042. and t.create_time &lt; #{endDate}
  1043. <if test="feeTypeCd != null and feeTypeCd != ''">
  1044. and pf.fee_type_cd = #{feeTypeCd}
  1045. </if>
  1046. </select>
  1047. <!-- 已收房屋金额 -->
  1048. <select id="getReceivedRoomAmount" parameterType="Map" resultType="Map">
  1049. select ifnull(sum(t.received_amount),0) amount from pay_fee_detail t
  1050. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1051. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1052. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1053. where
  1054. bu.floor_id = #{floorId}
  1055. and t.community_id = #{communityId}
  1056. and t.create_time &gt; #{startDate}
  1057. and t.create_time &lt; #{endDate}
  1058. <if test="feeTypeCd != null and feeTypeCd != ''">
  1059. and pf.fee_type_cd = #{feeTypeCd}
  1060. </if>
  1061. </select>
  1062. <!-- 欠费清缴户 -->
  1063. <select id="getHisOweReceivedRoomCount" parameterType="Map" resultType="Map">
  1064. select count(DISTINCT t.obj_id) count
  1065. from pay_fee_detail_month t
  1066. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1067. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1068. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1069. where 1=1
  1070. and bu.floor_id = #{floorId}
  1071. and t.community_id = #{communityId}
  1072. and t.pay_fee_time &gt; #{startDate}
  1073. and t.pay_fee_time &lt; #{endDate}
  1074. and t.cur_month_time &lt; #{hisDate}
  1075. <if test="feeTypeCd != null and feeTypeCd != ''">
  1076. and pf.fee_type_cd = #{feeTypeCd}
  1077. </if>
  1078. and t.detail_id != '-1'
  1079. and t.status_cd = '0'
  1080. </select>
  1081. <!-- 欠费清缴金额 -->
  1082. <select id="getHisOweReceivedRoomAmount" parameterType="Map" resultType="Map">
  1083. select ifnull(sum(t.received_amount),0) amount
  1084. from pay_fee_detail_month t
  1085. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' and pf.payer_obj_type = '3333'
  1086. LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
  1087. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1088. where 1=1
  1089. and bu.floor_id = #{floorId}
  1090. and t.community_id = #{communityId}
  1091. and t.pay_fee_time &gt; #{startDate}
  1092. and t.pay_fee_time &lt; #{endDate}
  1093. and t.cur_month_time &lt; #{hisDate}
  1094. <if test="feeTypeCd != null and feeTypeCd != ''">
  1095. and pf.fee_type_cd = #{feeTypeCd}
  1096. </if>
  1097. and t.detail_id != '-1'
  1098. and t.status_cd = '0'
  1099. </select>
  1100. </mapper>