ReportFeeMonthStatisticsServiceDaoImplMapper.xml 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437
  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.obj_name objName,t.fee_name feeName,t.owner_name ownerName,t.link ownerTel,br.built_up_area builtUpArea,
  1419. MIN(t.cur_month_time) startTime,MAX(t.cur_month_time) endTime,max(t.deadline_time) deadlineTime,SUM(t.receivable_amount) oweAmount
  1420. from pay_fee_detail_month t
  1421. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1422. where 1=1
  1423. and t.detail_id = '-1'
  1424. <if test="communityId !=null and communityId != ''">
  1425. and t.community_id= #{communityId}
  1426. </if>
  1427. <if test="startTime !=null and startTime != ''">
  1428. and t.cur_month_time &gt;= #{startTime}
  1429. </if>
  1430. <if test="endTime !=null and endTime != ''">
  1431. and t.cur_month_time &lt; #{endTime}
  1432. </if>
  1433. <if test="objName !=null and objName != ''">
  1434. and t.obj_name= #{objName}
  1435. </if>
  1436. <if test="objNameLike !=null and objNameLike != ''">
  1437. and t.obj_name like concat('%', #{objNameLike},'%')
  1438. </if>
  1439. <if test="ownerName !=null and ownerName != ''">
  1440. and t.owner_name = #{ownerName}
  1441. </if>
  1442. <if test="ownerNameLike !=null and ownerNameLike != ''">
  1443. and t.owner_name like concat('%', #{ownerNameLike},'%')
  1444. </if>
  1445. <if test="floorId !=null and floorId != ''">
  1446. and t.obj_fpc_id = #{floorId}
  1447. </if>
  1448. <if test="feeId !=null and feeId != ''">
  1449. and t.fee_id= #{feeId}
  1450. </if>
  1451. <if test="configId !=null and configId != ''">
  1452. and t.config_id= #{configId}
  1453. </if>
  1454. <if test="objId !=null and objId != ''">
  1455. and t.obj_id= #{objId}
  1456. </if>
  1457. <if test="feeName !=null and feeName != ''">
  1458. and t.fee_name= #{feeName}
  1459. </if>
  1460. <if test="feeTypeCd != null and feeTypeCd != ''">
  1461. and t.fee_type_cd = #{feeTypeCd}
  1462. </if>
  1463. group by t.obj_name ,t.fee_name ,t.owner_name ,t.link ,br.built_up_area
  1464. ) t
  1465. </select>
  1466. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1467. <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
  1468. select t.obj_name objName,t.fee_name feeName,t.owner_name ownerName,t.link ownerTel,br.built_up_area builtUpArea,t.community_id communityId,
  1469. MIN(t.cur_month_time) startTime,MAX(t.cur_month_time) endTime,max(t.deadline_time) deadlineTime,SUM(t.receivable_amount) oweAmount
  1470. from pay_fee_detail_month t
  1471. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1472. where 1=1
  1473. and t.detail_id = '-1'
  1474. <if test="communityId !=null and communityId != ''">
  1475. and t.community_id= #{communityId}
  1476. </if>
  1477. <if test="startTime !=null and startTime != ''">
  1478. and t.cur_month_time &gt;= #{startTime}
  1479. </if>
  1480. <if test="endTime !=null and endTime != ''">
  1481. and t.cur_month_time &lt; #{endTime}
  1482. </if>
  1483. <if test="objName !=null and objName != ''">
  1484. and t.obj_name= #{objName}
  1485. </if>
  1486. <if test="objNameLike !=null and objNameLike != ''">
  1487. and t.obj_name like concat('%', #{objNameLike},'%')
  1488. </if>
  1489. <if test="ownerName !=null and ownerName != ''">
  1490. and t.owner_name = #{ownerName}
  1491. </if>
  1492. <if test="ownerNameLike !=null and ownerNameLike != ''">
  1493. and t.owner_name like concat('%', #{ownerNameLike},'%')
  1494. </if>
  1495. <if test="floorId !=null and floorId != ''">
  1496. and t.obj_fpc_id = #{floorId}
  1497. </if>
  1498. <if test="feeId !=null and feeId != ''">
  1499. and t.fee_id= #{feeId}
  1500. </if>
  1501. <if test="configId !=null and configId != ''">
  1502. and t.config_id= #{configId}
  1503. </if>
  1504. <if test="objId !=null and objId != ''">
  1505. and t.obj_id= #{objId}
  1506. </if>
  1507. <if test="feeName !=null and feeName != ''">
  1508. and t.fee_name= #{feeName}
  1509. </if>
  1510. <if test="feeTypeCd != null and feeTypeCd != ''">
  1511. and t.fee_type_cd = #{feeTypeCd}
  1512. </if>
  1513. group by t.obj_name ,t.fee_name ,t.owner_name ,t.link ,br.built_up_area,t.community_id
  1514. order by t.obj_name
  1515. <if test="page != -1 and page != null ">
  1516. limit #{page}, #{row}
  1517. </if>
  1518. </select>
  1519. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1520. <select id="queryOweFeeDetailMajor" parameterType="Map" resultType="Map">
  1521. select SUM(t.receivable_amount) oweAmount
  1522. from pay_fee_detail_month t
  1523. left join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  1524. where 1=1
  1525. and t.detail_id = '-1'
  1526. <if test="communityId !=null and communityId != ''">
  1527. and t.community_id= #{communityId}
  1528. </if>
  1529. <if test="startTime !=null and startTime != ''">
  1530. and t.cur_month_time &gt;= #{startTime}
  1531. </if>
  1532. <if test="endTime !=null and endTime != ''">
  1533. and t.cur_month_time &lt; #{endTime}
  1534. </if>
  1535. <if test="objName !=null and objName != ''">
  1536. and t.obj_name= #{objName}
  1537. </if>
  1538. <if test="floorId !=null and floorId != ''">
  1539. and t.obj_fpc_id = #{floorId}
  1540. </if>
  1541. <if test="feeId !=null and feeId != ''">
  1542. and t.fee_id= #{feeId}
  1543. </if>
  1544. <if test="configId !=null and configId != ''">
  1545. and t.config_id= #{configId}
  1546. </if>
  1547. <if test="objId !=null and objId != ''">
  1548. and t.obj_id= #{objId}
  1549. </if>
  1550. <if test="feeName !=null and feeName != ''">
  1551. and t.fee_name= #{feeName}
  1552. </if>
  1553. <if test="feeTypeCd != null and feeTypeCd != ''">
  1554. and t.fee_type_cd = #{feeTypeCd}
  1555. </if>
  1556. </select>
  1557. <select id="queryPayFeeDetailCount" parameterType="Map" resultType="Map">
  1558. select count(1) count,SUM(t.received_amount) totalReceivedAmount,SUM(t.receivable_amount) totalReceivableAmount,
  1559. sum(t.acct_amount) accAmount,sum(t.discount_amount) discountAmount,sum(t.deduction_amount) deductionAmount,sum(t.late_amount) lateAmount,
  1560. sum(t.gift_amount) giftAmount
  1561. from pay_fee_detail t
  1562. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1563. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1564. <if test="ownerId != null and ownerId != ''">
  1565. left join pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390007'
  1566. </if>
  1567. where t.status_cd = '0'
  1568. and pf.status_cd = '0' and t.state != '1500'
  1569. <if test="detailId !=null and detailId != ''">
  1570. and t.detail_id= #{detailId}
  1571. </if>
  1572. <if test="payerObjName !=null and payerObjName != ''">
  1573. and pfa3.value = #{payerObjName}
  1574. </if>
  1575. <if test="ownerId !=null and ownerId != ''">
  1576. and pfa1.value = #{ownerId}
  1577. </if>
  1578. <if test="feeId !=null and feeId != ''">
  1579. and pf.fee_id= #{feeId}
  1580. </if>
  1581. <if test="configId !=null and configId != ''">
  1582. and pf.config_id= #{configId}
  1583. </if>
  1584. <if test="objId !=null and objId != ''">
  1585. and pf.payer_obj_id = #{objId}
  1586. </if>
  1587. <if test="feeName !=null and feeName != ''">
  1588. and pf.fee_name= #{feeName}
  1589. </if>
  1590. <if test="communityId !=null and communityId != ''">
  1591. and t.community_id= #{communityId}
  1592. </if>
  1593. <if test="primeRate != null and primeRate != ''">
  1594. and t.prime_rate = #{primeRate}
  1595. </if>
  1596. <if test="state != null and state != ''">
  1597. and t.state = #{state}
  1598. </if>
  1599. <if test="feeTypeCd != null and feeTypeCd != ''">
  1600. and pf.fee_type_cd = #{feeTypeCd}
  1601. </if>
  1602. <if test="startTime !=null and startTime != ''">
  1603. and t.create_time &gt;= #{startTime}
  1604. </if>
  1605. <if test="endTime !=null and endTime != ''">
  1606. and t.create_time &lt;= #{endTime}
  1607. </if>
  1608. <if test="feeStartTime !=null and feeStartTime != ''">
  1609. and t.start_time &gt;= #{feeStartTime}
  1610. </if>
  1611. <if test="feeEndTime !=null and feeEndTime != ''">
  1612. and t.end_time &lt;= #{feeEndTime}
  1613. </if>
  1614. <if test="cashierId !=null and cashierId != ''">
  1615. and t.cashier_id= #{cashierId}
  1616. </if>
  1617. <if test="cashierName !=null and cashierName != ''">
  1618. and t.cashier_name= #{cashierName}
  1619. </if>
  1620. </select>
  1621. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1622. <select id="queryPayFeeDetail" parameterType="Map" resultType="Map">
  1623. select pfc.fee_name feeName,pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time
  1624. endTime,t.create_time createTime,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
  1625. 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,
  1626. t.state,d3.name stateName,t.fee_id feeId,t.detail_id detailId,pf.payer_obj_id payerObjId,
  1627. t.cashier_id cashierId,t.cashier_name cashierName,t.payable_amount payableAmount,pfc.fee_flag feeFlag,
  1628. t.acct_amount acctAmount, t.discount_amount discountAmount, t.deduction_amount deductionAmount, t.late_amount lateAmount,
  1629. t.gift_amount giftAmount,t.remark,t.community_id communityId
  1630. from pay_fee_detail t
  1631. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1632. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1633. <if test="ownerId != null and ownerId != ''">
  1634. left join pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390007'
  1635. </if>
  1636. left join pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008'
  1637. left join pay_fee_attrs pfa3 on t.fee_id = pfa3.fee_id and pfa3.spec_cd = '390012'
  1638. left join t_dict d on t.prime_rate = d.status_cd and d.table_name='pay_fee_detail' and
  1639. d.table_columns='prime_rate'
  1640. left join t_dict d2 on pfc.fee_type_cd = d2.status_cd and d2.table_name = 'pay_fee_config' and d2.table_columns
  1641. = 'fee_type_cd'
  1642. left join t_dict d3 on t.state = d3.status_cd and d3.table_name = 'pay_fee_detail' and d3.table_columns =
  1643. 'state'
  1644. where t.status_cd = '0'
  1645. and pf.status_cd = '0' and t.state != '1500'
  1646. <if test="detailId !=null and detailId != ''">
  1647. and t.detail_id= #{detailId}
  1648. </if>
  1649. <if test="payerObjName !=null and payerObjName != ''">
  1650. and pfa3.value = #{payerObjName}
  1651. </if>
  1652. <if test="ownerId !=null and ownerId != ''">
  1653. and pfa1.value = #{ownerId}
  1654. </if>
  1655. <if test="feeId !=null and feeId != ''">
  1656. and pf.fee_id= #{feeId}
  1657. </if>
  1658. <if test="configId !=null and configId != ''">
  1659. and pf.config_id= #{configId}
  1660. </if>
  1661. <if test="objId !=null and objId != ''">
  1662. and pf.payer_obj_id = #{objId}
  1663. </if>
  1664. <if test="feeName !=null and feeName != ''">
  1665. and pf.fee_name= #{feeName}
  1666. </if>
  1667. <if test="communityId !=null and communityId != ''">
  1668. and t.community_id= #{communityId}
  1669. </if>
  1670. <if test="primeRate != null and primeRate != ''">
  1671. and t.prime_rate = #{primeRate}
  1672. </if>
  1673. <if test="state != null and state != ''">
  1674. and t.state = #{state}
  1675. </if>
  1676. <if test="feeTypeCd != null and feeTypeCd != ''">
  1677. and pf.fee_type_cd = #{feeTypeCd}
  1678. </if>
  1679. <if test="startTime !=null and startTime != ''">
  1680. and t.create_time &gt;= #{startTime}
  1681. </if>
  1682. <if test="endTime !=null and endTime != ''">
  1683. and t.create_time &lt;= #{endTime}
  1684. </if>
  1685. <if test="feeStartTime !=null and feeStartTime != ''">
  1686. and t.start_time &gt;= #{feeStartTime}
  1687. </if>
  1688. <if test="feeEndTime !=null and feeEndTime != ''">
  1689. and t.end_time &lt;= #{feeEndTime}
  1690. </if>
  1691. <if test="cashierId !=null and cashierId != ''">
  1692. and t.cashier_id= #{cashierId}
  1693. </if>
  1694. <if test="cashierName !=null and cashierName != ''">
  1695. and t.cashier_name= #{cashierName}
  1696. </if>
  1697. order by t.create_time desc
  1698. <if test="page != -1 and page != null ">
  1699. limit #{page}, #{row}
  1700. </if>
  1701. </select>
  1702. <!--查询账户抵扣大计金额-->
  1703. <select id="queryFeeAccountDetailSum" parameterType="Map" resultType="Map">
  1704. select fad.state fadState,SUM(fad.amount) fadAmount
  1705. from pay_fee_detail t
  1706. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1707. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1708. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1709. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1710. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1711. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
  1712. LEFT JOIN parking_space ps on oc.ps_id = ps.ps_id and ps.status_cd = '0'
  1713. left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
  1714. LEFT JOIN contract co on pf.payer_obj_id = co.contract_id and co.status_cd = '0' and pf.payer_obj_type='7777'
  1715. left join fee_account_detail fad on t.detail_id = fad.detail_id and fad.status_cd = '0'
  1716. where t.status_cd = '0' and fad.state is not null
  1717. and pf.status_cd = '0' and t.state != '1500'
  1718. <if test="detailId !=null and detailId != ''">
  1719. and t.detail_id= #{detailId}
  1720. </if>
  1721. <if test="roomNum !=null and roomNum != ''">
  1722. and br.room_num= #{roomNum}
  1723. </if>
  1724. <if test="unitId !=null and unitId != ''">
  1725. and bu.unit_id= #{unitId}
  1726. </if>
  1727. <if test="unitNum !=null and unitNum != ''">
  1728. and bu.unit_num= #{unitNum}
  1729. </if>
  1730. <if test="floorId !=null and floorId != ''">
  1731. and f.floor_id = #{floorId}
  1732. </if>
  1733. <if test="floorNum !=null and floorNum != ''">
  1734. and f.floor_num = #{floorNum}
  1735. </if>
  1736. <if test="objName !=null and objName != ''">
  1737. and t.obj_name= #{objName}
  1738. </if>
  1739. <if test="feeYear !=null and feeYear != ''">
  1740. and t.fee_year= #{feeYear}
  1741. </if>
  1742. <if test="feeMonth !=null and feeMonth != ''">
  1743. and t.fee_month= #{feeMonth}
  1744. </if>
  1745. <if test="feeId !=null and feeId != ''">
  1746. and t.fee_id= #{feeId}
  1747. </if>
  1748. <if test="configId !=null and configId != ''">
  1749. and pfc.config_id= #{configId}
  1750. </if>
  1751. <if test="objId !=null and objId != ''">
  1752. and pf.payer_obj_id = #{objId}
  1753. </if>
  1754. <if test="feeName !=null and feeName != ''">
  1755. and t.fee_name= #{feeName}
  1756. </if>
  1757. <if test="communityId !=null and communityId != ''">
  1758. and t.community_id= #{communityId}
  1759. </if>
  1760. <if test="primeRate != null and primeRate != ''">
  1761. and t.prime_rate = #{primeRate}
  1762. </if>
  1763. <if test="state != null and state != ''">
  1764. and t.state = #{state}
  1765. </if>
  1766. <if test="feeTypeCd != null and feeTypeCd != ''">
  1767. and pfc.fee_type_cd = #{feeTypeCd}
  1768. </if>
  1769. <if test="startTime !=null and startTime != ''">
  1770. and t.create_time &gt;= #{startTime}
  1771. </if>
  1772. <if test="endTime !=null and endTime != ''">
  1773. and t.create_time &lt;= #{endTime}
  1774. </if>
  1775. <if test="feeStartTime !=null and feeStartTime != ''">
  1776. and t.start_time &gt;= #{feeStartTime}
  1777. </if>
  1778. <if test="feeEndTime !=null and feeEndTime != ''">
  1779. and t.end_time &lt;= #{feeEndTime}
  1780. </if>
  1781. <if test="cashierId !=null and cashierId != ''">
  1782. and t.cashier_id= #{cashierId}
  1783. </if>
  1784. <if test="cashierName !=null and cashierName != ''">
  1785. and t.cashier_name= #{cashierName}
  1786. </if>
  1787. group by fad.state
  1788. </select>
  1789. <select id="queryAllPayFeeDetail" parameterType="Map" resultType="Map">
  1790. select SUM(t.receivable_amount) allReceivableAmount,SUM(t.received_amount) allReceivedAmount
  1791. from pay_fee_detail t
  1792. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1793. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1794. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1795. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1796. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1797. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  1798. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  1799. where t.status_cd = '0' and t.state != '1500'
  1800. <if test="roomNum !=null and roomNum != ''">
  1801. and br.room_num= #{roomNum}
  1802. </if>
  1803. <if test="unitId !=null and unitId != ''">
  1804. and bu.unit_id= #{unitId}
  1805. </if>
  1806. <if test="unitNum !=null and unitNum != ''">
  1807. and bu.unit_num= #{unitNum}
  1808. </if>
  1809. <if test="floorId !=null and floorId != ''">
  1810. and f.floor_id = #{floorId}
  1811. </if>
  1812. <if test="floorNum !=null and floorNum != ''">
  1813. and f.floor_num = #{floorNum}
  1814. </if>
  1815. <if test="objName !=null and objName != ''">
  1816. and t.obj_name= #{objName}
  1817. </if>
  1818. <if test="feeYear !=null and feeYear != ''">
  1819. and t.fee_year= #{feeYear}
  1820. </if>
  1821. <if test="feeMonth !=null and feeMonth != ''">
  1822. and t.fee_month= #{feeMonth}
  1823. </if>
  1824. <if test="feeId !=null and feeId != ''">
  1825. and t.fee_id= #{feeId}
  1826. </if>
  1827. <if test="configId !=null and configId != ''">
  1828. and pfc.config_id= #{configId}
  1829. </if>
  1830. <if test="feeTypeCd != null and feeTypeCd != ''">
  1831. and pfc.fee_type_cd = #{feeTypeCd}
  1832. </if>
  1833. <if test="objId !=null and objId != ''">
  1834. and pf.payer_obj_id= #{objId}
  1835. </if>
  1836. <if test="feeName !=null and feeName != ''">
  1837. and t.fee_name= #{feeName}
  1838. </if>
  1839. <if test="communityId !=null and communityId != ''">
  1840. and t.community_id= #{communityId}
  1841. </if>
  1842. <if test="primeRate != null and primeRate != ''">
  1843. and t.prime_rate = #{primeRate}
  1844. </if>
  1845. <if test="state != null and state != ''">
  1846. and t.state = #{state}
  1847. </if>
  1848. <if test="startTime !=null and startTime != ''">
  1849. and t.create_time &gt;= #{startTime}
  1850. </if>
  1851. <if test="endTime !=null and endTime != ''">
  1852. and t.create_time &lt;= #{endTime}
  1853. </if>
  1854. </select>
  1855. <select id="queryPayFeeDetailSum" parameterType="Map" resultType="Map">
  1856. select pfc.fee_name feeName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,oc.car_num carNum,
  1857. pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time endTime,t.create_time createTime,
  1858. t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfa.`value`
  1859. importFeeName,t.prime_rate,d.name primeRate,fdr.discount_small_type discountSmallType,fdr.rule_name
  1860. ruleName,pfdd.discount_price,t.detail_id detailId,t.community_id communityId,
  1861. SUM(pfdd.discount_price) discountPrice
  1862. from pay_fee_detail t
  1863. left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1864. left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
  1865. left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
  1866. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  1867. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  1868. left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  1869. left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
  1870. left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
  1871. left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
  1872. left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
  1873. left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
  1874. d.table_columns="prime_rate"
  1875. where t.status_cd = '0'
  1876. and pfdd.discount_price > 0
  1877. <if test="roomNum !=null and roomNum != ''">
  1878. and br.room_num= #{roomNum}
  1879. </if>
  1880. <if test="unitId !=null and unitId != ''">
  1881. and bu.unit_id= #{unitId}
  1882. </if>
  1883. <if test="unitNum !=null and unitNum != ''">
  1884. and bu.unit_num= #{unitNum}
  1885. </if>
  1886. <if test="floorId !=null and floorId != ''">
  1887. and f.floor_id = #{floorId}
  1888. </if>
  1889. <if test="floorNum !=null and floorNum != ''">
  1890. and f.floor_num = #{floorNum}
  1891. </if>
  1892. <if test="objName !=null and objName != ''">
  1893. and t.obj_name= #{objName}
  1894. </if>
  1895. <if test="feeYear !=null and feeYear != ''">
  1896. and t.fee_year= #{feeYear}
  1897. </if>
  1898. <if test="feeMonth !=null and feeMonth != ''">
  1899. and t.fee_month= #{feeMonth}
  1900. </if>
  1901. <if test="feeId !=null and feeId != ''">
  1902. and t.fee_id= #{feeId}
  1903. </if>
  1904. <if test="configId !=null and configId != ''">
  1905. and pfc.config_id= #{configId}
  1906. </if>
  1907. <if test="feeTypeCd != null and feeTypeCd != ''">
  1908. and pfc.fee_type_cd = #{feeTypeCd}
  1909. </if>
  1910. <if test="objId !=null and objId != ''">
  1911. and pf.payer_obj_id= #{objId}
  1912. </if>
  1913. <if test="feeName !=null and feeName != ''">
  1914. and t.fee_name= #{feeName}
  1915. </if>
  1916. <if test="communityId !=null and communityId != ''">
  1917. and t.community_id= #{communityId}
  1918. </if>
  1919. <if test="primeRate != null and primeRate != ''">
  1920. and t.prime_rate = #{primeRate}
  1921. </if>
  1922. <if test="startTime !=null and startTime != ''">
  1923. and t.create_time &gt;= #{startTime}
  1924. </if>
  1925. <if test="endTime !=null and endTime != ''">
  1926. and t.create_time &lt;= #{endTime}
  1927. </if>
  1928. group by t.detail_id,pfc.fee_name,f.floor_num,bu.unit_num ,br.room_num ,oc.car_num ,
  1929. pf.payer_obj_type ,t.start_time ,t.end_time ,t.create_time ,
  1930. t.receivable_amount ,t.received_amount ,pfa.`value`
  1931. ,t.prime_rate,d.name ,fdr.discount_small_type ,fdr.rule_name,pfdd.discount_price
  1932. order by t.create_time desc
  1933. </select>
  1934. <select id="queryDeadlineFeeCount" parameterType="Map" resultType="Map">
  1935. select count(1) count
  1936. from pay_fee_detail_month t
  1937. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1938. where 1=1
  1939. and t.detail_id = '-1'
  1940. <if test="configId !=null and configId != ''">
  1941. and t.config_id = #{configId}
  1942. </if>
  1943. <if test="objName !=null and objName != ''">
  1944. and t.obj_name like CONCAT('%',#{objName},'%')
  1945. </if>
  1946. <if test="ownerName !=null and ownerName != ''">
  1947. and t.owner_name like CONCAT('%',#{ownerName},'%')
  1948. </if>
  1949. <if test="link !=null and link != ''">
  1950. and t.link = #{link}
  1951. </if>
  1952. <if test="communityId !=null and communityId != ''">
  1953. and t.community_id= #{communityId}
  1954. </if>
  1955. <if test="startTime !=null and startTime !=''">
  1956. and t.deadline_time &gt;= #{startTime}
  1957. </if>
  1958. <if test="endTime !=null and endTime != ''">
  1959. and t.deadline_time &lt;= #{endTime}
  1960. </if>
  1961. </select>
  1962. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  1963. <select id="queryDeadlineFee" parameterType="Map" resultType="Map">
  1964. select
  1965. t.obj_name objName,
  1966. pf.payer_obj_type objType,
  1967. t.fee_name feeName,
  1968. t.deadline_time deadlineTime
  1969. from pay_fee_detail_month t
  1970. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  1971. where 1=1
  1972. and t.detail_id = '-1'
  1973. <if test="configId !=null and configId != ''">
  1974. and t.config_id = #{configId}
  1975. </if>
  1976. <if test="objName !=null and objName != ''">
  1977. and t.obj_name like CONCAT('%',#{objName},'%')
  1978. </if>
  1979. <if test="ownerName !=null and ownerName != ''">
  1980. and t.owner_name like CONCAT('%',#{ownerName},'%')
  1981. </if>
  1982. <if test="link !=null and link != ''">
  1983. and t.link = #{link}
  1984. </if>
  1985. <if test="communityId !=null and communityId != ''">
  1986. and t.community_id= #{communityId}
  1987. </if>
  1988. <if test="startTime !=null and startTime !=''">
  1989. and t.deadline_time &gt;= #{startTime}
  1990. </if>
  1991. <if test="endTime !=null and endTime != ''">
  1992. and t.deadline_time &lt;= #{endTime}
  1993. </if>
  1994. order by t.deadline_time
  1995. <if test="page != -1 and page != null ">
  1996. limit #{page}, #{row}
  1997. </if>
  1998. </select>
  1999. <select id="queryPrePaymentNewCount" parameterType="Map" resultType="Map">
  2000. select count(1) count
  2001. from (
  2002. select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
  2003. t.payer_obj_type payerObjType
  2004. from pay_fee t
  2005. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2006. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
  2007. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
  2008. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
  2009. where t.state = '2008001'
  2010. and t.status_cd = '0'
  2011. <if test="ownerName != null and ownerName != ''">
  2012. and pfa2.value like concat('%' #{ownerName} ,'%')
  2013. </if>
  2014. <if test="objName != null and objName != ''">
  2015. and pfa.`value` like concat('%',#{objName},'%')
  2016. </if>
  2017. <if test="link != null and link != ''">
  2018. and pfa1.`value` = #{link}
  2019. </if>
  2020. <if test="configId !=null and configId != ''">
  2021. and t.config_id = #{configId}
  2022. </if>
  2023. <if test="communityId !=null and communityId != ''">
  2024. and t.community_id= #{communityId}
  2025. </if>
  2026. <if test="startTime !=null and startTime != ''">
  2027. and t.end_time &gt;= #{startTime}
  2028. </if>
  2029. <if test="endTime !=null and endTime != ''">
  2030. and t.end_time &lt;= #{endTime}
  2031. </if>
  2032. ) t
  2033. </select>
  2034. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2035. <select id="queryPrePayment" parameterType="Map" resultType="Map">
  2036. select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
  2037. t.payer_obj_type payerObjType
  2038. from pay_fee t
  2039. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2040. LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
  2041. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
  2042. LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
  2043. where t.state = '2008001'
  2044. and t.status_cd = '0'
  2045. <if test="ownerName != null and ownerName != ''">
  2046. and pfa2.value like concat('%' #{ownerName} ,'%')
  2047. </if>
  2048. <if test="objName != null and objName != ''">
  2049. and pfa.`value` like concat('%',#{objName},'%')
  2050. </if>
  2051. <if test="link != null and link != ''">
  2052. and pfa1.`value` = #{link}
  2053. </if>
  2054. <if test="configId !=null and configId != ''">
  2055. and t.config_id = #{configId}
  2056. </if>
  2057. <if test="communityId !=null and communityId != ''">
  2058. and t.community_id= #{communityId}
  2059. </if>
  2060. <if test="startTime !=null and startTime != ''">
  2061. and t.end_time &gt;= #{startTime}
  2062. </if>
  2063. <if test="endTime !=null and endTime != ''">
  2064. and t.end_time &lt;= #{endTime}
  2065. </if>
  2066. <if test="page != -1 and page != null ">
  2067. limit #{page}, #{row}
  2068. </if>
  2069. </select>
  2070. <select id="queryPrePaymentCount" parameterType="Map" resultType="Map">
  2071. select pfc.fee_name feeName, count(t.payer_obj_id) objCount
  2072. from pay_fee t
  2073. inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
  2074. where t.state = '2008001'
  2075. and t.status_cd = '0'
  2076. and t.end_time &gt; #{startTime}
  2077. and t.end_time &lt; #{endTime}
  2078. and t.community_id = #{communityId}
  2079. group by pfc.fee_name, pfc.config_id
  2080. order by objCount
  2081. </select>
  2082. <select id="queryDeadlinePaymentCount" parameterType="Map" resultType="Map">
  2083. SELECT t.fee_name feeName, count(t.obj_id) objCount
  2084. FROM report_fee_month_statistics t
  2085. inner join pay_fee pf on t.fee_id = pf.fee_id
  2086. and pf.community_id = t.community_id and pf.status_cd = '0'
  2087. WHERE 1 = 1
  2088. AND t.status_cd = '0'
  2089. and t.community_id = #{communityId}
  2090. AND t.deadline_time &gt; #{startTime}
  2091. AND t.deadline_time &lt; #{endTime}
  2092. group by t.config_id, t.fee_name
  2093. order by objCount desc
  2094. </select>
  2095. <select id="queryOwePaymentCount" parameterType="Map" resultType="Map">
  2096. select t.fee_name feeName, count(distinct t.obj_id) objCount
  2097. from report_fee_month_statistics t
  2098. inner join pay_fee pf
  2099. on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  2100. where t.community_id = #{communityId}
  2101. and t.owe_amount > 0
  2102. group by t.config_id, t.fee_name
  2103. order by objCount desc
  2104. </select>
  2105. <select id="queryAllPaymentCount" parameterType="Map" resultType="Map">
  2106. select t.fee_name feeName, count(distinct t.obj_id) objCount
  2107. from report_fee_month_statistics t
  2108. inner join pay_fee pf
  2109. on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
  2110. where t.community_id = #{communityId}
  2111. group by t.config_id, t.fee_name
  2112. order by objCount desc
  2113. </select>
  2114. <select id="queryFinishOweFee" parameterType="Map" resultType="Map">
  2115. select t.config_id configId,
  2116. t.fee_id feeId,
  2117. t.statistics_id statisticsId,
  2118. t.fee_year feeYear,
  2119. fee_month feeMonth
  2120. from report_fee_month_statistics t
  2121. inner join pay_fee pf
  2122. on t.fee_id = pf.fee_id and pf.state = '2009001' and pf.community_id = #{communityId} and
  2123. pf.status_cd = '0'
  2124. where t.owe_amount > 0
  2125. and t.status_cd = '0'
  2126. and t.community_id = #{communityId} limit 100
  2127. </select>
  2128. <!-- 查询费用配置信息 add by wuxw 2018-07-03 -->
  2129. <select id="getFeeConfigInfo" parameterType="Map" resultType="Map">
  2130. select t.fee_type_cd,t.fee_type_cd feeTypeCd,t.computing_formula,t.computing_formula
  2131. computingFormula,t.additional_amount,t.additional_amount additionalAmount,t.status_cd,t.status_cd
  2132. statusCd,t.square_price,t.square_price squarePrice,t.is_default,t.is_default isDefault,t.config_id,t.config_id
  2133. configId,t.fee_flag,t.fee_flag feeFlag,t.fee_name,t.fee_name feeName,t.start_time,t.start_time
  2134. startTime,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,
  2135. td1.name feeTypeCdName,td2.name feeFlagName,t.bill_type billType,t.bill_type,td3.name billTypeName,
  2136. t.payment_cd,t.payment_cycle,t.payment_cd paymentCd,t.payment_cycle paymentCycle
  2137. from pay_fee_config t,t_dict td1,t_dict td2,t_dict td3
  2138. where 1 =1
  2139. and t.fee_type_cd = td1.status_cd
  2140. and td1.table_name = 'pay_fee_config'
  2141. and td1.table_columns = 'fee_type_cd'
  2142. and t.fee_flag = td2.status_cd
  2143. and td2.table_name = 'pay_fee_config'
  2144. and td2.table_columns = 'fee_flag'
  2145. and t.bill_type = td3.status_cd
  2146. and td3.table_name = 'pay_fee_config'
  2147. and td3.table_columns = 'bill_type'
  2148. and t.is_default = 'F'
  2149. and t.status_cd = '0'
  2150. <if test="feeTypeCd !=null and feeTypeCd != ''">
  2151. and t.fee_type_cd= #{feeTypeCd}
  2152. </if>
  2153. <if test="computingFormula !=null and computingFormula != ''">
  2154. and t.computing_formula= #{computingFormula}
  2155. </if>
  2156. <if test="additionalAmount !=null and additionalAmount != ''">
  2157. and t.additional_amount= #{additionalAmount}
  2158. </if>
  2159. <if test="squarePrice !=null and squarePrice != ''">
  2160. and t.square_price= #{squarePrice}
  2161. </if>
  2162. <if test="configId !=null and configId != ''">
  2163. and t.config_id= #{configId}
  2164. </if>
  2165. <if test="feeFlag !=null and feeFlag != ''">
  2166. and t.fee_flag= #{feeFlag}
  2167. </if>
  2168. <if test="feeName !=null and feeName != ''">
  2169. and t.fee_name like '%${feeName}%'
  2170. </if>
  2171. <if test="startTime !=null ">
  2172. and t.start_time= #{startTime}
  2173. </if>
  2174. <if test="endTime !=null ">
  2175. and t.end_time= #{endTime}
  2176. </if>
  2177. <if test="valid !=null and valid == 1">
  2178. and t.end_time &gt; now()
  2179. </if>
  2180. <if test="curTime !=null ">
  2181. and t.end_time &gt; #{curTime}
  2182. and t.start_time &lt; #{curTime}
  2183. </if>
  2184. <if test="communityId !=null and communityId != ''">
  2185. and t.community_id= #{communityId}
  2186. </if>
  2187. <if test="bId !=null and bId != ''">
  2188. and t.b_id= #{bId}
  2189. </if>
  2190. <if test="paymentCd !=null and paymentCd != ''">
  2191. and t.payment_cd= #{paymentCd}
  2192. </if>
  2193. <if test="paymentCycle !=null and paymentCycle != ''">
  2194. and t.payment_cycle= #{paymentCycle}
  2195. </if>
  2196. <if test="billType !=null and billType != ''">
  2197. and t.bill_type= #{billType}
  2198. </if>
  2199. order by t.create_time desc
  2200. <if test="page != -1 and page != null ">
  2201. limit #{page}, #{row}
  2202. </if>
  2203. </select>
  2204. <select id="getRepairInfo" parameterType="Map" resultType="Map">
  2205. select r.staff_id staffId,r.staff_name staffName,r.state, t.name stateName, count(*) amount from r_repair_user r
  2206. left join t_dict t on t.table_name="r_repair_user" and t.table_columns="state" and t.status_cd=r.state
  2207. where r.state != "10005" and r.status_cd = "0"
  2208. <if test="ruId != null and ruId != ''">
  2209. and r.ru_id = #{ruId}
  2210. </if>
  2211. <if test="repairId != null and repairId != ''">
  2212. and r.repair_id = #{repairId}
  2213. </if>
  2214. <if test="communityId != null and communityId !=''">
  2215. and r.community_id = #{communityId}
  2216. </if>
  2217. <if test="bId != null and bId !=''">
  2218. and r.b_id = #{bId}
  2219. </if>
  2220. <if test="state != null and state != ''">
  2221. and r.state = #{state}
  2222. </if>
  2223. <if test="context != null and context !=''">
  2224. and r.context = #{context}
  2225. </if>
  2226. <if test="statusCd != null and statusCd != ''">
  2227. and r.status_cd = #{statusCd}
  2228. </if>
  2229. <if test="staffId != null and staffId !=''">
  2230. and r.staff_id = #{staffId}
  2231. </if>
  2232. <if test="staffName != null and staffName !=''">
  2233. and r.staff_name = #{staffName}
  2234. </if>
  2235. <if test="preStaffId != null and preStaffId !=''">
  2236. and r.pre_staff_id = #{preStaffId}
  2237. </if>
  2238. <if test="preStaffName != null and preStaffName !=''">
  2239. and r.pre_staff_name = #{preStaffName}
  2240. </if>
  2241. <if test="beginStartTime != null and beginStartTime !=''">
  2242. and r.start_time &gt;= #{beginStartTime}
  2243. </if>
  2244. <if test="beginEndTime != null and beginEndTime !=''">
  2245. and r.start_time &lt;= #{beginEndTime}
  2246. </if>
  2247. <if test="finishStartTime != null and finishStartTime !=''">
  2248. and r.end_time &gt;= #{finishStartTime}
  2249. </if>
  2250. <if test="finishEndTime != null and finishEndTime !=''">
  2251. and r.end_time &lt;= #{finishEndTime}
  2252. </if>
  2253. <if test="createTime != null and createTime !=''">
  2254. and r.create_time = #{createTime}
  2255. </if>
  2256. group by r.staff_id,r.state
  2257. order by r.create_time desc
  2258. <if test="page != -1 and page != null ">
  2259. limit #{page}, #{row}
  2260. </if>
  2261. </select>
  2262. <select id="getRepairWithOutPage" parameterType="Map" resultType="Map">
  2263. select r.staff_id staffId,u.name staffName,r.state,u.score, count(*) amount from
  2264. r_repair_user r
  2265. left join t_dict td on td.table_name="r_repair_user" and td.table_columns="state" and td.status_cd=r.state
  2266. left join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
  2267. where r.state != '10005' and r.status_cd = '0'
  2268. <if test="ruId != null and ruId != ''">
  2269. and r.ru_id = #{ruId}
  2270. </if>
  2271. <if test="repairId != null and repairId != ''">
  2272. and r.repair_id = #{repairId}
  2273. </if>
  2274. <if test="communityId != null and communityId !=''">
  2275. and r.community_id = #{communityId}
  2276. </if>
  2277. <if test="bId != null and bId !=''">
  2278. and r.b_id = #{bId}
  2279. </if>
  2280. <if test="state != null and state != ''">
  2281. and r.state = #{state}
  2282. </if>
  2283. <if test="context != null and context !=''">
  2284. and r.context = #{context}
  2285. </if>
  2286. <if test="statusCd != null and statusCd != ''">
  2287. and r.status_cd = #{statusCd}
  2288. </if>
  2289. <if test="staffId != null and staffId !=''">
  2290. and r.staff_id = #{staffId}
  2291. </if>
  2292. <if test="staffName != null and staffName !=''">
  2293. and r.staff_name = #{staffName}
  2294. </if>
  2295. <if test="preStaffId != null and preStaffId !=''">
  2296. and r.pre_staff_id = #{preStaffId}
  2297. </if>
  2298. <if test="preStaffName != null and preStaffName !=''">
  2299. and r.pre_staff_name = #{preStaffName}
  2300. </if>
  2301. <if test="beginStartTime != null and beginStartTime !=''">
  2302. and r.start_time &gt;= #{beginStartTime}
  2303. </if>
  2304. <if test="beginEndTime != null and beginEndTime !=''">
  2305. and r.start_time &lt;= #{beginEndTime}
  2306. </if>
  2307. <if test="finishStartTime != null and finishStartTime !=''">
  2308. and r.end_time &gt;= #{finishStartTime}
  2309. </if>
  2310. <if test="finishEndTime != null and finishEndTime !=''">
  2311. and r.end_time &lt;= #{finishEndTime}
  2312. </if>
  2313. <if test="createTime != null and createTime !=''">
  2314. and r.create_time = #{createTime}
  2315. </if>
  2316. group by r.staff_id,u.name,r.state,u.score
  2317. </select>
  2318. <select id="queryRepairForStaff" parameterType="Map" resultType="Map">
  2319. SELECT r.staff_id staffId,u.name staffName,r.state,td.name stateName
  2320. FROM r_repair_user r
  2321. inner join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
  2322. left join t_dict td on r.state = td.status_cd and td.table_name = 'r_repair_user' and td.table_columns = 'state'
  2323. WHERE r.state!='10005' AND r.state!='10009' AND r.state!='11000' AND
  2324. r.state!='12000' AND r.state != '10007' AND r.status_cd = '0' AND
  2325. r.repair_event != 'payUser' AND r.repair_event != 'startUser' AND r.staff_id != '-1'
  2326. <if test="communityId != null and communityId !=''">
  2327. and r.community_id = #{communityId}
  2328. </if>
  2329. <if test="staffId != null and staffId != ''">
  2330. and r.staff_id = #{staffId}
  2331. </if>
  2332. <if test="state != null and state != ''">
  2333. and r.state = #{state}
  2334. </if>
  2335. <if test="beginStartTime != null and beginStartTime !=''">
  2336. and r.start_time &gt;= #{beginStartTime}
  2337. </if>
  2338. <if test="beginEndTime != null and beginEndTime !=''">
  2339. and r.start_time &lt;= #{beginEndTime}
  2340. </if>
  2341. <if test="finishStartTime != null and finishStartTime !=''">
  2342. and r.end_time &gt;= #{finishStartTime}
  2343. </if>
  2344. <if test="finishEndTime != null and finishEndTime !=''">
  2345. and r.end_time &lt;= #{finishEndTime}
  2346. </if>
  2347. group by r.staff_id,u.name,r.state,td.name
  2348. <if test="page != -1 and page != null ">
  2349. limit #{page}, #{row}
  2350. </if>
  2351. </select>
  2352. <select id="getReceivableInformation" parameterType="Map" resultType="Map">
  2353. select a.receivableAmount,
  2354. a.receivedAmount,
  2355. IF(a.receivableAmount &lt;
  2356. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2357. from (
  2358. select sum(t.his_owe_amount + t.cur_receivable_amount)
  2359. receivableAmount,
  2360. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2361. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2362. from report_fee_month_statistics t
  2363. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2364. where 1 = 1
  2365. and t.fee_year = #{feeYear}
  2366. and t.fee_month = #{feeMonth}
  2367. and t.community_id = #{communityId}
  2368. ) a
  2369. </select>
  2370. <select id="getFloorReceivableInformation" parameterType="Map" resultType="Map">
  2371. select a.floorNum,
  2372. a.`name`,
  2373. a.receivableAmount,
  2374. a.receivedAmount,
  2375. IF(a.receivableAmount &lt;
  2376. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2377. from (
  2378. select f.floor_num floorNum,
  2379. f.`name`,
  2380. sum(t.his_owe_amount + t.cur_receivable_amount)
  2381. receivableAmount,
  2382. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2383. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2384. from report_fee_month_statistics t
  2385. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2386. inner join building_room br
  2387. on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
  2388. t.community_id and
  2389. br.status_cd = '0'
  2390. inner join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  2391. inner join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
  2392. where 1 = 1
  2393. and t.fee_year = #{feeYear}
  2394. and t.fee_month = #{feeMonth}
  2395. and t.community_id = #{communityId}
  2396. group by f.floor_num, f.`name`
  2397. ) a
  2398. </select>
  2399. <select id="getFeeConfigReceivableInformation" parameterType="Map" resultType="Map">
  2400. select a.feeName,
  2401. a.receivableAmount,
  2402. a.receivedAmount,
  2403. IF(a.receivableAmount &lt;
  2404. a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
  2405. from (
  2406. select t.fee_name feeName,
  2407. sum(t.his_owe_amount + t.cur_receivable_amount)
  2408. receivableAmount,
  2409. sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
  2410. sum(t.cur_received_amount + t.his_owe_received_amount) oweReceivedAmount
  2411. from report_fee_month_statistics t
  2412. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2413. left join building_room br
  2414. on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
  2415. t.community_id and
  2416. br.status_cd = '0'
  2417. left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
  2418. left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
  2419. where 1 = 1
  2420. and t.fee_year = #{feeYear}
  2421. and t.fee_month = #{feeMonth}
  2422. and t.community_id = #{communityId}
  2423. group by t.fee_name
  2424. ) a
  2425. </select>
  2426. <!-- 查询未收费房屋统计数量 add by wuxw 2018-07-03 -->
  2427. <select id="queryNoFeeRoomsCount" parameterType="Map" resultType="Map">
  2428. select count(1) count
  2429. from building_room t
  2430. inner join building_unit bu
  2431. on t.unit_id = bu.unit_id and bu.status_cd = '0'
  2432. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2433. left join building_owner_room_rel borr on borr.room_id = t.room_id and borr.status_cd ='0'
  2434. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  2435. where t.status_cd = '0'
  2436. and not exists (
  2437. select 1 from pay_fee pf where t.room_id = pf.payer_obj_id
  2438. and pf.status_cd = '0'
  2439. and pf.state = '2008001'
  2440. )
  2441. <if test="communityId != null and communityId !=''">
  2442. and t.community_id = #{communityId}
  2443. </if>
  2444. <if test="floorId != null and floorId !=''">
  2445. and f.floor_id = #{floorId}
  2446. </if>
  2447. <if test="unitId != null and unitId !=''">
  2448. and bu.unit_id = #{unitId}
  2449. </if>
  2450. <if test="roomId != null and roomId !=''">
  2451. and t.room_id = #{roomId}
  2452. </if>
  2453. <if test="ownerName != null and ownerName !=''">
  2454. and bo.name like '%${ownerName}%'
  2455. </if>
  2456. <if test="link != null and link !=''">
  2457. and bo.link = #{link}
  2458. </if>
  2459. </select>
  2460. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2461. <select id="queryNoFeeRooms" parameterType="Map" resultType="Map">
  2462. select f.floor_num floorNum,bu.unit_num unitNum,t.room_num roomNum,t.room_id roomId,bo.owner_id ownerId,bo.name
  2463. ownerName,bo.link
  2464. from building_room t
  2465. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  2466. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2467. left join building_owner_room_rel borr on borr.room_id = t.room_id and borr.status_cd ='0'
  2468. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  2469. where t.status_cd = '0'
  2470. and not exists(
  2471. select 1 from pay_fee pf where t.room_id = pf.payer_obj_id and pf.status_cd = '0' and pf.state = '2008001'
  2472. )
  2473. <if test="communityId != null and communityId !=''">
  2474. and t.community_id = #{communityId}
  2475. </if>
  2476. <if test="floorId != null and floorId !=''">
  2477. and f.floor_id = #{floorId}
  2478. </if>
  2479. <if test="unitId != null and unitId !=''">
  2480. and bu.unit_id = #{unitId}
  2481. </if>
  2482. <if test="roomId != null and roomId !=''">
  2483. and t.room_id = #{roomId}
  2484. </if>
  2485. <if test="ownerName != null and ownerName !=''">
  2486. and bo.name like '%${ownerName}%'
  2487. </if>
  2488. <if test="link != null and link !=''">
  2489. and bo.link = #{link}
  2490. </if>
  2491. order by bo.name
  2492. <if test="page != -1 and page != null ">
  2493. limit #{page}, #{row}
  2494. </if>
  2495. </select>
  2496. <!-- 查询押金 -->
  2497. <select id="queryPayFeeDeposit" parameterType="Map" resultType="Map">
  2498. select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
  2499. feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
  2500. 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
  2501. userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
  2502. additionalAmount,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
  2503. pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
  2504. computingFormula,pfc.computing_formula_text computingFormulaText,
  2505. pfc.bill_type billType,t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
  2506. configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,td4.name
  2507. billTypeName,t.create_time createTime,td5.name payerObjTypeName,pfd.state detailState,td6.name
  2508. detailStateName,pfa1.`value` deadlineTime
  2509. ,pfo.`value` ownerName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,oc.car_num carNum
  2510. from pay_fee t
  2511. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0' and pfc.fee_type_cd =
  2512. '888800010006'
  2513. left join pay_fee_detail pfd on t.fee_id = pfd.fee_id and pfd.status_cd = '0' and pfd.state != '1300'
  2514. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  2515. td1.table_columns = 'fee_type_cd'
  2516. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  2517. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  2518. 'fee_flag'
  2519. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  2520. td4.table_columns = 'bill_type'
  2521. left join t_dict td5 on t.payer_obj_type = td5.status_cd and td5.table_name = 'pay_fee' and
  2522. td5.table_columns = 'payer_obj_type'
  2523. left join t_dict td6 on pfd.state = td6.status_cd and td6.table_name = 'pay_fee_detail' and
  2524. td6.table_columns = 'state'
  2525. left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
  2526. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  2527. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  2528. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2529. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2530. left join owner_car oc on t.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
  2531. where 1 = 1
  2532. <if test="roomNum !=null and roomNum != ''">
  2533. and br.room_num= #{roomNum}
  2534. </if>
  2535. <if test="unitId !=null and unitId != ''">
  2536. and bu.unit_id= #{unitId}
  2537. </if>
  2538. <if test="floorId !=null and floorId != ''">
  2539. and f.floor_id = #{floorId}
  2540. </if>
  2541. <if test="amount != null and amount != ''">
  2542. and t.amount = #{amount}
  2543. </if>
  2544. <if test="incomeObjId != null and incomeObjId != ''">
  2545. and t.income_obj_id = #{incomeObjId}
  2546. </if>
  2547. <if test="feeTypeCd != null and feeTypeCd != ''">
  2548. and t.fee_type_cd = #{feeTypeCd}
  2549. </if>
  2550. <if test="startTime != null and startTime != ''">
  2551. and t.start_time = #{startTime}
  2552. </if>
  2553. <if test="endTime != null and endTime != ''">
  2554. and t.end_time = #{endTime}
  2555. </if>
  2556. <if test="statusCd != null and statusCd != ''">
  2557. and t.status_cd = #{statusCd}
  2558. </if>
  2559. <if test="communityId != null and communityId != ''">
  2560. and t.community_id = #{communityId}
  2561. </if>
  2562. <if test="feeId != null and feeId != ''">
  2563. and t.fee_id = #{feeId}
  2564. </if>
  2565. <if test="userId != null and userId != ''">
  2566. and t.user_id = #{userId}
  2567. </if>
  2568. <if test="payerObjId != null and payerObjId != ''">
  2569. and t.payer_obj_id = #{payerObjId}
  2570. </if>
  2571. <if test="squarePrice != null and squarePrice != ''">
  2572. and pfc.square_price = #{squarePrice}
  2573. </if>
  2574. <if test="additionalAmount != null and additionalAmount != ''">
  2575. and pfc.additional_amount = #{additionalAmount}
  2576. </if>
  2577. <if test="feeFlag != null and feeFlag != ''">
  2578. and t.fee_flag = #{feeFlag}
  2579. </if>
  2580. <if test="state != null and state != ''">
  2581. and t.state = #{state}
  2582. </if>
  2583. <if test="configId != null and configId != ''">
  2584. and t.config_id = #{configId}
  2585. </if>
  2586. <if test="feeName != null and feeName != ''">
  2587. and pfc.fee_name = #{feeName}
  2588. </if>
  2589. <if test="computingFormula != null and computingFormula != ''">
  2590. and pfc.computing_formula = #{computingFormula}
  2591. </if>
  2592. <if test="computingFormulaText != null and computingFormulaText != ''">
  2593. and pfc.computing_formula_text = #{computingFormulaText}
  2594. </if>
  2595. <if test="billType != null and billType != ''">
  2596. and pfc.bill_type = #{billType}
  2597. </if>
  2598. <if test="payerObjType != null and payerObjType != ''">
  2599. and t.payer_obj_type = #{payerObjType}
  2600. </if>
  2601. <if test="isDefault != null and isDefault != ''">
  2602. and pfc.is_default = #{isDefault}
  2603. </if>
  2604. <if test="configStartTime != null and configStartTime != ''">
  2605. and pfc.start_time = #{configStartTime}
  2606. </if>
  2607. <if test="configEndTime != null and configEndTime != ''">
  2608. and pfc.end_time = #{configEndTime}
  2609. </if>
  2610. <if test="paymentCd != null and paymentCd != ''">
  2611. and pfc.payment_cd = #{paymentCd}
  2612. </if>
  2613. <if test="paymentCycle != null and paymentCycle != ''">
  2614. and pfc.payment_cycle = #{paymentCycle}
  2615. </if>
  2616. <if test="feeStartTime != null and feeStartTime != ''">
  2617. and t.create_time &gt;= #{feeStartTime}
  2618. </if>
  2619. <if test="feeEndTime != null and feeEndTime != ''">
  2620. and t.create_time &lt;= #{feeEndTime}
  2621. </if>
  2622. <if test="detailState != null and detailState != ''">
  2623. and pfd.state = #{detailState}
  2624. </if>
  2625. order by t.create_time desc
  2626. <if test="page != -1 and page != null ">
  2627. limit #{page}, #{row}
  2628. </if>
  2629. </select>
  2630. <!-- 查询押金退费总金额 -->
  2631. <select id="queryFeeDepositAmount" parameterType="Map" resultType="Map">
  2632. select SUM(pfc.additional_amount) allAmount,pfd.state detailState
  2633. from pay_fee t
  2634. INNER join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0' and pfc.fee_type_cd =
  2635. '888800010006'
  2636. left join pay_fee_detail pfd on t.fee_id = pfd.fee_id and pfd.status_cd = '0' and pfd.state != '1300'
  2637. left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
  2638. td1.table_columns = 'fee_type_cd'
  2639. left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
  2640. left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
  2641. 'fee_flag'
  2642. left join t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and
  2643. td4.table_columns = 'bill_type'
  2644. left join t_dict td5 on t.payer_obj_type = td5.status_cd and td5.table_name = 'pay_fee' and
  2645. td5.table_columns = 'payer_obj_type'
  2646. left join t_dict td6 on pfd.state = td6.status_cd and td6.table_name = 'pay_fee_detail' and
  2647. td6.table_columns = 'state'
  2648. left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
  2649. LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
  2650. left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
  2651. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2652. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  2653. left join owner_car oc on t.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
  2654. where 1 = 1
  2655. <if test="roomNum !=null and roomNum != ''">
  2656. and br.room_num= #{roomNum}
  2657. </if>
  2658. <if test="unitId !=null and unitId != ''">
  2659. and bu.unit_id= #{unitId}
  2660. </if>
  2661. <if test="floorId !=null and floorId != ''">
  2662. and f.floor_id = #{floorId}
  2663. </if>
  2664. <if test="amount != null and amount != ''">
  2665. and t.amount = #{amount}
  2666. </if>
  2667. <if test="incomeObjId != null and incomeObjId != ''">
  2668. and t.income_obj_id = #{incomeObjId}
  2669. </if>
  2670. <if test="feeTypeCd != null and feeTypeCd != ''">
  2671. and t.fee_type_cd = #{feeTypeCd}
  2672. </if>
  2673. <if test="startTime != null and startTime != ''">
  2674. and t.start_time = #{startTime}
  2675. </if>
  2676. <if test="endTime != null and endTime != ''">
  2677. and t.end_time = #{endTime}
  2678. </if>
  2679. <if test="statusCd != null and statusCd != ''">
  2680. and t.status_cd = #{statusCd}
  2681. </if>
  2682. <if test="communityId != null and communityId != ''">
  2683. and t.community_id = #{communityId}
  2684. </if>
  2685. <if test="feeId != null and feeId != ''">
  2686. and t.fee_id = #{feeId}
  2687. </if>
  2688. <if test="userId != null and userId != ''">
  2689. and t.user_id = #{userId}
  2690. </if>
  2691. <if test="payerObjId != null and payerObjId != ''">
  2692. and t.payer_obj_id = #{payerObjId}
  2693. </if>
  2694. <if test="squarePrice != null and squarePrice != ''">
  2695. and pfc.square_price = #{squarePrice}
  2696. </if>
  2697. <if test="additionalAmount != null and additionalAmount != ''">
  2698. and pfc.additional_amount = #{additionalAmount}
  2699. </if>
  2700. <if test="feeFlag != null and feeFlag != ''">
  2701. and t.fee_flag = #{feeFlag}
  2702. </if>
  2703. <if test="state != null and state != ''">
  2704. and t.state = #{state}
  2705. </if>
  2706. <if test="configId != null and configId != ''">
  2707. and t.config_id = #{configId}
  2708. </if>
  2709. <if test="feeName != null and feeName != ''">
  2710. and pfc.fee_name = #{feeName}
  2711. </if>
  2712. <if test="computingFormula != null and computingFormula != ''">
  2713. and pfc.computing_formula = #{computingFormula}
  2714. </if>
  2715. <if test="computingFormulaText != null and computingFormulaText != ''">
  2716. and pfc.computing_formula_text = #{computingFormulaText}
  2717. </if>
  2718. <if test="billType != null and billType != ''">
  2719. and pfc.bill_type = #{billType}
  2720. </if>
  2721. <if test="payerObjType != null and payerObjType != ''">
  2722. and t.payer_obj_type = #{payerObjType}
  2723. </if>
  2724. <if test="isDefault != null and isDefault != ''">
  2725. and pfc.is_default = #{isDefault}
  2726. </if>
  2727. <if test="configStartTime != null and configStartTime != ''">
  2728. and pfc.start_time = #{configStartTime}
  2729. </if>
  2730. <if test="configEndTime != null and configEndTime != ''">
  2731. and pfc.end_time = #{configEndTime}
  2732. </if>
  2733. <if test="paymentCd != null and paymentCd != ''">
  2734. and pfc.payment_cd = #{paymentCd}
  2735. </if>
  2736. <if test="paymentCycle != null and paymentCycle != ''">
  2737. and pfc.payment_cycle = #{paymentCycle}
  2738. </if>
  2739. <if test="feeStartTime != null and feeStartTime != ''">
  2740. and t.create_time &gt;= #{feeStartTime}
  2741. </if>
  2742. <if test="feeEndTime != null and feeEndTime != ''">
  2743. and t.create_time &lt;= #{feeEndTime}
  2744. </if>
  2745. <if test="detailState != null and detailState != ''">
  2746. and pfd.state = #{detailState}
  2747. </if>
  2748. group by pfd.state
  2749. </select>
  2750. <select id="queryHuaningOweFeeCount" parameterType="Map" resultType="Map">
  2751. select count(1) count
  2752. from f_floor f
  2753. where 1=1
  2754. and f.community_id = #{communityId}
  2755. and f.status_cd = '0'
  2756. </select>
  2757. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2758. <select id="queryHuaningOweFee" parameterType="Map" resultType="Map">
  2759. select
  2760. f.floor_num floorNum,
  2761. (
  2762. select ifnull(SUM(t.receivable_amount),0)
  2763. from pay_fee_detail_month t
  2764. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2765. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2766. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2767. where 1=1
  2768. and bu.floor_id = f.floor_id
  2769. and t.community_id = f.community_id
  2770. <if test="feeTypeCd != null and feeTypeCd != ''">
  2771. and pf.fee_type_cd = #{feeTypeCd}
  2772. </if>
  2773. and t.detail_id = '-1'
  2774. and t.cur_month_time &lt;= #{endTime}
  2775. ) oweAmount,
  2776. (
  2777. select ifnull(SUM(t.receivable_amount),0)
  2778. from pay_fee_detail_month t
  2779. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2780. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2781. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2782. where 1=1
  2783. and bu.floor_id = f.floor_id
  2784. and t.community_id = f.community_id
  2785. <if test="feeTypeCd != null and feeTypeCd != ''">
  2786. and pf.fee_type_cd = #{feeTypeCd}
  2787. </if>
  2788. and t.detail_id = '-1'
  2789. and t.cur_month_time &lt;= #{endTime}
  2790. and t.cur_month_time &gt;= #{startTime}
  2791. ) curOweAmount,
  2792. (
  2793. select ifnull(SUM(t.receivable_amount),0)
  2794. from pay_fee_detail_month t
  2795. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2796. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2797. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2798. where 1=1
  2799. and bu.floor_id = f.floor_id
  2800. and t.community_id = f.community_id
  2801. <if test="feeTypeCd != null and feeTypeCd != ''">
  2802. and pf.fee_type_cd = #{feeTypeCd}
  2803. </if>
  2804. and t.detail_id = '-1'
  2805. and t.cur_month_time &lt; #{startTime}
  2806. ) preOweAmount
  2807. from f_floor f
  2808. where 1=1
  2809. and f.community_id = #{communityId}
  2810. <if test="floorNum != null and floorNum != ''">
  2811. and f.floor_num = #{floorNum}
  2812. </if>
  2813. and f.status_cd = '0'
  2814. <if test="page != -1 and page != null ">
  2815. limit #{page}, #{row}
  2816. </if>
  2817. </select>
  2818. <select id="queryHuaningOweFeeCounts" parameterType="Map" resultType="Map">
  2819. select count(1) count from (
  2820. select
  2821. f.floor_num floorNum,
  2822. (
  2823. select ifnull(SUM(t.receivable_amount),0)
  2824. from pay_fee_detail_month t
  2825. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2826. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2827. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2828. where 1=1
  2829. and bu.floor_id = f.floor_id
  2830. and t.community_id = f.community_id
  2831. <if test="feeTypeCd != null and feeTypeCd != ''">
  2832. and pf.fee_type_cd = #{feeTypeCd}
  2833. </if>
  2834. and t.detail_id = '-1'
  2835. and t.cur_month_time &lt;= #{endTime}
  2836. ) oweAmount,
  2837. (
  2838. select ifnull(SUM(t.receivable_amount),0)
  2839. from pay_fee_detail_month t
  2840. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2841. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2842. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2843. where 1=1
  2844. and bu.floor_id = f.floor_id
  2845. and t.community_id = f.community_id
  2846. <if test="feeTypeCd != null and feeTypeCd != ''">
  2847. and pf.fee_type_cd = #{feeTypeCd}
  2848. </if>
  2849. and t.detail_id = '-1'
  2850. and t.cur_month_time &lt;= #{endTime}
  2851. and t.cur_month_time &gt;= #{startTime}
  2852. ) curOweAmount,
  2853. (
  2854. select ifnull(SUM(t.receivable_amount),0)
  2855. from pay_fee_detail_month t
  2856. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2857. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2858. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2859. where 1=1
  2860. and bu.floor_id = f.floor_id
  2861. and t.community_id = f.community_id
  2862. <if test="feeTypeCd != null and feeTypeCd != ''">
  2863. and pf.fee_type_cd = #{feeTypeCd}
  2864. </if>
  2865. and t.detail_id = '-1'
  2866. and t.cur_month_time &lt; #{startTime}
  2867. ) preOweAmount
  2868. from f_floor f
  2869. where 1=1
  2870. and f.community_id = #{communityId}
  2871. <if test="floorNum != null and floorNum != ''">
  2872. and f.floor_num = #{floorNum}
  2873. </if>
  2874. and f.status_cd = '0'
  2875. ) st
  2876. </select>
  2877. <select id="queryHuaningPayFeeCount" parameterType="Map" resultType="Map">
  2878. select count(1) count
  2879. from (
  2880. select t.floor_num
  2881. from f_floor t
  2882. where 1=1
  2883. and t.community_id= #{communityId}
  2884. GROUP BY t.floor_num
  2885. ) tt
  2886. </select>
  2887. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  2888. <select id="queryHuaningPayFee" parameterType="Map" resultType="Map">
  2889. select
  2890. f.floor_num floorNum,
  2891. (
  2892. select ifnull(SUM(t.receivable_amount),0)
  2893. from pay_fee_detail_month t
  2894. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2895. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2896. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2897. where 1=1
  2898. <if test="feeTypeCd != null and feeTypeCd != ''">
  2899. and pf.fee_type_cd = #{feeTypeCd}
  2900. </if>
  2901. and bu.floor_id = f.floor_id
  2902. and t.community_id = f.community_id
  2903. and t.cur_month_time = #{endTime}
  2904. ) receivableAmount,
  2905. (
  2906. select ifnull(SUM(t.received_amount),0)
  2907. from pay_fee_detail_month t
  2908. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2909. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2910. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2911. where 1=1
  2912. <if test="feeTypeCd != null and feeTypeCd != ''">
  2913. and pf.fee_type_cd = #{feeTypeCd}
  2914. </if>
  2915. and bu.floor_id = f.floor_id
  2916. and t.community_id = f.community_id
  2917. and t.pay_fee_time &gt;= #{endTime}
  2918. and t.pay_fee_time &lt; #{nextMonthTime}
  2919. and t.detail_id != '-1'
  2920. ) receivedAmount,
  2921. (
  2922. select ifnull(SUM(t.received_amount),0)
  2923. from pay_fee_detail_month t
  2924. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2925. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2926. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2927. where 1=1
  2928. <if test="feeTypeCd != null and feeTypeCd != ''">
  2929. and pf.fee_type_cd = #{feeTypeCd}
  2930. </if>
  2931. and bu.floor_id = f.floor_id
  2932. and t.community_id = f.community_id
  2933. and t.pay_fee_time &gt;= #{endTime}
  2934. and t.pay_fee_time &lt; #{nextMonthTime}
  2935. and t.cur_month_time &lt; #{endTime}
  2936. and t.cur_month_time &gt;= #{startTime}
  2937. and t.detail_id != '-1'
  2938. ) receivedAmount1,
  2939. (
  2940. select ifnull(SUM(t.received_amount),0)
  2941. from pay_fee_detail_month t
  2942. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2943. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2944. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2945. where 1=1
  2946. <if test="feeTypeCd != null and feeTypeCd != ''">
  2947. and pf.fee_type_cd = #{feeTypeCd}
  2948. </if>
  2949. and bu.floor_id = f.floor_id
  2950. and t.community_id = f.community_id
  2951. and t.pay_fee_time &gt;= #{endTime}
  2952. and t.pay_fee_time &lt; #{nextMonthTime}
  2953. and t.cur_month_time = #{endTime}
  2954. and t.detail_id != '-1'
  2955. ) receivedAmount2,
  2956. (
  2957. select ifnull(SUM(t.received_amount),0)
  2958. from pay_fee_detail_month t
  2959. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2960. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2961. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2962. where 1=1
  2963. <if test="feeTypeCd != null and feeTypeCd != ''">
  2964. and pf.fee_type_cd = #{feeTypeCd}
  2965. </if>
  2966. and bu.floor_id = f.floor_id
  2967. and t.community_id = f.community_id
  2968. and t.pay_fee_time &gt;= #{endTime}
  2969. and t.pay_fee_time &lt; #{nextMonthTime}
  2970. and t.cur_month_time &gt;= #{nextMonthTime}
  2971. and t.detail_id != '-1'
  2972. ) receivedAmount3,
  2973. (
  2974. select ifnull(SUM(t.received_amount),0)
  2975. from pay_fee_detail_month t
  2976. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  2977. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  2978. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  2979. where 1=1
  2980. <if test="feeTypeCd != null and feeTypeCd != ''">
  2981. and pf.fee_type_cd = #{feeTypeCd}
  2982. </if>
  2983. and bu.floor_id = f.floor_id
  2984. and t.community_id = f.community_id
  2985. and t.pay_fee_time &gt;= #{endTime}
  2986. and t.pay_fee_time &lt; #{nextMonthTime}
  2987. and t.cur_month_time &lt; #{startTime}
  2988. and t.detail_id != '-1'
  2989. ) receivedAmount4
  2990. from f_floor f
  2991. where 1=1
  2992. and f.community_id = #{communityId}
  2993. <if test="floorNum != null and floorNum != ''">
  2994. and f.floor_num = #{floorNum}
  2995. </if>
  2996. and f.status_cd = '0'
  2997. <if test="page != -1 and page != null ">
  2998. limit #{page}, #{row}
  2999. </if>
  3000. </select>
  3001. <select id="queryHuaningPayFeeCounts" parameterType="Map" resultType="Map">
  3002. select count(1) count
  3003. from (
  3004. select
  3005. f.floor_num floorNum,
  3006. (
  3007. select ifnull(SUM(t.receivable_amount),0)
  3008. from pay_fee_detail_month t
  3009. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3010. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3011. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3012. where 1=1
  3013. <if test="feeTypeCd != null and feeTypeCd != ''">
  3014. and pf.fee_type_cd = #{feeTypeCd}
  3015. </if>
  3016. and bu.floor_id = f.floor_id
  3017. and t.community_id = f.community_id
  3018. and t.cur_month_time = #{endTime}
  3019. ) receivableAmount,
  3020. (
  3021. select ifnull(SUM(t.received_amount),0)
  3022. from pay_fee_detail_month t
  3023. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3024. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3025. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3026. where 1=1
  3027. <if test="feeTypeCd != null and feeTypeCd != ''">
  3028. and pf.fee_type_cd = #{feeTypeCd}
  3029. </if>
  3030. and bu.floor_id = f.floor_id
  3031. and t.community_id = f.community_id
  3032. and t.pay_fee_time &gt;= #{endTime}
  3033. and t.pay_fee_time &lt; #{nextMonthTime}
  3034. and t.detail_id != '-1'
  3035. ) receivedAmount,
  3036. (
  3037. select ifnull(SUM(t.received_amount),0)
  3038. from pay_fee_detail_month t
  3039. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3040. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3041. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3042. where 1=1
  3043. <if test="feeTypeCd != null and feeTypeCd != ''">
  3044. and pf.fee_type_cd = #{feeTypeCd}
  3045. </if>
  3046. and bu.floor_id = f.floor_id
  3047. and t.community_id = f.community_id
  3048. and t.pay_fee_time &gt;= #{endTime}
  3049. and t.pay_fee_time &lt; #{nextMonthTime}
  3050. and t.cur_month_time &lt; #{endTime}
  3051. and t.cur_month_time &gt;= #{startTime}
  3052. and t.detail_id != '-1'
  3053. ) receivedAmount1,
  3054. (
  3055. select ifnull(SUM(t.received_amount),0)
  3056. from pay_fee_detail_month t
  3057. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3058. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3059. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3060. where 1=1
  3061. <if test="feeTypeCd != null and feeTypeCd != ''">
  3062. and pf.fee_type_cd = #{feeTypeCd}
  3063. </if>
  3064. and bu.floor_id = f.floor_id
  3065. and t.community_id = f.community_id
  3066. and t.pay_fee_time &gt;= #{endTime}
  3067. and t.pay_fee_time &lt; #{nextMonthTime}
  3068. and t.cur_month_time = #{endTime}
  3069. and t.detail_id != '-1'
  3070. ) receivedAmount2,
  3071. (
  3072. select ifnull(SUM(t.received_amount),0)
  3073. from pay_fee_detail_month t
  3074. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3075. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3076. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3077. where 1=1
  3078. <if test="feeTypeCd != null and feeTypeCd != ''">
  3079. and pf.fee_type_cd = #{feeTypeCd}
  3080. </if>
  3081. and bu.floor_id = f.floor_id
  3082. and t.community_id = f.community_id
  3083. and t.pay_fee_time &gt;= #{endTime}
  3084. and t.pay_fee_time &lt; #{nextMonthTime}
  3085. and t.cur_month_time &gt;= #{nextMonthTime}
  3086. and t.detail_id != '-1'
  3087. ) receivedAmount3,
  3088. (
  3089. select ifnull(SUM(t.received_amount),0)
  3090. from pay_fee_detail_month t
  3091. inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
  3092. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3093. inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
  3094. where 1=1
  3095. <if test="feeTypeCd != null and feeTypeCd != ''">
  3096. and pf.fee_type_cd = #{feeTypeCd}
  3097. </if>
  3098. and bu.floor_id = f.floor_id
  3099. and t.community_id = f.community_id
  3100. and t.pay_fee_time &gt;= #{endTime}
  3101. and t.pay_fee_time &lt; #{nextMonthTime}
  3102. and t.cur_month_time &lt; #{startTime}
  3103. and t.detail_id != '-1'
  3104. ) receivedAmount4
  3105. from f_floor f
  3106. where 1=1
  3107. and f.community_id = #{communityId}
  3108. <if test="floorNum != null and floorNum != ''">
  3109. and f.floor_num = #{floorNum}
  3110. </if>
  3111. and f.status_cd = '0'
  3112. ) st
  3113. </select>
  3114. <select id="queryHuaningPayFeeTwoCount" parameterType="Map" resultType="Map">
  3115. select count(1) count
  3116. from (
  3117. select a.floorNum, d.receivableAmount,
  3118. a.receivedAmount, b.receivedAmount1,
  3119. c.receivedAmount2
  3120. from
  3121. (select t.floor_num floorNum, sum (pfd.received_amount) receivedAmount
  3122. from f_floor t
  3123. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3124. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3125. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3126. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3127. where 1=1
  3128. and t.status_cd = '0'
  3129. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3130. and t.community_id= #{communityId}
  3131. GROUP BY floor_num
  3132. ) a,
  3133. (select t.floor_num floorNum, SUM (pfdm1.discount_amount) receivedAmount1
  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. LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
  3140. pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
  3141. where 1=1
  3142. and t.status_cd = '0'
  3143. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3144. and t.community_id= #{communityId}
  3145. GROUP BY floor_num
  3146. ) b,
  3147. (select t.floor_num floorNum, SUM (pfdm2.received_amount) receivedAmount2
  3148. from f_floor t
  3149. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3150. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3151. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3152. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3153. LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
  3154. pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month &gt; #{month}
  3155. where 1=1
  3156. and t.status_cd = '0'
  3157. and DATE_FORMAT(pfd.create_time, '%Y-%m') = #{yearMonth}
  3158. and t.community_id= #{communityId}
  3159. GROUP BY floor_num
  3160. ) c,
  3161. (select t.floor_num floorNum, SUM (rfms.owe_amount) receivableAmount
  3162. from f_floor t
  3163. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3164. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3165. inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
  3166. where t.community_id= #{communityId}
  3167. group by t.floor_num
  3168. ) d
  3169. where a.floorNum = b.floorNum
  3170. and b.floorNum = c.floorNum
  3171. and c.floorNum = d.floorNum
  3172. ) tt
  3173. </select>
  3174. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3175. <select id="queryHuaningPayFeeTwo" parameterType="Map" resultType="Map">
  3176. select a.floorNum,d.receivableAmount ,
  3177. a.receivedAmount,b.receivedAmount1,
  3178. c.receivedAmount2
  3179. from
  3180. (select t.floor_num floorNum,sum(pfd.received_amount) receivedAmount
  3181. from f_floor t
  3182. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3183. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3184. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3185. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3186. where 1=1
  3187. and t.status_cd = '0'
  3188. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3189. and t.community_id= #{communityId}
  3190. GROUP BY floor_num
  3191. ) a,
  3192. (select t.floor_num floorNum,SUM(pfdm1.discount_amount) receivedAmount1
  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. LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
  3199. pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
  3200. where 1=1
  3201. and t.status_cd = '0'
  3202. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3203. and t.community_id= #{communityId}
  3204. GROUP BY floor_num
  3205. ) b,
  3206. (select t.floor_num floorNum,SUM(pfdm2.received_amount) receivedAmount2
  3207. from f_floor t
  3208. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3209. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3210. inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
  3211. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  3212. LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
  3213. pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month &gt; #{month}
  3214. where 1=1
  3215. and t.status_cd = '0'
  3216. and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
  3217. and t.community_id= #{communityId}
  3218. GROUP BY floor_num
  3219. ) c,
  3220. (select t.floor_num floorNum,SUM(rfms.owe_amount) receivableAmount
  3221. from f_floor t
  3222. inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
  3223. inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
  3224. inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
  3225. where t.community_id= #{communityId}
  3226. group by t.floor_num
  3227. ) d
  3228. where a.floorNum = b.floorNum
  3229. and b.floorNum = c.floorNum
  3230. and c.floorNum = d.floorNum
  3231. <if test="page != -1 and page != null ">
  3232. limit #{page}, #{row}
  3233. </if>
  3234. </select>
  3235. <select id="queryHuaningOweFeeDetailCount" parameterType="Map" resultType="Map">
  3236. select
  3237. count(1) count
  3238. from building_room br
  3239. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3240. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3241. inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
  3242. inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
  3243. where 1=1
  3244. and br.community_id = #{communityId}
  3245. and br.status_cd = '0'
  3246. and rof.amount_owed > 0
  3247. <if test="feeTypeCd != null and feeTypeCd != ''">
  3248. and pf.fee_type_cd = #{feeTypeCd}
  3249. </if>
  3250. <if test="floorId != null and floorId != ''">
  3251. and f.floor_id = #{floorId}
  3252. </if>
  3253. <if test="floorNum != null and floorNum != ''">
  3254. and f.floor_num = #{floorNum}
  3255. </if>
  3256. </select>
  3257. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3258. <select id="queryHuaningOweFeeDetail" parameterType="Map" resultType="Map">
  3259. select
  3260. f.floor_num floorNum,
  3261. concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) roomName,
  3262. br.built_up_area builtUpArea,
  3263. rof.fee_name feeName,
  3264. rof.end_time endTime,
  3265. rof.deadline_time deadlineTime,
  3266. (
  3267. select ifnull(SUM(t.receivable_amount),0)
  3268. from pay_fee_detail_month t
  3269. where 1=1
  3270. and t.fee_id = rof.fee_id
  3271. and t.community_id = f.community_id
  3272. and t.detail_id = '-1'
  3273. and t.cur_month_time &lt;= #{startTime}
  3274. ) oweAmount,
  3275. (
  3276. select ifnull(SUM(t.receivable_amount),0)
  3277. from pay_fee_detail_month t
  3278. where 1=1
  3279. and t.fee_id = rof.fee_id
  3280. and t.community_id = f.community_id
  3281. and t.detail_id = '-1'
  3282. and t.cur_month_time &lt;= #{startTime}
  3283. and t.cur_month_time &gt;= #{endTime}
  3284. ) curOweAmount,
  3285. (
  3286. select ifnull(SUM(t.receivable_amount),0)
  3287. from pay_fee_detail_month t
  3288. where 1=1
  3289. and t.fee_id = rof.fee_id
  3290. and t.community_id = f.community_id
  3291. and t.detail_id = '-1'
  3292. and t.cur_month_time &lt;= #{startTime}
  3293. ) preOweAmount
  3294. from building_room br
  3295. inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3296. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3297. inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
  3298. inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
  3299. where 1=1
  3300. and br.community_id = #{communityId}
  3301. and br.status_cd = '0'
  3302. and rof.amount_owed > 0
  3303. <if test="feeTypeCd != null and feeTypeCd != ''">
  3304. and pf.fee_type_cd = #{feeTypeCd}
  3305. </if>
  3306. <if test="floorId != null and floorId != ''">
  3307. and f.floor_id = #{floorId}
  3308. </if>
  3309. <if test="floorNum != null and floorNum != ''">
  3310. and f.floor_num = #{floorNum}
  3311. </if>
  3312. <if test="page != -1 and page != null ">
  3313. limit #{page}, #{row}
  3314. </if>
  3315. </select>
  3316. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3317. <select id="getReceivedAmountByMonth" parameterType="Map" resultType="Map">
  3318. select ifnull(sum(t.received_amount),0) total
  3319. from pay_fee_detail_month t
  3320. where 1=1
  3321. and t.create_time &gt; #{startTime}
  3322. and t.create_time &lt; #{endTime}
  3323. and t.fee_id = #{feeId}
  3324. <if test="flag == 1">
  3325. and concat(t.detail_year,lpad(t.detail_month,2,0)) = #{yearMonth}
  3326. </if>
  3327. <if test="flag == 2">
  3328. and concat(t.detail_year,lpad(t.detail_month,2,0)) &lt; #{yearMonth}
  3329. </if>
  3330. <if test="flag == 3">
  3331. and concat(t.detail_year,lpad(t.detail_month,2,0)) &gt; #{yearMonth}
  3332. </if>
  3333. <if test="communityId !=null and communityId != ''">
  3334. and t.community_id= #{communityId}
  3335. </if>
  3336. </select>
  3337. <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
  3338. <select id="queryRoomAndParkingSpace" parameterType="Map" resultType="Map">
  3339. select
  3340. br.room_id roomId,br.room_num roomNum,bu.unit_num unitNum,f.floor_num floorNum,t.owner_id ownerId
  3341. from building_owner_room_rel t
  3342. left join building_room br on t.room_id = br.room_id and br.status_cd = '0'
  3343. left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
  3344. left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  3345. where t.status_cd = '0'
  3346. and t.owner_id in
  3347. <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
  3348. #{item}
  3349. </foreach>
  3350. </select>
  3351. <!-- 查询无效费用 add by wuxw 2018-07-03 -->
  3352. <select id="queryInvalidFeeMonthStatistics" parameterType="Map" resultType="Map">
  3353. select t.fee_id feeId
  3354. from pay_fee t
  3355. inner join pay_fee_config pfc on t.config_id = pfc.config_id
  3356. inner join report_fee_month_statistics rfms on t.fee_id = rfms.fee_id and rfms.status_cd = '0'
  3357. where (t.status_cd = '1' or pfc.status_cd = '1')
  3358. and t.community_id = #{communityId}
  3359. </select>
  3360. <!--清理报表 无效数据-->
  3361. <update id="deleteInvalidFee" parameterType="Map">
  3362. delete from report_fee_month_statistics where fee_id in
  3363. <foreach collection="feeIds" item="item" open="(" close=")" separator=",">
  3364. #{item}
  3365. </foreach>
  3366. and community_id = #{communityId}
  3367. </update>
  3368. </mapper>