ReportFeeStatisticsServiceDaoImplMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 - t.received_amount - t.discount_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.community_id= #{communityId}
  43. and t.cur_month_time &lt; #{startDate}
  44. </select>
  45. <!-- 查询单月欠费 -->
  46. <select id="getCurMonthOweFee" parameterType="Map" resultType="Map">
  47. select ifnull(sum(t.receivable_amount - t.received_amount - t.discount_amount),0.0) curOweFee
  48. from pay_fee_detail_month t
  49. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  50. <if test="floorId != null and floorId != ''">
  51. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  52. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  53. </if>
  54. where
  55. 1=1
  56. <if test="floorId != null and floorId != ''">
  57. and bu.floor_id = #{floorId}
  58. </if>
  59. <if test="configId != null and configId != ''">
  60. and t.config_id = #{configId}
  61. </if>
  62. <if test="objName != null and objName != ''">
  63. and t.obj_name like concat('%',#{objName},'%')
  64. </if>
  65. <if test="ownerName != null and ownerName != ''">
  66. and t.owner_name like concat('%',#{ownerName},'%')
  67. </if>
  68. <if test="link != null and link != ''">
  69. and t.link = #{link}
  70. </if>
  71. <if test="configIds !=null ">
  72. and t.config_id in
  73. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  74. #{item}
  75. </foreach>
  76. </if>
  77. <if test="feeTypeCd != null and feeTypeCd != ''">
  78. and pf.fee_type_cd = #{feeTypeCd}
  79. </if>
  80. and t.status_cd = '0'
  81. and t.community_id= #{communityId}
  82. and t.cur_month_time &gt; #{startDate}
  83. and t.cur_month_time &lt; #{endDate}
  84. </select>
  85. <!-- 查询当月应收 -->
  86. <select id="getCurReceivableFee" parameterType="Map" resultType="Map">
  87. select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
  88. from pay_fee_detail_month t
  89. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  90. <if test="floorId != null and floorId != ''">
  91. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  92. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  93. </if>
  94. where
  95. 1=1
  96. <if test="floorId != null and floorId != ''">
  97. and bu.floor_id = #{floorId}
  98. </if>
  99. <if test="configId != null and configId != ''">
  100. and t.config_id = #{configId}
  101. </if>
  102. <if test="objName != null and objName != ''">
  103. and t.obj_name like concat('%',#{objName},'%')
  104. </if>
  105. <if test="ownerName != null and ownerName != ''">
  106. and t.owner_name like concat('%',#{ownerName},'%')
  107. </if>
  108. <if test="link != null and link != ''">
  109. and t.link = #{link}
  110. </if>
  111. <if test="configIds !=null ">
  112. and t.config_id in
  113. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  114. #{item}
  115. </foreach>
  116. </if>
  117. <if test="feeTypeCd != null and feeTypeCd != ''">
  118. and pf.fee_type_cd = #{feeTypeCd}
  119. </if>
  120. and t.status_cd = '0'
  121. and t.community_id= #{communityId}
  122. and t.cur_month_time &gt; #{startDate}
  123. and t.cur_month_time &lt; #{endDate}
  124. </select>
  125. <!-- 查询欠费追回 -->
  126. <select id="getHisReceivedFee" parameterType="Map" resultType="Map">
  127. select ifnull(sum(t.received_amount),0.0) hisReceivedFee
  128. from pay_fee_detail_month t
  129. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  130. <if test="floorId != null and floorId != ''">
  131. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  132. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  133. </if>
  134. where
  135. 1=1
  136. <if test="floorId != null and floorId != ''">
  137. and bu.floor_id = #{floorId}
  138. </if>
  139. <if test="configId != null and configId != ''">
  140. and t.config_id = #{configId}
  141. </if>
  142. <if test="objName != null and objName != ''">
  143. and t.obj_name like concat('%',#{objName},'%')
  144. </if>
  145. <if test="ownerName != null and ownerName != ''">
  146. and t.owner_name like concat('%',#{ownerName},'%')
  147. </if>
  148. <if test="link != null and link != ''">
  149. and t.link = #{link}
  150. </if>
  151. <if test="configIds !=null ">
  152. and t.config_id in
  153. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. <if test="feeTypeCd != null and feeTypeCd != ''">
  158. and pf.fee_type_cd = #{feeTypeCd}
  159. </if>
  160. and t.status_cd = '0'
  161. and t.community_id= #{communityId}
  162. and t.pay_fee_time &gt; #{startDate}
  163. and t.pay_fee_time &lt; #{endDate}
  164. and t.cur_month_time &lt; #{startDate}
  165. </select>
  166. <!-- 查询 预交费用 -->
  167. <select id="getPreReceivedFee" parameterType="Map" resultType="Map">
  168. select ifnull(sum(t.received_amount),0.0) preReceivedFee
  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 &gt; #{endDate}
  206. </select>
  207. <!-- 查询实收费用 -->
  208. <select id="getReceivedFee" parameterType="Map" resultType="Map">
  209. select ifnull(sum(t.received_amount),0.0) receivedFee
  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. </select>
  247. <!-- 查询欠费户数 -->
  248. <select id="getOweRoomCount" parameterType="Map" resultType="Map">
  249. select count(1) oweRoomCount
  250. from
  251. (
  252. select t.obj_id from pay_fee_detail_month t
  253. INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  254. <if test="floorId != null and floorId != ''">
  255. LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  256. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  257. </if>
  258. where
  259. 1=1
  260. <if test="floorId != null and floorId != ''">
  261. and bu.floor_id = #{floorId}
  262. </if>
  263. <if test="configId != null and configId != ''">
  264. and t.config_id = #{configId}
  265. </if>
  266. <if test="objName != null and objName != ''">
  267. and t.obj_name like concat('%',#{objName},'%')
  268. </if>
  269. <if test="ownerName != null and ownerName != ''">
  270. and t.owner_name like concat('%',#{ownerName},'%')
  271. </if>
  272. <if test="link != null and link != ''">
  273. and t.link = #{link}
  274. </if>
  275. <if test="configIds !=null ">
  276. and t.config_id in
  277. <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
  278. #{item}
  279. </foreach>
  280. </if>
  281. <if test="feeTypeCd != null and feeTypeCd != ''">
  282. and pf.fee_type_cd = #{feeTypeCd}
  283. </if>
  284. and t.status_cd = '0'
  285. and pf.payer_obj_type = '3333'
  286. and t.community_id= #{communityId}
  287. and t.cur_month_time &lt; #{endDate}
  288. and (t.receivable_amount - t.received_amount - t.discount_amount) > 0
  289. group by t.obj_id
  290. ) a
  291. </select>
  292. </mapper>