| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.fnc.dao.InsPlyIncomeMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.InsPlyIncome">
- <id column="id" property="id" />
- <result column="orderno" property="orderno" />
- <result column="policyno" property="policyno" />
- <result column="dept_id" property="deptId" />
- <result column="dept_name" property="deptName" />
- <result column="riskcode" property="riskcode" />
- <result column="pay_date" property="payDate" />
- <result column="company_id" property="companyId" />
- <result column="company_name" property="companyName" />
- <result column="agreement_id" property="agreementId" />
- <result column="licenseno" property="licenseno" />
- <result column="taxamount" property="taxamount" />
- <result column="no_tax_premium" property="noTaxPremium" />
- <result column="commission_feerate" property="commissionFeerate" />
- <result column="other_feerate" property="otherFeerate" />
- <result column="commission_feevalue" property="commissionFeevalue" />
- <result column="other_feevalue" property="otherFeevalue" />
- <result column="all_fee_value" property="allFeeValue" />
- <result column="final_fee_value" property="finalFeeValue" />
- <result column="doing_fee_value" property="doingFeeValue" />
- <result column="create_time" property="createTime" />
- <result column="voucher_number" property="voucherNumber"/>
- <result column="contract_id" property="contractId"/>
- <result column="contract_file_id" property="contractFileId"/>
- <result column="handling_fees_status" property="handlingFeesStatus"/>
- <result column="documentary_fees_status" property="documentaryFeesStatus"/>
- <result column="no_policyno" property="noPolicyno"/>
- <result column="sy_policyno" property="syPolicyno"/>
- <result column="is_not_car" property="isNotCar"/>
- <result column="is_not_documentary" property="isNotDocumentary"/>
- <result column="invoic_amount" property="invoicAmount"/>
- <result column="invoic_id" property="invoicId"/>
- <result column="tax_premium" property="taxPremium"/>
- <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
- <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
- <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
- <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
- <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
- <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
- <result column="jq_premium" property="jqPremium"/>
- <result column="sy_premium" property="syPremium"/>
- <result column="no_premium" property="noPremium"/>
- <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
- <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
- <result column="no_no_tax_premium" property="noNoTaxPremium"/>
- <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
- <result column="sy_receivable_proportion" property="syReceivableProportion"/>
- <result column="no_receivable_proportion" property="noReceivableProportion"/>
- <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
- <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
- <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
- <result column="settlement_time" property="settlementTime"/>
- <result column="update_time" property="updateTime"/>
- <result column="settlement_user_id" property="settlementUserId"/>
- <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
- <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
- <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
- <result column="user_id" property="userId"/>
- <result column="update_user_id" property="updateUserId"/>
- <result column="partner_companies_id" property="partnerCompaniesId"/>
- <result column="partner_companies_name" property="partnerCompaniesName"/>
- <result column="receivable_amount" property="receivableAmount"/>
- <result column="insured_name" property="insuredName"/>
- <result column="invoicing_method" property="invoicingMethod"/>
- <result column="remarks" property="remarks"/>
- <result column="jq_start_date" property="jqStartDate"/>
- <result column="jq_end_date" property="jqEndDate"/>
- <result column="sy_start_date" property="syStartDate"/>
- <result column="sy_end_date" property="syEndDate"/>
- <result column="settle_other_status" property="settleOtherStatus"/>
- <result column="settlement_image_id" property="settlementImageId"/>
- <result column="task_id" property="taskId"/>
- </resultMap>
- <sql id="income_com">
- a.id as "id",
- a.orderno as "orderno",
- a.policyno as "policyno",
- a.dept_id as "deptId",
- a.riskcode as "riskcode",
- a.pay_date as "payDate",
- a.signdate as "signdate",
- a.company_id as "companyId",
- a.agreement_id as "agreementId",
- a.licenseno as "licenseno",
- a.taxamount as "taxamount",
- a.no_tax_premium as "noTaxPremium",
- a.commission_feerate as "commissionFeerate",
- a.other_feerate as "otherFeerate",
- a.commission_feevalue as "commissionFeevalue",
- a.other_feevalue as "otherFeevalue",
- a.all_fee_value as "allFeeValue",
- a.final_fee_value as "finalFeeValue",
- a.doing_fee_value as "doingFeeValue",
- a.voucher_number as "voucherNumber",
- a.contract_id as "contractId",
- a.contract_file_id as "contractFileId",
- a.handling_fees_status as "handlingFeesStatus",
- a.no_policyno as "noPolicyno",
- a.sy_policyno as "syPolicyno",
- a.documentary_fees_status as "documentaryFeesStatus",
- a.is_not_car as "isNotCar",
- a.is_not_documentary as "isNotDocumentary",
- a.invoic_amount as "invoicAmount",
- a.invoic_id as "invoicId",
- a.tax_premium as "taxPremium",
- a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
- a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
- a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
- a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
- a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
- a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
- a.partner_companies_id as "partnerCompaniesId",
- a.jq_premium as "jqPremium",
- a.sy_premium as "syPremium",
- a.no_premium as "noPremium",
- a.jq_no_tax_premium as "jqNoTaxPremium",
- a.sy_no_tax_premium as "syNoTaxPremium",
- a.no_no_tax_premium as "noNoTaxPremium",
- a.jq_receivable_proportion as "jqReceivableProportion",
- a.sy_receivable_proportion as "syReceivableProportion",
- a.no_receivable_proportion as "noReceivableProportion",
- a.jq_other_costs_proportion as "jqOtherCostsProportion",
- a.sy_other_costs_proportion as "syOtherCostsProportion",
- a.no_other_costs_proportion as "noOtherCostsProportion",
- a.settlement_time as "settlementTime",
- a.update_time as "updateTime",
- a.settlement_user_id as "settlementUserId",
- a.update_user_id as "updateUserId",
- a.jq_other_costs_premium as "jqOtherCostsPremium",
- a.sy_other_costs_premium as "syOtherCostsPremium",
- a.no_other_costs_premium as "noOtherCostsPremium",
- a.partner_companies_name as "partnerCompaniesName",
- a.company_name as "companyName",
- a.receivable_amount as "receivableAmount",
- a.invoic_time as "invoicTime",
- a.insured_name as "insuredName",
- a.remarks as "remarks",
- a.jq_start_date as "jqStartDate",
- a.jq_end_date as "jqEndDate",
- a.sy_start_date as "syStartDate",
- a.sy_end_date as "syEndDate",
- a.settle_other_status as "settleOtherStatus",
- a.user_id as "userId",
- a.invoicing_method as "invoicingMethod",
- a.settlement_image_id as "settlementImageId",
- a.task_id as "taskId",
- a.create_time as "createTime"
- </sql>
- <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- su1.name as "settlementUserName",
- su2.name as "updateUserName",
- CONCAT_WS( '-', pa.agreement_abbreviation, NULLIF( pa.business_description, '' ), NULLIF( pa.job_description, '' ) ) AS agreementName,
- pa.agreement_type as "agreementType",
- pa.docking_person as "dockingPerson",
- pa.is_external as "isExternal",
- upf.url as "imageUrl",
- su.name as "userName",
- b.name as "deptName",
- <include refid="income_com"/>
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
- LEFT JOIN sys_user su2 on su2.id=a.update_user_id
- LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- LEFT JOIN sys_dept b on pa.dept_id=b.id
- <where>
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
- and a.jq_receivable_proportion =#{jqReceivableProportion}
- </if>
- <if test="syReceivableProportion !=null and syReceivableProportion !=''">
- and a.sy_receivable_proportion =#{syReceivableProportion}
- </if>
- <if test="noReceivableProportion !=null and noReceivableProportion !=''">
- and a.no_receivable_proportion =#{noReceivableProportion}
- </if>
- <if test="id !=null and id !=''">
- and a.id =#{id}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="provinceId != null and provinceId != ''">
- and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
- </if>
- <if test="cityId != null and cityId != ''">
- and pa.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="countyId != null and countyId != ''">
- and pa.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="taskId != null and taskId != ''">
- and a.task_id = #{taskId}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
- and a.id in
- <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="settlementDate !=null and settlementDate !=''">
- AND a.settlement_time =#{settlementDate}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- </where>
- ORDER BY a.create_time desc
- </select>
- <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- pa.agreement_name as "agreementName",
- pa.agreement_type as "agreementType",
- su.name as "userName",
- <include refid="income_com"/>
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- <where>
- <if test="id!=null and id!=''">
- a.id=#{id}
- </if>
- </where>
- </select>
- <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- count(MONTH(a.signdate)) as "totalorders",
- MONTH(a.signdate) as "monthSigdate",
- sum(a.other_feevalue) as "allLOtherFeevalue",
- GROUP_CONCAT(a.id) as "ids"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- <where>
- <if test="isNotCar !=null and isNotCar !=''" >
- a.is_not_car =#{isNotCar}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="year !=null and year !=''">
- and YEAR(a.signdate) =#{year}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- group by MONTH(a.signdate)
- </where>
- </select>
- <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- update ins_ply_income
- <set>
- <if test="contractId != null">
- contract_id = #{contractId},
- </if>
- <if test="voucherNumber != null">
- voucher_number = #{voucherNumber},
- </if>
- <if test="contractFileId != null">
- contract_file_id = #{contractFileId},
- </if>
- <if test="handlingFeesStatus != null">
- handling_fees_status = #{handlingFeesStatus}
- </if>
- <if test="documentaryFeesStatus != null">
- documentary_fees_status = #{documentaryFeesStatus}
- </if>
- </set>
- where orderno =#{orderno}
- </update>
- <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- SELECT
- a.companyId as "companyId",
- a.totalorders as "totalorders",
- a.ids as "ids",
- a.allLOtherFeevalue as "allLOtherFeevalue"
- FROM
- (
- SELECT
- a.company_id AS "companyId",
- count(a.orderno) as "totalorders",
- sum( a.other_feevalue ) AS "allLOtherFeevalue",
- GROUP_CONCAT(a.id) as "ids"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- WHERE
- pa.agreement_type = '2'
- <if test="isNotCar !=null and isNotCar !=''" >
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
- AND a.documentary_fees_status = #{documentaryFeesStatus}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="year !=null and year !=''">
- and YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- and month(a.signdate) =#{month}
- </if>
- GROUP BY
- a.company_id
- ) a
- LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
- </select>
- <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- <include refid="income_com"/>
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
- LEFT JOIN sys_user su2 on su2.id=a.update_user_id
- LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- LEFT JOIN sys_dept b on pa.dept_id=b.id
- <where>
- 1=1
- <if test="licenseno !=null and licenseno !=''">
- AND a.licenseno=#{licenseno}
- </if>
- <if test="policyno !=null and policyno !=''">
- AND a.policyno=#{policyno}
- </if>
- <if test="syPolicyno !=null and syPolicyno !=''">
- AND a.sy_policyno=#{syPolicyno}
- </if>
- <if test="noPolicyno !=null and noPolicyno !=''">
- AND a.no_policyno=#{noPolicyno}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
- and a.jq_receivable_proportion =#{jqReceivableProportion}
- </if>
- <if test="syReceivableProportion !=null and syReceivableProportion !=''">
- and a.sy_receivable_proportion =#{syReceivableProportion}
- </if>
- <if test="noReceivableProportion !=null and noReceivableProportion !=''">
- and a.no_receivable_proportion =#{noReceivableProportion}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="id !=null and id !=''">
- and a.id =#{id}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="provinceId != null and provinceId != ''">
- and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
- </if>
- <if test="cityId != null and cityId != ''">
- and pa.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="countyId != null and countyId != ''">
- and pa.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="taskId != null and taskId != ''">
- and a.task_id = #{taskId}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
- and a.id in
- <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="settlementDate !=null and settlementDate !=''">
- AND a.settlement_time =#{settlementDate}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- </where>
- </select>
- <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- <include refid="income_com"/>
- from ins_ply_income a
- <where>
- 1=1
- <if test="licenseno !=null and licenseno !=''">
- AND a.licenseno=#{licenseno}
- </if>
- <if test="policyno !=null and policyno !=''">
- AND a.policyno=#{policyno}
- </if>
- <if test="syPolicyno !=null and syPolicyno !=''">
- AND a.sy_policyno=#{syPolicyno}
- </if>
- <if test="noPolicyno !=null and noPolicyno !=''">
- AND a.no_policyno=#{noPolicyno}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
- and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
- and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
- </if>
- <if test="jqOtherCostsProportion !=null and jqOtherCostsProportion !=''">
- and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
- </if>
- <if test="syOtherCostsProportion !=null and syOtherCostsProportion !=''">
- and a.sy_other_costs_proportion =#{syOtherCostsProportion}
- </if>
- <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
- and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
- </if>
- <if test="noOtherCostsProportion !=null and noOtherCostsProportion !=''">
- and a.no_other_costs_proportion =#{noOtherCostsProportion}
- </if>
- <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
- and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
- </if>
- <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
- and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
- </if>
- <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
- and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
- </if>
- <if test="jqPremium !=null and jqPremium !=''">
- and a.jq_premium =#{jqPremium}
- </if>
- <if test="syPremium !=null and syPremium !=''">
- and a.sy_premium =#{jqPremium}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="noPremium !=null and noPremium !=''">
- and a.no_premium =#{noPremium}
- </if>
- </where>
- limit 1
- </select>
- <select id="totalAmount" resultType="java.util.HashMap">
- select
- COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
- COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
- COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
- and a.licenseno in
- <foreach collection="licenseno" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="policyno != null and policyno != '' ">
- and a.policyno =#{policyno}
- </if>
- <if test="syPolicyno != null and syPolicyno != '' ">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- and a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- and a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="createTime !=null and createTime !=''">
- a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- a.settlement_time =#{settlementTime}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- </where>
- </select>
- <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- SELECT
- SUM(a.commission_feevalue) AS commissionFeevalue,
- SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
- SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
- SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
- SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != '' ">
- and a.licenseno =#{licenseno}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="syPolicyno != null and syPolicyno != '' ">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="ptTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
- SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != '' ">
- and a.licenseno =#{licenseno}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="syPolicyno != null and syPolicyno != '' ">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- a.partner_companies_id as "partnerCompaniesId",
- MAX( ec.name ) AS "companyName",
- sum( a.commission_feevalue ) AS "commissionFeevalue",
- sum( a.other_feevalue ) AS "otherFeevalue",
- SUM( IFNULL(a.commission_feevalue,0) + IFNULL (a.other_feevalue,0) ) AS "totalFeevalue",
- MAX( a.partner_companies_name) as "partnerCompaniesName",
- MAX(pa.docking_person) as "dockingPerson"
- from ins_ply_income a
- LEFT JOIN esm_ins_company ec on ec.id= a.company_id
- LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
- <where>
- 1=1
- <if test="agreementType !=null and agreementType!='' ">
- AND pa.agreement_type =#{agreementType}
- </if>
- <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
- AND a.documentary_fees_status = #{documentaryFeesStatus}
- </if>
- <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
- AND a.handling_fees_status = #{handlingFeesStatus}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- </where>
- GROUP BY a.partner_companies_id,pa.insurance_company_id,pa.docking_person
- </select>
- <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- sum(a.commission_feevalue) as "commissionFeevalue",
- sum(a.invoic_amount) as "invoicAmount"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- and a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- and a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="createTime !=null and createTime !=''">
- and a.create_time =#{createTime}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- and a.settlement_time =#{settlementTime}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- </where>
- </select>
- <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- SELECT
- a.partner_companies_id AS "partnerCompaniesId",
- MAX( a.company_name ) AS "companyName",
- MAX( a.company_id ) AS "companyId",
- MAX( a.partner_companies_name ) AS "partnerCompaniesName"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="provinceId != null and provinceId != ''">
- and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
- </if>
- <if test="cityId != null and cityId != ''">
- and pa.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="countyId != null and countyId != ''">
- and pa.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="taskId != null and taskId != ''">
- and a.task_id = #{taskId}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
- and a.id in
- <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- </where>
- GROUP BY a.partner_companies_id
- </select>
- <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- a.partner_companies_id AS "partnerCompaniesId",
- a.id as "id"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
- <where>
- 1=1
- and a.handling_fees_status ='2'
- <if test="agreementType !=null and agreementType!='' ">
- AND pa.agreement_type =#{agreementType}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- </where>
- </select>
- <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- SELECT
- a.partner_companies_id AS "partnerCompaniesId",
- MAX( a.company_name ) AS "companyName",
- MAX( a.company_id ) AS "companyId",
- MAX( a.partner_companies_name ) AS "partnerCompaniesName",
- IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
- IFNULL(max(f.settleMentAmount) , 0.00) + IFNULL(max(d.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
- IFNULL(max(d.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
- sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
- sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
- IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
- IFNULL(max(f.expendAmount),0) as "expendAmount",
- sum( a.other_feevalue ) AS "otherFeevalue"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
- settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
- WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
- and a.handling_fees_status ='1'
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- GROUP BY partner_companies_id
- ) c ON c.partnerCompaniesId = a.partner_companies_id
- LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
- settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
- WHERE a.settlement_status = '1'
- and a.handling_fees_status ='1'
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- GROUP BY partner_companies_id
- ) d ON d.partnerCompaniesId = a.partner_companies_id
- LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
- settlement_amount ) AS "settleMentAmount",
- sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
- sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
- SUM(a.tax_points) as "taxPoints"
- FROM settlement_documentary_fees a
- WHERE a.settlement_status = '2'
- and a.handling_fees_status ='1'
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- GROUP BY partner_companies_id
- ) f ON f.partnerCompaniesId = a.partner_companies_id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id
- </select>
- <select id="getOtherIds" resultType="java.util.HashMap">
- SELECT
- a.id as "id",
- a.partner_companies_id AS "partnerCompaniesId"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- <where>
- 1=1
- <if test="agreementType !=null and agreementType!='' ">
- AND pa.agreement_type =#{agreementType}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
- AND a.documentary_fees_status = #{documentaryFeesStatus}
- </if>
- </where>
- </select>
- <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- pa.agreement_name as "agreementName",
- su.name as "userName",
- <include refid="income_com"/>
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- <where>
- <if test="id !=null and id !=''">
- a.id=#{id}
- </if>
- </where>
- </select>
- <select id="groupByInvoic" resultType="java.util.HashMap">
- select
- sum(a.commission_feevalue) as "invoicCommissionFeevalue",
- MAX(invoic_id) as "invoicId",
- MAX(invoic_time) as "invoicTime",
- GROUP_CONCAT(a.id) as "ids"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- <where>
- 1=1
- AND a.invoic_id is not null
- <if test="idArr !=null and idArr!=''">
- a.id IN
- <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="agreementType !=null and agreementType!='' ">
- AND pa.agreement_type =#{agreementType}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- </where>
- group by a.invoic_id
- </select>
- <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- update ins_ply_income
- set handling_fees_status ='1',
- settlement_time =NOW()
- <where>
- 1=1
- <if test="split != null and split != '' and split.length > 0">
- and id in
- <foreach collection="split" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </update>
- <select id="otherTimeDetail" resultType="java.util.HashMap">
- SELECT
- i.YEAR as "year",
- LPAD(i.monthNumber, 2, '0') as "monthNumber",
- i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
- IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
- CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
- IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
- FROM (
- SELECT
- YEAR(a.signdate) AS YEAR,
- MONTH(a.signdate) AS monthNumber,
- SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
- FROM ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- <where>
- YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
- and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="cityId != null and cityId != ''">
- and a.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="countyId != null and countyId != ''">
- and a.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- </where>
- GROUP BY YEAR(a.signdate), MONTH(a.signdate)
- ) i
- LEFT JOIN (
- SELECT
- YEAR(a.signing_time) AS YEAR,
- MONTH(a.signing_time) AS monthNumber,
- SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
- FROM settlement_documentary_fees a
- <where>
- YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
- and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
- </if>
- </where>
- GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
- ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
- ORDER BY i.YEAR, i.monthNumber;
- </select>
- <select id="platformSettlementRecord" resultType="com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto">
- SELECT
- DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
- MAX(upf.url) as "imageUrl",
- sum(a.commission_feevalue + a.other_feevalue) AS "settlementAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
- <where>
- pa.agreement_type ='1'
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- </where>
- group by a.settlement_time
- </select>
- <select id="getTotalPtReceivables" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
- select
- pa.agreement_type as "agreementType",
- sum(a.all_fee_value) as "allFeeValue"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
- LEFT JOIN sys_user su2 on su2.id=a.update_user_id
- LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- LEFT JOIN sys_dept b on pa.dept_id=b.id
- <where>
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
- and a.jq_receivable_proportion =#{jqReceivableProportion}
- </if>
- <if test="syReceivableProportion !=null and syReceivableProportion !=''">
- and a.sy_receivable_proportion =#{syReceivableProportion}
- </if>
- <if test="noReceivableProportion !=null and noReceivableProportion !=''">
- and a.no_receivable_proportion =#{noReceivableProportion}
- </if>
- <if test="id !=null and id !=''">
- and a.id =#{id}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="provinceId != null and provinceId != ''">
- and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
- </if>
- <if test="cityId != null and cityId != ''">
- and pa.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="countyId != null and countyId != ''">
- and pa.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="taskId != null and taskId != ''">
- and a.task_id = #{taskId}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
- and a.id in
- <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="settlementDate !=null and settlementDate !=''">
- AND a.settlement_time =#{settlementDate}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- </where>
- group by pa.agreement_type
- </select>
- <select id="ptSumGroupByMonth" resultType="java.util.HashMap">
- SELECT
- DATE_FORMAT( a.signdate, '%m') as "month",
- sum(a.all_fee_value) as "commissionFeevalue"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN sys_user su ON su.id = a.user_id
- LEFT JOIN sys_user su1 ON su1.id = a.settlement_user_id
- LEFT JOIN sys_user su2 ON su2.id = a.update_user_id
- LEFT JOIN ins_upload_files upf ON a.settlement_image_id = upf.id
- LEFT JOIN esm_ins_company eic ON eic.id = a.partner_companies_id
- LEFT JOIN sys_dept b ON pa.dept_id = b.id
- <where>
- 1=1
- <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
- and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
- </if>
- <if test="agreementType !=null and agreementType !=''">
- and pa.agreement_type =#{agreementType}
- </if>
- <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
- and a.signdate between #{signDateStart} and #{signDateEnd}
- </if>
- <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
- and a.handling_fees_status =#{handlingFeesStatus}
- </if>
- <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
- and a.jq_receivable_proportion =#{jqReceivableProportion}
- </if>
- <if test="syReceivableProportion !=null and syReceivableProportion !=''">
- and a.sy_receivable_proportion =#{syReceivableProportion}
- </if>
- <if test="noReceivableProportion !=null and noReceivableProportion !=''">
- and a.no_receivable_proportion =#{noReceivableProportion}
- </if>
- <if test="id !=null and id !=''">
- and a.id =#{id}
- </if>
- <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
- AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
- </if>
- <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
- and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
- </if>
- <if test="dockingPerson !=null and dockingPerson !=''">
- and pa.docking_person =#{dockingPerson}
- </if>
- <if test="provinceId != null and provinceId != ''">
- and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
- </if>
- <if test="cityId != null and cityId != ''">
- and pa.dept_id LIKE CONCAT(#{cityId}, '%')
- </if>
- <if test="createTimeQuery != null and createTimeQuery != ''">
- and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
- </if>
- <if test="countyId != null and countyId != ''">
- and pa.dept_id LIKE CONCAT(#{countyId}, '%')
- </if>
- <if test="taskId != null and taskId != ''">
- and a.task_id = #{taskId}
- </if>
- <if test="orderno !=null and orderno !=''">
- and a.orderno =#{orderno}
- </if>
- <if test="companyName !=null and companyName !=''">
- and a.company_id =#{companyName}
- </if>
- <if test="isExternal !=null and isExternal != ''">
- AND pa.is_external =#{isExternal}
- </if>
- <if test="policyno !=null and policyno !=''">
- and a.policyno =#{policyno}
- </if>
- <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
- and a.documentary_fees_status =#{documentaryFeesStatus}
- </if>
- <if test="isNotCar !=null and isNotCar !=''">
- and a.is_not_car =#{isNotCar}
- </if>
- <if test="deptId !=null and deptId !=''">
- and pa.dept_id =#{deptId}
- </if>
- <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
- AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
- </if>
- <if test="ids != null and ids != '' and ids.length > 0">
- and a.id in
- <foreach collection="ids" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
- and a.id in
- <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
- and a.id in
- <foreach collection="selectIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
- and a.partner_companies_id in
- <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="isOther !=null and isOther !=''">
- and a.is_not_documentary =#{isOther}
- </if>
- <if test="licenseno != null and licenseno != ''">
- and a.licenseno =#{licenseno}
- </if>
- <if test="syPolicyno != null and syPolicyno != ''">
- and a.sy_policyno =#{syPolicyno}
- </if>
- <if test="noPolicyno != null and noPolicyno != ''">
- and a.no_policyno =#{noPolicyno}
- </if>
- <if test="signdate !=null and signdate !=''">
- AND a.signdate =#{signdate}
- </if>
- <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
- AND a.partner_companies_id =#{partnerCompaniesId}
- </if>
- <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
- AND a.partner_companies_name =#{partnerCompaniesName}
- </if>
- <if test="createTime !=null and createTime !=''">
- AND a.create_time =#{createTime}
- </if>
- <if test="settlementTime !=null and settlementTime !=''">
- AND a.settlement_time =#{settlementTime}
- </if>
- <if test="settlementDate !=null and settlementDate !=''">
- AND a.settlement_time =#{settlementDate}
- </if>
- <if test="userId !=null and userId !=''">
- and a.userId =#{userId}
- </if>
- <if test="companyId !=null and companyId !=''">
- and a.company_id =#{companyId}
- </if>
- <if test="riskcode !=null and riskcode !=''">
- and a.riskcode =#{riskcode}
- </if>
- <if test="year !=null and year !=''">
- AND YEAR(a.signdate) =#{year}
- </if>
- <if test="month !=null and month !=''">
- AND month(a.signdate) =#{month}
- </if>
- <if test="day !=null and day !=''">
- AND day(a.signdate) =#{day}
- </if>
- <if test="insuredName !=null and insuredName !=''">
- AND a.insured_name =#{insuredName}
- </if>
- <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
- AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
- </if>
- <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
- AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
- </if>
- <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
- AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( a.signdate, '%m')
- </select>
- <select id="queryPage" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
- SELECT
- c.years AS yearAndMonth,
- c.sumpremium AS sumpremium,
- IFNULL( a.sumcount, 0 ) AS sumcount,
- IFNULL( a.paid, 0 ) AS paid,
- IFNULL( a.unpaid, 0 ) AS unpaid,
- (IFNULL( a.sumcount, 0 ) - IFNULL( a.paid, 0 )) grossProfit,
- IFNULL( b.labor_cost, 0 ) AS laborCost,
- IFNULL( b.fixed_cost, 0 ) AS fixedCost,
- IFNULL( b.variable_cost, 0 ) AS variableCost,
- IFNULL( b.operating_profit, 0 ) AS operatingProfit,
- IFNULL( b.taxation, 0 ) AS taxation,
- IFNULL( b.net_profit, 0 ) AS netProfit
- FROM
- (
- SELECT
- DATE_FORMAT( createtime, '%Y-%m' ) AS years,
- sum( sumpremium ) AS sumpremium
- FROM
- ins_area_company
- <where>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND signing_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.days !=null and vo.days !='' ">
- and signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( signing_time, '%Y-%m' )
- ORDER BY
- DATE_FORMAT( signing_time, '%Y-%m' )
- ) c
- LEFT JOIN (
- SELECT
- DATE_FORMAT( create_time, '%Y-%m' ) AS years,
- sum( all_fee_value ) AS sumcount,
- SUM( CASE WHEN handling_fees_status = '2' THEN ifnull( invoic_amount, 0 ) ELSE 0 END ) AS paid,
- SUM( CASE WHEN handling_fees_status != '2' THEN ifnull(( all_fee_value - ifnull( invoic_amount, 0 )), 0 ) ELSE 0 END ) AS unpaid
- FROM
- ins_ply_income
- <where>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.days !=null and vo.days !='' ">
- and signdate >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( signdate, '%Y-%m' )
- ) a ON c.years = a.years
- LEFT JOIN ins_labor_cost b ON a.years = b.year_and_month
- </select>
- <select id="queryDateByTypeSumAmount" resultType="java.math.BigDecimal">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- <if test="vo.type !=null and vo.type !=''">
- and pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.isNotCar !=null and vo.isNotCar !=''">
- and a.is_not_car =#{vo.isNotCar}
- </if>
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
- </if>
- </where>
- </select>
- <select id="queryDateByType"
- resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
- SELECT
- a.subSigndate as "yearAndMonth",
- a.allAmount as "commissionFeevalue",
- IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
- IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
- (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
- a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
- FROM
- (
- SELECT
- DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
- IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- pa.agreement_type = '2'
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( a.signdate, '%Y-%m' )
- ) a
- LEFT JOIN (
- SELECT
- DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
- sum( a.settlement_amount ) AS "settCommAmount",
- sum(a.remaining_amount) as "remainingAmount",
- sum(a.total_amount) as "invoicComm"
- FROM
- sys_insurance_handling_settlement_month a
- <where>
- <if test="vo.year !=null and vo.year !=''">
- DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( a.signing_time, '%Y-%m' )
- ) b ON a.subSigndate = b.subSigndate
- left join (
- select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
- from
- settlement_documentary_fees a
- <where>
- a.settlement_status='1'
- and handling_fees_status ='1'
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
- ) c on c.subSigndate=a.subSigndate
- </select>
- <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- <if test="vo.type !=null and vo.type !=''">
- and pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- </where>
- </select>
- <select id="queryDateByTypeByMonth"
- resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
- SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- 1=1
- <if test="vo.type !=null and vo.type !=''">
- and pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.yearAndMonth != null and vo.yearAndMonth!=''">
- AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
- </if>
- </where>
- </select>
- <select id="queryDateByTypeByMonthList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
- SELECT
- a.subPathner,
- sa.area_cname as "areaName",
- eic.namesimple as "companyName",
- a.partnerCompaniesId as "partnerCompaniesId",
- IFNULL(a.allAmount,0) as "commissionFeevalue",
- a.companyId as "companyId",
- IFNULL(b.noSettHandlingFee,0) as "settlementAmount",
- IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0) as "noSettlementAmount",
- (IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)) +IFNULL(b.noSettHandlingFee,0) as "noInvoicCommissionFeevalue",
- "手续费" as "isHand",
- IFNULL( b.settAmount,0) as "readyCommissionFeevalue"
- FROM
- (
- SELECT
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- a.company_id AS "companyId",
- a.partner_companies_id AS "partnerCompaniesId" ,
- sum(a.commission_feevalue) as "allAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- <where>
- pa.agreement_type = '2'
- AND a.is_not_documentary = '0'
- <if test="vo.isNoCar != null and vo.isNoCar !='' ">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
- and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id,
- a.company_id
- ) a
- LEFT JOIN (
- SELECT
- sum( a.total_amount ) AS "invoicAmount",
- sum( a.remaining_amount ) AS "noSettHandlingFee",
- sum( a.settlement_amount ) AS "settAmount",
- a.task_id AS "taskId",
- DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigne",
- a.partner_companies_id AS "subPathner"
- FROM
- sys_insurance_handling_settlement_month a
- <where>
- <if test="vo.isNoCar != null and vo.isNoCar !='' ">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
- and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id,
- DATE_FORMAT( a.signing_time, '%Y-%m' ),
- a.task_id
- ) b ON b.subPathner = a.partnerCompaniesId
- LEFT JOIN esm_ins_company eic on eic.id = a.companyId
- LEFT JOIN sys_area sa on sa.area_code = a.subPathner
- </select>
- <select id="queryDateByTypeByMonthOtherList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
- SELECT
- a.partner_companies_id,
- sa.area_cname as "areaName",
- eic.namesimple as "companyName",
- sum(a.other_feevalue) as "commissionFeevalue",
- IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
- sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
- IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "settlementAmount",
- sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- "跟单费" as "isHand",
- a.company_id AS "companyId"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN (
- SELECT
- a.partner_companies_id,
- sum(a.invoiced_settled_amount) as "invoicedSettledAmount",
- sum(a.Invoiced_not_settled_amount) as "invoicedNotSettledAmount"
- FROM
- settlement_documentary_fees a
- <where>
- a.handling_fees_status ='1'
- AND settlement_status = '1'
- <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
- and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
- </if>
- <if test="vo.isNoCar !=null and vo.isNoCar !=''">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id
- ) b on b.partner_companies_id =a.partner_companies_id
- LEFT JOIN esm_ins_company eic on eic.id = a.company_Id
- LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
- <where>
- pa.agreement_type = '2'
- AND a.is_not_documentary = '1'
- <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
- and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
- </if>
- <if test="vo.isNoCar !=null and vo.isNoCar !=''">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- </where>
- group by
- a.partner_companies_id,a.company_id,sa.area_cname
- </select>
- <select id="queryPlatHanding" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
- SELECT
- 1 as orderNumber,
- '手续费' AS isHand,
- sa.area_cname AS areaName,
- eic.namesimple AS companyName,
- a.partner_companies_id AS partnerCompaniesId,
- SUM(a.commission_feevalue) AS commissionFeevalue,
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
- LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
- <where>
- pa.agreement_type = '1'
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.isNoCar !=null and vo.isNoCar !=''">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id, eic.namesimple, sa.area_cname
- UNION ALL
- SELECT
- 2 as orderNumber,
- '跟单费' AS isHand,
- sa.area_cname AS areaName,
- eic.namesimple AS companyName,
- a.partner_companies_id AS partnerCompaniesId,
- SUM(a.other_feevalue) AS commissionFeevalue,
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
- LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
- <where>
- pa.agreement_type = '1'
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.isNoCar !=null and vo.isNoCar !=''">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id, eic.namesimple, sa.area_cname
- UNION ALL
- SELECT
- 3 as orderNumber,
- '合计' AS isHand,
- sa.area_cname AS areaName,
- eic.namesimple AS companyName,
- a.partner_companies_id AS partnerCompaniesId,
- SUM(a.all_fee_value) AS commissionFeevalue,
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue",
- SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
- LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
- <where>
- pa.agreement_type = '1'
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.isNoCar !=null and vo.isNoCar !=''">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id, eic.namesimple, sa.area_cname
- ORDER BY
- companyName,
- areaName,
- orderNumber;
- </select>
- <select id="queryPrivateCar" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
- SELECT
- a.subSigndate as "yearAndMonth",
- a.allAmount as "commissionFeevalue",
- IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
- IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
- (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
- a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
- FROM
- (
- SELECT
- DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
- IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- pa.agreement_type = '2'
- <if test="vo.isNotCar !=null and vo.isNotCar !=''">
- and a.is_not_car =#{vo.isNotCar}
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( a.signdate, '%Y-%m' )
- ) a
- LEFT JOIN (
- SELECT
- DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
- sum( a.settlement_amount ) AS "settCommAmount",
- sum(a.remaining_amount) as "remainingAmount",
- sum(a.total_amount) as "invoicComm"
- FROM
- sys_insurance_handling_settlement_month a
- <where>
- 1=1
- <if test="vo.isNotCar !=null and vo.isNotCar !=''">
- and a.is_not_car =#{vo.isNotCar}
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( a.signing_time, '%Y-%m' )
- ) b ON a.subSigndate = b.subSigndate
- left join (
- select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
- from
- settlement_documentary_fees a
- where a.settlement_status='1'
- and handling_fees_status ='1'
- <if test="vo.isNotCar !=null and vo.isNotCar !=''">
- and a.is_not_car =#{vo.isNotCar}
- </if>
- GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
- ) c on c.subSigndate=a.subSigndate
- </select>
- <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- <if test="vo.type !=null and vo.type !=''">
- and pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- </where>
- </select>
- <select id="queryDateByTypeByMonth"
- resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
- SELECT
- SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
- SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
- SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
- FROM
- ins_ply_income a
- LEFT JOIN
- ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- 1=1
- <if test="vo.type !=null and vo.type !=''">
- and pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.yearAndMonth != null and vo.yearAndMonth!=''">
- AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
- </if>
- </where>
- </select>
- <select id="getProfitAnalysisQueryList" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
- SELECT
- a.signingTime as "yearAndMonth",
- IFNULL(a.sumpremium,0) as "sumpremium",
- IFNULL(b.allAmount,0) as "sumcount",
- IFNULL(d.settlement,0) as "meet",
- IFNULL(c.actualPayment,0) as "paid",
- ifnull(d.settlement,0) - IFNULL(c.actualPayment,0) as "unpaid",
- IFNULL(b.allAmount,0)- IFNULL (d.settlement,0) as "grossProfit",
- IFNULL(e.applyAmount,0) as "laborCost",
- IFNULL(f.applyAmount,0) as "fixedCost",
- IFNULL(j.applyAmount,0) as "variableCost",
- (IFNULL (b.allAmount,0) - IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) as "operatingProfit",
- IFNULL(g.applyAmount,0) as "taxation",
- (IFNULL(b.allAmount,0)- IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) - IFNULL(g.applyAmount,0) as "netProfit"
- FROM
- (
- SELECT
- IFNULL(sum( iac.jqpremium ),0) +IFNULL(sum( iac.sypremium ),0) + IFNULL(sum(iac.jypremium),0) as "sumpremium",
- DATE_FORMAT( iac.signing_time, '%Y-%m' ) AS "signingTime"
- FROM
- `ins_fee_audit` ifa
- LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
- <where>
- ifa.auditstatus = '1'
- AND iac.signing_time IS NOT NULL
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( iac.signing_time, '%Y') =#{vo.year}
- </if>
- <if test="vo.days !=null and vo.days !='' ">
- and iac.signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- </where>
- GROUP BY
- DATE_FORMAT( iac.signing_time, '%Y-%m' )
- ) a
- LEFT JOIN (
- SELECT
- sum( ipi.commission_feevalue) + sum(ipi.other_feevalue ) as "allAmount",
- DATE_FORMAT( ipi.signdate, '%Y-%m' ) AS "signingTime"
- FROM
- ins_ply_income ipi
- <where>
- 1=1
- </where>
- GROUP BY
- DATE_FORMAT( ipi.signdate, '%Y-%m' )
- ) b ON a.signingTime = b.signingTime
- left join (
- select
- sum(a.amount) as "actualPayment",DATE_FORMAT( a.auditing_time, '%Y-%m' ) as "auditingTime"
- from sys_amount_auditing a
- left join sys_user_account_history b on a.id = b.auditiing_id
- left join sys_user su on su.id =a.user_id
- <where>
- a.auditing_status= '3'
- </where>
- GROUP BY DATE_FORMAT( a.auditing_time, '%Y-%m' )
- ) c on c.auditingTime =a.signingTime
- left join (
- SELECT
- sum(
- ifo.jq_export_supervise_costs_premiums + ifo.sy_export_supervise_costs_premiums + ifo.no_export_supervise_costs_premiums + ifo.jq_export_other_costs_premiums + ifo.sy_export_other_costs_premiums + ifo.no_export_other_costs_premiums + ifo.first_detail_premiums + ifo.second_detail_premiums + ifo.third_detail_premiums
- ) AS "settlement",
- DATE_FORMAT( iac.signing_time, '%Y-%m' ) as "signingTime"
- FROM
- ins_fee_order_new ifo
- LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
- LEFT JOIN ins_area_company iac ON ifa.ins_order_no = iac.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- <where>
- ifa.auditstatus = '1'
- AND iac.orderstatus = '3'
- AND io.orderstatus = '3'
- </where>
- GROUP BY
- DATE_FORMAT( iac.signing_time, '%Y-%m' )
- ) d on d.signingTime =a.signingTime
- left join (
- SELECT
- sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
- DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
- b.expenditureDetails
- FROM
- inv_account_operate a
- left join (
- select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
- left join inv_account_expenses b on a.parent_id =b.expenses_id
- where b.category is not null
- ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
- <where>
- a.out_card_num IN (
- SELECT
- bank_card_num
- FROM
- inv_account_card iac
- LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
- WHERE
- ia.del_flag = '0'
- AND ia.outer_flag LIKE concat( '%', '0', '%' )
- )
- AND a.revenue_outlay = '1'
- AND a.del_flag = '0'
- AND b.expenditureDetails = '1'
- </where>
- GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
- ) e on e.createTime =a.signingTime
- left join (
- SELECT
- sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
- DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
- b.expenditureDetails
- FROM
- inv_account_operate a
- left join (
- select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
- left join inv_account_expenses b on a.parent_id =b.expenses_id
- where b.category is not null
- ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
- <where>
- a.out_card_num IN (
- SELECT
- bank_card_num
- FROM
- inv_account_card iac
- LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
- WHERE
- ia.del_flag = '0'
- AND ia.outer_flag LIKE concat( '%', '0', '%' )
- )
- AND a.revenue_outlay = '1'
- AND a.del_flag = '0'
- AND b.expenditureDetails = '2'
- </where>
- GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
- ) f on f.createTime =a.signingTime
- left join (
- SELECT
- sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
- DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
- b.expenditureDetails
- FROM
- inv_account_operate a
- left join (
- select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
- left join inv_account_expenses b on a.parent_id =b.expenses_id
- where b.category is not null
- ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
- <where>
- a.out_card_num IN (
- SELECT
- bank_card_num
- FROM
- inv_account_card iac
- LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
- WHERE
- ia.del_flag = '0'
- AND ia.outer_flag LIKE concat( '%', '0', '%' )
- )
- AND a.revenue_outlay = '1'
- AND a.del_flag = '0'
- AND b.expenditureDetails = '3'
- </where>
- GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
- ) j on j.createTime =a.signingTime
- left join (
- SELECT
- sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
- DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
- b.expenditureDetails
- FROM
- inv_account_operate a
- left join (
- select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
- left join inv_account_expenses b on a.parent_id =b.expenses_id
- where b.category is not null
- ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
- <where>
- a.out_card_num IN (
- SELECT
- bank_card_num
- FROM
- inv_account_card iac
- LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
- WHERE
- ia.del_flag = '0'
- AND ia.outer_flag LIKE concat( '%', '0', '%' )
- )
- AND a.revenue_outlay = '1'
- AND a.del_flag = '0'
- AND b.expenditureDetails = '4'
- </where>
- GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
- ) g on g.createTime =a.signingTime
- </select>
- <select id="getInvociAmount" resultType="com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto" >
- select
- DATE_FORMAT( a.signdate, '%Y-%m' ) as "incomeSigningTime",
- a.task_id as "taskId",
- sum(a.commission_feevalue) as "totalAmount"
- from ins_ply_income a
- LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
- LEFT JOIN sys_user su on su.id=a.user_id
- LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
- LEFT JOIN sys_user su2 on su2.id=a.update_user_id
- LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
- LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
- LEFT JOIN sys_dept b on pa.dept_id=b.id
- <where>
- 1=1
- <if test="vo.isNotCar !=null and vo.isNotCar !=''">
- and a.is_not_car =#{vo.isNotCar}
- </if>
- <if test="vo.isNotDocumentary !=null and vo.isNotDocumentary !=''">
- and a.is_not_documentary =#{vo.isNotDocumentary}
- </if>
- <if test="vo.taskId != null and vo.taskId != ''">
- and a.task_id = #{vo.taskId}
- </if>
- </where>
- group by a.task_id , DATE_FORMAT( a.signdate, '%Y-%m' )
- </select>
- <select id="queryDateByTypePt" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
- SELECT IFNULL(a.signingTime, 0) as "yearAndMonth",
- IFNULL(a.allAmount, 0) as "commissionFeevalue",
- IFNULL(c.settAmount, 0) as "noInvoicCommissionFeevalue",
- IFNULL(b.notInvoicAmount, 0) as "noSettlementAmount",
- IFNULL(c.settAmount, 0) as "readyCommissionFeevalue"
- FROM (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "allAmount",
- DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
- FROM ins_ply_income a
- LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- pa.agreement_type = '1'
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) a
- left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount",
- DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
- FROM ins_ply_income a
- LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- pa.agreement_type = '1'
- and a.handling_fees_status = '0'
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) b on a.signingTime = b.signingTime
- left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "settAmount",
- DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
- FROM ins_ply_income a
- LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
- <where>
- pa.agreement_type = '1'
- and a.handling_fees_status = '1'
- <if test="vo.year !=null and vo.year !=''">
- and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
- </if>
- </where>
- GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) c on c.signingTime = a.signingTime
- </select>
- <select id="getPatherId" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
- SELECT
- sa.area_cname as "areaName",
- eic.namesimple as "companyName",
- SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
- a.company_id AS "companyId",
- a.partner_companies_id AS "partnerCompaniesId"
- FROM
- ins_ply_income a
- LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
- LEFT JOIN esm_ins_company eic on eic.id = a.company_id
- LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
- <where>
- <if test="vo.type !=null and vo.type!=''">
- pa.agreement_type =#{vo.type}
- </if>
- <if test="vo.isNoCar != null and vo.isNoCar !='' ">
- and a.is_not_car =#{vo.isNoCar}
- </if>
- <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
- and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
- </if>
- </where>
- GROUP BY
- a.partner_companies_id,
- a.company_id,
- eic.namesimple,
- sa.area_cname
- </select>
- </mapper>
|