FeeReceiptServiceDaoImplMapper.xml 13 KB

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