FeeReceiptServiceDaoImplMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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="feeReceiptServiceDaoImpl">
  6. <!-- 保存收据信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveFeeReceiptInfo" parameterType="Map">
  8. insert into fee_receipt(
  9. amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
  10. <if test="createTime != null">
  11. ,create_time
  12. </if>
  13. ) values (
  14. #{amount},#{objId},#{remark},#{objName},#{communityId},#{receiptId},#{objType},#{payObjId},#{payObjName}
  15. <if test="createTime != null">
  16. ,#{createTime}
  17. </if>
  18. )
  19. </insert>
  20. <!-- 批量插入费用 -->
  21. <insert id="saveFeeReceipts" parameterType="Map">
  22. insert into fee_receipt(
  23. amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
  24. ) values
  25. <foreach collection="feeReceiptPos" item="item" separator=",">
  26. (#{item.amount},#{item.objId},#{item.remark},#{item.objName},#{item.communityId},#{item.receiptId},#{item.objType},#{item.payObjId},#{item.payObjName})
  27. </foreach>
  28. </insert>
  29. <!-- 查询收据信息 add by wuxw 2018-07-03 -->
  30. <select id="getFeeReceiptInfo" parameterType="Map" resultType="Map">
  31. select t.amount,t.obj_id,t.obj_id objId,t.remark,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name
  32. objName,t.community_id,t.community_id communityId,t.receipt_id,t.receipt_id receiptId,t.obj_type,t.obj_type
  33. objType,t.create_time createTime,frd.fee_name feeName,t.pay_obj_id payObjId,t.pay_obj_name payObjName,pf.fee_type_cd feeTypeCd,
  34. frd.start_time startTime,frd.end_time endTime
  35. from fee_receipt t
  36. inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
  37. inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
  38. where 1 =1
  39. <if test="amount !=null and amount != ''">
  40. and t.amount= #{amount}
  41. </if>
  42. <if test="objId !=null and objId != ''">
  43. and t.obj_id= #{objId}
  44. </if>
  45. <if test="payObjId !=null and payObjId != ''">
  46. and t.pay_obj_id= #{payObjId}
  47. </if>
  48. <if test="payObjName !=null and payObjName != ''">
  49. and t.pay_obj_name= #{payObjName}
  50. </if>
  51. <if test="remark !=null and remark != ''">
  52. and t.remark= #{remark}
  53. </if>
  54. <if test="statusCd !=null and statusCd != ''">
  55. and t.status_cd= #{statusCd}
  56. </if>
  57. <if test="objName !=null and objName != ''">
  58. and t.obj_name= #{objName}
  59. </if>
  60. <if test="communityId !=null and communityId != ''">
  61. and t.community_id= #{communityId}
  62. </if>
  63. <if test="receiptId !=null and receiptId != ''">
  64. and t.receipt_id= #{receiptId}
  65. </if>
  66. <if test="receiptIds !=null">
  67. and t.receipt_id in
  68. <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
  69. #{item}
  70. </foreach>
  71. </if>
  72. <if test="detailIds !=null">
  73. and frd.detail_id in
  74. <foreach collection="detailIds" item="item" open="(" close=")" separator=",">
  75. #{item}
  76. </foreach>
  77. </if>
  78. <if test="objType !=null and objType != ''">
  79. and t.obj_type= #{objType}
  80. </if>
  81. <if test="qstartTime !=null and qstartTime != ''">
  82. and t.create_time &gt;= #{qstartTime}
  83. </if>
  84. <if test="qendTime !=null and qendTime != ''">
  85. and t.create_time &lt;= #{qendTime}
  86. </if>
  87. order by t.create_time desc
  88. <if test="page != -1 and page != null ">
  89. limit #{page}, #{row}
  90. </if>
  91. </select>
  92. <!-- 查询收据信息 add by wuxw 2018-07-03 -->
  93. <select id="getFeeReceiptInfoNew" parameterType="Map" resultType="Map">
  94. SELECT
  95. *
  96. FROM
  97. (
  98. SELECT
  99. t.obj_name AS objName,
  100. '' AS carNum,
  101. bo.NAME AS name,
  102. b.built_up_area AS roomArea,
  103. tt.fee_name feeName,
  104. tt.area num,
  105. SPLIT_STR ( tt.square_price, '/', 1 ) AS unit,
  106. CASE
  107. pf.fee_flag
  108. WHEN '1003006' THEN
  109. tt.start_time ELSE NULL
  110. END start,
  111. tt.start_time as startTime,
  112. CASE
  113. pf.fee_flag
  114. WHEN '1003006' THEN
  115. tt.end_time ELSE NULL
  116. END
  117. end,
  118. tt.end_time as endTime,
  119. tt.cycle as cycle,
  120. tt.amount amount,
  121. uu.NAME AS userName,
  122. t.create_time AS createTime,
  123. p.remark as remark
  124. FROM
  125. fee_receipt t
  126. LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
  127. LEFT JOIN building_room b ON t.obj_id = b.room_id
  128. LEFT JOIN building_owner_room_rel borr ON b.room_id = borr.room_id
  129. LEFT JOIN building_owner bo ON borr.owner_id = bo.owner_id
  130. LEFT JOIN pay_fee pf ON tt.fee_id = pf.fee_id
  131. LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
  132. AND tt.detail_id = p.detail_id
  133. LEFT JOIN c_business cb ON p.b_id = cb.b_id
  134. LEFT JOIN c_orders co ON cb.o_id = co.o_id
  135. LEFT JOIN u_user uu ON co.user_id = uu.user_id
  136. WHERE
  137. t.status_cd = '0'
  138. AND t.obj_type = '3333'
  139. AND p.state='1400'
  140. AND tt.status_cd = '0'
  141. AND b.status_cd = '0'
  142. AND borr.status_cd = '0'
  143. AND bo.status_cd = '0'
  144. AND bo.owner_type_cd = '1001'
  145. AND p.status_cd = '0'
  146. <if test="communityId !=null and communityId != ''">
  147. and t.community_id= #{communityId}
  148. </if>
  149. UNION ALL
  150. SELECT
  151. CONCAT( f.floor_num, '栋', bu.unit_num, '单元', b.room_num, '室' ) AS objName,
  152. oc.car_num AS carNum,
  153. bo.NAME AS name,
  154. b.built_up_area AS roomArea,
  155. tt.fee_name feeName,
  156. tt.cycle num,
  157. SPLIT_STR ( tt.square_price, '/', 1 ) AS unit,
  158. CASE
  159. pf.fee_flag
  160. WHEN '1003006' THEN
  161. tt.start_time ELSE NULL
  162. END start,
  163. tt.start_time as startTime,
  164. CASE
  165. pf.fee_flag
  166. WHEN '1003006' THEN
  167. tt.end_time ELSE NULL
  168. END
  169. end,
  170. tt.end_time as endTime,
  171. tt.cycle as cycle,
  172. tt.amount amount,
  173. uu.NAME AS userName,
  174. t.create_time AS createTime,
  175. p.remark as remark
  176. FROM
  177. fee_receipt t
  178. LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
  179. LEFT JOIN owner_car oc ON oc.car_id = t.obj_id and oc.car_type_cd='1001'
  180. LEFT JOIN building_owner bo ON bo.member_id = oc.owner_id
  181. LEFT JOIN building_owner_room_rel borr ON bo.owner_id = borr.owner_id
  182. LEFT JOIN building_room b ON borr.room_id = b.room_id
  183. LEFT JOIN building_room_attr ba ON b.room_id = ba.room_id
  184. LEFT JOIN building_unit bu ON b.unit_id = bu.unit_id
  185. AND bu.status_cd = '0'
  186. LEFT JOIN f_floor f ON bu.floor_id = f.floor_id
  187. LEFT JOIN pay_fee pf ON tt.fee_id = pf.fee_id
  188. AND pf.status_cd = '0'
  189. LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
  190. AND p.status_cd = '0'
  191. AND tt.detail_id = p.detail_id
  192. LEFT JOIN c_business cb ON p.b_id = cb.b_id
  193. LEFT JOIN c_orders co ON cb.o_id = co.o_id
  194. LEFT JOIN u_user uu ON co.user_id = uu.user_id
  195. WHERE
  196. t.obj_type = '6666'
  197. AND p.state='1400'
  198. <if test="statusCd !=null and statusCd != ''">
  199. and t.status_cd= #{statusCd}
  200. </if>
  201. <if test="communityId !=null and communityId != ''">
  202. and t.community_id= #{communityId}
  203. </if>
  204. AND bo.owner_type_cd = '1001'
  205. ) AS t
  206. WHERE 1=1
  207. <if test="type !=null and type == 1 ">
  208. AND feeName in ('预交物业管理费','装修垃圾清运费','装修电梯使用费','水费','电费')
  209. </if>
  210. <if test="type !=null and type == 2">
  211. AND feeName in ('装修保证金','施工进入证')
  212. </if>
  213. <if test="type !=null and type == 3">
  214. AND feeName in ('预交物业管理费','水费','电费','地下停车费','地上停车费')
  215. </if>
  216. <if test="type !=null and type == 4">
  217. AND feeName in ('地上停车费','地下停车费')
  218. </if>
  219. <if test="type !=null and type == 5">
  220. AND feeName in ('公共区域公摊电费','生活水泵公摊电费','走廊楼道应急公摊电费','电梯公摊电费')
  221. </if>
  222. <if test="qstartTime !=null and qstartTime != ''">
  223. AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &gt;= DATE_FORMAT( #{qstartTime}, '%Y-%m-%d' )
  224. </if>
  225. <if test="qendTime !=null and qendTime != ''">
  226. AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &lt;= DATE_FORMAT( #{qendTime}, '%Y-%m-%d' )
  227. </if>
  228. <if test="amount !=null and amount != ''">
  229. and t.amount= #{amount}
  230. </if>
  231. <if test="objId !=null and objId != ''">
  232. and t.obj_id= #{objId}
  233. </if>
  234. <if test="remark !=null and remark != ''">
  235. and t.remark= #{remark}
  236. </if>
  237. <if test="objName !=null and objName != ''">
  238. and t.objName= #{objName}
  239. </if>
  240. <if test="receiptId !=null and receiptId != ''">
  241. and t.receipt_id= #{receiptId}
  242. </if>
  243. <if test="objType !=null and objType != ''">
  244. and t.obj_type= #{objType}
  245. </if>
  246. order by t.createTime desc
  247. <if test="page != -1 and page != null ">
  248. limit #{page}, #{row}
  249. </if>
  250. </select>
  251. <!-- 修改收据信息 add by wuxw 2018-07-03 -->
  252. <update id="updateFeeReceiptInfo" parameterType="Map">
  253. update fee_receipt t set t.status_cd = #{statusCd}
  254. <if test="newBId != null and newBId != ''">
  255. ,t.b_id = #{newBId}
  256. </if>
  257. <if test="amount !=null and amount != ''">
  258. , t.amount= #{amount}
  259. </if>
  260. <if test="objId !=null and objId != ''">
  261. , t.obj_id= #{objId}
  262. </if>
  263. <if test="remark !=null and remark != ''">
  264. , t.remark= #{remark}
  265. </if>
  266. <if test="objName !=null and objName != ''">
  267. , t.obj_name= #{objName}
  268. </if>
  269. <if test="communityId !=null and communityId != ''">
  270. , t.community_id= #{communityId}
  271. </if>
  272. <if test="objType !=null and objType != ''">
  273. , t.obj_type= #{objType}
  274. </if>
  275. where 1=1
  276. <if test="receiptId !=null and receiptId != ''">
  277. and t.receipt_id= #{receiptId}
  278. </if>
  279. </update>
  280. <!-- 查询收据数量 add by wuxw 2018-07-03 -->
  281. <select id="queryFeeReceiptsCount" parameterType="Map" resultType="Map">
  282. select count(1) count
  283. from fee_receipt t
  284. inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
  285. inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
  286. where 1 =1
  287. <if test="amount !=null and amount != ''">
  288. and t.amount= #{amount}
  289. </if>
  290. <if test="objId !=null and objId != ''">
  291. and t.obj_id= #{objId}
  292. </if>
  293. <if test="payObjId !=null and payObjId != ''">
  294. and t.pay_obj_id= #{payObjId}
  295. </if>
  296. <if test="payObjName !=null and payObjName != ''">
  297. and t.pay_obj_name= #{payObjName}
  298. </if>
  299. <if test="remark !=null and remark != ''">
  300. and t.remark= #{remark}
  301. </if>
  302. <if test="statusCd !=null and statusCd != ''">
  303. and t.status_cd= #{statusCd}
  304. </if>
  305. <if test="objName !=null and objName != ''">
  306. and t.obj_name= #{objName}
  307. </if>
  308. <if test="communityId !=null and communityId != ''">
  309. and t.community_id= #{communityId}
  310. </if>
  311. <if test="receiptId !=null and receiptId != ''">
  312. and t.receipt_id= #{receiptId}
  313. </if>
  314. <if test="receiptIds !=null">
  315. and t.receipt_id in
  316. <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
  317. #{item}
  318. </foreach>
  319. </if>
  320. <if test="detailIds !=null">
  321. and frd.detail_id in
  322. <foreach collection="detailIds" item="item" open="(" close=")" separator=",">
  323. #{item}
  324. </foreach>
  325. </if>
  326. <if test="objType !=null and objType != ''">
  327. and t.obj_type= #{objType}
  328. </if>
  329. <if test="qstartTime !=null and qstartTime != ''">
  330. and t.create_time &gt;= #{qstartTime}
  331. </if>
  332. <if test="qendTime !=null and qendTime != ''">
  333. and t.create_time &lt;= #{qendTime}
  334. </if>
  335. </select>
  336. </mapper>