FeeServiceDaoImplMapper.xml 34 KB

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