FeeServiceDaoImplMapper.xml 33 KB

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