FeeServiceDaoImplMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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,batch_id
  10. ) values (
  11. #{amount},#{operate},#{incomeObjId},#{feeTypeCd},#{startTime},#{endTime},#{communityId},#{bId},#{feeId},#{userId},#{payerObjId},
  12. #{feeFlag},#{state},#{configId},#{payerObjType},#{batchId}
  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,t.batch_id,t.batch_id batchId
  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="payerObjId !=null and payerObjId != ''">
  52. and t.payer_obj_id= #{payerObjId}
  53. </if>
  54. <if test="state !=null and state != ''">
  55. and t.state= #{state}
  56. </if>
  57. <if test="feeFlag !=null and feeFlag != ''">
  58. and t.fee_flag= #{feeFlag}
  59. </if>
  60. <if test="configId !=null and configId != ''">
  61. and t.config_id= #{configId}
  62. </if>
  63. <if test="payerObjType !=null and payerObjType != ''">
  64. and t.payer_obj_type = #{payerObjType}
  65. </if>
  66. </select>
  67. <!-- 保存费用信息至 instance表中 add by wuxw 2018-07-03 -->
  68. <insert id="saveFeeInfoInstance" parameterType="Map">
  69. insert into pay_fee(
  70. 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,batch_id
  71. ) select
  72. 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
  73. ,t.fee_flag,t.state,t.config_id,t.payer_obj_type,t.batch_id
  74. from business_pay_fee t where 1=1
  75. <if test="amount !=null and amount != ''">
  76. and t.amount= #{amount}
  77. </if>
  78. and t.operate= 'ADD'
  79. <if test="incomeObjId !=null and incomeObjId != ''">
  80. and t.income_obj_id= #{incomeObjId}
  81. </if>
  82. <if test="feeTypeCd !=null and feeTypeCd != ''">
  83. and t.fee_type_cd= #{feeTypeCd}
  84. </if>
  85. <if test="startTime !=null ">
  86. and t.start_time= #{startTime}
  87. </if>
  88. <if test="endTime !=null ">
  89. and t.end_time= #{endTime}
  90. </if>
  91. <if test="communityId !=null and communityId != ''">
  92. and t.community_id= #{communityId}
  93. </if>
  94. <if test="bId !=null and bId != ''">
  95. and t.b_id= #{bId}
  96. </if>
  97. <if test="feeId !=null and feeId != ''">
  98. and t.fee_id= #{feeId}
  99. </if>
  100. <if test="payerObjId !=null and payerObjId != ''">
  101. and t.payer_obj_id= #{payerObjId}
  102. </if>
  103. <if test="state !=null and state != ''">
  104. and t.state= #{state}
  105. </if>
  106. <if test="feeFlag !=null and feeFlag != ''">
  107. and t.fee_flag= #{feeFlag}
  108. </if>
  109. <if test="configId !=null and configId != ''">
  110. and t.config_id= #{configId}
  111. </if>
  112. <if test="payerObjType !=null and payerObjType != ''">
  113. and t.payer_obj_type = #{payerObjType}
  114. </if>
  115. </insert>
  116. <!-- 查询费用信息 add by wuxw 2018-07-03 -->
  117. <select id="getFeeInfo" parameterType="Map" resultType="Map">
  118. select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  119. feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
  120. 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
  121. userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
  122. additionalAmount,pfc.fee_flag,pfc.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
  123. pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
  124. computingFormula,pfc.computing_formula_text computingFormulaText,
  125. pfc.bill_type billType,t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
  126. configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,td4.name
  127. billTypeName,pfa.value importFeeName,ifd.end_time importFeeEndTime,mw.cur_degrees curDegrees,mw.pre_degrees
  128. preDegrees,
  129. mw.pre_reading_time preReadingTime,mw.cur_reading_time curReadingTime,pfa1.`value` deadlineTime,pfa1.`value` maxEndTime,mw.price
  130. mwPrice,
  131. pfa2.`value` ownerName,t.batch_id,t.batch_id batchId,
  132. pfc.pay_online payOnline,pfc.scale,pfc.decimal_place decimalPlace,pfc.units,pfc.prepayment_period prepaymentPeriod
  133. from pay_fee t
  134. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and
  135. pfc.status_cd = '0'
  136. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  137. td1.table_columns = 'fee_type_cd'
  138. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  139. left join t_dict td3 on pfc.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  140. 'fee_flag'
  141. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  142. td4.table_columns = 'bill_type'
  143. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002' and pfa.status_cd = '0'
  144. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  145. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.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. <if test="ownerId != null and ownerId != ''">
  149. LEFT JOIN pay_fee_attrs pfao on t.fee_id = pfao.fee_id and pfao.spec_cd = '390007' and pfao.status_cd = '0'
  150. </if>
  151. where 1 =1
  152. <if test="amount !=null and amount != ''">
  153. and t.amount= #{amount}
  154. </if>
  155. <if test="ownerId !=null and ownerId != ''">
  156. and pfao.value= #{ownerId}
  157. </if>
  158. <if test="incomeObjId !=null and incomeObjId != ''">
  159. and t.income_obj_id= #{incomeObjId}
  160. </if>
  161. <if test="feeTypeCd !=null and feeTypeCd != ''">
  162. and t.fee_type_cd= #{feeTypeCd}
  163. </if>
  164. <if test="feeTypeCds != null ">
  165. and t.fee_type_cd in
  166. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  167. #{item}
  168. </foreach>
  169. </if>
  170. <if test="startTime !=null ">
  171. and t.start_time= #{startTime}
  172. </if>
  173. <if test="statusCd !=null and statusCd != ''">
  174. and t.status_cd= #{statusCd}
  175. </if>
  176. <if test="endTime !=null ">
  177. and t.end_time= #{endTime}
  178. </if>
  179. <if test="arrearsEndTime != null">
  180. and t.end_time &lt; #{arrearsEndTime}
  181. </if>
  182. <if test="nowDate != null">
  183. and t.end_time &gt; #{nowDate}
  184. </if>
  185. <if test="communityId !=null and communityId != ''">
  186. and t.community_id= #{communityId}
  187. and pfc.community_id in (#{communityId},'9999')
  188. </if>
  189. <if test="bId !=null and bId != ''">
  190. and t.b_id= #{bId}
  191. </if>
  192. <if test="feeId !=null and feeId != ''">
  193. and t.fee_id= #{feeId}
  194. </if>
  195. <if test="payerObjId !=null and payerObjId != ''">
  196. and t.payer_obj_id= #{payerObjId}
  197. </if>
  198. <if test="payerObjIds != null and payerObjIds.length > 0">
  199. and t.payer_obj_id in
  200. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  201. #{item}
  202. </foreach>
  203. </if>
  204. <if test="state !=null and state != ''">
  205. and t.state= #{state}
  206. </if>
  207. <if test="feeFlag !=null and feeFlag != ''">
  208. and t.fee_flag= #{feeFlag}
  209. </if>
  210. <if test="configId !=null and configId != ''">
  211. and t.config_id= #{configId}
  212. </if>
  213. <if test="payerObjType !=null and payerObjType != ''">
  214. and t.payer_obj_type = #{payerObjType}
  215. </if>
  216. <if test="deductFrom !=null and deductFrom != ''">
  217. and pfc.deduct_from = #{deductFrom}
  218. </if>
  219. order by t.payer_obj_id,pfc.fee_name,t.end_time
  220. <if test="page != -1 and page != null ">
  221. limit #{page}, #{row}
  222. </if>
  223. </select>
  224. <!-- 修改费用信息 add by wuxw 2018-07-03 -->
  225. <update id="updateFeeInfoInstance" parameterType="Map">
  226. update pay_fee t set t.status_cd = #{statusCd}
  227. <if test="newBId != null and newBId != ''">
  228. ,t.b_id = #{newBId}
  229. </if>
  230. <if test="amount !=null and amount != ''">
  231. , t.amount= #{amount}
  232. </if>
  233. <if test="incomeObjId !=null and incomeObjId != ''">
  234. , t.income_obj_id= #{incomeObjId}
  235. </if>
  236. <if test="feeTypeCd !=null and feeTypeCd != ''">
  237. , t.fee_type_cd= #{feeTypeCd}
  238. </if>
  239. <if test="startTime !=null ">
  240. , t.start_time= #{startTime}
  241. </if>
  242. <if test="endTime !=null">
  243. , t.end_time= #{endTime}
  244. </if>
  245. <if test="communityId !=null and communityId != ''">
  246. , t.community_id= #{communityId}
  247. </if>
  248. <if test="userId !=null and userId != ''">
  249. , t.user_id= #{userId}
  250. </if>
  251. <if test="payerObjId !=null and payerObjId != ''">
  252. , t.payer_obj_id= #{payerObjId}
  253. </if>
  254. <if test="state !=null and state != ''">
  255. , t.state= #{state}
  256. </if>
  257. <if test="feeFlag !=null and feeFlag != ''">
  258. , t.fee_flag= #{feeFlag}
  259. </if>
  260. where 1=1
  261. <if test="bId !=null and bId != ''">
  262. and t.b_id= #{bId}
  263. </if>
  264. <if test="feeId !=null and feeId != ''">
  265. and t.fee_id= #{feeId}
  266. </if>
  267. </update>
  268. <!-- 查询费用数量 add by wuxw 2018-07-03 -->
  269. <select id="queryFeesCount" parameterType="Map" resultType="Map">
  270. select count(1) count
  271. from pay_fee t
  272. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and
  273. pfc.status_cd = '0'
  274. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  275. td1.table_columns = 'fee_type_cd'
  276. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  277. left join t_dict td3 on pfc.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  278. 'fee_flag'
  279. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  280. td4.table_columns = 'bill_type'
  281. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002' and pfa.status_cd = '0'
  282. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  283. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
  284. left join import_fee_detail ifd on t.fee_id = ifd.fee_id and ifd.status_cd = '0' and t.fee_flag = '2006012'
  285. LEFT JOIN meter_water mw on t.fee_id = mw.fee_id and mw.status_cd = '0' and mw.community_id = t.community_id
  286. <if test="ownerId != null and ownerId != ''">
  287. LEFT JOIN pay_fee_attrs pfao on t.fee_id = pfao.fee_id and pfao.spec_cd = '390007' and pfao.status_cd = '0'
  288. </if>
  289. where 1 =1
  290. <if test="amount !=null and amount != ''">
  291. and t.amount= #{amount}
  292. </if>
  293. <if test="ownerId !=null and ownerId != ''">
  294. and pfao.value= #{ownerId}
  295. </if>
  296. <if test="incomeObjId !=null and incomeObjId != ''">
  297. and t.income_obj_id= #{incomeObjId}
  298. </if>
  299. <if test="feeTypeCd !=null and feeTypeCd != ''">
  300. and t.fee_type_cd= #{feeTypeCd}
  301. </if>
  302. <if test="feeTypeCds != null ">
  303. and t.fee_type_cd in
  304. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  305. #{item}
  306. </foreach>
  307. </if>
  308. <if test="startTime !=null ">
  309. and t.start_time= #{startTime}
  310. </if>
  311. <if test="statusCd !=null and statusCd != ''">
  312. and t.status_cd= #{statusCd}
  313. </if>
  314. <if test="endTime !=null ">
  315. and t.end_time= #{endTime}
  316. </if>
  317. <if test="arrearsEndTime != null">
  318. and t.end_time &lt; #{arrearsEndTime}
  319. </if>
  320. <if test="nowDate != null">
  321. and t.end_time &gt; #{nowDate}
  322. </if>
  323. <if test="communityId !=null and communityId != ''">
  324. and t.community_id= #{communityId}
  325. and pfc.community_id in (#{communityId},'9999')
  326. </if>
  327. <if test="bId !=null and bId != ''">
  328. and t.b_id= #{bId}
  329. </if>
  330. <if test="feeId !=null and feeId != ''">
  331. and t.fee_id= #{feeId}
  332. </if>
  333. <if test="payerObjId !=null and payerObjId != ''">
  334. and t.payer_obj_id= #{payerObjId}
  335. </if>
  336. <if test="payerObjIds != null and payerObjIds.length > 0">
  337. and t.payer_obj_id in
  338. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  339. #{item}
  340. </foreach>
  341. </if>
  342. <if test="state !=null and state != ''">
  343. and t.state= #{state}
  344. </if>
  345. <if test="feeFlag !=null and feeFlag != ''">
  346. and t.fee_flag= #{feeFlag}
  347. </if>
  348. <if test="configId !=null and configId != ''">
  349. and t.config_id= #{configId}
  350. </if>
  351. <if test="payerObjType !=null and payerObjType != ''">
  352. and t.payer_obj_type = #{payerObjType}
  353. </if>
  354. <if test="deductFrom !=null and deductFrom != ''">
  355. and pfc.deduct_from = #{deductFrom}
  356. </if>
  357. </select>
  358. <!-- 查询账期 -->
  359. <select id="queryBills" parameterType="Map" resultType="Map">
  360. select
  361. t.bill_id billId,
  362. t.bill_name billName,
  363. t.receivable,
  364. t.cur_receivable curReceivable,
  365. t.receipts,
  366. t.bill_time billTime,
  367. t.community_id communityId,
  368. t.config_id configId,
  369. t.cur_bill curBill,
  370. td.name curBillName,
  371. c.fee_name feeName
  372. from bill t
  373. left join pay_fee_config c on t.config_id = c.config_id and c.community_id = t.community_id and c.status_cd =
  374. '0'
  375. left join t_dict td on td.table_name = 'bill' and td.table_columns = 'cur_bill' and t.cur_bill = td.status_cd
  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 like '%${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 like '%${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. td2.name stateName
  465. from bill_owe_fee t
  466. <if test="curBill !=null and curBill != ''">
  467. inner join bill b on t.bill_id = b.bill_id and b.community_id = t.community_id and b.cur_bill = #{curBill}
  468. </if>
  469. left join pay_fee pf on t.fee_id = pf.fee_id and t.community_id = pf.community_id and pf.status_cd = '0'
  470. left join t_dict td on pf.fee_type_cd = td.status_cd and td.table_name = 'pay_fee_config' and td.table_columns =
  471. 'fee_type_cd'
  472. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'bill_owe_fee' and td2.table_columns =
  473. 'state'
  474. where 1 = 1
  475. <if test="oweId !=null and oweId != ''">
  476. and t.owe_id= #{oweId}
  477. </if>
  478. <if test="billId !=null and billId != ''">
  479. and t.bill_id= #{billId}
  480. </if>
  481. <if test="feeId !=null and feeId != ''">
  482. and t.fee_id= #{feeId}
  483. </if>
  484. <if test="billAmountOwed !=null and billAmountOwed != ''">
  485. and t.bill_amount_owed= #{billAmountOwed}
  486. </if>
  487. <if test="amountOwed !=null and amountOwed != ''">
  488. and t.amount_owed= #{amountOwed}
  489. </if>
  490. <if test="feeEndTime != null">
  491. and t.fee_end_time = #{feeEndTime}
  492. </if>
  493. <if test="ownerId != null and ownerId != ''">
  494. and t.owner_id = #{ownerId}
  495. </if>
  496. <if test="ownerIds !=null">
  497. and t.owner_id in
  498. <foreach collection="ownerIds" open="(" close=")"
  499. separator="," item="item">
  500. #{item}
  501. </foreach>
  502. </if>
  503. <if test="ownerName != null and ownerName != ''">
  504. and t.owner_name like '%${ownerName}%'
  505. </if>
  506. <if test="communityId !=null and communityId != ''">
  507. and t.community_id= #{communityId}
  508. </if>
  509. <if test="state !=null and state != ''">
  510. and t.state= #{state}
  511. </if>
  512. order by t.create_time desc
  513. <if test="page != -1 and page != null ">
  514. limit #{page}, #{row}
  515. </if>
  516. </select>
  517. <!-- 查询账期 -->
  518. <select id="queryBillOweFeeCount" parameterType="Map" resultType="Map">
  519. select count(1) count
  520. from bill_owe_fee t
  521. where 1 =1
  522. <if test="oweId !=null and oweId != ''">
  523. and t.owe_id= #{oweId}
  524. </if>
  525. <if test="billId !=null and billId != ''">
  526. and t.bill_id= #{billId}
  527. </if>
  528. <if test="feeId !=null and feeId != ''">
  529. and t.fee_id= #{feeId}
  530. </if>
  531. <if test="billAmountOwed !=null and billAmountOwed != ''">
  532. and t.bill_amount_owed= #{billAmountOwed}
  533. </if>
  534. <if test="amountOwed !=null and amountOwed != ''">
  535. and t.amount_owed= #{amountOwed}
  536. </if>
  537. <if test="feeEndTime != null">
  538. and t.fee_end_time = #{feeEndTime}
  539. </if>
  540. <if test="ownerId != null and ownerId != ''">
  541. and t.owner_id = #{ownerId}
  542. </if>
  543. <if test="ownerName != null and ownerName != ''">
  544. and t.owner_name like '%${ownerName}%'
  545. </if>
  546. <if test="communityId !=null and communityId != ''">
  547. and t.community_id= #{communityId}
  548. </if>
  549. <if test="state !=null and state != ''">
  550. and t.state= #{state}
  551. </if>
  552. </select>
  553. <insert id="insertBillOweFees" parameterType="Map">
  554. INSERT INTO bill_owe_fee
  555. (`owe_id`, `bill_id`, `fee_id`, `bill_amount_owed`, `amount_owed`, `fee_end_time`, `owner_id`, `owner_name`,
  556. `owner_tel`, `payer_obj_name`, `payer_obj_type`, `community_id`, `state`,deadline_time)
  557. VALUES (#{oweId}, #{billId}, #{feeId}, #{billAmountOwed}, #{amountOwed}, #{feeEndTime}, #{ownerId},
  558. #{ownerName},
  559. #{ownerTel}, #{payerObjName}, #{payerObjType}, #{communityId}, #{state},#{deadlineTime})
  560. </insert>
  561. <update id="updateBillOweFees" parameterType="Map">
  562. update bill_owe_fee t set t.state = #{state} where t.fee_id = #{feeId} and t.community_id=#{communityId}
  563. and t.bill_id=#{billId}
  564. </update>
  565. <insert id="insertBill" parameterType="Map">
  566. INSERT INTO bill (`bill_id`, `bill_name`, `receivable`, `receipts`, `bill_time`, `community_id`, `config_id`,
  567. `remark`, `cur_bill`, `cur_receivable`)
  568. VALUES (#{billId}, #{billName}, #{receivable}, #{receipts}, #{billTime}, #{communityId}, #{configId},
  569. #{remark}, #{curBill}, #{curReceivable})
  570. </insert>
  571. <update id="updateBill" parameterType="Map">
  572. update bill set cur_bill= 'F' where config_id = #{configId}
  573. </update>
  574. <!-- 查询费用数量 add by wuxw 2018-07-03 -->
  575. <select id="queryFeeByAttrCount" parameterType="Map" resultType="Map">
  576. select count(1) count
  577. from pay_fee t
  578. left join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and t.config_id = pfc.config_id and
  579. pfc.status_cd = '0'
  580. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_columns = 'fee_type_cd' and td1.table_name
  581. = 'pay_fee_config'
  582. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  583. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  584. 'fee_flag'
  585. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.status_cd='0'
  586. where pfa.spec_cd = #{specCd}
  587. and pfa.value = #{value}
  588. <if test="amount !=null and amount != ''">
  589. and t.amount= #{amount}
  590. </if>
  591. <if test="incomeObjId !=null and incomeObjId != ''">
  592. and t.income_obj_id= #{incomeObjId}
  593. </if>
  594. <if test="feeTypeCd !=null and feeTypeCd != ''">
  595. and t.fee_type_cd= #{feeTypeCd}
  596. </if>
  597. <if test="feeTypeCds != null ">
  598. and t.fee_type_cd in
  599. <foreach collection="feeTypeCds" item="item" open="(" close=")" separator=",">
  600. #{item}
  601. </foreach>
  602. </if>
  603. <if test="startTime !=null">
  604. and t.start_time= #{startTime}
  605. </if>
  606. <if test="statusCd !=null and statusCd != ''">
  607. and t.status_cd= #{statusCd}
  608. </if>
  609. <if test="endTime !=null ">
  610. and t.end_time= #{endTime}
  611. </if>
  612. <if test="arrearsEndTime != null">
  613. and t.end_time &lt; #{arrearsEndTime}
  614. </if>
  615. <if test="noArrearsEndTime != null">
  616. and t.end_time &gt; #{noArrearsEndTime}
  617. </if>
  618. <if test="communityId !=null and communityId != ''">
  619. and t.community_id= #{communityId}
  620. and pfc.community_id= #{communityId}
  621. </if>
  622. <if test="bId !=null and bId != ''">
  623. and t.b_id= #{bId}
  624. </if>
  625. <if test="feeId !=null and feeId != ''">
  626. and t.fee_id= #{feeId}
  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,pfc.computing_formula_text computingFormulaText,
  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="payerObjId !=null and payerObjId != ''">
  710. and t.payer_obj_id= #{payerObjId}
  711. </if>
  712. <if test="payerObjIds != null ">
  713. and t.payer_obj_id in
  714. <foreach collection="payerObjIds" item="item" open="(" close=")" separator=",">
  715. #{item}
  716. </foreach>
  717. </if>
  718. <if test="state !=null and state != ''">
  719. and t.state= #{state}
  720. </if>
  721. <if test="feeFlag !=null and feeFlag != ''">
  722. and t.fee_flag= #{feeFlag}
  723. </if>
  724. <if test="configId !=null and configId != ''">
  725. and t.config_id= #{configId}
  726. </if>
  727. <if test="payerObjType !=null and payerObjType != ''">
  728. and t.payer_obj_type = #{payerObjType}
  729. </if>
  730. order by t.create_time desc
  731. <if test="page != -1 and page != null ">
  732. limit #{page}, #{row}
  733. </if>
  734. </select>
  735. <!-- 批量插入费用 -->
  736. <insert id="insertFees" parameterType="Map">
  737. insert into pay_fee (amount,status_cd,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,
  738. user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type,batch_id)
  739. VALUES
  740. <foreach collection="payFeePos" item="item" separator=",">
  741. (#{item.amount},'0',#{item.incomeObjId},#{item.feeTypeCd},#{item.startTime},#{item.endTime},#{item.communityId},
  742. '-1',#{item.feeId},#{item.userId},#{item.payerObjId},#{item.feeFlag},#{item.state},#{item.configId},#{item.payerObjType},#{item.batchId})
  743. </foreach>
  744. </insert>
  745. <select id="computeBillOweFeeCount" parameterType="Map" resultType="Map">
  746. select count(1) count
  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
  751. ='1000' and bof.amount_owed &gt; 0
  752. inner join bill b on bof.bill_id = b.bill_id and b.community_id = bof.community_id and b.cur_bill = 'T'
  753. where pf.status_cd = '0'
  754. and pf.state = '2008001'
  755. and pf.community_id = #{communityId}
  756. <if test="payerObjId !=null and payerObjId != ''">
  757. and pf.payer_obj_id= #{payerObjId}
  758. </if>
  759. <if test="payerObjType !=null and payerObjType != ''">
  760. and pf.payer_obj_type = #{payerObjType}
  761. </if>
  762. </select>
  763. <select id="computeBillOweFee" parameterType="Map" resultType="Map">
  764. select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,bof.amount_owed amountOwed,bof.payer_obj_name
  765. roomName,bof.owner_name ownerName,bof.owner_tel ownerTel,pf.payer_obj_id payerObjId,pf.payer_obj_type
  766. payerObjType,
  767. pf.community_id communityId
  768. from pay_fee pf
  769. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type in ('001','002','003') and
  770. pfc.status_cd = '0' and pf.community_id = pfc.community_id
  771. inner join bill_owe_fee bof on pf.fee_id = bof.fee_id and bof.community_id = pf.community_id and bof.state
  772. ='1000' and bof.amount_owed &gt; 0
  773. inner join bill b on bof.bill_id = b.bill_id and b.community_id = bof.community_id and b.cur_bill = 'T'
  774. where pf.status_cd = '0'
  775. and pf.state = '2008001'
  776. and pf.community_id = #{communityId}
  777. <if test="payerObjId !=null and payerObjId != ''">
  778. and pf.payer_obj_id= #{payerObjId}
  779. </if>
  780. <if test="payerObjType !=null and payerObjType != ''">
  781. and pf.payer_obj_type = #{payerObjType}
  782. </if>
  783. <if test="page != -1 and page != null ">
  784. limit #{page}, #{row}
  785. </if>
  786. </select>
  787. <select id="computeEveryOweFeeCount" parameterType="Map" resultType="Map">
  788. select count(1) count
  789. from pay_fee pf
  790. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0'
  791. and pf.community_id = pfc.community_id
  792. where pf.end_time &lt; NOW()
  793. and pf.status_cd = '0'
  794. and pf.state = '2008001'
  795. and pf.community_id = #{communityId}
  796. <if test="payerObjId !=null and payerObjId != ''">
  797. and pf.payer_obj_id= #{payerObjId}
  798. </if>
  799. <if test="payerObjType !=null and payerObjType != ''">
  800. and pf.payer_obj_type = #{payerObjType}
  801. </if>
  802. </select>
  803. <select id="computeEveryOweFee" parameterType="Map" resultType="Map">
  804. select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,pf.payer_obj_id payerObjId,pf.payer_obj_type
  805. payerObjType,
  806. pf.community_id communityId,pfc.computing_formula computingFormula,pfc.computing_formula_text
  807. computingFormulaText,
  808. pfc.square_price
  809. squarePrice,pfc.additional_amount additionalAmount
  810. from pay_fee pf
  811. INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0'
  812. and pf.community_id = pfc.community_id
  813. where pf.end_time &lt; NOW()
  814. and pf.status_cd = '0'
  815. and pf.state = '2008001'
  816. and pf.community_id = #{communityId}
  817. <if test="payerObjId !=null and payerObjId != ''">
  818. and pf.payer_obj_id= #{payerObjId}
  819. </if>
  820. <if test="payerObjType !=null and payerObjType != ''">
  821. and pf.payer_obj_type = #{payerObjType}
  822. </if>
  823. <if test="page != -1 and page != null ">
  824. limit #{page}, #{row}
  825. </if>
  826. </select>
  827. <!-- 根据批次删除费用 add by wuxw 2018-07-03 -->
  828. <update id="deleteFeesByBatch" parameterType="Map">
  829. update pay_fee t set t.status_cd = '1'
  830. where 1=1
  831. and t.batch_id= #{batchId}
  832. and t.community_id= #{communityId}
  833. </update>
  834. </mapper>