ReportFeeMonthStatisticsServiceDaoImplMapper.xml 149 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="reportFeeMonthStatisticsServiceDaoImpl">
  5. <!-- 保存费用月统计信息 add by wuxw 2018-07-03 -->
  6. <insert id="saveReportFeeMonthStatisticsInfo" parameterType="Map">
  7. insert into report_fee_month_statistics(receivable_amount, statistics_id, update_time, remark, obj_name,
  8. received_amount, fee_year, fee_month, fee_id, config_id,
  9. obj_id, fee_name, owe_amount, community_id, fee_create_time, obj_type,
  10. deadline_time, cur_max_time,
  11. his_owe_amount, cur_receivable_amount, cur_received_amount,
  12. his_owe_received_amount, pre_received_amount, obj_name_num)
  13. values (#{receivableAmount}, #{statisticsId}, #{updateTime}, #{remark}, #{objName}, #{receivedAmount},
  14. #{feeYear}, #{feeMonth},
  15. #{feeId}, #{configId}, #{objId}, #{feeName}, #{oweAmount}, #{communityId}, #{feeCreateTime}, #{objType},
  16. #{deadlineTime}, #{curMaxTime},
  17. #{hisOweAmount}, #{curReceivableAmount}, #{curReceivedAmount}, #{hisOweReceivedAmount},
  18. #{preReceivedAmount}, #{objNameNum})
  19. </insert>
  20. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  21. <select id="getReportFeeMonthStatisticsInfo" parameterType="Map" resultType="Map">
  22. select t.receivable_amount,t.receivable_amount receivableAmount,t.statistics_id,t.statistics_id
  23. statisticsId,t.update_time,t.update_time updateTime,t.remark,t.status_cd,t.status_cd
  24. statusCd,t.obj_name,t.obj_name objName,t.received_amount,t.received_amount receivedAmount,t.fee_year,t.fee_year
  25. feeYear,t.fee_month,t.fee_month feeMonth,t.fee_id,t.fee_id feeId,t.config_id,t.config_id
  26. configId,t.obj_id,t.obj_id objId,t.fee_name,t.fee_name feeName,t.owe_amount,t.owe_amount
  27. oweAmount,t.community_id,t.community_id communityId,t.fee_create_time,t.fee_create_time
  28. feeCreateTime,t.obj_type,t.obj_type objType,t.cur_max_time curMaxTime,
  29. t.his_owe_amount hisOweAmount,t.cur_receivable_amount curReceivableAmount,t.cur_received_amount
  30. curReceivedAmount,t.obj_name_num,t.obj_name_num objNameNum,
  31. t.his_owe_received_amount hisOweReceivedAmount,t.pre_received_amount preReceivedAmount
  32. from report_fee_month_statistics t
  33. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  34. where 1 =1
  35. <if test="receivableAmount !=null and receivableAmount != ''">
  36. and t.receivable_amount= #{receivableAmount}
  37. </if>
  38. <if test="statisticsId !=null and statisticsId != ''">
  39. and t.statistics_id= #{statisticsId}
  40. </if>
  41. <if test="updateTime !=null and updateTime != ''">
  42. and t.update_time= #{updateTime}
  43. </if>
  44. <if test="remark !=null and remark != ''">
  45. and t.remark= #{remark}
  46. </if>
  47. <if test="statusCd !=null and statusCd != ''">
  48. and t.status_cd= #{statusCd}
  49. </if>
  50. <if test="objName !=null and objName != ''">
  51. and t.obj_name= #{objName}
  52. </if>
  53. <if test="objNameNum != null and objNameNum != ''">
  54. and t.obj_name_num = #{objNameNum}
  55. </if>
  56. <if test="receivedAmount !=null and receivedAmount != ''">
  57. and t.received_amount= #{receivedAmount}
  58. </if>
  59. <if test="feeYear !=null and feeYear != ''">
  60. and t.fee_year= #{feeYear}
  61. </if>
  62. <if test="feeMonth !=null and feeMonth != ''">
  63. and t.fee_month= #{feeMonth}
  64. </if>
  65. <if test="feeId !=null and feeId != ''">
  66. and t.fee_id= #{feeId}
  67. </if>
  68. <if test="configId !=null and configId != ''">
  69. and t.config_id= #{configId}
  70. </if>
  71. <if test="objId !=null and objId != ''">
  72. and t.obj_id= #{objId}
  73. </if>
  74. <if test="feeName !=null and feeName != ''">
  75. and t.fee_name= #{feeName}
  76. </if>
  77. <if test="oweAmount !=null and oweAmount != ''">
  78. and t.owe_amount= #{oweAmount}
  79. </if>
  80. <if test="communityId !=null and communityId != ''">
  81. and t.community_id= #{communityId}
  82. </if>
  83. <if test="feeCreateTime !=null and feeCreateTime != ''">
  84. and t.fee_create_time= #{feeCreateTime}
  85. </if>
  86. <if test="objType !=null and objType != ''">
  87. and t.obj_type= #{objType}
  88. </if>
  89. order by t.create_time desc
  90. <if test="page != -1 and page != null ">
  91. limit #{page}, #{row}
  92. </if>
  93. </select>
  94. <!-- 修改费用月统计信息 add by wuxw 2018-07-03 -->
  95. <update id="updateReportFeeMonthStatisticsOwe" parameterType="Map">
  96. update report_fee_month_statistics t set
  97. t.owe_amount= #{oweAmount}
  98. where 1=1
  99. <if test="statisticsId !=null and statisticsId != ''">
  100. and t.statistics_id= #{statisticsId}
  101. </if>
  102. <if test="curMaxTime !=null ">
  103. and t.cur_max_time &lt;= #{curMaxTime}
  104. </if>
  105. <if test="feeId !=null and feeId != ''">
  106. and t.fee_id= #{feeId}
  107. </if>
  108. </update>
  109. <!-- 修改费用月统计信息 add by wuxw 2018-07-03 -->
  110. <update id="updateReportFeeMonthStatisticsInfo" parameterType="Map">
  111. update report_fee_month_statistics t set t.status_cd = #{statusCd}
  112. <if test="newBId != null and newBId != ''">
  113. ,t.b_id = #{newBId}
  114. </if>
  115. <if test="receivableAmount !=null and receivableAmount != ''">
  116. , t.receivable_amount= #{receivableAmount}
  117. </if>
  118. <if test="updateTime !=null and updateTime != ''">
  119. , t.update_time= #{updateTime}
  120. </if>
  121. <if test="deadlineTime !=null ">
  122. , t.deadline_time= #{deadlineTime}
  123. </if>
  124. <if test="remark !=null and remark != ''">
  125. , t.remark= #{remark}
  126. </if>
  127. <if test="objName !=null and objName != ''">
  128. , t.obj_name= #{objName}
  129. </if>
  130. <if test="objNameNum != null and objNameNum != ''">
  131. , t.obj_name_num= #{objNameNum}
  132. </if>
  133. <if test="receivedAmount !=null and receivedAmount != ''">
  134. , t.received_amount= #{receivedAmount}
  135. </if>
  136. <if test="feeYear !=null and feeYear != ''">
  137. , t.fee_year= #{feeYear}
  138. </if>
  139. <if test="feeMonth !=null and feeMonth != ''">
  140. , t.fee_month= #{feeMonth}
  141. </if>
  142. <if test="feeId !=null and feeId != ''">
  143. , t.fee_id= #{feeId}
  144. </if>
  145. <if test="configId !=null and configId != ''">
  146. , t.config_id= #{configId}
  147. </if>
  148. <if test="objId !=null and objId != ''">
  149. , t.obj_id= #{objId}
  150. </if>
  151. <if test="feeName !=null and feeName != ''">
  152. , t.fee_name= #{feeName}
  153. </if>
  154. <if test="oweAmount !=null and oweAmount != ''">
  155. , t.owe_amount= #{oweAmount}
  156. </if>
  157. <if test="feeCreateTime !=null and feeCreateTime != ''">
  158. , t.fee_create_time= #{feeCreateTime}
  159. </if>
  160. <if test="objType !=null and objType != ''">
  161. , t.obj_type= #{objType}
  162. </if>
  163. <if test="hisOweAmount !=null and hisOweAmount != ''">
  164. , t.his_owe_amount= #{hisOweAmount}
  165. </if>
  166. <if test="curReceivableAmount !=null and curReceivableAmount != ''">
  167. , t.cur_receivable_amount= #{curReceivableAmount}
  168. </if>
  169. <if test="curReceivedAmount !=null and curReceivedAmount != ''">
  170. , t.cur_received_amount= #{curReceivedAmount}
  171. </if>
  172. <if test="hisOweReceivedAmount !=null and hisOweReceivedAmount != ''">
  173. , t.his_owe_received_amount= #{hisOweReceivedAmount}
  174. </if>
  175. <if test="preReceivedAmount !=null and preReceivedAmount != ''">
  176. , t.pre_received_amount= #{preReceivedAmount}
  177. </if>
  178. where 1=1
  179. and t.statistics_id= #{statisticsId}
  180. <if test="communityId !=null and communityId != ''">
  181. and t.community_id= #{communityId}
  182. </if>
  183. </update>
  184. <!-- 修改费用月统计信息 add by wuxw 2018-07-03 -->
  185. <update id="deleteReportFeeMonthStatisticsInfo" parameterType="Map">
  186. update report_fee_month_statistics t set t.status_cd = '1'
  187. where 1=1
  188. <if test="statisticsId !=null and statisticsId != ''">
  189. and t.statistics_id= #{statisticsId}
  190. </if>
  191. <if test="communityId !=null and communityId != ''">
  192. and t.community_id= #{communityId}
  193. </if>
  194. <if test="feeId !=null and feeId != ''">
  195. and t.fee_id= #{feeId}
  196. </if>
  197. <if test="configId !=null and configId != ''">
  198. and t.config_id= #{configId}
  199. </if>
  200. </update>
  201. <select id="queryPayFeeDetailDiscount" parameterType="Map" resultType="Map">
  202. select t.detail_id detailId,
  203. t.receivable_amount receivableAmount,
  204. t.received_amount receivedAmount,
  205. pfdd.discount_price discountPrice,
  206. fdr.discount_small_type discountSmallType,
  207. fdr.rule_name ruleName
  208. from pay_fee_detail t
  209. left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
  210. left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
  211. left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
  212. where 1 = 1
  213. <if test="detailId !=null and detailId != ''">
  214. and t.detail_id = #{detailId}
  215. </if>
  216. </select>
  217. <!-- 查询费用月统计数量 add by wuxw 2018-07-03 -->
  218. <select id="queryReportFeeSummaryCount" parameterType="Map" resultType="Map">
  219. select count(1) count
  220. from (
  221. select t.fee_year,t.fee_month
  222. from report_fee_month_statistics t
  223. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  224. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  225. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  226. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  227. where t.status_cd = '0'
  228. <if test="roomNum !=null and roomNum != ''">
  229. and br.room_num= #{roomNum}
  230. </if>
  231. <if test="unitId !=null and unitId != ''">
  232. and bu.unit_id= #{unitId}
  233. </if>
  234. <if test="unitIds !=null ">
  235. and bu.unit_id in
  236. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  237. #{item}
  238. </foreach>
  239. </if>
  240. <if test="floorId !=null and floorId != ''">
  241. and f.floor_id = #{floorId}
  242. </if>
  243. <if test="objName !=null and objName != ''">
  244. and t.obj_name= #{objName}
  245. </if>
  246. <if test="objNameNum != null and objNameNum != ''">
  247. and t.obj_name_num= #{objNameNum}
  248. </if>
  249. <if test="feeYear !=null and feeYear != ''">
  250. and t.fee_year= #{feeYear}
  251. </if>
  252. <if test="feeMonth !=null and feeMonth != ''">
  253. and t.fee_month= #{feeMonth}
  254. </if>
  255. <if test="feeId !=null and feeId != ''">
  256. and t.fee_id= #{feeId}
  257. </if>
  258. <if test="configId !=null and configId != ''">
  259. and t.config_id= #{configId}
  260. </if>
  261. <if test="configIds !=null">
  262. and t.config_id in
  263. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  264. #{item}
  265. </foreach>
  266. </if>
  267. <if test="objId !=null and objId != ''">
  268. and t.obj_id= #{objId}
  269. </if>
  270. <if test="feeName !=null and feeName != ''">
  271. and t.fee_name= #{feeName}
  272. </if>
  273. <if test="communityId !=null and communityId != ''">
  274. and t.community_id= #{communityId}
  275. </if>
  276. <if test="startTime !=null and startTime != ''">
  277. and t.create_time &gt;= #{startTime}
  278. </if>
  279. <if test="endTime !=null and endTime != ''">
  280. and t.create_time &lt;= #{endTime}
  281. </if>
  282. group by t.fee_year,t.fee_month
  283. ) t
  284. </select>
  285. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  286. <select id="queryReportFeeSummary" parameterType="Map" resultType="Map">
  287. select t.fee_year feeYear,t.fee_month feeMonth,max(t.create_time) createTime
  288. <if test="configIds !=null">
  289. ,t.config_id configId
  290. </if>
  291. ,SUM(t.his_owe_amount) hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
  292. SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
  293. hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
  294. max(t.update_time) updateTime,sum(t.his_owe_amount+t.cur_receivable_amount)
  295. receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount
  296. from report_fee_month_statistics t
  297. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  298. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  299. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  300. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  301. where t.status_cd = '0'
  302. <if test="roomNum !=null and roomNum != ''">
  303. and br.room_num= #{roomNum}
  304. </if>
  305. <if test="unitId !=null and unitId != ''">
  306. and bu.unit_id= #{unitId}
  307. </if>
  308. <if test="unitIds !=null ">
  309. and bu.unit_id in
  310. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  311. #{item}
  312. </foreach>
  313. </if>
  314. <if test="floorId !=null and floorId != ''">
  315. and f.floor_id = #{floorId}
  316. </if>
  317. <if test="objName !=null and objName != ''">
  318. and t.obj_name= #{objName}
  319. </if>
  320. <if test="objNameNum != null and objNameNum != ''">
  321. and t.obj_name_num= #{objNameNum}
  322. </if>
  323. <if test="feeYear !=null and feeYear != ''">
  324. and t.fee_year= #{feeYear}
  325. </if>
  326. <if test="feeMonth !=null and feeMonth != ''">
  327. and t.fee_month= #{feeMonth}
  328. </if>
  329. <if test="feeId !=null and feeId != ''">
  330. and t.fee_id= #{feeId}
  331. </if>
  332. <if test="configId !=null and configId != ''">
  333. and t.config_id= #{configId}
  334. </if>
  335. <if test="configIds !=null">
  336. and t.config_id in
  337. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  338. #{item}
  339. </foreach>
  340. </if>
  341. <if test="objId !=null and objId != ''">
  342. and t.obj_id= #{objId}
  343. </if>
  344. <if test="feeName !=null and feeName != ''">
  345. and t.fee_name= #{feeName}
  346. </if>
  347. <if test="communityId !=null and communityId != ''">
  348. and t.community_id= #{communityId}
  349. </if>
  350. <if test="startTime !=null and startTime != ''">
  351. and t.create_time &gt;= #{startTime}
  352. </if>
  353. <if test="endTime !=null and endTime != ''">
  354. and t.create_time &lt;= #{endTime}
  355. </if>
  356. group by t.fee_year,t.fee_month
  357. <if test="configIds !=null">
  358. ,t.config_id
  359. </if>
  360. order by CONVERT(t.fee_month,SIGNED),CONVERT(t.fee_year,SIGNED) desc
  361. <if test="page != -1 and page != null ">
  362. limit #{page}, #{row}
  363. </if>
  364. </select>
  365. <select id="queryReportFeeSummaryDetailCount" parameterType="Map" resultType="Map">
  366. select count(1) count
  367. from report_fee_month_statistics t
  368. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  369. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  370. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  371. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  372. where t.status_cd = '0'
  373. <if test="roomNum !=null and roomNum != ''">
  374. and br.room_num= #{roomNum}
  375. </if>
  376. <if test="unitId !=null and unitId != ''">
  377. and bu.unit_id= #{unitId}
  378. </if>
  379. <if test="unitIds !=null ">
  380. and bu.unit_id in
  381. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  382. #{item}
  383. </foreach>
  384. </if>
  385. <if test="floorId !=null and floorId != ''">
  386. and f.floor_id = #{floorId}
  387. </if>
  388. <if test="objName !=null and objName != ''">
  389. and t.obj_name= #{objName}
  390. </if>
  391. <if test="objNameNum != null and objNameNum != ''">
  392. and t.obj_name_num= #{objNameNum}
  393. </if>
  394. <if test="feeYear !=null and feeYear != ''">
  395. and t.fee_year= #{feeYear}
  396. </if>
  397. <if test="feeMonth !=null and feeMonth != ''">
  398. and t.fee_month= #{feeMonth}
  399. </if>
  400. <if test="feeId !=null and feeId != ''">
  401. and t.fee_id= #{feeId}
  402. </if>
  403. <if test="configId !=null and configId != ''">
  404. and t.config_id= #{configId}
  405. </if>
  406. <if test="configIds !=null">
  407. and t.config_id in
  408. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  409. #{item}
  410. </foreach>
  411. </if>
  412. <if test="objId !=null and objId != ''">
  413. and t.obj_id= #{objId}
  414. </if>
  415. <if test="feeName !=null and feeName != ''">
  416. and t.fee_name= #{feeName}
  417. </if>
  418. <if test="communityId !=null and communityId != ''">
  419. and t.community_id= #{communityId}
  420. </if>
  421. <if test="startTime !=null and startTime != ''">
  422. and t.create_time &gt;= #{startTime}
  423. </if>
  424. <if test="endTime !=null and endTime != ''">
  425. and t.create_time &lt;= #{endTime}
  426. </if>
  427. </select>
  428. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  429. <select id="queryReportFeeSummaryDetail" parameterType="Map" resultType="Map">
  430. select t.obj_name objName,t.fee_name feeName,t.fee_year feeYear,t.fee_month feeMonth,t.create_time createTime
  431. ,t.config_id configId,t.obj_name_num objNameNum,t.his_owe_amount hisOweAmount,t.cur_receivable_amount
  432. curReceivableAmount,t.cur_received_amount curReceivedAmount,t.his_owe_received_amount
  433. hisOweReceivedAmount,t.pre_received_amount preReceivedAmount,
  434. t.update_time updateTime,t.his_owe_amount+t.cur_receivable_amount
  435. receivableAmount,t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount receivedAmount
  436. from report_fee_month_statistics t
  437. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  438. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  439. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  440. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  441. where t.status_cd = '0'
  442. <if test="roomNum !=null and roomNum != ''">
  443. and br.room_num= #{roomNum}
  444. </if>
  445. <if test="unitId !=null and unitId != ''">
  446. and bu.unit_id= #{unitId}
  447. </if>
  448. <if test="unitIds !=null ">
  449. and bu.unit_id in
  450. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  451. #{item}
  452. </foreach>
  453. </if>
  454. <if test="floorId !=null and floorId != ''">
  455. and f.floor_id = #{floorId}
  456. </if>
  457. <if test="objName !=null and objName != ''">
  458. and t.obj_name= #{objName}
  459. </if>
  460. <if test="objNameNum != null and objNameNum != ''">
  461. and t.obj_name_num= #{objNameNum}
  462. </if>
  463. <if test="feeYear !=null and feeYear != ''">
  464. and t.fee_year= #{feeYear}
  465. </if>
  466. <if test="feeMonth !=null and feeMonth != ''">
  467. and t.fee_month= #{feeMonth}
  468. </if>
  469. <if test="feeId !=null and feeId != ''">
  470. and t.fee_id= #{feeId}
  471. </if>
  472. <if test="configId !=null and configId != ''">
  473. and t.config_id= #{configId}
  474. </if>
  475. <if test="configIds !=null">
  476. and t.config_id in
  477. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  478. #{item}
  479. </foreach>
  480. </if>
  481. <if test="objId !=null and objId != ''">
  482. and t.obj_id= #{objId}
  483. </if>
  484. <if test="feeName !=null and feeName != ''">
  485. and t.fee_name= #{feeName}
  486. </if>
  487. <if test="communityId !=null and communityId != ''">
  488. and t.community_id= #{communityId}
  489. </if>
  490. <if test="startTime !=null and startTime != ''">
  491. and t.create_time &gt;= #{startTime}
  492. </if>
  493. <if test="endTime !=null and endTime != ''">
  494. and t.create_time &lt;= #{endTime}
  495. </if>
  496. <if test="page != -1 and page != null ">
  497. limit #{page}, #{row}
  498. </if>
  499. </select>
  500. <!-- 查询费用月统计信息 大计 add by wuxw 2018-07-03 -->
  501. <select id="queryReportFeeSummaryMajor" parameterType="Map" resultType="Map">
  502. select
  503. sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) allReceivedAmount,
  504. sum(t.his_owe_received_amount) allHisOweReceivedAmount
  505. from report_fee_month_statistics t
  506. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  507. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  508. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  509. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  510. where t.status_cd = '0'
  511. <if test="roomNum !=null and roomNum != ''">
  512. and br.room_num= #{roomNum}
  513. </if>
  514. <if test="unitId !=null and unitId != ''">
  515. and bu.unit_id= #{unitId}
  516. </if>
  517. <if test="unitIds !=null ">
  518. and bu.unit_id in
  519. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  520. #{item}
  521. </foreach>
  522. </if>
  523. <if test="floorId !=null and floorId != ''">
  524. and f.floor_id = #{floorId}
  525. </if>
  526. <if test="objName !=null and objName != ''">
  527. and t.obj_name= #{objName}
  528. </if>
  529. <if test="objNameNum != null and objNameNum != ''">
  530. and t.obj_name_num= #{objNameNum}
  531. </if>
  532. <if test="feeYear !=null and feeYear != ''">
  533. and t.fee_year= #{feeYear}
  534. </if>
  535. <if test="feeMonth !=null and feeMonth != ''">
  536. and t.fee_month= #{feeMonth}
  537. </if>
  538. <if test="feeId !=null and feeId != ''">
  539. and t.fee_id= #{feeId}
  540. </if>
  541. <if test="configId !=null and configId != ''">
  542. and t.config_id= #{configId}
  543. </if>
  544. <if test="configIds !=null">
  545. and t.config_id in
  546. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  547. #{item}
  548. </foreach>
  549. </if>
  550. <if test="objId !=null and objId != ''">
  551. and t.obj_id= #{objId}
  552. </if>
  553. <if test="feeName !=null and feeName != ''">
  554. and t.fee_name= #{feeName}
  555. </if>
  556. <if test="communityId !=null and communityId != ''">
  557. and t.community_id= #{communityId}
  558. </if>
  559. <if test="startTime !=null and startTime != ''">
  560. and t.create_time &gt;= #{startTime}
  561. </if>
  562. <if test="endTime !=null and endTime != ''">
  563. and t.create_time &lt;= #{endTime}
  564. </if>
  565. </select>
  566. <select id="queryReportFloorUnitFeeSummaryCount" parameterType="Map" resultType="Map">
  567. select count(1) count
  568. from (
  569. select t.fee_year feeYear,t.fee_month feeMonth, f.floor_num flooNum, bu.unit_num unitNum
  570. from report_fee_month_statistics t
  571. INNER JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  572. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  573. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  574. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  575. where t.status_cd = '0'
  576. <if test="roomNum !=null and roomNum != ''">
  577. and br.room_num= #{roomNum}
  578. </if>
  579. <if test="unitId !=null and unitId != ''">
  580. and bu.unit_id= #{unitId}
  581. </if>
  582. <if test="floorId !=null and floorId != ''">
  583. and f.floor_id = #{floorId}
  584. </if>
  585. <if test="objName !=null and objName != ''">
  586. and t.obj_name= #{objName}
  587. </if>
  588. <if test="objNameNum != null and objNameNum != ''">
  589. and t.obj_name_num= #{objNameNum}
  590. </if>
  591. <if test="feeYear !=null and feeYear != ''">
  592. and t.fee_year= #{feeYear}
  593. </if>
  594. <if test="feeMonth !=null and feeMonth != ''">
  595. and t.fee_month= #{feeMonth}
  596. </if>
  597. <if test="feeId !=null and feeId != ''">
  598. and t.fee_id= #{feeId}
  599. </if>
  600. <if test="configId !=null and configId != ''">
  601. and t.config_id= #{configId}
  602. </if>
  603. <if test="configIds !=null">
  604. and t.config_id in
  605. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  606. #{item}
  607. </foreach>
  608. </if>
  609. <if test="objId !=null and objId != ''">
  610. and t.obj_id= #{objId}
  611. </if>
  612. <if test="feeName !=null and feeName != ''">
  613. and t.fee_name= #{feeName}
  614. </if>
  615. <if test="communityId !=null and communityId != ''">
  616. and t.community_id= #{communityId}
  617. </if>
  618. <if test="startTime !=null and startTime != ''">
  619. and t.create_time &gt;= #{startTime}
  620. </if>
  621. <if test="endTime !=null and endTime != ''">
  622. and t.create_time &lt;= #{endTime}
  623. </if>
  624. GROUP BY t.fee_year,t.fee_month,f.floor_num,bu.unit_id,bu.unit_num
  625. ) t
  626. </select>
  627. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  628. <select id="queryReportFloorUnitFeeSummary" parameterType="Map" resultType="Map">
  629. select t.fee_year feeYear,t.fee_month feeMonth, f.floor_num floorNum, bu.unit_num unitNum,max(t.update_time)
  630. updateTime
  631. <if test="configIds !=null">
  632. ,t.config_id configId
  633. </if>
  634. ,SUM(t.his_owe_amount) hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
  635. SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
  636. hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
  637. max(t.update_time) updateTime,sum(t.his_owe_amount+t.cur_receivable_amount) receivableAmount,
  638. sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount
  639. from report_fee_month_statistics t
  640. INNER JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  641. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  642. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  643. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  644. where t.status_cd = '0'
  645. <if test="roomNum !=null and roomNum != ''">
  646. and br.room_num= #{roomNum}
  647. </if>
  648. <if test="unitId !=null and unitId != ''">
  649. and bu.unit_id= #{unitId}
  650. </if>
  651. <if test="floorId !=null and floorId != ''">
  652. and f.floor_id = #{floorId}
  653. </if>
  654. <if test="objName !=null and objName != ''">
  655. and t.obj_name= #{objName}
  656. </if>
  657. <if test="objNameNum != null and objNameNum != ''">
  658. and t.obj_name_num= #{objNameNum}
  659. </if>
  660. <if test="feeYear !=null and feeYear != ''">
  661. and t.fee_year= #{feeYear}
  662. </if>
  663. <if test="feeMonth !=null and feeMonth != ''">
  664. and t.fee_month= #{feeMonth}
  665. </if>
  666. <if test="feeId !=null and feeId != ''">
  667. and t.fee_id= #{feeId}
  668. </if>
  669. <if test="configId !=null and configId != ''">
  670. and t.config_id= #{configId}
  671. </if>
  672. <if test="configIds !=null">
  673. and t.config_id in
  674. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  675. #{item}
  676. </foreach>
  677. </if>
  678. <if test="objId !=null and objId != ''">
  679. and t.obj_id= #{objId}
  680. </if>
  681. <if test="feeName !=null and feeName != ''">
  682. and t.fee_name= #{feeName}
  683. </if>
  684. <if test="communityId !=null and communityId != ''">
  685. and t.community_id= #{communityId}
  686. </if>
  687. <if test="startTime !=null and startTime != ''">
  688. and t.create_time &gt;= #{startTime}
  689. </if>
  690. <if test="endTime !=null and endTime != ''">
  691. and t.create_time &lt;= #{endTime}
  692. </if>
  693. GROUP BY t.fee_year,t.fee_month,f.floor_num,bu.unit_id,bu.unit_num
  694. <if test="configIds !=null">
  695. ,t.config_id
  696. </if>
  697. <if test="page != -1 and page != null ">
  698. limit #{page}, #{row}
  699. </if>
  700. </select>
  701. <select id="queryReportFloorUnitFeeSummaryDetailCount" parameterType="Map" resultType="Map">
  702. select count(1) count
  703. from report_fee_month_statistics t
  704. INNER JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  705. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  706. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  707. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  708. where t.status_cd = '0'
  709. <if test="roomNum !=null and roomNum != ''">
  710. and br.room_num= #{roomNum}
  711. </if>
  712. <if test="unitId !=null and unitId != ''">
  713. and bu.unit_id= #{unitId}
  714. </if>
  715. <if test="unitNum !=null and unitNum != ''">
  716. and bu.unit_num= #{unitNum}
  717. </if>
  718. <if test="floorId !=null and floorId != ''">
  719. and f.floor_id = #{floorId}
  720. </if>
  721. <if test="floorNum !=null and floorNum != ''">
  722. and f.floor_num = #{floorNum}
  723. </if>
  724. <if test="objName !=null and objName != ''">
  725. and t.obj_name= #{objName}
  726. </if>
  727. <if test="objNameNum != null and objNameNum != ''">
  728. and t.obj_name_num= #{objNameNum}
  729. </if>
  730. <if test="feeYear !=null and feeYear != ''">
  731. and t.fee_year= #{feeYear}
  732. </if>
  733. <if test="feeMonth !=null and feeMonth != ''">
  734. and t.fee_month= #{feeMonth}
  735. </if>
  736. <if test="feeId !=null and feeId != ''">
  737. and t.fee_id= #{feeId}
  738. </if>
  739. <if test="configId !=null and configId != ''">
  740. and t.config_id= #{configId}
  741. </if>
  742. <if test="configIds !=null">
  743. and t.config_id in
  744. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  745. #{item}
  746. </foreach>
  747. </if>
  748. <if test="objId !=null and objId != ''">
  749. and t.obj_id= #{objId}
  750. </if>
  751. <if test="feeName !=null and feeName != ''">
  752. and t.fee_name= #{feeName}
  753. </if>
  754. <if test="communityId !=null and communityId != ''">
  755. and t.community_id= #{communityId}
  756. </if>
  757. <if test="startTime !=null and startTime != ''">
  758. and t.create_time &gt;= #{startTime}
  759. </if>
  760. <if test="endTime !=null and endTime != ''">
  761. and t.create_time &lt;= #{endTime}
  762. </if>
  763. </select>
  764. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  765. <select id="queryReportFloorUnitFeeSummaryDetail" parameterType="Map" resultType="Map">
  766. select t.obj_name objName,t.fee_name feeName,t.fee_year feeYear,t.fee_month feeMonth,t.create_time createTime
  767. ,t.config_id configId,t.obj_name_num objNameNum,t.his_owe_amount hisOweAmount,t.cur_receivable_amount
  768. curReceivableAmount,t.cur_received_amount curReceivedAmount,t.his_owe_received_amount
  769. hisOweReceivedAmount,t.pre_received_amount preReceivedAmount,
  770. t.update_time updateTime,t.his_owe_amount+t.cur_receivable_amount receivableAmount,
  771. t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount receivedAmount
  772. from report_fee_month_statistics t
  773. INNER JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  774. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  775. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  776. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  777. where t.status_cd = '0'
  778. <if test="roomNum !=null and roomNum != ''">
  779. and br.room_num= #{roomNum}
  780. </if>
  781. <if test="unitId !=null and unitId != ''">
  782. and bu.unit_id= #{unitId}
  783. </if>
  784. <if test="unitNum !=null and unitNum != ''">
  785. and bu.unit_num= #{unitNum}
  786. </if>
  787. <if test="floorId !=null and floorId != ''">
  788. and f.floor_id = #{floorId}
  789. </if>
  790. <if test="floorNum !=null and floorNum != ''">
  791. and f.floor_num = #{floorNum}
  792. </if>
  793. <if test="objName !=null and objName != ''">
  794. and t.obj_name= #{objName}
  795. </if>
  796. <if test="objNameNum != null and objNameNum != ''">
  797. and t.obj_name_num= #{objNameNum}
  798. </if>
  799. <if test="feeYear !=null and feeYear != ''">
  800. and t.fee_year= #{feeYear}
  801. </if>
  802. <if test="feeMonth !=null and feeMonth != ''">
  803. and t.fee_month= #{feeMonth}
  804. </if>
  805. <if test="feeId !=null and feeId != ''">
  806. and t.fee_id= #{feeId}
  807. </if>
  808. <if test="configId !=null and configId != ''">
  809. and t.config_id= #{configId}
  810. </if>
  811. <if test="configIds !=null">
  812. and t.config_id in
  813. <foreach collection="configIds" item="item" open="(" close=")" separator=",">
  814. #{item}
  815. </foreach>
  816. </if>
  817. <if test="objId !=null and objId != ''">
  818. and t.obj_id= #{objId}
  819. </if>
  820. <if test="feeName !=null and feeName != ''">
  821. and t.fee_name= #{feeName}
  822. </if>
  823. <if test="communityId !=null and communityId != ''">
  824. and t.community_id= #{communityId}
  825. </if>
  826. <if test="startTime !=null and startTime != ''">
  827. and t.create_time &gt;= #{startTime}
  828. </if>
  829. <if test="endTime !=null and endTime != ''">
  830. and t.create_time &lt;= #{endTime}
  831. </if>
  832. <if test="page != -1 and page != null ">
  833. limit #{page}, #{row}
  834. </if>
  835. </select>
  836. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  837. <select id="queryReportFloorUnitFeeSummaryMajor" parameterType="Map" resultType="Map">
  838. select
  839. sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) allReceivedAmount,
  840. sum(t.his_owe_received_amount) allHisOweReceivedAmount
  841. from report_fee_month_statistics t
  842. INNER JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  843. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  844. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  845. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  846. where t.status_cd = '0'
  847. <if test="roomNum !=null and roomNum != ''">
  848. and br.room_num= #{roomNum}
  849. </if>
  850. <if test="unitId !=null and unitId != ''">
  851. and bu.unit_id= #{unitId}
  852. </if>
  853. <if test="floorId !=null and floorId != ''">
  854. and f.floor_id = #{floorId}
  855. </if>
  856. <if test="objName !=null and objName != ''">
  857. and t.obj_name= #{objName}
  858. </if>
  859. <if test="objNameNum != null and objNameNum != ''">
  860. and t.obj_name_num= #{objNameNum}
  861. </if>
  862. <if test="feeYear !=null and feeYear != ''">
  863. and t.fee_year= #{feeYear}
  864. </if>
  865. <if test="feeMonth !=null and feeMonth != ''">
  866. and t.fee_month= #{feeMonth}
  867. </if>
  868. <if test="feeId !=null and feeId != ''">
  869. and t.fee_id= #{feeId}
  870. </if>
  871. <if test="configId !=null and configId != ''">
  872. and t.config_id= #{configId}
  873. </if>
  874. <if test="objId !=null and objId != ''">
  875. and t.obj_id= #{objId}
  876. </if>
  877. <if test="feeName !=null and feeName != ''">
  878. and t.fee_name= #{feeName}
  879. </if>
  880. <if test="communityId !=null and communityId != ''">
  881. and t.community_id= #{communityId}
  882. </if>
  883. <if test="startTime !=null and startTime != ''">
  884. and t.create_time &gt;= #{startTime}
  885. </if>
  886. <if test="endTime !=null and endTime != ''">
  887. and t.create_time &lt;= #{endTime}
  888. </if>
  889. </select>
  890. <!-- and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0 -->
  891. <select id="queryFeeBreakdownCount" parameterType="Map" resultType="Map">
  892. select count(1) count
  893. from (
  894. select t.fee_name feeName,td.name feeTypeCd,pfc.fee_type_cd,pfc.start_time feeCreateTime,t.create_time
  895. createTime
  896. from report_fee_month_statistics t
  897. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  898. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  899. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  900. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  901. left join t_dict td on pfc.fee_type_cd = td.status_cd and td.table_name='pay_fee_config' and
  902. td.table_columns='fee_type_cd'
  903. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  904. where t.status_cd = '0'
  905. <if test="roomNum !=null and roomNum != ''">
  906. and br.room_num= #{roomNum}
  907. </if>
  908. <if test="unitId !=null and unitId != ''">
  909. and bu.unit_id= #{unitId}
  910. </if>
  911. <if test="floorId !=null and floorId != ''">
  912. and f.floor_id = #{floorId}
  913. </if>
  914. <if test="objName !=null and objName != ''">
  915. and t.obj_name= #{objName}
  916. </if>
  917. <if test="objNameNum != null and objNameNum != ''">
  918. and t.obj_name_num= #{objNameNum}
  919. </if>
  920. <if test="feeYear !=null and feeYear != ''">
  921. and t.fee_year= #{feeYear}
  922. </if>
  923. <if test="feeMonth !=null and feeMonth != ''">
  924. and t.fee_month= #{feeMonth}
  925. </if>
  926. <if test="feeId !=null and feeId != ''">
  927. and t.fee_id= #{feeId}
  928. </if>
  929. <if test="configId !=null and configId != ''">
  930. and pfc.config_id= #{configId}
  931. </if>
  932. <if test="objId !=null and objId != ''">
  933. and t.obj_id= #{objId}
  934. </if>
  935. <if test="feeName !=null and feeName != ''">
  936. and t.fee_name= #{feeName}
  937. </if>
  938. <if test="feeTypeCd != null and feeTypeCd != ''">
  939. and pfc.fee_type_cd = #{feeTypeCd}
  940. </if>
  941. <if test="communityId !=null and communityId != ''">
  942. and t.community_id= #{communityId}
  943. </if>
  944. <if test="startTime !=null and startTime != ''">
  945. and pfc.start_time &gt;= #{startTime}
  946. </if>
  947. <if test="endTime !=null and endTime != ''">
  948. and pfc.start_time &lt;= #{endTime}
  949. </if>
  950. <if test="yearMonth !=null and yearMonth != ''">
  951. and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
  952. </if>
  953. group by t.fee_name ,td.name ,pfc.fee_type_cd,pfc.start_time ,t.create_time
  954. ) t
  955. </select>
  956. <!-- 查询费用月统计信息 add by wuxw 2018-07-03
  957. and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0-->
  958. <select id="queryFeeBreakdown" parameterType="Map" resultType="Map">
  959. select t.fee_name feeName,td.name feeTypeCd,pfc.fee_type_cd,t.config_id configId,SUM(t.his_owe_amount)
  960. hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
  961. SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
  962. hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
  963. max(t.update_time) updateTime,sum(t.his_owe_amount+t.cur_receivable_amount) receivableAmount,
  964. sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,max(t.update_time)
  965. updateTime
  966. from report_fee_month_statistics t
  967. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  968. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  969. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  970. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  971. left join t_dict td on pfc.fee_type_cd = td.status_cd and td.table_name='pay_fee_config' and
  972. td.table_columns='fee_type_cd'
  973. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  974. where t.status_cd = '0'
  975. <if test="roomNum !=null and roomNum != ''">
  976. and br.room_num= #{roomNum}
  977. </if>
  978. <if test="unitId !=null and unitId != ''">
  979. and bu.unit_id= #{unitId}
  980. </if>
  981. <if test="floorId !=null and floorId != ''">
  982. and f.floor_id = #{floorId}
  983. </if>
  984. <if test="objName !=null and objName != ''">
  985. and t.obj_name= #{objName}
  986. </if>
  987. <if test="objNameNum != null and objNameNum != ''">
  988. and t.obj_name_num= #{objNameNum}
  989. </if>
  990. <if test="feeYear !=null and feeYear != ''">
  991. and t.fee_year= #{feeYear}
  992. </if>
  993. <if test="feeMonth !=null and feeMonth != ''">
  994. and t.fee_month= #{feeMonth}
  995. </if>
  996. <if test="feeId !=null and feeId != ''">
  997. and t.fee_id= #{feeId}
  998. </if>
  999. <if test="configId !=null and configId != ''">
  1000. and pfc.config_id= #{configId}
  1001. </if>
  1002. <if test="objId !=null and objId != ''">
  1003. and t.obj_id= #{objId}
  1004. </if>
  1005. <if test="feeName !=null and feeName != ''">
  1006. and t.fee_name= #{feeName}
  1007. </if>
  1008. <if test="feeTypeCd != null and feeTypeCd != ''">
  1009. and pfc.fee_type_cd = #{feeTypeCd}
  1010. </if>
  1011. <if test="communityId !=null and communityId != ''">
  1012. and t.community_id= #{communityId}
  1013. </if>
  1014. <if test="startTime !=null and startTime != ''">
  1015. and pfc.start_time &gt;= #{startTime}
  1016. </if>
  1017. <if test="endTime !=null and endTime != ''">
  1018. and pfc.start_time &lt;= #{endTime}
  1019. </if>
  1020. <if test="yearMonth !=null and yearMonth != ''">
  1021. and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
  1022. </if>
  1023. group by t.fee_name,td.name ,pfc.fee_type_cd,t.config_id ,t.create_time
  1024. order by t.create_time desc
  1025. <if test="page != -1 and page != null ">
  1026. limit #{page}, #{row}
  1027. </if>
  1028. </select>
  1029. <select id="queryFeeBreakdownDetailCount" parameterType="Map" resultType="Map">
  1030. select count(1) count
  1031. from report_fee_month_statistics t
  1032. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1033. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1034. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1035. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1036. left join t_dict td on pfc.fee_type_cd = td.status_cd and td.table_name='pay_fee_config' and
  1037. td.table_columns='fee_type_cd'
  1038. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1039. where t.status_cd = '0'
  1040. <if test="roomNum !=null and roomNum != ''">
  1041. and br.room_num= #{roomNum}
  1042. </if>
  1043. <if test="unitId !=null and unitId != ''">
  1044. and bu.unit_id= #{unitId}
  1045. </if>
  1046. <if test="floorId !=null and floorId != ''">
  1047. and f.floor_id = #{floorId}
  1048. </if>
  1049. <if test="objName !=null and objName != ''">
  1050. and t.obj_name= #{objName}
  1051. </if>
  1052. <if test="objNameNum != null and objNameNum != ''">
  1053. and t.obj_name_num= #{objNameNum}
  1054. </if>
  1055. <if test="feeYear !=null and feeYear != ''">
  1056. and t.fee_year= #{feeYear}
  1057. </if>
  1058. <if test="feeMonth !=null and feeMonth != ''">
  1059. and t.fee_month= #{feeMonth}
  1060. </if>
  1061. <if test="feeId !=null and feeId != ''">
  1062. and t.fee_id= #{feeId}
  1063. </if>
  1064. <if test="configId !=null and configId != ''">
  1065. and pfc.config_id= #{configId}
  1066. </if>
  1067. <if test="objId !=null and objId != ''">
  1068. and t.obj_id= #{objId}
  1069. </if>
  1070. <if test="feeName !=null and feeName != ''">
  1071. and t.fee_name= #{feeName}
  1072. </if>
  1073. <if test="feeTypeCd != null and feeTypeCd != ''">
  1074. and pfc.fee_type_cd = #{feeTypeCd}
  1075. </if>
  1076. <if test="communityId !=null and communityId != ''">
  1077. and t.community_id= #{communityId}
  1078. </if>
  1079. <if test="startTime !=null and startTime != ''">
  1080. and pfc.start_time &gt;= #{startTime}
  1081. </if>
  1082. <if test="endTime !=null and endTime != ''">
  1083. and pfc.start_time &lt;= #{endTime}
  1084. </if>
  1085. <if test="yearMonth !=null and yearMonth != ''">
  1086. and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
  1087. </if>
  1088. </select>
  1089. <!-- 查询费用月统计信息 add by wuxw 2018-07-03
  1090. and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0-->
  1091. <select id="queryFeeBreakdownDetail" parameterType="Map" resultType="Map">
  1092. select t.obj_name objName,t.fee_name feeName,t.fee_year feeYear,t.fee_month feeMonth,t.create_time createTime
  1093. ,t.config_id configId,t.his_owe_amount hisOweAmount,t.obj_name_num objNameNum,t.cur_receivable_amount
  1094. curReceivableAmount,t.cur_received_amount curReceivedAmount,t.his_owe_received_amount
  1095. hisOweReceivedAmount,t.pre_received_amount preReceivedAmount,
  1096. t.update_time updateTime,t.his_owe_amount+t.cur_receivable_amount receivableAmount,
  1097. t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount receivedAmount,t.update_time
  1098. updateTime
  1099. from report_fee_month_statistics t
  1100. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1101. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1102. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1103. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1104. left join t_dict td on pfc.fee_type_cd = td.status_cd and td.table_name='pay_fee_config' and
  1105. td.table_columns='fee_type_cd'
  1106. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1107. where t.status_cd = '0'
  1108. <if test="roomNum !=null and roomNum != ''">
  1109. and br.room_num= #{roomNum}
  1110. </if>
  1111. <if test="unitId !=null and unitId != ''">
  1112. and bu.unit_id= #{unitId}
  1113. </if>
  1114. <if test="floorId !=null and floorId != ''">
  1115. and f.floor_id = #{floorId}
  1116. </if>
  1117. <if test="objName !=null and objName != ''">
  1118. and t.obj_name= #{objName}
  1119. </if>
  1120. <if test="objNameNum != null and objNameNum != ''">
  1121. and t.obj_name_num= #{objNameNum}
  1122. </if>
  1123. <if test="feeYear !=null and feeYear != ''">
  1124. and t.fee_year= #{feeYear}
  1125. </if>
  1126. <if test="feeMonth !=null and feeMonth != ''">
  1127. and t.fee_month= #{feeMonth}
  1128. </if>
  1129. <if test="feeId !=null and feeId != ''">
  1130. and t.fee_id= #{feeId}
  1131. </if>
  1132. <if test="configId !=null and configId != ''">
  1133. and pfc.config_id= #{configId}
  1134. </if>
  1135. <if test="objId !=null and objId != ''">
  1136. and t.obj_id= #{objId}
  1137. </if>
  1138. <if test="feeName !=null and feeName != ''">
  1139. and t.fee_name= #{feeName}
  1140. </if>
  1141. <if test="feeTypeCd != null and feeTypeCd != ''">
  1142. and pfc.fee_type_cd = #{feeTypeCd}
  1143. </if>
  1144. <if test="communityId !=null and communityId != ''">
  1145. and t.community_id= #{communityId}
  1146. </if>
  1147. <if test="startTime !=null and startTime != ''">
  1148. and pfc.start_time &gt;= #{startTime}
  1149. </if>
  1150. <if test="endTime !=null and endTime != ''">
  1151. and pfc.start_time &lt;= #{endTime}
  1152. </if>
  1153. <if test="yearMonth !=null and yearMonth != ''">
  1154. and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
  1155. </if>
  1156. order by t.create_time desc
  1157. <if test="page != -1 and page != null ">
  1158. limit #{page}, #{row}
  1159. </if>
  1160. </select>
  1161. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0 -->
  1162. <select id="queryFeeBreakdownMajor" parameterType="Map" resultType="Map">
  1163. select
  1164. SUM(t.his_owe_amount + t.cur_receivable_amount) allReceivableAmount,
  1165. SUM(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) allReceivedAmount,
  1166. if(SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount) &lt; 0,0,
  1167. SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount))
  1168. allOweAmount,
  1169. SUM(t.his_owe_received_amount) allHisOweReceivedAmount
  1170. from report_fee_month_statistics t
  1171. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1172. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1173. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1174. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1175. left join t_dict td on pfc.fee_type_cd = td.status_cd and td.table_name='pay_fee_config' and
  1176. td.table_columns='fee_type_cd'
  1177. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1178. where t.status_cd = '0'
  1179. <if test="roomNum !=null and roomNum != ''">
  1180. and br.room_num= #{roomNum}
  1181. </if>
  1182. <if test="unitId !=null and unitId != ''">
  1183. and bu.unit_id= #{unitId}
  1184. </if>
  1185. <if test="floorId !=null and floorId != ''">
  1186. and f.floor_id = #{floorId}
  1187. </if>
  1188. <if test="objName !=null and objName != ''">
  1189. and t.obj_name= #{objName}
  1190. </if>
  1191. <if test="objNameNum != null and objNameNum != ''">
  1192. and t.obj_name_num= #{objNameNum}
  1193. </if>
  1194. <if test="feeYear !=null and feeYear != ''">
  1195. and t.fee_year= #{feeYear}
  1196. </if>
  1197. <if test="feeMonth !=null and feeMonth != ''">
  1198. and t.fee_month= #{feeMonth}
  1199. </if>
  1200. <if test="feeId !=null and feeId != ''">
  1201. and t.fee_id= #{feeId}
  1202. </if>
  1203. <if test="configId !=null and configId != ''">
  1204. and pfc.config_id= #{configId}
  1205. </if>
  1206. <if test="objId !=null and objId != ''">
  1207. and t.obj_id= #{objId}
  1208. </if>
  1209. <if test="feeName !=null and feeName != ''">
  1210. and t.fee_name= #{feeName}
  1211. </if>
  1212. <if test="feeTypeCd != null and feeTypeCd != ''">
  1213. and pfc.fee_type_cd = #{feeTypeCd}
  1214. </if>
  1215. <if test="communityId !=null and communityId != ''">
  1216. and t.community_id= #{communityId}
  1217. </if>
  1218. <if test="startTime !=null and startTime != ''">
  1219. and pfc.start_time &gt;= #{startTime}
  1220. </if>
  1221. <if test="endTime !=null and endTime != ''">
  1222. and pfc.start_time &lt;= #{endTime}
  1223. </if>
  1224. <if test="yearMonth !=null and yearMonth != ''">
  1225. and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
  1226. </if>
  1227. order by t.create_time desc
  1228. </select>
  1229. <select id="queryFeeDetailCount" parameterType="Map" resultType="Map">
  1230. select count(1) count
  1231. from (
  1232. select t.obj_name objName,t.fee_name feeName,pfc.start_time
  1233. from report_fee_month_statistics t
  1234. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1235. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1236. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1237. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1238. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1239. where t.status_cd = '0'
  1240. <if test="roomNum !=null and roomNum != ''">
  1241. and br.room_num= #{roomNum}
  1242. </if>
  1243. <if test="unitId !=null and unitId != ''">
  1244. and bu.unit_id= #{unitId}
  1245. </if>
  1246. <if test="floorId !=null and floorId != ''">
  1247. and f.floor_id = #{floorId}
  1248. </if>
  1249. <if test="objName !=null and objName != ''">
  1250. and t.obj_name= #{objName}
  1251. </if>
  1252. <if test="objNameNum != null and objNameNum != ''">
  1253. and t.obj_name_num= #{objNameNum}
  1254. </if>
  1255. <if test="feeYear !=null and feeYear != ''">
  1256. and t.fee_year= #{feeYear}
  1257. </if>
  1258. <if test="feeMonth !=null and feeMonth != ''">
  1259. and t.fee_month= #{feeMonth}
  1260. </if>
  1261. <if test="feeId !=null and feeId != ''">
  1262. and t.fee_id= #{feeId}
  1263. </if>
  1264. <if test="configId !=null and configId != ''">
  1265. and t.config_id= #{configId}
  1266. </if>
  1267. <if test="objId !=null and objId != ''">
  1268. and t.obj_id= #{objId}
  1269. </if>
  1270. <if test="feeName !=null and feeName != ''">
  1271. and t.fee_name= #{feeName}
  1272. </if>
  1273. <if test="communityId !=null and communityId != ''">
  1274. and t.community_id= #{communityId}
  1275. </if>
  1276. <if test="startTime !=null and startTime != ''">
  1277. and t.fee_create_time &gt;= #{startTime}
  1278. </if>
  1279. <if test="endTime !=null and endTime != ''">
  1280. and t.deadline_time &lt;= #{endTime}
  1281. </if>
  1282. <if test="feeTypeCd !=null and feeTypeCd != ''">
  1283. and pfc.fee_type_cd = #{feeTypeCd}
  1284. </if>
  1285. group by t.config_id,t.fee_name,t.fee_create_time,t.obj_id,t.obj_name,t.deadline_time
  1286. ) t
  1287. </select>
  1288. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1289. <select id="queryFeeDetail" parameterType="Map" resultType="Map">
  1290. select t.config_id configId,t.obj_id objId,t.obj_name objName,t.obj_type objType,t.fee_name
  1291. feeName,t.fee_create_time feeCreateTime,pfa.`value`
  1292. ownerName,br.built_up_area builtUpArea ,max(t.deadline_time)
  1293. deadlineTime,max(t.create_time) createTime,max(t.update_time) updateTime,SUM(t.his_owe_amount)
  1294. hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
  1295. SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
  1296. hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
  1297. sum(t.his_owe_amount+t.cur_receivable_amount) receivableAmount,
  1298. sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
  1299. t.obj_type objType
  1300. from report_fee_month_statistics t
  1301. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1302. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1303. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1304. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1305. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1306. left join pay_fee_attrs pfa on pf.fee_id = pfa.fee_id and pfa.spec_cd = '390008' and pfa.status_cd ='0'
  1307. where t.status_cd = '0'
  1308. <if test="roomNum !=null and roomNum != ''">
  1309. and br.room_num= #{roomNum}
  1310. </if>
  1311. <if test="unitId !=null and unitId != ''">
  1312. and bu.unit_id= #{unitId}
  1313. </if>
  1314. <if test="floorId !=null and floorId != ''">
  1315. and f.floor_id = #{floorId}
  1316. </if>
  1317. <if test="objName !=null and objName != ''">
  1318. and t.obj_name= #{objName}
  1319. </if>
  1320. <if test="feeYear !=null and feeYear != ''">
  1321. and t.fee_year= #{feeYear}
  1322. </if>
  1323. <if test="feeMonth !=null and feeMonth != ''">
  1324. and t.fee_month= #{feeMonth}
  1325. </if>
  1326. <if test="feeId !=null and feeId != ''">
  1327. and t.fee_id= #{feeId}
  1328. </if>
  1329. <if test="configId !=null and configId != ''">
  1330. and t.config_id= #{configId}
  1331. </if>
  1332. <if test="objId !=null and objId != ''">
  1333. and t.obj_id= #{objId}
  1334. </if>
  1335. <if test="feeName !=null and feeName != ''">
  1336. and t.fee_name= #{feeName}
  1337. </if>
  1338. <if test="communityId !=null and communityId != ''">
  1339. and t.community_id= #{communityId}
  1340. </if>
  1341. <if test="startTime !=null and startTime != ''">
  1342. and t.fee_create_time &gt;= #{startTime}
  1343. </if>
  1344. <if test="endTime !=null and endTime != ''">
  1345. and t.deadline_time &lt;= #{endTime}
  1346. </if>
  1347. <if test="feeTypeCd !=null and feeTypeCd != ''">
  1348. and pfc.fee_type_cd = #{feeTypeCd}
  1349. </if>
  1350. group by t.config_id,t.fee_name,t.fee_create_time,t.obj_id,t.obj_type,t.obj_name,pfa.`value`,br.built_up_area
  1351. order by pfa.`value`
  1352. <if test="page != -1 and page != null ">
  1353. limit #{page}, #{row}
  1354. </if>
  1355. </select>
  1356. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1357. <select id="queryAllFeeDetail" parameterType="Map" resultType="Map">
  1358. select
  1359. SUM(t.his_owe_amount + t.cur_receivable_amount) allReceivableAmount,
  1360. SUM(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) allReceivedAmount,
  1361. if(SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount) &lt; 0,0,
  1362. SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount))
  1363. allOweAmount,
  1364. SUM(t.his_owe_received_amount) allHisOweReceivedAmount
  1365. from report_fee_month_statistics t
  1366. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1367. left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
  1368. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1369. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1370. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1371. where t.status_cd = '0'
  1372. <if test="roomNum !=null and roomNum != ''">
  1373. and br.room_num= #{roomNum}
  1374. </if>
  1375. <if test="unitId !=null and unitId != ''">
  1376. and bu.unit_id= #{unitId}
  1377. </if>
  1378. <if test="floorId !=null and floorId != ''">
  1379. and f.floor_id = #{floorId}
  1380. </if>
  1381. <if test="objName !=null and objName != ''">
  1382. and t.obj_name= #{objName}
  1383. </if>
  1384. <if test="objNameNum != null and objNameNum != ''">
  1385. and t.obj_name_num= #{objNameNum}
  1386. </if>
  1387. <if test="feeYear !=null and feeYear != ''">
  1388. and t.fee_year= #{feeYear}
  1389. </if>
  1390. <if test="feeMonth !=null and feeMonth != ''">
  1391. and t.fee_month= #{feeMonth}
  1392. </if>
  1393. <if test="feeId !=null and feeId != ''">
  1394. and t.fee_id= #{feeId}
  1395. </if>
  1396. <if test="configId !=null and configId != ''">
  1397. and t.config_id= #{configId}
  1398. </if>
  1399. <if test="objId !=null and objId != ''">
  1400. and t.obj_id= #{objId}
  1401. </if>
  1402. <if test="feeName !=null and feeName != ''">
  1403. and t.fee_name= #{feeName}
  1404. </if>
  1405. <if test="communityId !=null and communityId != ''">
  1406. and t.community_id= #{communityId}
  1407. </if>
  1408. <if test="startTime !=null and startTime != ''">
  1409. and t.fee_create_time &gt;= #{startTime}
  1410. </if>
  1411. <if test="endTime !=null and endTime != ''">
  1412. and t.deadline_time &lt;= #{endTime}
  1413. </if>
  1414. </select>
  1415. <select id="queryOweFeeDetailCount" parameterType="Map" resultType="Map">
  1416. select count(1) count
  1417. from (
  1418. select t.payer_obj_name objName,t.fee_name feeName,pf.end_time feeCreateTime,t.create_time
  1419. createTime,SUM(t.amount_owed) oweAmount,max(t.deadline_time) deadlineTime
  1420. from report_owe_fee t
  1421. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1422. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  1423. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1424. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1425. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1426. where 1=1
  1427. <if test="roomNum !=null and roomNum != ''">
  1428. and br.room_num= #{roomNum}
  1429. </if>
  1430. <if test="unitId !=null and unitId != ''">
  1431. and bu.unit_id= #{unitId}
  1432. </if>
  1433. <if test="floorId !=null and floorId != ''">
  1434. and f.floor_id = #{floorId}
  1435. </if>
  1436. <if test="objName !=null and objName != ''">
  1437. and t.payer_obj_name= #{objName}
  1438. </if>
  1439. <if test="feeId !=null and feeId != ''">
  1440. and t.fee_id= #{feeId}
  1441. </if>
  1442. <if test="configId !=null and configId != ''">
  1443. and t.config_id= #{configId}
  1444. </if>
  1445. <if test="objId !=null and objId != ''">
  1446. and t.payer_obj_id= #{objId}
  1447. </if>
  1448. <if test="feeName !=null and feeName != ''">
  1449. and t.fee_name= #{feeName}
  1450. </if>
  1451. <if test="communityId !=null and communityId != ''">
  1452. and t.community_id= #{communityId}
  1453. </if>
  1454. <if test="startTime !=null and startTime != ''">
  1455. and t.end_time &gt;= #{startTime}
  1456. </if>
  1457. <if test="endTime !=null and endTime != ''">
  1458. and t.end_time &lt;= #{endTime}
  1459. </if>
  1460. and t.amount_owed != 0 and pf.end_time &lt; now()
  1461. group by t.payer_obj_name ,t.fee_name ,pf.end_time ,t.create_time
  1462. HAVING oweAmount != 0
  1463. ) t
  1464. </select>
  1465. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1466. <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
  1467. select t.payer_obj_name objName,t.fee_name feeName,pf.end_time feeCreateTime,t.update_time updateTime,
  1468. t.owner_name ownerName,t.owner_tel ownerTel,br.built_up_area builtUpArea ,SUM(t.amount_owed) oweAmount,max(t.deadline_time)
  1469. deadlineTime
  1470. from report_owe_fee t
  1471. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1472. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  1473. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1474. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1475. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1476. left join pay_fee_attrs pfa on pf.fee_id = pfa.fee_id and pfa.spec_cd = '390008' and pfa.status_cd ='0'
  1477. where 1=1
  1478. <if test="roomNum !=null and roomNum != ''">
  1479. and br.room_num= #{roomNum}
  1480. </if>
  1481. <if test="unitId !=null and unitId != ''">
  1482. and bu.unit_id= #{unitId}
  1483. </if>
  1484. <if test="unitNum !=null and unitNum != ''">
  1485. and bu.unit_num= #{unitNum}
  1486. </if>
  1487. <if test="floorId !=null and floorId != ''">
  1488. and f.floor_id = #{floorId}
  1489. </if>
  1490. <if test="floorNum !=null and floorNum != ''">
  1491. and f.floor_num = #{floorNum}
  1492. </if>
  1493. <if test="objName !=null and objName != ''">
  1494. and t.payer_obj_name= #{objName}
  1495. </if>
  1496. <if test="feeId !=null and feeId != ''">
  1497. and t.fee_id= #{feeId}
  1498. </if>
  1499. <if test="configId !=null and configId != ''">
  1500. and t.config_id= #{configId}
  1501. </if>
  1502. <if test="objId !=null and objId != ''">
  1503. and t.payer_obj_id= #{objId}
  1504. </if>
  1505. <if test="feeName !=null and feeName != ''">
  1506. and t.fee_name= #{feeName}
  1507. </if>
  1508. <if test="communityId !=null and communityId != ''">
  1509. and t.community_id= #{communityId}
  1510. </if>
  1511. <if test="startTime !=null and startTime != ''">
  1512. and t.end_time &gt;= #{startTime}
  1513. </if>
  1514. <if test="endTime !=null and endTime != ''">
  1515. and t.end_time &lt;= #{endTime}
  1516. </if>
  1517. and t.amount_owed != 0 and pf.end_time &lt; now()
  1518. group by t.payer_obj_name ,t.fee_name ,pf.end_time ,t.update_time, t.owner_name ,t.owner_tel ,br.built_up_area
  1519. HAVING oweAmount != 0
  1520. order by t.payer_obj_name
  1521. <if test="page != -1 and page != null ">
  1522. limit #{page}, #{row}
  1523. </if>
  1524. </select>
  1525. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1526. <select id="queryOweFeeDetailMajor" parameterType="Map" resultType="Map">
  1527. select SUM(t.amount_owed) oweAmount
  1528. from report_owe_fee t
  1529. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  1530. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  1531. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1532. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1533. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  1534. where 1=1
  1535. <if test="roomNum !=null and roomNum != ''">
  1536. and br.room_num= #{roomNum}
  1537. </if>
  1538. <if test="unitId !=null and unitId != ''">
  1539. and bu.unit_id= #{unitId}
  1540. </if>
  1541. <if test="floorId !=null and floorId != ''">
  1542. and f.floor_id = #{floorId}
  1543. </if>
  1544. <if test="objName !=null and objName != ''">
  1545. and t.payer_obj_name= #{objName}
  1546. </if>
  1547. <if test="feeId !=null and feeId != ''">
  1548. and t.fee_id= #{feeId}
  1549. </if>
  1550. <if test="configId !=null and configId != ''">
  1551. and t.config_id= #{configId}
  1552. </if>
  1553. <if test="objId !=null and objId != ''">
  1554. and t.payer_obj_id= #{objId}
  1555. </if>
  1556. <if test="feeName !=null and feeName != ''">
  1557. and t.fee_name= #{feeName}
  1558. </if>
  1559. <if test="communityId !=null and communityId != ''">
  1560. and t.community_id= #{communityId}
  1561. </if>
  1562. <if test="startTime !=null and startTime != ''">
  1563. and t.end_time &gt;= #{startTime}
  1564. </if>
  1565. <if test="endTime !=null and endTime != ''">
  1566. and t.end_time &lt;= #{endTime}
  1567. </if>
  1568. </select>
  1569. <select id="queryPayFeeDetailCount" parameterType="Map" resultType="Map">
  1570. select count(1) count,SUM(t.received_amount) totalReceivedAmount,SUM(t.receivable_amount) totalReceivableAmount,
  1571. sum(t.acct_amount) accAmount,sum(t.discount_amount) discountAmount,sum(t.deduction_amount) deductionAmount,sum(t.late_amount) lateAmount,
  1572. sum(t.gift_amount) giftAmount
  1573. from pay_fee_detail t
  1574. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1575. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1576. <if test="ownerId != null and ownerId != ''">
  1577. left join pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390007'
  1578. </if>
  1579. where t.status_cd = '0'
  1580. and pf.status_cd = '0' and t.state != '1500'
  1581. <if test="detailId !=null and detailId != ''">
  1582. and t.detail_id= #{detailId}
  1583. </if>
  1584. <if test="payerObjName !=null and payerObjName != ''">
  1585. and pfa3.value = #{payerObjName}
  1586. </if>
  1587. <if test="ownerId !=null and ownerId != ''">
  1588. and pfa1.value = #{ownerId}
  1589. </if>
  1590. <if test="feeId !=null and feeId != ''">
  1591. and pf.fee_id= #{feeId}
  1592. </if>
  1593. <if test="configId !=null and configId != ''">
  1594. and pf.config_id= #{configId}
  1595. </if>
  1596. <if test="objId !=null and objId != ''">
  1597. and pf.payer_obj_id = #{objId}
  1598. </if>
  1599. <if test="feeName !=null and feeName != ''">
  1600. and pf.fee_name= #{feeName}
  1601. </if>
  1602. <if test="communityId !=null and communityId != ''">
  1603. and t.community_id= #{communityId}
  1604. </if>
  1605. <if test="primeRate != null and primeRate != ''">
  1606. and t.prime_rate = #{primeRate}
  1607. </if>
  1608. <if test="state != null and state != ''">
  1609. and t.state = #{state}
  1610. </if>
  1611. <if test="feeTypeCd != null and feeTypeCd != ''">
  1612. and pf.fee_type_cd = #{feeTypeCd}
  1613. </if>
  1614. <if test="startTime !=null and startTime != ''">
  1615. and t.create_time &gt;= #{startTime}
  1616. </if>
  1617. <if test="endTime !=null and endTime != ''">
  1618. and t.create_time &lt;= #{endTime}
  1619. </if>
  1620. <if test="feeStartTime !=null and feeStartTime != ''">
  1621. and t.start_time &gt;= #{feeStartTime}
  1622. </if>
  1623. <if test="feeEndTime !=null and feeEndTime != ''">
  1624. and t.end_time &lt;= #{feeEndTime}
  1625. </if>
  1626. <if test="cashierId !=null and cashierId != ''">
  1627. and t.cashier_id= #{cashierId}
  1628. </if>
  1629. <if test="cashierName !=null and cashierName != ''">
  1630. and t.cashier_name= #{cashierName}
  1631. </if>
  1632. </select>
  1633. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1634. <select id="queryPayFeeDetail" parameterType="Map" resultType="Map">
  1635. select pfc.fee_name feeName,pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time
  1636. endTime,t.create_time createTime,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
  1637. t.prime_rate,d.name primeRate,pfa2.`value` ownerName,pfa3.`value` payerObjName,t.pay_order_id oId,d2.name feeTypeCdName,pfc.fee_type_cd feeTypeCd,
  1638. t.state,d3.name stateName,t.fee_id feeId,t.detail_id detailId,pf.payer_obj_id payerObjId,
  1639. t.cashier_id cashierId,t.cashier_name cashierName,t.payable_amount payableAmount,pfc.fee_flag feeFlag,
  1640. t.acct_amount acctAmount, t.discount_amount discountAmount, t.deduction_amount deductionAmount, t.late_amount lateAmount,
  1641. t.gift_amount giftAmount,t.remark
  1642. from pay_fee_detail t
  1643. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1644. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1645. <if test="ownerId != null and ownerId != ''">
  1646. left join pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390007'
  1647. </if>
  1648. left join pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008'
  1649. left join pay_fee_attrs pfa3 on t.fee_id = pfa3.fee_id and pfa3.spec_cd = '390012'
  1650. left join t_dict d on t.prime_rate = d.status_cd and d.table_name='pay_fee_detail' and
  1651. d.table_columns='prime_rate'
  1652. left join t_dict d2 on pfc.fee_type_cd = d2.status_cd and d2.table_name = 'pay_fee_config' and d2.table_columns
  1653. = 'fee_type_cd'
  1654. left join t_dict d3 on t.state = d3.status_cd and d3.table_name = 'pay_fee_detail' and d3.table_columns =
  1655. 'state'
  1656. where t.status_cd = '0'
  1657. and pf.status_cd = '0' and t.state != '1500'
  1658. <if test="detailId !=null and detailId != ''">
  1659. and t.detail_id= #{detailId}
  1660. </if>
  1661. <if test="payerObjName !=null and payerObjName != ''">
  1662. and pfa3.value = #{payerObjName}
  1663. </if>
  1664. <if test="ownerId !=null and ownerId != ''">
  1665. and pfa1.value = #{ownerId}
  1666. </if>
  1667. <if test="feeId !=null and feeId != ''">
  1668. and pf.fee_id= #{feeId}
  1669. </if>
  1670. <if test="configId !=null and configId != ''">
  1671. and pf.config_id= #{configId}
  1672. </if>
  1673. <if test="objId !=null and objId != ''">
  1674. and pf.payer_obj_id = #{objId}
  1675. </if>
  1676. <if test="feeName !=null and feeName != ''">
  1677. and pf.fee_name= #{feeName}
  1678. </if>
  1679. <if test="communityId !=null and communityId != ''">
  1680. and t.community_id= #{communityId}
  1681. </if>
  1682. <if test="primeRate != null and primeRate != ''">
  1683. and t.prime_rate = #{primeRate}
  1684. </if>
  1685. <if test="state != null and state != ''">
  1686. and t.state = #{state}
  1687. </if>
  1688. <if test="feeTypeCd != null and feeTypeCd != ''">
  1689. and pf.fee_type_cd = #{feeTypeCd}
  1690. </if>
  1691. <if test="startTime !=null and startTime != ''">
  1692. and t.create_time &gt;= #{startTime}
  1693. </if>
  1694. <if test="endTime !=null and endTime != ''">
  1695. and t.create_time &lt;= #{endTime}
  1696. </if>
  1697. <if test="feeStartTime !=null and feeStartTime != ''">
  1698. and t.start_time &gt;= #{feeStartTime}
  1699. </if>
  1700. <if test="feeEndTime !=null and feeEndTime != ''">
  1701. and t.end_time &lt;= #{feeEndTime}
  1702. </if>
  1703. <if test="cashierId !=null and cashierId != ''">
  1704. and t.cashier_id= #{cashierId}
  1705. </if>
  1706. <if test="cashierName !=null and cashierName != ''">
  1707. and t.cashier_name= #{cashierName}
  1708. </if>
  1709. order by t.create_time desc
  1710. <if test="page != -1 and page != null ">
  1711. limit #{page}, #{row}
  1712. </if>
  1713. </select>
  1714. <!--查询账户抵扣大计金额-->
  1715. <select id="queryFeeAccountDetailSum" parameterType="Map" resultType="Map">
  1716. select fad.state fadState,SUM(fad.amount) fadAmount
  1717. from pay_fee_detail t
  1718. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1719. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1720. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1721. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1722. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1723. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
  1724. LEFT JOIN parking_space ps on oc.ps_id = ps.ps_id and ps.status_cd = '0'
  1725. left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
  1726. LEFT JOIN contract co on pf.payer_obj_id = co.contract_id and co.status_cd = '0' and pf.payer_obj_type='7777'
  1727. left join fee_account_detail fad on t.detail_id = fad.detail_id and fad.status_cd = '0'
  1728. where t.status_cd = '0' and fad.state is not null
  1729. and pf.status_cd = '0' and t.state != '1500'
  1730. <if test="detailId !=null and detailId != ''">
  1731. and t.detail_id= #{detailId}
  1732. </if>
  1733. <if test="roomNum !=null and roomNum != ''">
  1734. and br.room_num= #{roomNum}
  1735. </if>
  1736. <if test="unitId !=null and unitId != ''">
  1737. and bu.unit_id= #{unitId}
  1738. </if>
  1739. <if test="unitNum !=null and unitNum != ''">
  1740. and bu.unit_num= #{unitNum}
  1741. </if>
  1742. <if test="floorId !=null and floorId != ''">
  1743. and f.floor_id = #{floorId}
  1744. </if>
  1745. <if test="floorNum !=null and floorNum != ''">
  1746. and f.floor_num = #{floorNum}
  1747. </if>
  1748. <if test="objName !=null and objName != ''">
  1749. and t.obj_name= #{objName}
  1750. </if>
  1751. <if test="feeYear !=null and feeYear != ''">
  1752. and t.fee_year= #{feeYear}
  1753. </if>
  1754. <if test="feeMonth !=null and feeMonth != ''">
  1755. and t.fee_month= #{feeMonth}
  1756. </if>
  1757. <if test="feeId !=null and feeId != ''">
  1758. and t.fee_id= #{feeId}
  1759. </if>
  1760. <if test="configId !=null and configId != ''">
  1761. and pfc.config_id= #{configId}
  1762. </if>
  1763. <if test="objId !=null and objId != ''">
  1764. and pf.payer_obj_id = #{objId}
  1765. </if>
  1766. <if test="feeName !=null and feeName != ''">
  1767. and t.fee_name= #{feeName}
  1768. </if>
  1769. <if test="communityId !=null and communityId != ''">
  1770. and t.community_id= #{communityId}
  1771. </if>
  1772. <if test="primeRate != null and primeRate != ''">
  1773. and t.prime_rate = #{primeRate}
  1774. </if>
  1775. <if test="state != null and state != ''">
  1776. and t.state = #{state}
  1777. </if>
  1778. <if test="feeTypeCd != null and feeTypeCd != ''">
  1779. and pfc.fee_type_cd = #{feeTypeCd}
  1780. </if>
  1781. <if test="startTime !=null and startTime != ''">
  1782. and t.create_time &gt;= #{startTime}
  1783. </if>
  1784. <if test="endTime !=null and endTime != ''">
  1785. and t.create_time &lt;= #{endTime}
  1786. </if>
  1787. <if test="feeStartTime !=null and feeStartTime != ''">
  1788. and t.start_time &gt;= #{feeStartTime}
  1789. </if>
  1790. <if test="feeEndTime !=null and feeEndTime != ''">
  1791. and t.end_time &lt;= #{feeEndTime}
  1792. </if>
  1793. <if test="cashierId !=null and cashierId != ''">
  1794. and t.cashier_id= #{cashierId}
  1795. </if>
  1796. <if test="cashierName !=null and cashierName != ''">
  1797. and t.cashier_name= #{cashierName}
  1798. </if>
  1799. group by fad.state
  1800. </select>
  1801. <select id="queryAllPayFeeDetail" parameterType="Map" resultType="Map">
  1802. select SUM(t.receivable_amount) allReceivableAmount,SUM(t.received_amount) allReceivedAmount
  1803. from pay_fee_detail t
  1804. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1805. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1806. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1807. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1808. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1809. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  1810. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  1811. where t.status_cd = '0' and t.state != '1500'
  1812. <if test="roomNum !=null and roomNum != ''">
  1813. and br.room_num= #{roomNum}
  1814. </if>
  1815. <if test="unitId !=null and unitId != ''">
  1816. and bu.unit_id= #{unitId}
  1817. </if>
  1818. <if test="unitNum !=null and unitNum != ''">
  1819. and bu.unit_num= #{unitNum}
  1820. </if>
  1821. <if test="floorId !=null and floorId != ''">
  1822. and f.floor_id = #{floorId}
  1823. </if>
  1824. <if test="floorNum !=null and floorNum != ''">
  1825. and f.floor_num = #{floorNum}
  1826. </if>
  1827. <if test="objName !=null and objName != ''">
  1828. and t.obj_name= #{objName}
  1829. </if>
  1830. <if test="feeYear !=null and feeYear != ''">
  1831. and t.fee_year= #{feeYear}
  1832. </if>
  1833. <if test="feeMonth !=null and feeMonth != ''">
  1834. and t.fee_month= #{feeMonth}
  1835. </if>
  1836. <if test="feeId !=null and feeId != ''">
  1837. and t.fee_id= #{feeId}
  1838. </if>
  1839. <if test="configId !=null and configId != ''">
  1840. and pfc.config_id= #{configId}
  1841. </if>
  1842. <if test="feeTypeCd != null and feeTypeCd != ''">
  1843. and pfc.fee_type_cd = #{feeTypeCd}
  1844. </if>
  1845. <if test="objId !=null and objId != ''">
  1846. and pf.payer_obj_id= #{objId}
  1847. </if>
  1848. <if test="feeName !=null and feeName != ''">
  1849. and t.fee_name= #{feeName}
  1850. </if>
  1851. <if test="communityId !=null and communityId != ''">
  1852. and t.community_id= #{communityId}
  1853. </if>
  1854. <if test="primeRate != null and primeRate != ''">
  1855. and t.prime_rate = #{primeRate}
  1856. </if>
  1857. <if test="state != null and state != ''">
  1858. and t.state = #{state}
  1859. </if>
  1860. <if test="startTime !=null and startTime != ''">
  1861. and t.create_time &gt;= #{startTime}
  1862. </if>
  1863. <if test="endTime !=null and endTime != ''">
  1864. and t.create_time &lt;= #{endTime}
  1865. </if>
  1866. </select>
  1867. <select id="queryPayFeeDetailSum" parameterType="Map" resultType="Map">
  1868. select pfc.fee_name feeName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,oc.car_num carNum,
  1869. pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time endTime,t.create_time createTime,
  1870. t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfa.`value`
  1871. importFeeName,t.prime_rate,d.name primeRate,fdr.discount_small_type discountSmallType,fdr.rule_name
  1872. ruleName,pfdd.discount_price,t.detail_id detailId,t.community_id communityId,
  1873. SUM(pfdd.discount_price) discountPrice
  1874. from pay_fee_detail t
  1875. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1876. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1877. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1878. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1879. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1880. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  1881. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  1882. left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
  1883. left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
  1884. left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
  1885. left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
  1886. d.table_columns="prime_rate"
  1887. where t.status_cd = '0'
  1888. and pfdd.discount_price > 0
  1889. <if test="roomNum !=null and roomNum != ''">
  1890. and br.room_num= #{roomNum}
  1891. </if>
  1892. <if test="unitId !=null and unitId != ''">
  1893. and bu.unit_id= #{unitId}
  1894. </if>
  1895. <if test="unitNum !=null and unitNum != ''">
  1896. and bu.unit_num= #{unitNum}
  1897. </if>
  1898. <if test="floorId !=null and floorId != ''">
  1899. and f.floor_id = #{floorId}
  1900. </if>
  1901. <if test="floorNum !=null and floorNum != ''">
  1902. and f.floor_num = #{floorNum}
  1903. </if>
  1904. <if test="objName !=null and objName != ''">
  1905. and t.obj_name= #{objName}
  1906. </if>
  1907. <if test="feeYear !=null and feeYear != ''">
  1908. and t.fee_year= #{feeYear}
  1909. </if>
  1910. <if test="feeMonth !=null and feeMonth != ''">
  1911. and t.fee_month= #{feeMonth}
  1912. </if>
  1913. <if test="feeId !=null and feeId != ''">
  1914. and t.fee_id= #{feeId}
  1915. </if>
  1916. <if test="configId !=null and configId != ''">
  1917. and pfc.config_id= #{configId}
  1918. </if>
  1919. <if test="feeTypeCd != null and feeTypeCd != ''">
  1920. and pfc.fee_type_cd = #{feeTypeCd}
  1921. </if>
  1922. <if test="objId !=null and objId != ''">
  1923. and pf.payer_obj_id= #{objId}
  1924. </if>
  1925. <if test="feeName !=null and feeName != ''">
  1926. and t.fee_name= #{feeName}
  1927. </if>
  1928. <if test="communityId !=null and communityId != ''">
  1929. and t.community_id= #{communityId}
  1930. </if>
  1931. <if test="primeRate != null and primeRate != ''">
  1932. and t.prime_rate = #{primeRate}
  1933. </if>
  1934. <if test="startTime !=null and startTime != ''">
  1935. and t.create_time &gt;= #{startTime}
  1936. </if>
  1937. <if test="endTime !=null and endTime != ''">
  1938. and t.create_time &lt;= #{endTime}
  1939. </if>
  1940. group by t.detail_id,pfc.fee_name,f.floor_num,bu.unit_num ,br.room_num ,oc.car_num ,
  1941. pf.payer_obj_type ,t.start_time ,t.end_time ,t.create_time ,
  1942. t.receivable_amount ,t.received_amount ,pfa.`value`
  1943. ,t.prime_rate,d.name ,fdr.discount_small_type ,fdr.rule_name,pfdd.discount_price
  1944. order by t.create_time desc
  1945. </select>
  1946. <select id="queryDeadlineFeeCount" parameterType="Map" resultType="Map">
  1947. select count(1) count
  1948. from pay_fee_detail_month t
  1949. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1950. where 1=1
  1951. and t.detail_id = '-1'
  1952. <if test="configId !=null and configId != ''">
  1953. and t.config_id = #{configId}
  1954. </if>
  1955. <if test="objName !=null and objName != ''">
  1956. and t.obj_name like CONCAT('%',#{objName},'%')
  1957. </if>
  1958. <if test="ownerName !=null and ownerName != ''">
  1959. and t.owner_name like CONCAT('%',#{ownerName},'%')
  1960. </if>
  1961. <if test="link !=null and link != ''">
  1962. and t.link = #{link}
  1963. </if>
  1964. <if test="communityId !=null and communityId != ''">
  1965. and t.community_id= #{communityId}
  1966. </if>
  1967. <if test="startTime !=null and startTime !=''">
  1968. and t.deadline_time &gt;= #{startTime}
  1969. </if>
  1970. <if test="endTime !=null and endTime != ''">
  1971. and t.deadline_time &lt;= #{endTime}
  1972. </if>
  1973. </select>
  1974. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1975. <select id="queryDeadlineFee" parameterType="Map" resultType="Map">
  1976. select
  1977. t.obj_name objName,
  1978. pf.payer_obj_type objType,
  1979. t.fee_name feeName,
  1980. t.deadline_time deadlineTime
  1981. from pay_fee_detail_month t
  1982. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1983. where 1=1
  1984. and t.detail_id = '-1'
  1985. <if test="configId !=null and configId != ''">
  1986. and t.config_id = #{configId}
  1987. </if>
  1988. <if test="objName !=null and objName != ''">
  1989. and t.obj_name like CONCAT('%',#{objName},'%')
  1990. </if>
  1991. <if test="ownerName !=null and ownerName != ''">
  1992. and t.owner_name like CONCAT('%',#{ownerName},'%')
  1993. </if>
  1994. <if test="link !=null and link != ''">
  1995. and t.link = #{link}
  1996. </if>
  1997. <if test="communityId !=null and communityId != ''">
  1998. and t.community_id= #{communityId}
  1999. </if>
  2000. <if test="startTime !=null and startTime !=''">
  2001. and t.deadline_time &gt;= #{startTime}
  2002. </if>
  2003. <if test="endTime !=null and endTime != ''">
  2004. and t.deadline_time &lt;= #{endTime}
  2005. </if>
  2006. order by t.deadline_time
  2007. <if test="page != -1 and page != null ">
  2008. limit #{page}, #{row}
  2009. </if>
  2010. </select>
  2011. <select id="queryPrePaymentNewCount" parameterType="Map" resultType="Map">
  2012. select count(1) count
  2013. from (
  2014. select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
  2015. t.payer_obj_type payerObjType
  2016. from pay_fee t
  2017. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2018. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
  2019. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
  2020. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
  2021. where t.state = '2008001'
  2022. and t.status_cd = '0'
  2023. <if test="ownerName != null and ownerName != ''">
  2024. and pfa2.value like concat('%' #{ownerName} ,'%')
  2025. </if>
  2026. <if test="objName != null and objName != ''">
  2027. and pfa.`value` like concat('%',#{objName},'%')
  2028. </if>
  2029. <if test="link != null and link != ''">
  2030. and pfa1.`value` = #{link}
  2031. </if>
  2032. <if test="configId !=null and configId != ''">
  2033. and t.config_id = #{configId}
  2034. </if>
  2035. <if test="communityId !=null and communityId != ''">
  2036. and t.community_id= #{communityId}
  2037. </if>
  2038. <if test="startTime !=null and startTime != ''">
  2039. and t.end_time &gt;= #{startTime}
  2040. </if>
  2041. <if test="endTime !=null and endTime != ''">
  2042. and t.end_time &lt;= #{endTime}
  2043. </if>
  2044. ) t
  2045. </select>
  2046. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2047. <select id="queryPrePayment" parameterType="Map" resultType="Map">
  2048. select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
  2049. t.payer_obj_type payerObjType
  2050. from pay_fee t
  2051. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2052. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
  2053. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
  2054. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
  2055. where t.state = '2008001'
  2056. and t.status_cd = '0'
  2057. <if test="ownerName != null and ownerName != ''">
  2058. and pfa2.value like concat('%' #{ownerName} ,'%')
  2059. </if>
  2060. <if test="objName != null and objName != ''">
  2061. and pfa.`value` like concat('%',#{objName},'%')
  2062. </if>
  2063. <if test="link != null and link != ''">
  2064. and pfa1.`value` = #{link}
  2065. </if>
  2066. <if test="configId !=null and configId != ''">
  2067. and t.config_id = #{configId}
  2068. </if>
  2069. <if test="communityId !=null and communityId != ''">
  2070. and t.community_id= #{communityId}
  2071. </if>
  2072. <if test="startTime !=null and startTime != ''">
  2073. and t.end_time &gt;= #{startTime}
  2074. </if>
  2075. <if test="endTime !=null and endTime != ''">
  2076. and t.end_time &lt;= #{endTime}
  2077. </if>
  2078. <if test="page != -1 and page != null ">
  2079. limit #{page}, #{row}
  2080. </if>
  2081. </select>
  2082. <select id="queryPrePaymentCount" parameterType="Map" resultType="Map">
  2083. select pfc.fee_name feeName, count(t.payer_obj_id) objCount
  2084. from pay_fee t
  2085. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2086. where t.state = '2008001'
  2087. and t.status_cd = '0'
  2088. and t.end_time &gt; #{startTime}
  2089. and t.end_time &lt; #{endTime}
  2090. and t.community_id = #{communityId}
  2091. group by pfc.fee_name, pfc.config_id
  2092. order by objCount
  2093. </select>
  2094. <select id="queryDeadlinePaymentCount" parameterType="Map" resultType="Map">
  2095. SELECT t.fee_name feeName, count(t.obj_id) objCount
  2096. FROM report_fee_month_statistics t
  2097. inner join pay_fee pf on t.fee_id = pf.fee_id
  2098. and pf.community_id = t.community_id and pf.status_cd = '0'
  2099. WHERE 1 = 1
  2100. AND t.status_cd = '0'
  2101. and t.community_id = #{communityId}
  2102. AND t.deadline_time &gt; #{startTime}
  2103. AND t.deadline_time &lt; #{endTime}
  2104. group by t.config_id, t.fee_name
  2105. order by objCount desc
  2106. </select>
  2107. <select id="queryOwePaymentCount" parameterType="Map" resultType="Map">
  2108. select t.fee_name feeName, count(distinct t.obj_id) objCount
  2109. from report_fee_month_statistics t
  2110. inner join pay_fee pf
  2111. on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  2112. where t.community_id = #{communityId}
  2113. and t.owe_amount > 0
  2114. group by t.config_id, t.fee_name
  2115. order by objCount desc
  2116. </select>
  2117. <select id="queryAllPaymentCount" parameterType="Map" resultType="Map">
  2118. select t.fee_name feeName, count(distinct t.obj_id) objCount
  2119. from report_fee_month_statistics t
  2120. inner join pay_fee pf
  2121. on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  2122. where t.community_id = #{communityId}
  2123. group by t.config_id, t.fee_name
  2124. order by objCount desc
  2125. </select>
  2126. <select id="queryFinishOweFee" parameterType="Map" resultType="Map">
  2127. select t.config_id configId,
  2128. t.fee_id feeId,
  2129. t.statistics_id statisticsId,
  2130. t.fee_year feeYear,
  2131. fee_month feeMonth
  2132. from report_fee_month_statistics t
  2133. inner join pay_fee pf
  2134. on t.fee_id = pf.fee_id and pf.state = '2009001' and pf.community_id = #{communityId} and
  2135. pf.status_cd = '0'
  2136. where t.owe_amount > 0
  2137. and t.status_cd = '0'
  2138. and t.community_id = #{communityId} limit 100
  2139. </select>
  2140. <!-- 查询费用配置信息 add by wuxw 2018-07-03 -->
  2141. <select id="getFeeConfigInfo" parameterType="Map" resultType="Map">
  2142. select t.fee_type_cd,t.fee_type_cd feeTypeCd,t.computing_formula,t.computing_formula
  2143. computingFormula,t.additional_amount,t.additional_amount additionalAmount,t.status_cd,t.status_cd
  2144. statusCd,t.square_price,t.square_price squarePrice,t.is_default,t.is_default isDefault,t.config_id,t.config_id
  2145. configId,t.fee_flag,t.fee_flag feeFlag,t.fee_name,t.fee_name feeName,t.start_time,t.start_time
  2146. startTime,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,
  2147. td1.name feeTypeCdName,td2.name feeFlagName,t.bill_type billType,t.bill_type,td3.name billTypeName,
  2148. t.payment_cd,t.payment_cycle,t.payment_cd paymentCd,t.payment_cycle paymentCycle
  2149. from pay_fee_config t,t_dict td1,t_dict td2,t_dict td3
  2150. where 1 =1
  2151. and t.fee_type_cd = td1.status_cd
  2152. and td1.table_name = 'pay_fee_config'
  2153. and td1.table_columns = 'fee_type_cd'
  2154. and t.fee_flag = td2.status_cd
  2155. and td2.table_name = 'pay_fee_config'
  2156. and td2.table_columns = 'fee_flag'
  2157. and t.bill_type = td3.status_cd
  2158. and td3.table_name = 'pay_fee_config'
  2159. and td3.table_columns = 'bill_type'
  2160. and t.is_default = 'F'
  2161. and t.status_cd = '0'
  2162. <if test="feeTypeCd !=null and feeTypeCd != ''">
  2163. and t.fee_type_cd= #{feeTypeCd}
  2164. </if>
  2165. <if test="computingFormula !=null and computingFormula != ''">
  2166. and t.computing_formula= #{computingFormula}
  2167. </if>
  2168. <if test="additionalAmount !=null and additionalAmount != ''">
  2169. and t.additional_amount= #{additionalAmount}
  2170. </if>
  2171. <if test="squarePrice !=null and squarePrice != ''">
  2172. and t.square_price= #{squarePrice}
  2173. </if>
  2174. <if test="configId !=null and configId != ''">
  2175. and t.config_id= #{configId}
  2176. </if>
  2177. <if test="feeFlag !=null and feeFlag != ''">
  2178. and t.fee_flag= #{feeFlag}
  2179. </if>
  2180. <if test="feeName !=null and feeName != ''">
  2181. and t.fee_name like '%${feeName}%'
  2182. </if>
  2183. <if test="startTime !=null ">
  2184. and t.start_time= #{startTime}
  2185. </if>
  2186. <if test="endTime !=null ">
  2187. and t.end_time= #{endTime}
  2188. </if>
  2189. <if test="valid !=null and valid == 1">
  2190. and t.end_time &gt; now()
  2191. </if>
  2192. <if test="curTime !=null ">
  2193. and t.end_time &gt; #{curTime}
  2194. and t.start_time &lt; #{curTime}
  2195. </if>
  2196. <if test="communityId !=null and communityId != ''">
  2197. and t.community_id= #{communityId}
  2198. </if>
  2199. <if test="bId !=null and bId != ''">
  2200. and t.b_id= #{bId}
  2201. </if>
  2202. <if test="paymentCd !=null and paymentCd != ''">
  2203. and t.payment_cd= #{paymentCd}
  2204. </if>
  2205. <if test="paymentCycle !=null and paymentCycle != ''">
  2206. and t.payment_cycle= #{paymentCycle}
  2207. </if>
  2208. <if test="billType !=null and billType != ''">
  2209. and t.bill_type= #{billType}
  2210. </if>
  2211. order by t.create_time desc
  2212. <if test="page != -1 and page != null ">
  2213. limit #{page}, #{row}
  2214. </if>
  2215. </select>
  2216. <select id="getRepairInfo" parameterType="Map" resultType="Map">
  2217. select r.staff_id staffId,r.staff_name staffName,r.state, t.name stateName, count(*) amount from r_repair_user r
  2218. left join t_dict t on t.table_name="r_repair_user" and t.table_columns="state" and t.status_cd=r.state
  2219. where r.state != "10005" and r.status_cd = "0"
  2220. <if test="ruId != null and ruId != ''">
  2221. and r.ru_id = #{ruId}
  2222. </if>
  2223. <if test="repairId != null and repairId != ''">
  2224. and r.repair_id = #{repairId}
  2225. </if>
  2226. <if test="communityId != null and communityId !=''">
  2227. and r.community_id = #{communityId}
  2228. </if>
  2229. <if test="bId != null and bId !=''">
  2230. and r.b_id = #{bId}
  2231. </if>
  2232. <if test="state != null and state != ''">
  2233. and r.state = #{state}
  2234. </if>
  2235. <if test="context != null and context !=''">
  2236. and r.context = #{context}
  2237. </if>
  2238. <if test="statusCd != null and statusCd != ''">
  2239. and r.status_cd = #{statusCd}
  2240. </if>
  2241. <if test="staffId != null and staffId !=''">
  2242. and r.staff_id = #{staffId}
  2243. </if>
  2244. <if test="staffName != null and staffName !=''">
  2245. and r.staff_name = #{staffName}
  2246. </if>
  2247. <if test="preStaffId != null and preStaffId !=''">
  2248. and r.pre_staff_id = #{preStaffId}
  2249. </if>
  2250. <if test="preStaffName != null and preStaffName !=''">
  2251. and r.pre_staff_name = #{preStaffName}
  2252. </if>
  2253. <if test="beginStartTime != null and beginStartTime !=''">
  2254. and r.start_time &gt;= #{beginStartTime}
  2255. </if>
  2256. <if test="beginEndTime != null and beginEndTime !=''">
  2257. and r.start_time &lt;= #{beginEndTime}
  2258. </if>
  2259. <if test="finishStartTime != null and finishStartTime !=''">
  2260. and r.end_time &gt;= #{finishStartTime}
  2261. </if>
  2262. <if test="finishEndTime != null and finishEndTime !=''">
  2263. and r.end_time &lt;= #{finishEndTime}
  2264. </if>
  2265. <if test="createTime != null and createTime !=''">
  2266. and r.create_time = #{createTime}
  2267. </if>
  2268. group by r.staff_id,r.state
  2269. order by r.create_time desc
  2270. <if test="page != -1 and page != null ">
  2271. limit #{page}, #{row}
  2272. </if>
  2273. </select>
  2274. <select id="getRepairWithOutPage" parameterType="Map" resultType="Map">
  2275. select r.staff_id staffId,u.name staffName,r.state,u.score, count(*) amount from
  2276. r_repair_user r
  2277. left join t_dict td on td.table_name="r_repair_user" and td.table_columns="state" and td.status_cd=r.state
  2278. left join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
  2279. where r.state != '10005' and r.status_cd = '0'
  2280. <if test="ruId != null and ruId != ''">
  2281. and r.ru_id = #{ruId}
  2282. </if>
  2283. <if test="repairId != null and repairId != ''">
  2284. and r.repair_id = #{repairId}
  2285. </if>
  2286. <if test="communityId != null and communityId !=''">
  2287. and r.community_id = #{communityId}
  2288. </if>
  2289. <if test="bId != null and bId !=''">
  2290. and r.b_id = #{bId}
  2291. </if>
  2292. <if test="state != null and state != ''">
  2293. and r.state = #{state}
  2294. </if>
  2295. <if test="context != null and context !=''">
  2296. and r.context = #{context}
  2297. </if>
  2298. <if test="statusCd != null and statusCd != ''">
  2299. and r.status_cd = #{statusCd}
  2300. </if>
  2301. <if test="staffId != null and staffId !=''">
  2302. and r.staff_id = #{staffId}
  2303. </if>
  2304. <if test="staffName != null and staffName !=''">
  2305. and r.staff_name = #{staffName}
  2306. </if>
  2307. <if test="preStaffId != null and preStaffId !=''">
  2308. and r.pre_staff_id = #{preStaffId}
  2309. </if>
  2310. <if test="preStaffName != null and preStaffName !=''">
  2311. and r.pre_staff_name = #{preStaffName}
  2312. </if>
  2313. <if test="beginStartTime != null and beginStartTime !=''">
  2314. and r.start_time &gt;= #{beginStartTime}
  2315. </if>
  2316. <if test="beginEndTime != null and beginEndTime !=''">
  2317. and r.start_time &lt;= #{beginEndTime}
  2318. </if>
  2319. <if test="finishStartTime != null and finishStartTime !=''">
  2320. and r.end_time &gt;= #{finishStartTime}
  2321. </if>
  2322. <if test="finishEndTime != null and finishEndTime !=''">
  2323. and r.end_time &lt;= #{finishEndTime}
  2324. </if>
  2325. <if test="createTime != null and createTime !=''">
  2326. and r.create_time = #{createTime}
  2327. </if>
  2328. group by r.staff_id,u.name,r.state,u.score
  2329. </select>
  2330. <select id="queryRepairForStaff" parameterType="Map" resultType="Map">
  2331. SELECT r.staff_id staffId,u.name staffName,r.state,td.name stateName
  2332. FROM r_repair_user r
  2333. inner join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
  2334. left join t_dict td on r.state = td.status_cd and td.table_name = 'r_repair_user' and td.table_columns = 'state'
  2335. WHERE r.state!='10005' AND r.state!='10009' AND r.state!='11000' AND
  2336. r.state!='12000' AND r.state != '10007' AND r.status_cd = '0' AND
  2337. r.repair_event != 'payUser' AND r.repair_event != 'startUser' AND r.staff_id != '-1'
  2338. <if test="communityId != null and communityId !=''">
  2339. and r.community_id = #{communityId}
  2340. </if>
  2341. <if test="staffId != null and staffId != ''">
  2342. and r.staff_id = #{staffId}
  2343. </if>
  2344. <if test="state != null and state != ''">
  2345. and r.state = #{state}
  2346. </if>
  2347. <if test="beginStartTime != null and beginStartTime !=''">
  2348. and r.start_time &gt;= #{beginStartTime}
  2349. </if>
  2350. <if test="beginEndTime != null and beginEndTime !=''">
  2351. and r.start_time &lt;= #{beginEndTime}
  2352. </if>
  2353. <if test="finishStartTime != null and finishStartTime !=''">
  2354. and r.end_time &gt;= #{finishStartTime}
  2355. </if>
  2356. <if test="finishEndTime != null and finishEndTime !=''">
  2357. and r.end_time &lt;= #{finishEndTime}
  2358. </if>
  2359. group by r.staff_id,u.name,r.state,td.name
  2360. <if test="page != -1 and page != null ">
  2361. limit #{page}, #{row}
  2362. </if>
  2363. </select>
  2364. <select id="getReceivableInformation" parameterType="Map" resultType="Map">
  2365. select a.receivableAmount,
  2366. a.receivedAmount,
  2367. IF(a.receivableAmount &lt;
  2368. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2369. from (
  2370. select sum(t.his_owe_amount + t.cur_receivable_amount)
  2371. receivableAmount,
  2372. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2373. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2374. from report_fee_month_statistics t
  2375. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2376. where 1 = 1
  2377. and t.fee_year = #{feeYear}
  2378. and t.fee_month = #{feeMonth}
  2379. and t.community_id = #{communityId}
  2380. ) a
  2381. </select>
  2382. <select id="getFloorReceivableInformation" parameterType="Map" resultType="Map">
  2383. select a.floorNum,
  2384. a.`name`,
  2385. a.receivableAmount,
  2386. a.receivedAmount,
  2387. IF(a.receivableAmount &lt;
  2388. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2389. from (
  2390. select f.floor_num floorNum,
  2391. f.`name`,
  2392. sum(t.his_owe_amount + t.cur_receivable_amount)
  2393. receivableAmount,
  2394. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2395. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2396. from report_fee_month_statistics t
  2397. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2398. inner join building_room br
  2399. on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
  2400. t.community_id and
  2401. br.status_cd = '0'
  2402. inner join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  2403. inner join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
  2404. where 1 = 1
  2405. and t.fee_year = #{feeYear}
  2406. and t.fee_month = #{feeMonth}
  2407. and t.community_id = #{communityId}
  2408. group by f.floor_num, f.`name`
  2409. ) a
  2410. </select>
  2411. <select id="getFeeConfigReceivableInformation" parameterType="Map" resultType="Map">
  2412. select a.feeName,
  2413. a.receivableAmount,
  2414. a.receivedAmount,
  2415. IF(a.receivableAmount &lt;
  2416. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2417. from (
  2418. select t.fee_name feeName,
  2419. sum(t.his_owe_amount + t.cur_receivable_amount)
  2420. receivableAmount,
  2421. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2422. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2423. from report_fee_month_statistics t
  2424. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2425. left join building_room br
  2426. on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
  2427. t.community_id and
  2428. br.status_cd = '0'
  2429. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  2430. left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
  2431. where 1 = 1
  2432. and t.fee_year = #{feeYear}
  2433. and t.fee_month = #{feeMonth}
  2434. and t.community_id = #{communityId}
  2435. group by t.fee_name
  2436. ) a
  2437. </select>
  2438. <!-- 查询未收费房屋统计数量 add by wuxw 2018-07-03 -->
  2439. <select id="queryNoFeeRoomsCount" parameterType="Map" resultType="Map">
  2440. select count(1) count
  2441. from building_room t
  2442. inner join building_unit bu
  2443. on t.unit_id = bu.unit_id and bu.status_cd = '0'
  2444. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2445. left join building_owner_room_rel borr on borr.room_id = t.room_id and borr.status_cd ='0'
  2446. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  2447. where t.status_cd = '0'
  2448. and not exists (
  2449. select 1 from pay_fee pf where t.room_id = pf.payer_obj_id
  2450. and pf.status_cd = '0'
  2451. and pf.state = '2008001'
  2452. )
  2453. <if test="communityId != null and communityId !=''">
  2454. and t.community_id = #{communityId}
  2455. </if>
  2456. <if test="floorId != null and floorId !=''">
  2457. and f.floor_id = #{floorId}
  2458. </if>
  2459. <if test="unitId != null and unitId !=''">
  2460. and bu.unit_id = #{unitId}
  2461. </if>
  2462. <if test="roomId != null and roomId !=''">
  2463. and t.room_id = #{roomId}
  2464. </if>
  2465. <if test="ownerName != null and ownerName !=''">
  2466. and bo.name like '%${ownerName}%'
  2467. </if>
  2468. <if test="link != null and link !=''">
  2469. and bo.link = #{link}
  2470. </if>
  2471. </select>
  2472. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2473. <select id="queryNoFeeRooms" parameterType="Map" resultType="Map">
  2474. select f.floor_num floorNum,bu.unit_num unitNum,t.room_num roomNum,t.room_id roomId,bo.owner_id ownerId,bo.name
  2475. ownerName,bo.link
  2476. from building_room t
  2477. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  2478. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2479. left join building_owner_room_rel borr on borr.room_id = t.room_id and borr.status_cd ='0'
  2480. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  2481. where t.status_cd = '0'
  2482. and not exists(
  2483. select 1 from pay_fee pf where t.room_id = pf.payer_obj_id and pf.status_cd = '0' and pf.state = '2008001'
  2484. )
  2485. <if test="communityId != null and communityId !=''">
  2486. and t.community_id = #{communityId}
  2487. </if>
  2488. <if test="floorId != null and floorId !=''">
  2489. and f.floor_id = #{floorId}
  2490. </if>
  2491. <if test="unitId != null and unitId !=''">
  2492. and bu.unit_id = #{unitId}
  2493. </if>
  2494. <if test="roomId != null and roomId !=''">
  2495. and t.room_id = #{roomId}
  2496. </if>
  2497. <if test="ownerName != null and ownerName !=''">
  2498. and bo.name like '%${ownerName}%'
  2499. </if>
  2500. <if test="link != null and link !=''">
  2501. and bo.link = #{link}
  2502. </if>
  2503. order by bo.name
  2504. <if test="page != -1 and page != null ">
  2505. limit #{page}, #{row}
  2506. </if>
  2507. </select>
  2508. <!-- 查询押金 -->
  2509. <select id="queryPayFeeDeposit" parameterType="Map" resultType="Map">
  2510. select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  2511. feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
  2512. 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
  2513. userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
  2514. additionalAmount,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
  2515. pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
  2516. computingFormula,pfc.computing_formula_text computingFormulaText,
  2517. pfc.bill_type billType,t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
  2518. configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,td4.name
  2519. billTypeName,t.create_time createTime,td5.name payerObjTypeName,pfd.state detailState,td6.name
  2520. detailStateName,pfa1.`value` deadlineTime
  2521. ,pfo.`value` ownerName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,oc.car_num carNum
  2522. from pay_fee t
  2523. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0' and pfc.fee_type_cd =
  2524. '888800010006'
  2525. left join pay_fee_detail pfd on t.fee_id = pfd.fee_id and pfd.status_cd = '0' and pfd.state != '1300'
  2526. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  2527. td1.table_columns = 'fee_type_cd'
  2528. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  2529. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  2530. 'fee_flag'
  2531. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  2532. td4.table_columns = 'bill_type'
  2533. left join t_dict td5 on t.payer_obj_type = td5.status_cd and td5.table_name = 'pay_fee' and
  2534. td5.table_columns = 'payer_obj_type'
  2535. left join t_dict td6 on pfd.state = td6.status_cd and td6.table_name = 'pay_fee_detail' and
  2536. td6.table_columns = 'state'
  2537. left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
  2538. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  2539. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  2540. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2541. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2542. left join owner_car oc on t.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
  2543. where 1 = 1
  2544. <if test="roomNum !=null and roomNum != ''">
  2545. and br.room_num= #{roomNum}
  2546. </if>
  2547. <if test="unitId !=null and unitId != ''">
  2548. and bu.unit_id= #{unitId}
  2549. </if>
  2550. <if test="floorId !=null and floorId != ''">
  2551. and f.floor_id = #{floorId}
  2552. </if>
  2553. <if test="amount != null and amount != ''">
  2554. and t.amount = #{amount}
  2555. </if>
  2556. <if test="incomeObjId != null and incomeObjId != ''">
  2557. and t.income_obj_id = #{incomeObjId}
  2558. </if>
  2559. <if test="feeTypeCd != null and feeTypeCd != ''">
  2560. and t.fee_type_cd = #{feeTypeCd}
  2561. </if>
  2562. <if test="startTime != null and startTime != ''">
  2563. and t.start_time = #{startTime}
  2564. </if>
  2565. <if test="endTime != null and endTime != ''">
  2566. and t.end_time = #{endTime}
  2567. </if>
  2568. <if test="statusCd != null and statusCd != ''">
  2569. and t.status_cd = #{statusCd}
  2570. </if>
  2571. <if test="communityId != null and communityId != ''">
  2572. and t.community_id = #{communityId}
  2573. </if>
  2574. <if test="feeId != null and feeId != ''">
  2575. and t.fee_id = #{feeId}
  2576. </if>
  2577. <if test="userId != null and userId != ''">
  2578. and t.user_id = #{userId}
  2579. </if>
  2580. <if test="payerObjId != null and payerObjId != ''">
  2581. and t.payer_obj_id = #{payerObjId}
  2582. </if>
  2583. <if test="squarePrice != null and squarePrice != ''">
  2584. and pfc.square_price = #{squarePrice}
  2585. </if>
  2586. <if test="additionalAmount != null and additionalAmount != ''">
  2587. and pfc.additional_amount = #{additionalAmount}
  2588. </if>
  2589. <if test="feeFlag != null and feeFlag != ''">
  2590. and t.fee_flag = #{feeFlag}
  2591. </if>
  2592. <if test="state != null and state != ''">
  2593. and t.state = #{state}
  2594. </if>
  2595. <if test="configId != null and configId != ''">
  2596. and t.config_id = #{configId}
  2597. </if>
  2598. <if test="feeName != null and feeName != ''">
  2599. and pfc.fee_name = #{feeName}
  2600. </if>
  2601. <if test="computingFormula != null and computingFormula != ''">
  2602. and pfc.computing_formula = #{computingFormula}
  2603. </if>
  2604. <if test="computingFormulaText != null and computingFormulaText != ''">
  2605. and pfc.computing_formula_text = #{computingFormulaText}
  2606. </if>
  2607. <if test="billType != null and billType != ''">
  2608. and pfc.bill_type = #{billType}
  2609. </if>
  2610. <if test="payerObjType != null and payerObjType != ''">
  2611. and t.payer_obj_type = #{payerObjType}
  2612. </if>
  2613. <if test="isDefault != null and isDefault != ''">
  2614. and pfc.is_default = #{isDefault}
  2615. </if>
  2616. <if test="configStartTime != null and configStartTime != ''">
  2617. and pfc.start_time = #{configStartTime}
  2618. </if>
  2619. <if test="configEndTime != null and configEndTime != ''">
  2620. and pfc.end_time = #{configEndTime}
  2621. </if>
  2622. <if test="paymentCd != null and paymentCd != ''">
  2623. and pfc.payment_cd = #{paymentCd}
  2624. </if>
  2625. <if test="paymentCycle != null and paymentCycle != ''">
  2626. and pfc.payment_cycle = #{paymentCycle}
  2627. </if>
  2628. <if test="feeStartTime != null and feeStartTime != ''">
  2629. and t.create_time &gt;= #{feeStartTime}
  2630. </if>
  2631. <if test="feeEndTime != null and feeEndTime != ''">
  2632. and t.create_time &lt;= #{feeEndTime}
  2633. </if>
  2634. <if test="detailState != null and detailState != ''">
  2635. and pfd.state = #{detailState}
  2636. </if>
  2637. order by t.create_time desc
  2638. <if test="page != -1 and page != null ">
  2639. limit #{page}, #{row}
  2640. </if>
  2641. </select>
  2642. <!-- 查询押金退费总金额 -->
  2643. <select id="queryFeeDepositAmount" parameterType="Map" resultType="Map">
  2644. select SUM(pfc.additional_amount) allAmount,pfd.state detailState
  2645. from pay_fee t
  2646. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0' and pfc.fee_type_cd =
  2647. '888800010006'
  2648. left join pay_fee_detail pfd on t.fee_id = pfd.fee_id and pfd.status_cd = '0' and pfd.state != '1300'
  2649. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  2650. td1.table_columns = 'fee_type_cd'
  2651. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  2652. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  2653. 'fee_flag'
  2654. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  2655. td4.table_columns = 'bill_type'
  2656. left join t_dict td5 on t.payer_obj_type = td5.status_cd and td5.table_name = 'pay_fee' and
  2657. td5.table_columns = 'payer_obj_type'
  2658. left join t_dict td6 on pfd.state = td6.status_cd and td6.table_name = 'pay_fee_detail' and
  2659. td6.table_columns = 'state'
  2660. left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
  2661. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  2662. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  2663. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2664. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2665. left join owner_car oc on t.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  2666. where 1 = 1
  2667. <if test="roomNum !=null and roomNum != ''">
  2668. and br.room_num= #{roomNum}
  2669. </if>
  2670. <if test="unitId !=null and unitId != ''">
  2671. and bu.unit_id= #{unitId}
  2672. </if>
  2673. <if test="floorId !=null and floorId != ''">
  2674. and f.floor_id = #{floorId}
  2675. </if>
  2676. <if test="amount != null and amount != ''">
  2677. and t.amount = #{amount}
  2678. </if>
  2679. <if test="incomeObjId != null and incomeObjId != ''">
  2680. and t.income_obj_id = #{incomeObjId}
  2681. </if>
  2682. <if test="feeTypeCd != null and feeTypeCd != ''">
  2683. and t.fee_type_cd = #{feeTypeCd}
  2684. </if>
  2685. <if test="startTime != null and startTime != ''">
  2686. and t.start_time = #{startTime}
  2687. </if>
  2688. <if test="endTime != null and endTime != ''">
  2689. and t.end_time = #{endTime}
  2690. </if>
  2691. <if test="statusCd != null and statusCd != ''">
  2692. and t.status_cd = #{statusCd}
  2693. </if>
  2694. <if test="communityId != null and communityId != ''">
  2695. and t.community_id = #{communityId}
  2696. </if>
  2697. <if test="feeId != null and feeId != ''">
  2698. and t.fee_id = #{feeId}
  2699. </if>
  2700. <if test="userId != null and userId != ''">
  2701. and t.user_id = #{userId}
  2702. </if>
  2703. <if test="payerObjId != null and payerObjId != ''">
  2704. and t.payer_obj_id = #{payerObjId}
  2705. </if>
  2706. <if test="squarePrice != null and squarePrice != ''">
  2707. and pfc.square_price = #{squarePrice}
  2708. </if>
  2709. <if test="additionalAmount != null and additionalAmount != ''">
  2710. and pfc.additional_amount = #{additionalAmount}
  2711. </if>
  2712. <if test="feeFlag != null and feeFlag != ''">
  2713. and t.fee_flag = #{feeFlag}
  2714. </if>
  2715. <if test="state != null and state != ''">
  2716. and t.state = #{state}
  2717. </if>
  2718. <if test="configId != null and configId != ''">
  2719. and t.config_id = #{configId}
  2720. </if>
  2721. <if test="feeName != null and feeName != ''">
  2722. and pfc.fee_name = #{feeName}
  2723. </if>
  2724. <if test="computingFormula != null and computingFormula != ''">
  2725. and pfc.computing_formula = #{computingFormula}
  2726. </if>
  2727. <if test="computingFormulaText != null and computingFormulaText != ''">
  2728. and pfc.computing_formula_text = #{computingFormulaText}
  2729. </if>
  2730. <if test="billType != null and billType != ''">
  2731. and pfc.bill_type = #{billType}
  2732. </if>
  2733. <if test="payerObjType != null and payerObjType != ''">
  2734. and t.payer_obj_type = #{payerObjType}
  2735. </if>
  2736. <if test="isDefault != null and isDefault != ''">
  2737. and pfc.is_default = #{isDefault}
  2738. </if>
  2739. <if test="configStartTime != null and configStartTime != ''">
  2740. and pfc.start_time = #{configStartTime}
  2741. </if>
  2742. <if test="configEndTime != null and configEndTime != ''">
  2743. and pfc.end_time = #{configEndTime}
  2744. </if>
  2745. <if test="paymentCd != null and paymentCd != ''">
  2746. and pfc.payment_cd = #{paymentCd}
  2747. </if>
  2748. <if test="paymentCycle != null and paymentCycle != ''">
  2749. and pfc.payment_cycle = #{paymentCycle}
  2750. </if>
  2751. <if test="feeStartTime != null and feeStartTime != ''">
  2752. and t.create_time &gt;= #{feeStartTime}
  2753. </if>
  2754. <if test="feeEndTime != null and feeEndTime != ''">
  2755. and t.create_time &lt;= #{feeEndTime}
  2756. </if>
  2757. <if test="detailState != null and detailState != ''">
  2758. and pfd.state = #{detailState}
  2759. </if>
  2760. group by pfd.state
  2761. </select>
  2762. <select id="queryHuaningOweFeeCount" parameterType="Map" resultType="Map">
  2763. select count(1) count
  2764. from f_floor f
  2765. where 1=1
  2766. and f.community_id = #{communityId}
  2767. and f.status_cd = '0'
  2768. </select>
  2769. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2770. <select id="queryHuaningOweFee" parameterType="Map" resultType="Map">
  2771. select
  2772. f.floor_num floorNum,
  2773. (
  2774. select ifnull(SUM(t.receivable_amount),0)
  2775. from pay_fee_detail_month t
  2776. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2777. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2778. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2779. where 1=1
  2780. and bu.floor_id = f.floor_id
  2781. and t.community_id = f.community_id
  2782. <if test="feeTypeCd != null and feeTypeCd != ''">
  2783. and pf.fee_type_cd = #{feeTypeCd}
  2784. </if>
  2785. and t.detail_id = '-1'
  2786. and t.cur_month_time &lt;= #{endTime}
  2787. ) oweAmount,
  2788. (
  2789. select ifnull(SUM(t.receivable_amount),0)
  2790. from pay_fee_detail_month t
  2791. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2792. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2793. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2794. where 1=1
  2795. and bu.floor_id = f.floor_id
  2796. and t.community_id = f.community_id
  2797. <if test="feeTypeCd != null and feeTypeCd != ''">
  2798. and pf.fee_type_cd = #{feeTypeCd}
  2799. </if>
  2800. and t.detail_id = '-1'
  2801. and t.cur_month_time &lt;= #{endTime}
  2802. and t.cur_month_time &gt;= #{startTime}
  2803. ) curOweAmount,
  2804. (
  2805. select ifnull(SUM(t.receivable_amount),0)
  2806. from pay_fee_detail_month t
  2807. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2808. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2809. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2810. where 1=1
  2811. and bu.floor_id = f.floor_id
  2812. and t.community_id = f.community_id
  2813. <if test="feeTypeCd != null and feeTypeCd != ''">
  2814. and pf.fee_type_cd = #{feeTypeCd}
  2815. </if>
  2816. and t.detail_id = '-1'
  2817. and t.cur_month_time &lt; #{startTime}
  2818. ) preOweAmount
  2819. from f_floor f
  2820. where 1=1
  2821. and f.community_id = #{communityId}
  2822. <if test="floorNum != null and floorNum != ''">
  2823. and f.floor_num = #{floorNum}
  2824. </if>
  2825. and f.status_cd = '0'
  2826. <if test="page != -1 and page != null ">
  2827. limit #{page}, #{row}
  2828. </if>
  2829. </select>
  2830. <select id="queryHuaningOweFeeCounts" parameterType="Map" resultType="Map">
  2831. select count(1) count from (
  2832. select
  2833. f.floor_num floorNum,
  2834. (
  2835. select ifnull(SUM(t.receivable_amount),0)
  2836. from pay_fee_detail_month t
  2837. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2838. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2839. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2840. where 1=1
  2841. and bu.floor_id = f.floor_id
  2842. and t.community_id = f.community_id
  2843. <if test="feeTypeCd != null and feeTypeCd != ''">
  2844. and pf.fee_type_cd = #{feeTypeCd}
  2845. </if>
  2846. and t.detail_id = '-1'
  2847. and t.cur_month_time &lt;= #{endTime}
  2848. ) oweAmount,
  2849. (
  2850. select ifnull(SUM(t.receivable_amount),0)
  2851. from pay_fee_detail_month t
  2852. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2853. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2854. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2855. where 1=1
  2856. and bu.floor_id = f.floor_id
  2857. and t.community_id = f.community_id
  2858. <if test="feeTypeCd != null and feeTypeCd != ''">
  2859. and pf.fee_type_cd = #{feeTypeCd}
  2860. </if>
  2861. and t.detail_id = '-1'
  2862. and t.cur_month_time &lt;= #{endTime}
  2863. and t.cur_month_time &gt;= #{startTime}
  2864. ) curOweAmount,
  2865. (
  2866. select ifnull(SUM(t.receivable_amount),0)
  2867. from pay_fee_detail_month t
  2868. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2869. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2870. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2871. where 1=1
  2872. and bu.floor_id = f.floor_id
  2873. and t.community_id = f.community_id
  2874. <if test="feeTypeCd != null and feeTypeCd != ''">
  2875. and pf.fee_type_cd = #{feeTypeCd}
  2876. </if>
  2877. and t.detail_id = '-1'
  2878. and t.cur_month_time &lt; #{startTime}
  2879. ) preOweAmount
  2880. from f_floor f
  2881. where 1=1
  2882. and f.community_id = #{communityId}
  2883. <if test="floorNum != null and floorNum != ''">
  2884. and f.floor_num = #{floorNum}
  2885. </if>
  2886. and f.status_cd = '0'
  2887. ) st
  2888. </select>
  2889. <select id="queryHuaningPayFeeCount" parameterType="Map" resultType="Map">
  2890. select count(1) count
  2891. from (
  2892. select t.floor_num
  2893. from f_floor t
  2894. where 1=1
  2895. and t.community_id= #{communityId}
  2896. GROUP BY t.floor_num
  2897. ) tt
  2898. </select>
  2899. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2900. <select id="queryHuaningPayFee" parameterType="Map" resultType="Map">
  2901. select
  2902. f.floor_num floorNum,
  2903. (
  2904. select ifnull(SUM(t.receivable_amount),0)
  2905. from pay_fee_detail_month t
  2906. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2907. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2908. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2909. where 1=1
  2910. <if test="feeTypeCd != null and feeTypeCd != ''">
  2911. and pf.fee_type_cd = #{feeTypeCd}
  2912. </if>
  2913. and bu.floor_id = f.floor_id
  2914. and t.community_id = f.community_id
  2915. and t.cur_month_time = #{endTime}
  2916. ) receivableAmount,
  2917. (
  2918. select ifnull(SUM(t.received_amount),0)
  2919. from pay_fee_detail_month t
  2920. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2921. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2922. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2923. where 1=1
  2924. <if test="feeTypeCd != null and feeTypeCd != ''">
  2925. and pf.fee_type_cd = #{feeTypeCd}
  2926. </if>
  2927. and bu.floor_id = f.floor_id
  2928. and t.community_id = f.community_id
  2929. and t.pay_fee_time &gt;= #{endTime}
  2930. and t.pay_fee_time &lt; #{nextMonthTime}
  2931. and t.detail_id != '-1'
  2932. ) receivedAmount,
  2933. (
  2934. select ifnull(SUM(t.received_amount),0)
  2935. from pay_fee_detail_month t
  2936. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2937. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2938. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2939. where 1=1
  2940. <if test="feeTypeCd != null and feeTypeCd != ''">
  2941. and pf.fee_type_cd = #{feeTypeCd}
  2942. </if>
  2943. and bu.floor_id = f.floor_id
  2944. and t.community_id = f.community_id
  2945. and t.pay_fee_time &gt;= #{endTime}
  2946. and t.pay_fee_time &lt; #{nextMonthTime}
  2947. and t.cur_month_time &lt; #{endTime}
  2948. and t.cur_month_time &gt;= #{startTime}
  2949. and t.detail_id != '-1'
  2950. ) receivedAmount1,
  2951. (
  2952. select ifnull(SUM(t.received_amount),0)
  2953. from pay_fee_detail_month t
  2954. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2955. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2956. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2957. where 1=1
  2958. <if test="feeTypeCd != null and feeTypeCd != ''">
  2959. and pf.fee_type_cd = #{feeTypeCd}
  2960. </if>
  2961. and bu.floor_id = f.floor_id
  2962. and t.community_id = f.community_id
  2963. and t.pay_fee_time &gt;= #{endTime}
  2964. and t.pay_fee_time &lt; #{nextMonthTime}
  2965. and t.cur_month_time = #{endTime}
  2966. and t.detail_id != '-1'
  2967. ) receivedAmount2,
  2968. (
  2969. select ifnull(SUM(t.received_amount),0)
  2970. from pay_fee_detail_month t
  2971. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2972. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2973. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2974. where 1=1
  2975. <if test="feeTypeCd != null and feeTypeCd != ''">
  2976. and pf.fee_type_cd = #{feeTypeCd}
  2977. </if>
  2978. and bu.floor_id = f.floor_id
  2979. and t.community_id = f.community_id
  2980. and t.pay_fee_time &gt;= #{endTime}
  2981. and t.pay_fee_time &lt; #{nextMonthTime}
  2982. and t.cur_month_time &gt;= #{nextMonthTime}
  2983. and t.detail_id != '-1'
  2984. ) receivedAmount3,
  2985. (
  2986. select ifnull(SUM(t.received_amount),0)
  2987. from pay_fee_detail_month t
  2988. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2989. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2990. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2991. where 1=1
  2992. <if test="feeTypeCd != null and feeTypeCd != ''">
  2993. and pf.fee_type_cd = #{feeTypeCd}
  2994. </if>
  2995. and bu.floor_id = f.floor_id
  2996. and t.community_id = f.community_id
  2997. and t.pay_fee_time &gt;= #{endTime}
  2998. and t.pay_fee_time &lt; #{nextMonthTime}
  2999. and t.cur_month_time &lt; #{startTime}
  3000. and t.detail_id != '-1'
  3001. ) receivedAmount4
  3002. from f_floor f
  3003. where 1=1
  3004. and f.community_id = #{communityId}
  3005. <if test="floorNum != null and floorNum != ''">
  3006. and f.floor_num = #{floorNum}
  3007. </if>
  3008. and f.status_cd = '0'
  3009. <if test="page != -1 and page != null ">
  3010. limit #{page}, #{row}
  3011. </if>
  3012. </select>
  3013. <select id="queryHuaningPayFeeCounts" parameterType="Map" resultType="Map">
  3014. select count(1) count
  3015. from (
  3016. select
  3017. f.floor_num floorNum,
  3018. (
  3019. select ifnull(SUM(t.receivable_amount),0)
  3020. from pay_fee_detail_month t
  3021. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3022. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3023. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3024. where 1=1
  3025. <if test="feeTypeCd != null and feeTypeCd != ''">
  3026. and pf.fee_type_cd = #{feeTypeCd}
  3027. </if>
  3028. and bu.floor_id = f.floor_id
  3029. and t.community_id = f.community_id
  3030. and t.cur_month_time = #{endTime}
  3031. ) receivableAmount,
  3032. (
  3033. select ifnull(SUM(t.received_amount),0)
  3034. from pay_fee_detail_month t
  3035. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3036. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3037. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3038. where 1=1
  3039. <if test="feeTypeCd != null and feeTypeCd != ''">
  3040. and pf.fee_type_cd = #{feeTypeCd}
  3041. </if>
  3042. and bu.floor_id = f.floor_id
  3043. and t.community_id = f.community_id
  3044. and t.pay_fee_time &gt;= #{endTime}
  3045. and t.pay_fee_time &lt; #{nextMonthTime}
  3046. and t.detail_id != '-1'
  3047. ) receivedAmount,
  3048. (
  3049. select ifnull(SUM(t.received_amount),0)
  3050. from pay_fee_detail_month t
  3051. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3052. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3053. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3054. where 1=1
  3055. <if test="feeTypeCd != null and feeTypeCd != ''">
  3056. and pf.fee_type_cd = #{feeTypeCd}
  3057. </if>
  3058. and bu.floor_id = f.floor_id
  3059. and t.community_id = f.community_id
  3060. and t.pay_fee_time &gt;= #{endTime}
  3061. and t.pay_fee_time &lt; #{nextMonthTime}
  3062. and t.cur_month_time &lt; #{endTime}
  3063. and t.cur_month_time &gt;= #{startTime}
  3064. and t.detail_id != '-1'
  3065. ) receivedAmount1,
  3066. (
  3067. select ifnull(SUM(t.received_amount),0)
  3068. from pay_fee_detail_month t
  3069. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3070. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3071. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3072. where 1=1
  3073. <if test="feeTypeCd != null and feeTypeCd != ''">
  3074. and pf.fee_type_cd = #{feeTypeCd}
  3075. </if>
  3076. and bu.floor_id = f.floor_id
  3077. and t.community_id = f.community_id
  3078. and t.pay_fee_time &gt;= #{endTime}
  3079. and t.pay_fee_time &lt; #{nextMonthTime}
  3080. and t.cur_month_time = #{endTime}
  3081. and t.detail_id != '-1'
  3082. ) receivedAmount2,
  3083. (
  3084. select ifnull(SUM(t.received_amount),0)
  3085. from pay_fee_detail_month t
  3086. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3087. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3088. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3089. where 1=1
  3090. <if test="feeTypeCd != null and feeTypeCd != ''">
  3091. and pf.fee_type_cd = #{feeTypeCd}
  3092. </if>
  3093. and bu.floor_id = f.floor_id
  3094. and t.community_id = f.community_id
  3095. and t.pay_fee_time &gt;= #{endTime}
  3096. and t.pay_fee_time &lt; #{nextMonthTime}
  3097. and t.cur_month_time &gt;= #{nextMonthTime}
  3098. and t.detail_id != '-1'
  3099. ) receivedAmount3,
  3100. (
  3101. select ifnull(SUM(t.received_amount),0)
  3102. from pay_fee_detail_month t
  3103. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3104. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3105. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3106. where 1=1
  3107. <if test="feeTypeCd != null and feeTypeCd != ''">
  3108. and pf.fee_type_cd = #{feeTypeCd}
  3109. </if>
  3110. and bu.floor_id = f.floor_id
  3111. and t.community_id = f.community_id
  3112. and t.pay_fee_time &gt;= #{endTime}
  3113. and t.pay_fee_time &lt; #{nextMonthTime}
  3114. and t.cur_month_time &lt; #{startTime}
  3115. and t.detail_id != '-1'
  3116. ) receivedAmount4
  3117. from f_floor f
  3118. where 1=1
  3119. and f.community_id = #{communityId}
  3120. <if test="floorNum != null and floorNum != ''">
  3121. and f.floor_num = #{floorNum}
  3122. </if>
  3123. and f.status_cd = '0'
  3124. ) st
  3125. </select>
  3126. <select id="queryHuaningPayFeeTwoCount" parameterType="Map" resultType="Map">
  3127. select count(1) count
  3128. from (
  3129. select a.floorNum, d.receivableAmount,
  3130. a.receivedAmount, b.receivedAmount1,
  3131. c.receivedAmount2
  3132. from
  3133. (select t.floor_num floorNum, sum (pfd.received_amount) receivedAmount
  3134. from f_floor t
  3135. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3136. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3137. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3138. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3139. where 1=1
  3140. and t.status_cd = '0'
  3141. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3142. and t.community_id= #{communityId}
  3143. GROUP BY floor_num
  3144. ) a,
  3145. (select t.floor_num floorNum, SUM (pfdm1.discount_amount) receivedAmount1
  3146. from f_floor t
  3147. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3148. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3149. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3150. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3151. LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
  3152. pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
  3153. where 1=1
  3154. and t.status_cd = '0'
  3155. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3156. and t.community_id= #{communityId}
  3157. GROUP BY floor_num
  3158. ) b,
  3159. (select t.floor_num floorNum, SUM (pfdm2.received_amount) receivedAmount2
  3160. from f_floor t
  3161. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3162. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3163. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3164. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3165. LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
  3166. pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month &gt; #{month}
  3167. where 1=1
  3168. and t.status_cd = '0'
  3169. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3170. and t.community_id= #{communityId}
  3171. GROUP BY floor_num
  3172. ) c,
  3173. (select t.floor_num floorNum, SUM (rfms.owe_amount) receivableAmount
  3174. from f_floor t
  3175. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3176. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3177. inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
  3178. where t.community_id= #{communityId}
  3179. group by t.floor_num
  3180. ) d
  3181. where a.floorNum = b.floorNum
  3182. and b.floorNum = c.floorNum
  3183. and c.floorNum = d.floorNum
  3184. ) tt
  3185. </select>
  3186. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3187. <select id="queryHuaningPayFeeTwo" parameterType="Map" resultType="Map">
  3188. select a.floorNum,d.receivableAmount ,
  3189. a.receivedAmount,b.receivedAmount1,
  3190. c.receivedAmount2
  3191. from
  3192. (select t.floor_num floorNum,sum(pfd.received_amount) receivedAmount
  3193. from f_floor t
  3194. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3195. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3196. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3197. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3198. where 1=1
  3199. and t.status_cd = '0'
  3200. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3201. and t.community_id= #{communityId}
  3202. GROUP BY floor_num
  3203. ) a,
  3204. (select t.floor_num floorNum,SUM(pfdm1.discount_amount) receivedAmount1
  3205. from f_floor t
  3206. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3207. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3208. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3209. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3210. LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
  3211. pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
  3212. where 1=1
  3213. and t.status_cd = '0'
  3214. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3215. and t.community_id= #{communityId}
  3216. GROUP BY floor_num
  3217. ) b,
  3218. (select t.floor_num floorNum,SUM(pfdm2.received_amount) receivedAmount2
  3219. from f_floor t
  3220. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3221. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3222. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3223. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3224. LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
  3225. pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month &gt; #{month}
  3226. where 1=1
  3227. and t.status_cd = '0'
  3228. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3229. and t.community_id= #{communityId}
  3230. GROUP BY floor_num
  3231. ) c,
  3232. (select t.floor_num floorNum,SUM(rfms.owe_amount) receivableAmount
  3233. from f_floor t
  3234. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3235. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3236. inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
  3237. where t.community_id= #{communityId}
  3238. group by t.floor_num
  3239. ) d
  3240. where a.floorNum = b.floorNum
  3241. and b.floorNum = c.floorNum
  3242. and c.floorNum = d.floorNum
  3243. <if test="page != -1 and page != null ">
  3244. limit #{page}, #{row}
  3245. </if>
  3246. </select>
  3247. <select id="queryHuaningOweFeeDetailCount" parameterType="Map" resultType="Map">
  3248. select
  3249. count(1) count
  3250. from building_room br
  3251. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3252. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3253. inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
  3254. inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
  3255. where 1=1
  3256. and br.community_id = #{communityId}
  3257. and br.status_cd = '0'
  3258. and rof.amount_owed > 0
  3259. <if test="feeTypeCd != null and feeTypeCd != ''">
  3260. and pf.fee_type_cd = #{feeTypeCd}
  3261. </if>
  3262. <if test="floorId != null and floorId != ''">
  3263. and f.floor_id = #{floorId}
  3264. </if>
  3265. <if test="floorNum != null and floorNum != ''">
  3266. and f.floor_num = #{floorNum}
  3267. </if>
  3268. </select>
  3269. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3270. <select id="queryHuaningOweFeeDetail" parameterType="Map" resultType="Map">
  3271. select
  3272. f.floor_num floorNum,
  3273. concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) roomName,
  3274. br.built_up_area builtUpArea,
  3275. rof.fee_name feeName,
  3276. rof.end_time endTime,
  3277. rof.deadline_time deadlineTime,
  3278. (
  3279. select ifnull(SUM(t.receivable_amount),0)
  3280. from pay_fee_detail_month t
  3281. where 1=1
  3282. and t.fee_id = rof.fee_id
  3283. and t.community_id = f.community_id
  3284. and t.detail_id = '-1'
  3285. and t.cur_month_time &lt;= #{startTime}
  3286. ) oweAmount,
  3287. (
  3288. select ifnull(SUM(t.receivable_amount),0)
  3289. from pay_fee_detail_month t
  3290. where 1=1
  3291. and t.fee_id = rof.fee_id
  3292. and t.community_id = f.community_id
  3293. and t.detail_id = '-1'
  3294. and t.cur_month_time &lt;= #{startTime}
  3295. and t.cur_month_time &gt;= #{endTime}
  3296. ) curOweAmount,
  3297. (
  3298. select ifnull(SUM(t.receivable_amount),0)
  3299. from pay_fee_detail_month t
  3300. where 1=1
  3301. and t.fee_id = rof.fee_id
  3302. and t.community_id = f.community_id
  3303. and t.detail_id = '-1'
  3304. and t.cur_month_time &lt;= #{startTime}
  3305. ) preOweAmount
  3306. from building_room br
  3307. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3308. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3309. inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
  3310. inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
  3311. where 1=1
  3312. and br.community_id = #{communityId}
  3313. and br.status_cd = '0'
  3314. and rof.amount_owed > 0
  3315. <if test="feeTypeCd != null and feeTypeCd != ''">
  3316. and pf.fee_type_cd = #{feeTypeCd}
  3317. </if>
  3318. <if test="floorId != null and floorId != ''">
  3319. and f.floor_id = #{floorId}
  3320. </if>
  3321. <if test="floorNum != null and floorNum != ''">
  3322. and f.floor_num = #{floorNum}
  3323. </if>
  3324. <if test="page != -1 and page != null ">
  3325. limit #{page}, #{row}
  3326. </if>
  3327. </select>
  3328. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3329. <select id="getReceivedAmountByMonth" parameterType="Map" resultType="Map">
  3330. select ifnull(sum(t.received_amount),0) total
  3331. from pay_fee_detail_month t
  3332. where 1=1
  3333. and t.create_time &gt; #{startTime}
  3334. and t.create_time &lt; #{endTime}
  3335. and t.fee_id = #{feeId}
  3336. <if test="flag == 1">
  3337. and concat(t.detail_year,lpad(t.detail_month,2,0)) = #{yearMonth}
  3338. </if>
  3339. <if test="flag == 2">
  3340. and concat(t.detail_year,lpad(t.detail_month,2,0)) &lt; #{yearMonth}
  3341. </if>
  3342. <if test="flag == 3">
  3343. and concat(t.detail_year,lpad(t.detail_month,2,0)) &gt; #{yearMonth}
  3344. </if>
  3345. <if test="communityId !=null and communityId != ''">
  3346. and t.community_id= #{communityId}
  3347. </if>
  3348. </select>
  3349. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3350. <select id="queryRoomAndParkingSpace" parameterType="Map" resultType="Map">
  3351. select
  3352. br.room_id roomId,br.room_num roomNum,bu.unit_num unitNum,f.floor_num floorNum,t.owner_id ownerId
  3353. from building_owner_room_rel t
  3354. left join building_room br on t.room_id = br.room_id and br.status_cd = '0'
  3355. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3356. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3357. where t.status_cd = '0'
  3358. and t.owner_id in
  3359. <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
  3360. #{item}
  3361. </foreach>
  3362. </select>
  3363. <!-- 查询无效费用 add by wuxw 2018-07-03 -->
  3364. <select id="queryInvalidFeeMonthStatistics" parameterType="Map" resultType="Map">
  3365. select t.fee_id feeId
  3366. from pay_fee t
  3367. inner join pay_fee_config pfc on t.config_id = pfc.config_id
  3368. inner join report_fee_month_statistics rfms on t.fee_id = rfms.fee_id and rfms.status_cd = '0'
  3369. where (t.status_cd = '1' or pfc.status_cd = '1')
  3370. and t.community_id = #{communityId}
  3371. </select>
  3372. <!--清理报表 无效数据-->
  3373. <update id="deleteInvalidFee" parameterType="Map">
  3374. delete from report_fee_month_statistics where fee_id in
  3375. <foreach collection="feeIds" item="item" open="(" close=")" separator=",">
  3376. #{item}
  3377. </foreach>
  3378. and community_id = #{communityId}
  3379. </update>
  3380. </mapper>