FeeServiceDaoImplMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  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="feeServiceDaoImpl">
  6. <!-- 保存费用信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessFeeInfo" parameterType="Map">
  8. insert into business_pay_fee(
  9. amount,operate,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type
  10. ) values (
  11. #{amount},#{operate},#{incomeObjId},#{feeTypeCd},#{startTime},#{endTime},#{communityId},#{bId},#{feeId},#{userId},#{payerObjId},
  12. #{feeFlag},#{state},#{configId},#{payerObjType}
  13. )
  14. </insert>
  15. <!-- 查询费用信息(Business) add by wuxw 2018-07-03 -->
  16. <select id="getBusinessFeeInfo" parameterType="Map" resultType="Map">
  17. select t.amount,t.operate,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  18. feeTypeCd,t.start_time,t.start_time startTime,t.end_time,t.end_time endTime,t.community_id,t.community_id
  19. communityId,t.b_id,t.b_id bId,t.fee_id,t.fee_id feeId,t.user_id,t.user_id userId,t.payer_obj_id,t.payer_obj_id
  20. payerObjId,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id
  21. configId,t.payer_obj_type,t.payer_obj_type payerObjType
  22. from business_pay_fee t
  23. where 1 =1
  24. <if test="amount !=null and amount != ''">
  25. and t.amount= #{amount}
  26. </if>
  27. <if test="operate !=null and operate != ''">
  28. and t.operate= #{operate}
  29. </if>
  30. <if test="incomeObjId !=null and incomeObjId != ''">
  31. and t.income_obj_id= #{incomeObjId}
  32. </if>
  33. <if test="feeTypeCd !=null and feeTypeCd != ''">
  34. and t.fee_type_cd= #{feeTypeCd}
  35. </if>
  36. <if test="startTime !=null ">
  37. and t.start_time= #{startTime}
  38. </if>
  39. <if test="endTime !=null ">
  40. and t.end_time= #{endTime}
  41. </if>
  42. <if test="communityId !=null and communityId != ''">
  43. and t.community_id= #{communityId}
  44. </if>
  45. <if test="bId !=null and bId != ''">
  46. and t.b_id= #{bId}
  47. </if>
  48. <if test="feeId !=null and feeId != ''">
  49. and t.fee_id= #{feeId}
  50. </if>
  51. <if test="userId !=null and userId != ''">
  52. and t.user_id= #{userId}
  53. </if>
  54. <if test="payerObjId !=null and payerObjId != ''">
  55. and t.payer_obj_id= #{payerObjId}
  56. </if>
  57. <if test="state !=null and state != ''">
  58. and t.state= #{state}
  59. </if>
  60. <if test="feeFlag !=null and feeFlag != ''">
  61. and t.fee_flag= #{feeFlag}
  62. </if>
  63. <if test="configId !=null and configId != ''">
  64. and t.config_id= #{configId}
  65. </if>
  66. <if test="payerObjType !=null and payerObjType != ''">
  67. and t.payer_obj_type = #{payerObjType}
  68. </if>
  69. </select>
  70. <!-- 保存费用信息至 instance表中 add by wuxw 2018-07-03 -->
  71. <insert id="saveFeeInfoInstance" parameterType="Map">
  72. insert into pay_fee(
  73. amount,income_obj_id,fee_type_cd,start_time,status_cd,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type
  74. ) select
  75. t.amount,t.income_obj_id,t.fee_type_cd,t.start_time,'0',t.end_time,t.community_id,t.b_id,t.fee_id,t.user_id,t.payer_obj_id
  76. ,t.fee_flag,t.state,t.config_id,t.payer_obj_type
  77. from business_pay_fee t where 1=1
  78. <if test="amount !=null and amount != ''">
  79. and t.amount= #{amount}
  80. </if>
  81. and t.operate= 'ADD'
  82. <if test="incomeObjId !=null and incomeObjId != ''">
  83. and t.income_obj_id= #{incomeObjId}
  84. </if>
  85. <if test="feeTypeCd !=null and feeTypeCd != ''">
  86. and t.fee_type_cd= #{feeTypeCd}
  87. </if>
  88. <if test="startTime !=null ">
  89. and t.start_time= #{startTime}
  90. </if>
  91. <if test="endTime !=null ">
  92. and t.end_time= #{endTime}
  93. </if>
  94. <if test="communityId !=null and communityId != ''">
  95. and t.community_id= #{communityId}
  96. </if>
  97. <if test="bId !=null and bId != ''">
  98. and t.b_id= #{bId}
  99. </if>
  100. <if test="feeId !=null and feeId != ''">
  101. and t.fee_id= #{feeId}
  102. </if>
  103. <if test="userId !=null and userId != ''">
  104. and t.user_id= #{userId}
  105. </if>
  106. <if test="payerObjId !=null and payerObjId != ''">
  107. and t.payer_obj_id= #{payerObjId}
  108. </if>
  109. <if test="state !=null and state != ''">
  110. and t.state= #{state}
  111. </if>
  112. <if test="feeFlag !=null and feeFlag != ''">
  113. and t.fee_flag= #{feeFlag}
  114. </if>
  115. <if test="configId !=null and configId != ''">
  116. and t.config_id= #{configId}
  117. </if>
  118. <if test="payerObjType !=null and payerObjType != ''">
  119. and t.payer_obj_type = #{payerObjType}
  120. </if>
  121. </insert>
  122. <!-- 查询费用信息 add by wuxw 2018-07-03 -->
  123. <select id="getFeeInfo" parameterType="Map" resultType="Map">
  124. select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  125. feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
  126. endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.fee_id,t.fee_id feeId,t.user_id,t.user_id
  127. userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
  128. additionalAmount,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
  129. pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
  130. computingFormula,
  131. pfc.bill_type billType,t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
  132. configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,td4.name
  133. billTypeName,pfa.value importFeeName,ifd.end_time importFeeEndTime,mw.cur_degrees curDegrees,mw.pre_degrees
  134. preDegrees,
  135. mw.pre_reading_time preReadingTime,mw.cur_reading_time curReadingTime
  136. from pay_fee t
  137. INNER join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and t.config_id = pfc.config_id and
  138. pfc.status_cd = '0'
  139. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  140. td1.table_columns = 'fee_type_cd'
  141. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  142. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  143. 'fee_flag'
  144. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  145. td4.table_columns = 'bill_type'
  146. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002' and pfa.status_cd = '0'
  147. left join import_fee_detail ifd on t.fee_id = ifd.fee_id and ifd.status_cd = '0' and t.fee_flag = '2006012'
  148. LEFT JOIN meter_water mw on t.fee_id = mw.fee_id and mw.status_cd = '0' and mw.community_id = t.community_id
  149. <if test="ownerId != null and ownerId != ''">
  150. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390007' and pfa.status_cd = '0'
  151. </if>
  152. where 1 =1
  153. <if test="amount !=null and amount != ''">
  154. and t.amount= #{amount}
  155. </if>
  156. <if test="ownerId !=null and ownerId != ''">
  157. and pfa.value= #{ownerId}
  158. </if>
  159. <if test="incomeObjId !=null and incomeObjId != ''">
  160. and t.income_obj_id= #{incomeObjId}
  161. </if>
  162. <if test="feeTypeCd !=null and feeTypeCd != ''">
  163. and t.fee_type_cd= #{feeTypeCd}
  164. </if>
  165. <if test="feeTypeCds != null ">
  166. and t.fee_type_cd in
  167. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  168. #{item}
  169. </foreach>
  170. </if>
  171. <if test="startTime !=null ">
  172. and t.start_time= #{startTime}
  173. </if>
  174. <if test="statusCd !=null and statusCd != ''">
  175. and t.status_cd= #{statusCd}
  176. </if>
  177. <if test="endTime !=null ">
  178. and t.end_time= #{endTime}
  179. </if>
  180. <if test="arrearsEndTime != null">
  181. and t.end_time &lt; #{arrearsEndTime}
  182. </if>
  183. <if test="communityId !=null and communityId != ''">
  184. and t.community_id= #{communityId}
  185. and pfc.community_id in (#{communityId},'9999')
  186. </if>
  187. <if test="bId !=null and bId != ''">
  188. and t.b_id= #{bId}
  189. </if>
  190. <if test="feeId !=null and feeId != ''">
  191. and t.fee_id= #{feeId}
  192. </if>
  193. <if test="userId !=null and userId != ''">
  194. and t.user_id= #{userId}
  195. </if>
  196. <if test="payerObjId !=null and payerObjId != ''">
  197. and t.payer_obj_id= #{payerObjId}
  198. </if>
  199. <if test="payerObjIds != null ">
  200. and t.payer_obj_id in
  201. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  202. #{item}
  203. </foreach>
  204. </if>
  205. <if test="state !=null and state != ''">
  206. and t.state= #{state}
  207. </if>
  208. <if test="feeFlag !=null and feeFlag != ''">
  209. and t.fee_flag= #{feeFlag}
  210. </if>
  211. <if test="configId !=null and configId != ''">
  212. and t.config_id= #{configId}
  213. </if>
  214. <if test="payerObjType !=null and payerObjType != ''">
  215. and t.payer_obj_type = #{payerObjType}
  216. </if>
  217. order by t.create_time desc
  218. <if test="page != -1 and page != null ">
  219. limit #{page}, #{row}
  220. </if>
  221. </select>
  222. <!-- 修改费用信息 add by wuxw 2018-07-03 -->
  223. <update id="updateFeeInfoInstance" parameterType="Map">
  224. update pay_fee t set t.status_cd = #{statusCd}
  225. <if test="newBId != null and newBId != ''">
  226. ,t.b_id = #{newBId}
  227. </if>
  228. <if test="amount !=null and amount != ''">
  229. , t.amount= #{amount}
  230. </if>
  231. <if test="incomeObjId !=null and incomeObjId != ''">
  232. , t.income_obj_id= #{incomeObjId}
  233. </if>
  234. <if test="feeTypeCd !=null and feeTypeCd != ''">
  235. , t.fee_type_cd= #{feeTypeCd}
  236. </if>
  237. <if test="startTime !=null ">
  238. , t.start_time= #{startTime}
  239. </if>
  240. <if test="endTime !=null">
  241. , t.end_time= #{endTime}
  242. </if>
  243. <if test="communityId !=null and communityId != ''">
  244. , t.community_id= #{communityId}
  245. </if>
  246. <if test="userId !=null and userId != ''">
  247. , t.user_id= #{userId}
  248. </if>
  249. <if test="payerObjId !=null and payerObjId != ''">
  250. , t.payer_obj_id= #{payerObjId}
  251. </if>
  252. <if test="state !=null and state != ''">
  253. , t.state= #{state}
  254. </if>
  255. <if test="feeFlag !=null and feeFlag != ''">
  256. , t.fee_flag= #{feeFlag}
  257. </if>
  258. where 1=1
  259. <if test="bId !=null and bId != ''">
  260. and t.b_id= #{bId}
  261. </if>
  262. <if test="feeId !=null and feeId != ''">
  263. and t.fee_id= #{feeId}
  264. </if>
  265. </update>
  266. <!-- 查询费用数量 add by wuxw 2018-07-03 -->
  267. <select id="queryFeesCount" parameterType="Map" resultType="Map">
  268. select count(1) count
  269. from pay_fee t,pay_fee_config pfc,t_dict td1,t_dict td2,t_dict td3,t_dict td4
  270. <if test="ownerId != null and ownerId != ''">
  271. ,pay_fee_attrs pfa
  272. </if>
  273. where 1 =1
  274. and t.fee_type_cd = pfc.fee_type_cd
  275. and t.config_id = pfc.config_id
  276. and pfc.status_cd = '0'
  277. and pfc.fee_type_cd = td1.status_cd
  278. and td1.table_name = 'pay_fee_config'
  279. and td1.table_columns = 'fee_type_cd'
  280. and t.state = td2.status_cd
  281. and td2.table_name = 'pay_fee'
  282. and td2.table_columns = 'state'
  283. and t.fee_flag = td3.status_cd
  284. and td3.table_name = 'pay_fee'
  285. and td3.table_columns = 'fee_flag'
  286. and pfc.bill_type = td4.status_cd
  287. and td4.table_name = 'pay_fee_config'
  288. and td4.table_columns = 'bill_type'
  289. <if test="ownerId != null and ownerId != ''">
  290. and t.fee_id = pfa.fee_id
  291. and pfa.spec_cd = '390007'
  292. and pfa.status_cd = '0'
  293. and pfa.value= #{ownerId}
  294. </if>
  295. <if test="amount !=null and amount != ''">
  296. and t.amount= #{amount}
  297. </if>
  298. <if test="incomeObjId !=null and incomeObjId != ''">
  299. and t.income_obj_id= #{incomeObjId}
  300. </if>
  301. <if test="feeTypeCd !=null and feeTypeCd != ''">
  302. and t.fee_type_cd= #{feeTypeCd}
  303. </if>
  304. <if test="feeTypeCds != null ">
  305. and t.fee_type_cd in
  306. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  307. #{item}
  308. </foreach>
  309. </if>
  310. <if test="startTime !=null">
  311. and t.start_time= #{startTime}
  312. </if>
  313. <if test="statusCd !=null and statusCd != ''">
  314. and t.status_cd= #{statusCd}
  315. </if>
  316. <if test="endTime !=null ">
  317. and t.end_time= #{endTime}
  318. </if>
  319. <if test="arrearsEndTime != null">
  320. and t.end_time &lt; #{arrearsEndTime}
  321. </if>
  322. <if test="noArrearsEndTime != null">
  323. and t.end_time &gt; #{noArrearsEndTime}
  324. </if>
  325. <if test="communityId !=null and communityId != ''">
  326. and t.community_id= #{communityId}
  327. and pfc.community_id= #{communityId}
  328. </if>
  329. <if test="bId !=null and bId != ''">
  330. and t.b_id= #{bId}
  331. </if>
  332. <if test="feeId !=null and feeId != ''">
  333. and t.fee_id= #{feeId}
  334. </if>
  335. <if test="userId !=null and userId != ''">
  336. and t.user_id= #{userId}
  337. </if>
  338. <if test="payerObjId !=null and payerObjId != ''">
  339. and t.payer_obj_id= #{payerObjId}
  340. </if>
  341. <if test="payerObjIds != null ">
  342. and t.payer_obj_id in
  343. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  344. #{item}
  345. </foreach>
  346. </if>
  347. <if test="state !=null and state != ''">
  348. and t.state= #{state}
  349. </if>
  350. <if test="feeFlag !=null and feeFlag != ''">
  351. and t.fee_flag= #{feeFlag}
  352. </if>
  353. <if test="configId !=null and configId != ''">
  354. and t.config_id= #{configId}
  355. </if>
  356. <if test="payerObjType !=null and payerObjType != ''">
  357. and t.payer_obj_type = #{payerObjType}
  358. </if>
  359. </select>
  360. <!-- 查询账期 -->
  361. <select id="queryBills" parameterType="Map" resultType="Map">
  362. select
  363. t.bill_id billId,
  364. t.bill_name billName,
  365. t.receivable,
  366. t.cur_receivable curReceivable,
  367. t.receipts,
  368. t.bill_time billTime,
  369. t.community_id communityId,
  370. t.config_id configId,
  371. t.cur_bill curBill,
  372. c.fee_name feeName
  373. from bill t
  374. left join pay_fee_config c on t.config_id = c.config_id and c.community_id = t.community_id and c.status_cd =
  375. '0'
  376. where 1 =1
  377. <if test="billId !=null and billId != ''">
  378. and t.bill_id= #{billId}
  379. </if>
  380. <if test="billName !=null and billName != ''">
  381. and t.bill_name= #{billName}
  382. </if>
  383. <if test="receivable !=null and receivable != ''">
  384. and t.receivable= #{receivable}
  385. </if>
  386. <if test="receipts !=null">
  387. and t.receipts= #{receipts}
  388. </if>
  389. <if test="billTime !=null">
  390. and t.bill_time= #{billTime}
  391. </if>
  392. <if test="curBillTime !=null">
  393. and t.bill_time &gt; #{curBillTime}
  394. </if>
  395. <if test="communityId !=null and communityId != ''">
  396. and t.community_id= #{communityId}
  397. </if>
  398. <if test="configId != null and configId != ''">
  399. and t.config_id = #{configId}
  400. </if>
  401. <if test="curBill != null and curBill != ''">
  402. and t.cur_bill = #{curBill}
  403. </if>
  404. order by t.create_time desc
  405. <if test="page != -1 and page != null ">
  406. limit #{page}, #{row}
  407. </if>
  408. </select>
  409. <!-- 查询账期 -->
  410. <select id="queryBillCount" parameterType="Map" resultType="Map">
  411. select count(1) count
  412. from bill t
  413. left join pay_fee_config c on t.config_id = c.config_id and c.community_id = t.community_id and c.status_cd =
  414. '0'
  415. where 1 =1
  416. <if test="billId !=null and billId != ''">
  417. and t.bill_id= #{billId}
  418. </if>
  419. <if test="billName !=null and billName != ''">
  420. and t.bill_name= #{billName}
  421. </if>
  422. <if test="receivable !=null and receivable != ''">
  423. and t.receivable= #{receivable}
  424. </if>
  425. <if test="curReceivable !=null and curReceivable != ''">
  426. and t.cur_receivable= #{curReceivable}
  427. </if>
  428. <if test="receipts !=null">
  429. and t.receipts= #{receipts}
  430. </if>
  431. <if test="billTime !=null">
  432. and t.bill_time= #{billTime}
  433. </if>
  434. <if test="communityId !=null and communityId != ''">
  435. and t.community_id= #{communityId}
  436. </if>
  437. <if test="configId != null and configId != ''">
  438. and t.config_id = #{configId}
  439. </if>
  440. <if test="curBill != null and curBill != ''">
  441. and t.cur_bill = #{curBill}
  442. </if>
  443. </select>
  444. <!-- 查询账期 -->
  445. <select id="queryBillOweFees" parameterType="Map" resultType="Map">
  446. select
  447. t.owe_id oweId,
  448. t.bill_id billId,
  449. t.fee_id feeId,
  450. t.bill_amount_owed billAmountOwed,
  451. t.amount_owed amountOwed,
  452. t.fee_end_time feeEndTime,
  453. t.owner_id ownerId,
  454. t.owner_name ownerName,
  455. t.owner_tel ownerTel,
  456. t.payer_obj_name payerObjName,
  457. t.payer_obj_type payerObjType,
  458. t.community_id communityId,
  459. t.state,
  460. t.create_time createTime,
  461. t.deadline_time deadlineTime,
  462. pf.payer_obj_id payObjId,
  463. td.`name` feeTypeName
  464. from bill_owe_fee t
  465. <if test="curBill !=null and curBill != ''">
  466. inner join bill b on t.bill_id = b.bill_id and b.community_id = t.community_id and b.cur_bill = #{curBill}
  467. </if>
  468. left join pay_fee pf on t.fee_id = pf.fee_id and t.community_id = pf.community_id and pf.status_cd = '0'
  469. left join t_dict td on pf.fee_type_cd = td.status_cd and td.table_name = 'pay_fee_config' and td.table_columns =
  470. 'fee_type_cd'
  471. where 1 =1
  472. <if test="oweId !=null and oweId != ''">
  473. and t.owe_id= #{oweId}
  474. </if>
  475. <if test="billId !=null and billId != ''">
  476. and t.bill_id= #{billId}
  477. </if>
  478. <if test="feeId !=null and feeId != ''">
  479. and t.fee_id= #{feeId}
  480. </if>
  481. <if test="billAmountOwed !=null and billAmountOwed != ''">
  482. and t.bill_amount_owed= #{billAmountOwed}
  483. </if>
  484. <if test="amountOwed !=null and amountOwed != ''">
  485. and t.amount_owed= #{amountOwed}
  486. </if>
  487. <if test="feeEndTime != null">
  488. and t.fee_end_time = #{feeEndTime}
  489. </if>
  490. <if test="ownerId != null and ownerId != ''">
  491. and t.owner_id = #{ownerId}
  492. </if>
  493. <if test="ownerIds !=null">
  494. and t.owner_id in
  495. <foreach collection="ownerIds" open="(" close=")"
  496. separator="," item="item">
  497. #{item}
  498. </foreach>
  499. </if>
  500. <if test="ownerName != null and ownerName != ''">
  501. and t.owner_name = #{ownerName}
  502. </if>
  503. <if test="communityId !=null and communityId != ''">
  504. and t.community_id= #{communityId}
  505. </if>
  506. <if test="state !=null and state != ''">
  507. and t.state= #{state}
  508. </if>
  509. order by t.create_time desc
  510. <if test="page != -1 and page != null ">
  511. limit #{page}, #{row}
  512. </if>
  513. </select>
  514. <!-- 查询账期 -->
  515. <select id="queryBillOweFeeCount" parameterType="Map" resultType="Map">
  516. select count(1) count
  517. from bill_owe_fee t
  518. where 1 =1
  519. <if test="oweId !=null and oweId != ''">
  520. and t.owe_id= #{oweId}
  521. </if>
  522. <if test="billId !=null and billId != ''">
  523. and t.bill_id= #{billId}
  524. </if>
  525. <if test="feeId !=null and feeId != ''">
  526. and t.fee_id= #{feeId}
  527. </if>
  528. <if test="billAmountOwed !=null and billAmountOwed != ''">
  529. and t.bill_amount_owed= #{billAmountOwed}
  530. </if>
  531. <if test="amountOwed !=null and amountOwed != ''">
  532. and t.amount_owed= #{amountOwed}
  533. </if>
  534. <if test="feeEndTime != null">
  535. and t.fee_end_time = #{feeEndTime}
  536. </if>
  537. <if test="ownerId != null and ownerId != ''">
  538. and t.owner_id = #{ownerId}
  539. </if>
  540. <if test="ownerName != null and ownerName != ''">
  541. and t.owner_name = #{ownerName}
  542. </if>
  543. <if test="communityId !=null and communityId != ''">
  544. and t.community_id= #{communityId}
  545. </if>
  546. <if test="state !=null and state != ''">
  547. and t.state= #{state}
  548. </if>
  549. </select>
  550. <insert id="insertBillOweFees" parameterType="Map">
  551. INSERT INTO bill_owe_fee
  552. (`owe_id`, `bill_id`, `fee_id`, `bill_amount_owed`, `amount_owed`, `fee_end_time`, `owner_id`, `owner_name`,
  553. `owner_tel`, `payer_obj_name`, `payer_obj_type`, `community_id`, `state`,deadline_time)
  554. VALUES (#{oweId}, #{billId}, #{feeId}, #{billAmountOwed}, #{amountOwed}, #{feeEndTime}, #{ownerId},
  555. #{ownerName},
  556. #{ownerTel}, #{payerObjName}, #{payerObjType}, #{communityId}, #{state},#{deadlineTime})
  557. </insert>
  558. <update id="updateBillOweFees" parameterType="Map">
  559. update bill_owe_fee t set t.state = #{state} where t.fee_id = #{feeId} and t.community_id=#{communityId}
  560. and t.bill_id=#{billId}
  561. </update>
  562. <insert id="insertBill" parameterType="Map">
  563. INSERT INTO bill (`bill_id`, `bill_name`, `receivable`, `receipts`, `bill_time`, `community_id`, `config_id`,
  564. `remark`, `cur_bill`, `cur_receivable`)
  565. VALUES (#{billId}, #{billName}, #{receivable}, #{receipts}, #{billTime}, #{communityId}, #{configId},
  566. #{remark}, #{curBill}, #{curReceivable})
  567. </insert>
  568. <update id="updateBill" parameterType="Map">
  569. update bill set cur_bill= 'F' where config_id = #{configId}
  570. </update>
  571. <!-- 查询费用数量 add by wuxw 2018-07-03 -->
  572. <select id="queryFeeByAttrCount" parameterType="Map" resultType="Map">
  573. select count(1) count
  574. from pay_fee t
  575. left join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and t.config_id = pfc.config_id and
  576. pfc.status_cd = '0'
  577. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_columns = 'fee_type_cd' and td1.table_name
  578. = 'pay_fee_config'
  579. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  580. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  581. 'fee_flag'
  582. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.status_cd='0'
  583. where pfa.spec_cd = #{specCd}
  584. and pfa.value = #{value}
  585. <if test="amount !=null and amount != ''">
  586. and t.amount= #{amount}
  587. </if>
  588. <if test="incomeObjId !=null and incomeObjId != ''">
  589. and t.income_obj_id= #{incomeObjId}
  590. </if>
  591. <if test="feeTypeCd !=null and feeTypeCd != ''">
  592. and t.fee_type_cd= #{feeTypeCd}
  593. </if>
  594. <if test="feeTypeCds != null ">
  595. and t.fee_type_cd in
  596. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  597. #{item}
  598. </foreach>
  599. </if>
  600. <if test="startTime !=null">
  601. and t.start_time= #{startTime}
  602. </if>
  603. <if test="statusCd !=null and statusCd != ''">
  604. and t.status_cd= #{statusCd}
  605. </if>
  606. <if test="endTime !=null ">
  607. and t.end_time= #{endTime}
  608. </if>
  609. <if test="arrearsEndTime != null">
  610. and t.end_time &lt; #{arrearsEndTime}
  611. </if>
  612. <if test="noArrearsEndTime != null">
  613. and t.end_time &gt; #{noArrearsEndTime}
  614. </if>
  615. <if test="communityId !=null and communityId != ''">
  616. and t.community_id= #{communityId}
  617. and pfc.community_id= #{communityId}
  618. </if>
  619. <if test="bId !=null and bId != ''">
  620. and t.b_id= #{bId}
  621. </if>
  622. <if test="feeId !=null and feeId != ''">
  623. and t.fee_id= #{feeId}
  624. </if>
  625. <if test="userId !=null and userId != ''">
  626. and t.user_id= #{userId}
  627. </if>
  628. <if test="payerObjId !=null and payerObjId != ''">
  629. and t.payer_obj_id= #{payerObjId}
  630. </if>
  631. <if test="payerObjIds != null ">
  632. and t.payer_obj_id in
  633. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  634. #{item}
  635. </foreach>
  636. </if>
  637. <if test="state !=null and state != ''">
  638. and t.state= #{state}
  639. </if>
  640. <if test="feeFlag !=null and feeFlag != ''">
  641. and t.fee_flag= #{feeFlag}
  642. </if>
  643. <if test="configId !=null and configId != ''">
  644. and t.config_id= #{configId}
  645. </if>
  646. <if test="payerObjType !=null and payerObjType != ''">
  647. and t.payer_obj_type = #{payerObjType}
  648. </if>
  649. </select>
  650. <!-- 查询费用信息 add by wuxw 2018-07-03 -->
  651. <select id="queryFeeByAttr" parameterType="Map" resultType="Map">
  652. select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  653. feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
  654. endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.fee_id,t.fee_id feeId,t.user_id,t.user_id
  655. userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
  656. additionalAmount,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
  657. pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
  658. computingFormula,
  659. t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
  660. configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle
  661. from pay_fee t
  662. left join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and t.config_id = pfc.config_id and
  663. pfc.status_cd = '0'
  664. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_columns = 'fee_type_cd' and td1.table_name
  665. = 'pay_fee_config'
  666. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  667. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  668. 'fee_flag'
  669. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.status_cd='0'
  670. where pfa.spec_cd = #{specCd}
  671. and pfa.value = #{value}
  672. <if test="amount !=null and amount != ''">
  673. and t.amount= #{amount}
  674. </if>
  675. <if test="incomeObjId !=null and incomeObjId != ''">
  676. and t.income_obj_id= #{incomeObjId}
  677. </if>
  678. <if test="feeTypeCd !=null and feeTypeCd != ''">
  679. and t.fee_type_cd= #{feeTypeCd}
  680. </if>
  681. <if test="feeTypeCds != null ">
  682. and t.fee_type_cd in
  683. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  684. #{item}
  685. </foreach>
  686. </if>
  687. <if test="startTime !=null ">
  688. and t.start_time= #{startTime}
  689. </if>
  690. <if test="statusCd !=null and statusCd != ''">
  691. and t.status_cd= #{statusCd}
  692. </if>
  693. <if test="endTime !=null ">
  694. and t.end_time= #{endTime}
  695. </if>
  696. <if test="arrearsEndTime != null">
  697. and t.end_time &lt; #{arrearsEndTime}
  698. </if>
  699. <if test="communityId !=null and communityId != ''">
  700. and t.community_id= #{communityId}
  701. and pfc.community_id= #{communityId}
  702. </if>
  703. <if test="bId !=null and bId != ''">
  704. and t.b_id= #{bId}
  705. </if>
  706. <if test="feeId !=null and feeId != ''">
  707. and t.fee_id= #{feeId}
  708. </if>
  709. <if test="userId !=null and userId != ''">
  710. and t.user_id= #{userId}
  711. </if>
  712. <if test="payerObjId !=null and payerObjId != ''">
  713. and t.payer_obj_id= #{payerObjId}
  714. </if>
  715. <if test="payerObjIds != null ">
  716. and t.payer_obj_id in
  717. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  718. #{item}
  719. </foreach>
  720. </if>
  721. <if test="state !=null and state != ''">
  722. and t.state= #{state}
  723. </if>
  724. <if test="feeFlag !=null and feeFlag != ''">
  725. and t.fee_flag= #{feeFlag}
  726. </if>
  727. <if test="configId !=null and configId != ''">
  728. and t.config_id= #{configId}
  729. </if>
  730. <if test="payerObjType !=null and payerObjType != ''">
  731. and t.payer_obj_type = #{payerObjType}
  732. </if>
  733. order by t.create_time desc
  734. <if test="page != -1 and page != null ">
  735. limit #{page}, #{row}
  736. </if>
  737. </select>
  738. <!-- 批量插入费用 -->
  739. <insert id="insertFees" parameterType="Map">
  740. insert into pay_fee (amount,status_cd,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,
  741. user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type)
  742. VALUES
  743. <foreach collection="payFeePos" item="item" separator=",">
  744. (#{item.amount},'0',#{item.incomeObjId},#{item.feeTypeCd},#{item.startTime},#{item.endTime},#{item.communityId},
  745. '-1',#{item.feeId},#{item.userId},#{item.payerObjId},#{item.feeFlag},#{item.state},#{item.configId},#{item.payerObjType})
  746. </foreach>
  747. </insert>
  748. <select id="computeBillOweFeeCount" parameterType="Map" resultType="Map">
  749. select count(1) count
  750. from pay_fee pf
  751. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type in ('001','002','003') and
  752. pfc.status_cd = '0' and pf.community_id = pfc.community_id
  753. inner join bill_owe_fee bof on pf.fee_id = bof.fee_id and bof.community_id = pf.community_id and bof.state
  754. ='1000' and bof.amount_owed &gt; 0
  755. inner join bill b on bof.bill_id = b.bill_id and b.community_id = bof.community_id and b.cur_bill = 'T'
  756. where pf.status_cd = '0'
  757. and pf.state = '2008001'
  758. and pf.community_id = #{communityId}
  759. <if test="payerObjId !=null and payerObjId != ''">
  760. and pf.payer_obj_id= #{payerObjId}
  761. </if>
  762. <if test="payerObjType !=null and payerObjType != ''">
  763. and pf.payer_obj_type = #{payerObjType}
  764. </if>
  765. </select>
  766. <select id="computeBillOweFee" parameterType="Map" resultType="Map">
  767. select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,bof.amount_owed amountOwed,bof.payer_obj_name
  768. roomName,bof.owner_name ownerName,bof.owner_tel ownerTel,pf.payer_obj_id payerObjId,pf.payer_obj_type
  769. payerObjType,
  770. pf.community_id communityId
  771. from pay_fee pf
  772. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type in ('001','002','003') and
  773. pfc.status_cd = '0' and pf.community_id = pfc.community_id
  774. inner join bill_owe_fee bof on pf.fee_id = bof.fee_id and bof.community_id = pf.community_id and bof.state
  775. ='1000' and bof.amount_owed &gt; 0
  776. inner join bill b on bof.bill_id = b.bill_id and b.community_id = bof.community_id and b.cur_bill = 'T'
  777. where pf.status_cd = '0'
  778. and pf.state = '2008001'
  779. and pf.community_id = #{communityId}
  780. <if test="payerObjId !=null and payerObjId != ''">
  781. and pf.payer_obj_id= #{payerObjId}
  782. </if>
  783. <if test="payerObjType !=null and payerObjType != ''">
  784. and pf.payer_obj_type = #{payerObjType}
  785. </if>
  786. <if test="page != -1 and page != null ">
  787. limit #{page}, #{row}
  788. </if>
  789. </select>
  790. <select id="computeEveryOweFeeCount" parameterType="Map" resultType="Map">
  791. select count(1) count
  792. from pay_fee pf
  793. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0'
  794. and pf.community_id = pfc.community_id
  795. where pf.end_time &lt; NOW()
  796. and pf.status_cd = '0'
  797. and pf.state = '2008001'
  798. and pf.community_id = #{communityId}
  799. <if test="payerObjId !=null and payerObjId != ''">
  800. and pf.payer_obj_id= #{payerObjId}
  801. </if>
  802. <if test="payerObjType !=null and payerObjType != ''">
  803. and pf.payer_obj_type = #{payerObjType}
  804. </if>
  805. </select>
  806. <select id="computeEveryOweFee" parameterType="Map" resultType="Map">
  807. select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,pf.payer_obj_id payerObjId,pf.payer_obj_type
  808. payerObjType,
  809. pf.community_id communityId,pfc.computing_formula computingFormula,pfc.square_price
  810. squarePrice,pfc.additional_amount additionalAmount
  811. from pay_fee pf
  812. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0'
  813. and pf.community_id = pfc.community_id
  814. where pf.end_time &lt; NOW()
  815. and pf.status_cd = '0'
  816. and pf.state = '2008001'
  817. and pf.community_id = #{communityId}
  818. <if test="payerObjId !=null and payerObjId != ''">
  819. and pf.payer_obj_id= #{payerObjId}
  820. </if>
  821. <if test="payerObjType !=null and payerObjType != ''">
  822. and pf.payer_obj_type = #{payerObjType}
  823. </if>
  824. <if test="page != -1 and page != null ">
  825. limit #{page}, #{row}
  826. </if>
  827. </select>
  828. </mapper>