InsPlyIncomeMapper.xml 162 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydtech.modules.fnc.dao.InsPlyIncomeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.InsPlyIncome">
  6. <id column="id" property="id" />
  7. <result column="orderno" property="orderno" />
  8. <result column="policyno" property="policyno" />
  9. <result column="dept_id" property="deptId" />
  10. <result column="dept_name" property="deptName" />
  11. <result column="riskcode" property="riskcode" />
  12. <result column="pay_date" property="payDate" />
  13. <result column="company_id" property="companyId" />
  14. <result column="company_name" property="companyName" />
  15. <result column="agreement_id" property="agreementId" />
  16. <result column="licenseno" property="licenseno" />
  17. <result column="taxamount" property="taxamount" />
  18. <result column="no_tax_premium" property="noTaxPremium" />
  19. <result column="commission_feerate" property="commissionFeerate" />
  20. <result column="other_feerate" property="otherFeerate" />
  21. <result column="commission_feevalue" property="commissionFeevalue" />
  22. <result column="other_feevalue" property="otherFeevalue" />
  23. <result column="all_fee_value" property="allFeeValue" />
  24. <result column="final_fee_value" property="finalFeeValue" />
  25. <result column="doing_fee_value" property="doingFeeValue" />
  26. <result column="create_time" property="createTime" />
  27. <result column="voucher_number" property="voucherNumber"/>
  28. <result column="contract_id" property="contractId"/>
  29. <result column="contract_file_id" property="contractFileId"/>
  30. <result column="handling_fees_status" property="handlingFeesStatus"/>
  31. <result column="documentary_fees_status" property="documentaryFeesStatus"/>
  32. <result column="no_policyno" property="noPolicyno"/>
  33. <result column="sy_policyno" property="syPolicyno"/>
  34. <result column="is_not_car" property="isNotCar"/>
  35. <result column="is_not_documentary" property="isNotDocumentary"/>
  36. <result column="invoic_amount" property="invoicAmount"/>
  37. <result column="invoic_id" property="invoicId"/>
  38. <result column="tax_premium" property="taxPremium"/>
  39. <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
  40. <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
  41. <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
  42. <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
  43. <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
  44. <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
  45. <result column="jq_premium" property="jqPremium"/>
  46. <result column="sy_premium" property="syPremium"/>
  47. <result column="no_premium" property="noPremium"/>
  48. <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
  49. <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
  50. <result column="no_no_tax_premium" property="noNoTaxPremium"/>
  51. <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
  52. <result column="sy_receivable_proportion" property="syReceivableProportion"/>
  53. <result column="no_receivable_proportion" property="noReceivableProportion"/>
  54. <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
  55. <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
  56. <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
  57. <result column="settlement_time" property="settlementTime"/>
  58. <result column="update_time" property="updateTime"/>
  59. <result column="settlement_user_id" property="settlementUserId"/>
  60. <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
  61. <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
  62. <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
  63. <result column="user_id" property="userId"/>
  64. <result column="update_user_id" property="updateUserId"/>
  65. <result column="partner_companies_id" property="partnerCompaniesId"/>
  66. <result column="partner_companies_name" property="partnerCompaniesName"/>
  67. <result column="receivable_amount" property="receivableAmount"/>
  68. <result column="insured_name" property="insuredName"/>
  69. <result column="invoicing_method" property="invoicingMethod"/>
  70. <result column="remarks" property="remarks"/>
  71. <result column="jq_start_date" property="jqStartDate"/>
  72. <result column="jq_end_date" property="jqEndDate"/>
  73. <result column="sy_start_date" property="syStartDate"/>
  74. <result column="sy_end_date" property="syEndDate"/>
  75. <result column="settle_other_status" property="settleOtherStatus"/>
  76. <result column="settlement_image_id" property="settlementImageId"/>
  77. <result column="task_id" property="taskId"/>
  78. </resultMap>
  79. <sql id="income_com">
  80. a.id as "id",
  81. a.orderno as "orderno",
  82. a.policyno as "policyno",
  83. a.dept_id as "deptId",
  84. a.riskcode as "riskcode",
  85. a.pay_date as "payDate",
  86. a.signdate as "signdate",
  87. a.company_id as "companyId",
  88. a.agreement_id as "agreementId",
  89. a.licenseno as "licenseno",
  90. a.taxamount as "taxamount",
  91. a.no_tax_premium as "noTaxPremium",
  92. a.commission_feerate as "commissionFeerate",
  93. a.other_feerate as "otherFeerate",
  94. a.commission_feevalue as "commissionFeevalue",
  95. a.other_feevalue as "otherFeevalue",
  96. a.all_fee_value as "allFeeValue",
  97. a.final_fee_value as "finalFeeValue",
  98. a.doing_fee_value as "doingFeeValue",
  99. a.voucher_number as "voucherNumber",
  100. a.contract_id as "contractId",
  101. a.contract_file_id as "contractFileId",
  102. a.handling_fees_status as "handlingFeesStatus",
  103. a.no_policyno as "noPolicyno",
  104. a.sy_policyno as "syPolicyno",
  105. a.documentary_fees_status as "documentaryFeesStatus",
  106. a.is_not_car as "isNotCar",
  107. a.is_not_documentary as "isNotDocumentary",
  108. a.invoic_amount as "invoicAmount",
  109. a.invoic_id as "invoicId",
  110. a.tax_premium as "taxPremium",
  111. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  112. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  113. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  114. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  115. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  116. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  117. a.partner_companies_id as "partnerCompaniesId",
  118. a.jq_premium as "jqPremium",
  119. a.sy_premium as "syPremium",
  120. a.no_premium as "noPremium",
  121. a.jq_no_tax_premium as "jqNoTaxPremium",
  122. a.sy_no_tax_premium as "syNoTaxPremium",
  123. a.no_no_tax_premium as "noNoTaxPremium",
  124. a.jq_receivable_proportion as "jqReceivableProportion",
  125. a.sy_receivable_proportion as "syReceivableProportion",
  126. a.no_receivable_proportion as "noReceivableProportion",
  127. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  128. a.sy_other_costs_proportion as "syOtherCostsProportion",
  129. a.no_other_costs_proportion as "noOtherCostsProportion",
  130. a.settlement_time as "settlementTime",
  131. a.update_time as "updateTime",
  132. a.settlement_user_id as "settlementUserId",
  133. a.update_user_id as "updateUserId",
  134. a.jq_other_costs_premium as "jqOtherCostsPremium",
  135. a.sy_other_costs_premium as "syOtherCostsPremium",
  136. a.no_other_costs_premium as "noOtherCostsPremium",
  137. a.partner_companies_name as "partnerCompaniesName",
  138. a.company_name as "companyName",
  139. a.receivable_amount as "receivableAmount",
  140. a.invoic_time as "invoicTime",
  141. a.insured_name as "insuredName",
  142. a.remarks as "remarks",
  143. a.jq_start_date as "jqStartDate",
  144. a.jq_end_date as "jqEndDate",
  145. a.sy_start_date as "syStartDate",
  146. a.sy_end_date as "syEndDate",
  147. a.settle_other_status as "settleOtherStatus",
  148. a.user_id as "userId",
  149. a.invoicing_method as "invoicingMethod",
  150. a.settlement_image_id as "settlementImageId",
  151. a.task_id as "taskId",
  152. a.create_time as "createTime",
  153. a.add_type as "addType"
  154. </sql>
  155. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  156. select
  157. su1.name as "settlementUserName",
  158. su2.name as "updateUserName",
  159. CONCAT_WS( '-', pa.agreement_abbreviation, NULLIF( pa.business_description, '' ), NULLIF( pa.job_description, '' ) ) AS agreementName,
  160. pa.agreement_type as "agreementType",
  161. pa.docking_person as "dockingPerson",
  162. pa.is_external as "isExternal",
  163. upf.url as "imageUrl",
  164. su.name as "userName",
  165. b.name as "deptName",
  166. <include refid="income_com"/>
  167. from ins_ply_income a
  168. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  169. LEFT JOIN sys_user su on su.id=a.user_id
  170. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  171. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  172. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  173. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  174. LEFT JOIN sys_dept b on pa.dept_id=b.id
  175. <where>
  176. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  177. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  178. </if>
  179. <if test="agreementType !=null and agreementType !=''">
  180. and pa.agreement_type =#{agreementType}
  181. </if>
  182. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  183. and a.signdate between #{signDateStart} and #{signDateEnd}
  184. </if>
  185. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  186. and a.handling_fees_status =#{handlingFeesStatus}
  187. </if>
  188. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  189. and a.jq_receivable_proportion =#{jqReceivableProportion}
  190. </if>
  191. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  192. and a.sy_receivable_proportion =#{syReceivableProportion}
  193. </if>
  194. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  195. and a.no_receivable_proportion =#{noReceivableProportion}
  196. </if>
  197. <if test="id !=null and id !=''">
  198. and a.id =#{id}
  199. </if>
  200. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  201. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  202. </if>
  203. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  204. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  205. </if>
  206. <if test="dockingPerson !=null and dockingPerson !=''">
  207. and pa.docking_person =#{dockingPerson}
  208. </if>
  209. <if test="provinceId != null and provinceId != ''">
  210. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  211. </if>
  212. <if test="cityId != null and cityId != ''">
  213. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  214. </if>
  215. <if test="createTimeQuery != null and createTimeQuery != ''">
  216. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  217. </if>
  218. <if test="countyId != null and countyId != ''">
  219. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  220. </if>
  221. <if test="taskId != null and taskId != ''">
  222. and a.task_id = #{taskId}
  223. </if>
  224. <if test="orderno !=null and orderno !=''">
  225. and a.orderno =#{orderno}
  226. </if>
  227. <if test="companyName !=null and companyName !=''">
  228. and a.company_id =#{companyName}
  229. </if>
  230. <if test="policyno !=null and policyno !=''">
  231. and a.policyno =#{policyno}
  232. </if>
  233. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  234. and a.documentary_fees_status =#{documentaryFeesStatus}
  235. </if>
  236. <if test="isNotCar !=null and isNotCar !=''">
  237. and a.is_not_car =#{isNotCar}
  238. </if>
  239. <if test="deptId !=null and deptId !=''">
  240. and pa.dept_id =#{deptId}
  241. </if>
  242. <if test="ids != null and ids != '' and ids.length > 0">
  243. and a.id in
  244. <foreach collection="ids" item="item" open="(" separator="," close=")">
  245. #{item}
  246. </foreach>
  247. </if>
  248. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  249. and a.id in
  250. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  251. #{item}
  252. </foreach>
  253. </if>
  254. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  255. and a.id in
  256. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  257. #{item}
  258. </foreach>
  259. </if>
  260. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  261. and a.partner_companies_id in
  262. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  263. #{item}
  264. </foreach>
  265. </if>
  266. <if test="isOther !=null and isOther !=''">
  267. and a.is_not_documentary =#{isOther}
  268. </if>
  269. <if test="licenseno != null and licenseno != ''">
  270. and a.licenseno =#{licenseno}
  271. </if>
  272. <if test="syPolicyno != null and syPolicyno != ''">
  273. and a.sy_policyno =#{syPolicyno}
  274. </if>
  275. <if test="noPolicyno != null and noPolicyno != ''">
  276. and a.no_policyno =#{noPolicyno}
  277. </if>
  278. <if test="signdate !=null and signdate !=''">
  279. AND a.signdate =#{signdate}
  280. </if>
  281. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  282. AND a.partner_companies_id =#{partnerCompaniesId}
  283. </if>
  284. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  285. AND a.partner_companies_name =#{partnerCompaniesName}
  286. </if>
  287. <if test="createTime !=null and createTime !=''">
  288. AND a.create_time =#{createTime}
  289. </if>
  290. <if test="settlementTime !=null and settlementTime !=''">
  291. AND a.settlement_time =#{settlementTime}
  292. </if>
  293. <if test="settlementDate !=null and settlementDate !=''">
  294. AND a.settlement_time =#{settlementDate}
  295. </if>
  296. <if test="userId !=null and userId !=''">
  297. and a.userId =#{userId}
  298. </if>
  299. <if test="companyId !=null and companyId !=''">
  300. and a.company_id =#{companyId}
  301. </if>
  302. <if test="riskcode !=null and riskcode !=''">
  303. and a.riskcode =#{riskcode}
  304. </if>
  305. <if test="year !=null and year !=''">
  306. AND YEAR(a.signdate) =#{year}
  307. </if>
  308. <if test="month !=null and month !=''">
  309. AND month(a.signdate) =#{month}
  310. </if>
  311. <if test="day !=null and day !=''">
  312. AND day(a.signdate) =#{day}
  313. </if>
  314. <if test="insuredName !=null and insuredName !=''">
  315. AND a.insured_name =#{insuredName}
  316. </if>
  317. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  318. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  319. </if>
  320. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  321. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  322. </if>
  323. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  324. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  325. </if>
  326. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  327. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  328. </if>
  329. <if test="isExternal !=null and isExternal != ''">
  330. AND pa.is_external =#{isExternal}
  331. </if>
  332. <if test="addType !=null and addType !=''">
  333. AND a.add_type =#{addType}
  334. </if>
  335. </where>
  336. ORDER BY a.create_time desc
  337. </select>
  338. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  339. select
  340. pa.agreement_name as "agreementName",
  341. pa.agreement_type as "agreementType",
  342. su.name as "userName",
  343. <include refid="income_com"/>
  344. from ins_ply_income a
  345. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  346. LEFT JOIN sys_user su on su.id=a.user_id
  347. <where>
  348. <if test="id!=null and id!=''">
  349. a.id=#{id}
  350. </if>
  351. </where>
  352. </select>
  353. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  354. select
  355. count(MONTH(a.signdate)) as "totalorders",
  356. MONTH(a.signdate) as "monthSigdate",
  357. sum(a.other_feevalue) as "allLOtherFeevalue",
  358. GROUP_CONCAT(a.id) as "ids"
  359. from ins_ply_income a
  360. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  361. <where>
  362. <if test="isNotCar !=null and isNotCar !=''" >
  363. a.is_not_car =#{isNotCar}
  364. </if>
  365. <if test="isOther !=null and isOther !=''">
  366. and a.is_not_documentary =#{isOther}
  367. </if>
  368. <if test="agreementType !=null and agreementType !=''">
  369. and pa.agreement_type =#{agreementType}
  370. </if>
  371. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  372. and a.documentary_fees_status =#{documentaryFeesStatus}
  373. </if>
  374. <if test="companyId !=null and companyId !=''">
  375. and a.company_id =#{companyId}
  376. </if>
  377. <if test="year !=null and year !=''">
  378. and YEAR(a.signdate) =#{year}
  379. </if>
  380. <if test="isExternal !=null and isExternal != ''">
  381. AND pa.is_external =#{isExternal}
  382. </if>
  383. group by MONTH(a.signdate)
  384. </where>
  385. </select>
  386. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  387. update ins_ply_income
  388. <set>
  389. <if test="contractId != null">
  390. contract_id = #{contractId},
  391. </if>
  392. <if test="voucherNumber != null">
  393. voucher_number = #{voucherNumber},
  394. </if>
  395. <if test="contractFileId != null">
  396. contract_file_id = #{contractFileId},
  397. </if>
  398. <if test="handlingFeesStatus != null">
  399. handling_fees_status = #{handlingFeesStatus}
  400. </if>
  401. <if test="documentaryFeesStatus != null">
  402. documentary_fees_status = #{documentaryFeesStatus}
  403. </if>
  404. </set>
  405. where orderno =#{orderno}
  406. </update>
  407. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  408. SELECT
  409. a.companyId as "companyId",
  410. a.totalorders as "totalorders",
  411. a.ids as "ids",
  412. a.allLOtherFeevalue as "allLOtherFeevalue"
  413. FROM
  414. (
  415. SELECT
  416. a.company_id AS "companyId",
  417. count(a.orderno) as "totalorders",
  418. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  419. GROUP_CONCAT(a.id) as "ids"
  420. FROM
  421. ins_ply_income a
  422. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  423. WHERE
  424. pa.agreement_type = '2'
  425. <if test="isNotCar !=null and isNotCar !=''" >
  426. and a.is_not_car =#{isNotCar}
  427. </if>
  428. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  429. AND a.documentary_fees_status = #{documentaryFeesStatus}
  430. </if>
  431. <if test="isOther !=null and isOther !=''">
  432. and a.is_not_documentary =#{isOther}
  433. </if>
  434. <if test="companyId !=null and companyId !=''">
  435. and a.company_id =#{companyId}
  436. </if>
  437. <if test="year !=null and year !=''">
  438. and YEAR(a.signdate) =#{year}
  439. </if>
  440. <if test="month !=null and month !=''">
  441. and month(a.signdate) =#{month}
  442. </if>
  443. GROUP BY
  444. a.company_id
  445. ) a
  446. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  447. </select>
  448. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  449. select
  450. <include refid="income_com"/>
  451. from ins_ply_income a
  452. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  453. LEFT JOIN sys_user su on su.id=a.user_id
  454. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  455. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  456. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  457. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  458. LEFT JOIN sys_dept b on pa.dept_id=b.id
  459. <where>
  460. 1=1
  461. <if test="licenseno !=null and licenseno !=''">
  462. AND a.licenseno=#{licenseno}
  463. </if>
  464. <if test="policyno !=null and policyno !=''">
  465. AND a.policyno=#{policyno}
  466. </if>
  467. <if test="syPolicyno !=null and syPolicyno !=''">
  468. AND a.sy_policyno=#{syPolicyno}
  469. </if>
  470. <if test="noPolicyno !=null and noPolicyno !=''">
  471. AND a.no_policyno=#{noPolicyno}
  472. </if>
  473. <if test="isOther !=null and isOther !=''">
  474. and a.is_not_documentary =#{isOther}
  475. </if>
  476. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  477. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  478. </if>
  479. <if test="agreementType !=null and agreementType !=''">
  480. and pa.agreement_type =#{agreementType}
  481. </if>
  482. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  483. and a.signdate between #{signDateStart} and #{signDateEnd}
  484. </if>
  485. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  486. and a.handling_fees_status =#{handlingFeesStatus}
  487. </if>
  488. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  489. and a.jq_receivable_proportion =#{jqReceivableProportion}
  490. </if>
  491. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  492. and a.sy_receivable_proportion =#{syReceivableProportion}
  493. </if>
  494. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  495. and a.no_receivable_proportion =#{noReceivableProportion}
  496. </if>
  497. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  498. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  499. </if>
  500. <if test="id !=null and id !=''">
  501. and a.id =#{id}
  502. </if>
  503. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  504. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  505. </if>
  506. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  507. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  508. </if>
  509. <if test="dockingPerson !=null and dockingPerson !=''">
  510. and pa.docking_person =#{dockingPerson}
  511. </if>
  512. <if test="provinceId != null and provinceId != ''">
  513. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  514. </if>
  515. <if test="cityId != null and cityId != ''">
  516. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  517. </if>
  518. <if test="createTimeQuery != null and createTimeQuery != ''">
  519. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  520. </if>
  521. <if test="countyId != null and countyId != ''">
  522. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  523. </if>
  524. <if test="taskId != null and taskId != ''">
  525. and a.task_id = #{taskId}
  526. </if>
  527. <if test="orderno !=null and orderno !=''">
  528. and a.orderno =#{orderno}
  529. </if>
  530. <if test="companyName !=null and companyName !=''">
  531. and a.company_id =#{companyName}
  532. </if>
  533. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  534. and a.documentary_fees_status =#{documentaryFeesStatus}
  535. </if>
  536. <if test="isNotCar !=null and isNotCar !=''">
  537. and a.is_not_car =#{isNotCar}
  538. </if>
  539. <if test="deptId !=null and deptId !=''">
  540. and pa.dept_id =#{deptId}
  541. </if>
  542. <if test="ids != null and ids != '' and ids.length > 0">
  543. and a.id in
  544. <foreach collection="ids" item="item" open="(" separator="," close=")">
  545. #{item}
  546. </foreach>
  547. </if>
  548. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  549. and a.id in
  550. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  551. #{item}
  552. </foreach>
  553. </if>
  554. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  555. and a.id in
  556. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  557. #{item}
  558. </foreach>
  559. </if>
  560. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  561. and a.partner_companies_id in
  562. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  563. #{item}
  564. </foreach>
  565. </if>
  566. <if test="signdate !=null and signdate !=''">
  567. AND a.signdate =#{signdate}
  568. </if>
  569. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  570. AND a.partner_companies_id =#{partnerCompaniesId}
  571. </if>
  572. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  573. AND a.partner_companies_name =#{partnerCompaniesName}
  574. </if>
  575. <if test="createTime !=null and createTime !=''">
  576. AND a.create_time =#{createTime}
  577. </if>
  578. <if test="settlementTime !=null and settlementTime !=''">
  579. AND a.settlement_time =#{settlementTime}
  580. </if>
  581. <if test="settlementDate !=null and settlementDate !=''">
  582. AND a.settlement_time =#{settlementDate}
  583. </if>
  584. <if test="userId !=null and userId !=''">
  585. and a.userId =#{userId}
  586. </if>
  587. <if test="companyId !=null and companyId !=''">
  588. and a.company_id =#{companyId}
  589. </if>
  590. <if test="riskcode !=null and riskcode !=''">
  591. and a.riskcode =#{riskcode}
  592. </if>
  593. <if test="year !=null and year !=''">
  594. AND YEAR(a.signdate) =#{year}
  595. </if>
  596. <if test="month !=null and month !=''">
  597. AND month(a.signdate) =#{month}
  598. </if>
  599. <if test="day !=null and day !=''">
  600. AND day(a.signdate) =#{day}
  601. </if>
  602. <if test="insuredName !=null and insuredName !=''">
  603. AND a.insured_name =#{insuredName}
  604. </if>
  605. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  606. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  607. </if>
  608. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  609. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  610. </if>
  611. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  612. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  613. </if>
  614. </where>
  615. </select>
  616. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  617. select
  618. <include refid="income_com"/>
  619. from ins_ply_income a
  620. <where>
  621. 1=1
  622. <if test="licenseno !=null and licenseno !=''">
  623. AND a.licenseno=#{licenseno}
  624. </if>
  625. <if test="policyno !=null and policyno !=''">
  626. AND a.policyno=#{policyno}
  627. </if>
  628. <if test="syPolicyno !=null and syPolicyno !=''">
  629. AND a.sy_policyno=#{syPolicyno}
  630. </if>
  631. <if test="noPolicyno !=null and noPolicyno !=''">
  632. AND a.no_policyno=#{noPolicyno}
  633. </if>
  634. <if test="isOther !=null and isOther !=''">
  635. and a.is_not_documentary =#{isOther}
  636. </if>
  637. <if test="isNotCar !=null and isNotCar !=''">
  638. and a.is_not_car =#{isNotCar}
  639. </if>
  640. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  641. and a.handling_fees_status =#{handlingFeesStatus}
  642. </if>
  643. <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
  644. and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
  645. </if>
  646. <if test="createTimeQuery != null and createTimeQuery != ''">
  647. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  648. </if>
  649. <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
  650. and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
  651. </if>
  652. <if test="jqOtherCostsProportion !=null and jqOtherCostsProportion !=''">
  653. and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
  654. </if>
  655. <if test="syOtherCostsProportion !=null and syOtherCostsProportion !=''">
  656. and a.sy_other_costs_proportion =#{syOtherCostsProportion}
  657. </if>
  658. <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
  659. and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
  660. </if>
  661. <if test="noOtherCostsProportion !=null and noOtherCostsProportion !=''">
  662. and a.no_other_costs_proportion =#{noOtherCostsProportion}
  663. </if>
  664. <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
  665. and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
  666. </if>
  667. <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
  668. and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
  669. </if>
  670. <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
  671. and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
  672. </if>
  673. <if test="jqPremium !=null and jqPremium !=''">
  674. and a.jq_premium =#{jqPremium}
  675. </if>
  676. <if test="syPremium !=null and syPremium !=''">
  677. and a.sy_premium =#{jqPremium}
  678. </if>
  679. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  680. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  681. </if>
  682. <if test="noPremium !=null and noPremium !=''">
  683. and a.no_premium =#{noPremium}
  684. </if>
  685. </where>
  686. limit 1
  687. </select>
  688. <select id="totalAmount" resultType="java.util.HashMap">
  689. select
  690. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  691. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  692. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  693. from ins_ply_income a
  694. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  695. <where>
  696. 1=1
  697. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  698. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  699. </if>
  700. <if test="agreementType !=null and agreementType !=''">
  701. and pa.agreement_type =#{agreementType}
  702. </if>
  703. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  704. and a.signdate between #{signDateStart} and #{signDateEnd}
  705. </if>
  706. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  707. and a.handling_fees_status =#{handlingFeesStatus}
  708. </if>
  709. <if test="orderno !=null and orderno !=''">
  710. and a.orderno =#{orderno}
  711. </if>
  712. <if test="policyno !=null and policyno !=''">
  713. and a.policyno =#{policyno}
  714. </if>
  715. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  716. and a.documentary_fees_status =#{documentaryFeesStatus}
  717. </if>
  718. <if test="createTimeQuery != null and createTimeQuery != ''">
  719. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  720. </if>
  721. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  722. and a.id in
  723. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  724. #{item}
  725. </foreach>
  726. </if>
  727. <if test="isNotCar !=null and isNotCar !=''">
  728. and a.is_not_car =#{isNotCar}
  729. </if>
  730. <if test="isOther !=null and isOther !=''">
  731. and a.is_not_documentary =#{isOther}
  732. </if>
  733. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  734. and a.licenseno in
  735. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  736. #{item}
  737. </foreach>
  738. </if>
  739. <if test="policyno != null and policyno != '' ">
  740. and a.policyno =#{policyno}
  741. </if>
  742. <if test="syPolicyno != null and syPolicyno != '' ">
  743. and a.sy_policyno =#{syPolicyno}
  744. </if>
  745. <if test="noPolicyno != null and noPolicyno != ''">
  746. and a.no_policyno =#{noPolicyno}
  747. </if>
  748. <if test="signdate !=null and signdate !=''">
  749. and a.signdate =#{signdate}
  750. </if>
  751. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  752. and a.partner_companies_id =#{partnerCompaniesId}
  753. </if>
  754. <if test="createTime !=null and createTime !=''">
  755. a.create_time =#{createTime}
  756. </if>
  757. <if test="settlementTime !=null and settlementTime !=''">
  758. a.settlement_time =#{settlementTime}
  759. </if>
  760. <if test="userId !=null and userId !=''">
  761. and a.userId =#{userId}
  762. </if>
  763. <if test="companyId !=null and companyId !=''">
  764. and a.company_id =#{companyId}
  765. </if>
  766. <if test="riskcode !=null and riskcode !=''">
  767. and a.riskcode =#{riskcode}
  768. </if>
  769. <if test="year !=null and year !=''">
  770. AND YEAR(a.signdate) =#{year}
  771. </if>
  772. <if test="month !=null and month !=''">
  773. AND month(a.signdate) =#{month}
  774. </if>
  775. <if test="day !=null and day !=''">
  776. AND day(a.signdate) =#{day}
  777. </if>
  778. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  779. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  780. </if>
  781. </where>
  782. </select>
  783. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  784. SELECT
  785. SUM(a.commission_feevalue) AS commissionFeevalue,
  786. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  787. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  788. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  789. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  790. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  791. FROM
  792. ins_ply_income a
  793. LEFT JOIN
  794. ptl_agreement pa ON pa.id = a.agreement_id
  795. <where>
  796. 1=1
  797. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  798. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  799. </if>
  800. <if test="agreementType !=null and agreementType !=''">
  801. and pa.agreement_type =#{agreementType}
  802. </if>
  803. <if test="orderno !=null and orderno !=''">
  804. and a.orderno =#{orderno}
  805. </if>
  806. <if test="companyName !=null and companyName !=''">
  807. and a.company_id =#{companyName}
  808. </if>
  809. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  810. and a.signdate between #{signDateStart} and #{signDateEnd}
  811. </if>
  812. <if test="policyno !=null and policyno !=''">
  813. and a.policyno =#{policyno}
  814. </if>
  815. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  816. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  817. </if>
  818. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  819. and a.handling_fees_status =#{handlingFeesStatus}
  820. </if>
  821. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  822. and a.documentary_fees_status =#{documentaryFeesStatus}
  823. </if>
  824. <if test="createTimeQuery != null and createTimeQuery != ''">
  825. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  826. </if>
  827. <if test="isNotCar !=null and isNotCar !=''">
  828. and a.is_not_car =#{isNotCar}
  829. </if>
  830. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  831. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  832. </if>
  833. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  834. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  835. </if>
  836. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  837. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  838. </if>
  839. <if test="isOther !=null and isOther !=''">
  840. and a.is_not_documentary =#{isOther}
  841. </if>
  842. <if test="licenseno != null and licenseno != '' ">
  843. and a.licenseno =#{licenseno}
  844. </if>
  845. <if test="deptId !=null and deptId !=''">
  846. and pa.dept_id =#{deptId}
  847. </if>
  848. <if test="ids != null and ids != '' and ids.length > 0">
  849. and a.id in
  850. <foreach collection="ids" item="item" open="(" separator="," close=")">
  851. #{item}
  852. </foreach>
  853. </if>
  854. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  855. and a.id in
  856. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  857. #{item}
  858. </foreach>
  859. </if>
  860. <if test="syPolicyno != null and syPolicyno != '' ">
  861. and a.sy_policyno =#{syPolicyno}
  862. </if>
  863. <if test="noPolicyno != null and noPolicyno != ''">
  864. and a.no_policyno =#{noPolicyno}
  865. </if>
  866. <if test="signdate !=null and signdate !=''">
  867. AND a.signdate =#{signdate}
  868. </if>
  869. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  870. AND a.partner_companies_id =#{partnerCompaniesId}
  871. </if>
  872. <if test="createTime !=null and createTime !=''">
  873. AND a.create_time =#{createTime}
  874. </if>
  875. <if test="settlementTime !=null and settlementTime !=''">
  876. AND a.settlement_time =#{settlementTime}
  877. </if>
  878. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  879. AND a.partner_companies_name =#{partnerCompaniesName}
  880. </if>
  881. <if test="userId !=null and userId !=''">
  882. and a.userId =#{userId}
  883. </if>
  884. <if test="companyId !=null and companyId !=''">
  885. and a.company_id =#{companyId}
  886. </if>
  887. <if test="riskcode !=null and riskcode !=''">
  888. and a.riskcode =#{riskcode}
  889. </if>
  890. <if test="year !=null and year !=''">
  891. AND YEAR(a.signdate) =#{year}
  892. </if>
  893. <if test="month !=null and month !=''">
  894. AND month(a.signdate) =#{month}
  895. </if>
  896. <if test="day !=null and day !=''">
  897. AND day(a.signdate) =#{day}
  898. </if>
  899. <if test="insuredName !=null and insuredName !=''">
  900. AND a.insured_name =#{insuredName}
  901. </if>
  902. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  903. and a.partner_companies_id in
  904. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  905. #{item}
  906. </foreach>
  907. </if>
  908. </where>
  909. </select>
  910. <select id="ptTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  911. SELECT
  912. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
  913. SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  914. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
  915. FROM
  916. ins_ply_income a
  917. LEFT JOIN
  918. ptl_agreement pa ON pa.id = a.agreement_id
  919. <where>
  920. 1=1
  921. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  922. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  923. </if>
  924. <if test="agreementType !=null and agreementType !=''">
  925. and pa.agreement_type =#{agreementType}
  926. </if>
  927. <if test="orderno !=null and orderno !=''">
  928. and a.orderno =#{orderno}
  929. </if>
  930. <if test="companyName !=null and companyName !=''">
  931. and a.company_id =#{companyName}
  932. </if>
  933. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  934. and a.signdate between #{signDateStart} and #{signDateEnd}
  935. </if>
  936. <if test="policyno !=null and policyno !=''">
  937. and a.policyno =#{policyno}
  938. </if>
  939. <if test="dockingPerson !=null and dockingPerson !=''">
  940. and pa.docking_person =#{dockingPerson}
  941. </if>
  942. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  943. and a.handling_fees_status =#{handlingFeesStatus}
  944. </if>
  945. <if test="isExternal !=null and isExternal != ''">
  946. AND pa.is_external =#{isExternal}
  947. </if>
  948. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  949. and a.documentary_fees_status =#{documentaryFeesStatus}
  950. </if>
  951. <if test="createTimeQuery != null and createTimeQuery != ''">
  952. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  953. </if>
  954. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  955. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  956. </if>
  957. <if test="isNotCar !=null and isNotCar !=''">
  958. and a.is_not_car =#{isNotCar}
  959. </if>
  960. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  961. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  962. </if>
  963. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  964. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  965. </if>
  966. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  967. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  968. </if>
  969. <if test="isOther !=null and isOther !=''">
  970. and a.is_not_documentary =#{isOther}
  971. </if>
  972. <if test="licenseno != null and licenseno != '' ">
  973. and a.licenseno =#{licenseno}
  974. </if>
  975. <if test="deptId !=null and deptId !=''">
  976. and pa.dept_id =#{deptId}
  977. </if>
  978. <if test="ids != null and ids != '' and ids.length > 0">
  979. and a.id in
  980. <foreach collection="ids" item="item" open="(" separator="," close=")">
  981. #{item}
  982. </foreach>
  983. </if>
  984. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  985. and a.id in
  986. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  987. #{item}
  988. </foreach>
  989. </if>
  990. <if test="syPolicyno != null and syPolicyno != '' ">
  991. and a.sy_policyno =#{syPolicyno}
  992. </if>
  993. <if test="noPolicyno != null and noPolicyno != ''">
  994. and a.no_policyno =#{noPolicyno}
  995. </if>
  996. <if test="signdate !=null and signdate !=''">
  997. AND a.signdate =#{signdate}
  998. </if>
  999. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1000. AND a.partner_companies_id =#{partnerCompaniesId}
  1001. </if>
  1002. <if test="createTime !=null and createTime !=''">
  1003. AND a.create_time =#{createTime}
  1004. </if>
  1005. <if test="settlementTime !=null and settlementTime !=''">
  1006. AND a.settlement_time =#{settlementTime}
  1007. </if>
  1008. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1009. AND a.partner_companies_name =#{partnerCompaniesName}
  1010. </if>
  1011. <if test="userId !=null and userId !=''">
  1012. and a.userId =#{userId}
  1013. </if>
  1014. <if test="companyId !=null and companyId !=''">
  1015. and a.company_id =#{companyId}
  1016. </if>
  1017. <if test="riskcode !=null and riskcode !=''">
  1018. and a.riskcode =#{riskcode}
  1019. </if>
  1020. <if test="year !=null and year !=''">
  1021. AND YEAR(a.signdate) =#{year}
  1022. </if>
  1023. <if test="month !=null and month !=''">
  1024. AND month(a.signdate) =#{month}
  1025. </if>
  1026. <if test="day !=null and day !=''">
  1027. AND day(a.signdate) =#{day}
  1028. </if>
  1029. <if test="insuredName !=null and insuredName !=''">
  1030. AND a.insured_name =#{insuredName}
  1031. </if>
  1032. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1033. and a.partner_companies_id in
  1034. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1035. #{item}
  1036. </foreach>
  1037. </if>
  1038. </where>
  1039. </select>
  1040. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1041. select
  1042. a.partner_companies_id as "partnerCompaniesId",
  1043. MAX( ec.name ) AS "companyName",
  1044. sum( a.commission_feevalue ) AS "commissionFeevalue",
  1045. sum( a.other_feevalue ) AS "otherFeevalue",
  1046. SUM( IFNULL(a.commission_feevalue,0) + IFNULL (a.other_feevalue,0) ) AS "totalFeevalue",
  1047. MAX( a.partner_companies_name) as "partnerCompaniesName",
  1048. MAX(pa.docking_person) as "dockingPerson"
  1049. from ins_ply_income a
  1050. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  1051. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1052. <where>
  1053. 1=1
  1054. <if test="agreementType !=null and agreementType!='' ">
  1055. AND pa.agreement_type =#{agreementType}
  1056. </if>
  1057. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1058. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1059. </if>
  1060. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  1061. AND a.handling_fees_status = #{handlingFeesStatus}
  1062. </if>
  1063. <if test="year !=null and year !=''">
  1064. AND YEAR(a.signdate) =#{year}
  1065. </if>
  1066. <if test="companyName !=null and companyName !=''">
  1067. and a.company_id =#{companyName}
  1068. </if>
  1069. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1070. AND a.partner_companies_name =#{partnerCompaniesName}
  1071. </if>
  1072. <if test="dockingPerson !=null and dockingPerson !=''">
  1073. and pa.docking_person =#{dockingPerson}
  1074. </if>
  1075. <if test="month !=null and month !=''">
  1076. AND month(a.signdate) =#{month}
  1077. </if>
  1078. <if test="day !=null and day !=''">
  1079. AND day(a.signdate) =#{day}
  1080. </if>
  1081. <if test="addType !=null and addType !=''">
  1082. AND a.add_type =#{addType}
  1083. </if>
  1084. </where>
  1085. GROUP BY a.partner_companies_id,pa.insurance_company_id,pa.docking_person
  1086. </select>
  1087. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1088. select
  1089. sum(a.commission_feevalue) as "commissionFeevalue",
  1090. sum(a.invoic_amount) as "invoicAmount"
  1091. from ins_ply_income a
  1092. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1093. <where>
  1094. 1=1
  1095. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1096. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1097. </if>
  1098. <if test="agreementType !=null and agreementType !=''">
  1099. and pa.agreement_type =#{agreementType}
  1100. </if>
  1101. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1102. and a.handling_fees_status =#{handlingFeesStatus}
  1103. </if>
  1104. <if test="orderno !=null and orderno !=''">
  1105. and a.orderno =#{orderno}
  1106. </if>
  1107. <if test="policyno !=null and policyno !=''">
  1108. and a.policyno =#{policyno}
  1109. </if>
  1110. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1111. and a.documentary_fees_status =#{documentaryFeesStatus}
  1112. </if>
  1113. <if test="isNotCar !=null and isNotCar !=''">
  1114. and a.is_not_car =#{isNotCar}
  1115. </if>
  1116. <if test="isOther !=null and isOther !=''">
  1117. and a.is_not_documentary =#{isOther}
  1118. </if>
  1119. <if test="licenseno != null and licenseno != ''">
  1120. and a.licenseno =#{licenseno}
  1121. </if>
  1122. <if test="syPolicyno != null and syPolicyno != ''">
  1123. and a.sy_policyno =#{syPolicyno}
  1124. </if>
  1125. <if test="noPolicyno != null and noPolicyno != ''">
  1126. and a.no_policyno =#{noPolicyno}
  1127. </if>
  1128. <if test="signdate !=null and signdate !=''">
  1129. and a.signdate =#{signdate}
  1130. </if>
  1131. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1132. and a.partner_companies_id =#{partnerCompaniesId}
  1133. </if>
  1134. <if test="createTime !=null and createTime !=''">
  1135. and a.create_time =#{createTime}
  1136. </if>
  1137. <if test="createTimeQuery != null and createTimeQuery != ''">
  1138. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1139. </if>
  1140. <if test="settlementTime !=null and settlementTime !=''">
  1141. and a.settlement_time =#{settlementTime}
  1142. </if>
  1143. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  1144. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  1145. </if>
  1146. <if test="userId !=null and userId !=''">
  1147. and a.userId =#{userId}
  1148. </if>
  1149. <if test="companyId !=null and companyId !=''">
  1150. and a.company_id =#{companyId}
  1151. </if>
  1152. <if test="riskcode !=null and riskcode !=''">
  1153. and a.riskcode =#{riskcode}
  1154. </if>
  1155. <if test="year !=null and year !=''">
  1156. AND YEAR(a.signdate) =#{year}
  1157. </if>
  1158. <if test="month !=null and month !=''">
  1159. AND month(a.signdate) =#{month}
  1160. </if>
  1161. <if test="day !=null and day !=''">
  1162. AND day(a.signdate) =#{day}
  1163. </if>
  1164. </where>
  1165. </select>
  1166. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1167. SELECT
  1168. a.partner_companies_id AS "partnerCompaniesId",
  1169. MAX( a.company_name ) AS "companyName",
  1170. MAX( a.company_id ) AS "companyId",
  1171. MAX( a.partner_companies_name ) AS "partnerCompaniesName"
  1172. FROM
  1173. ins_ply_income a
  1174. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1175. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1176. <where>
  1177. 1=1
  1178. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1179. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1180. </if>
  1181. <if test="agreementType !=null and agreementType !=''">
  1182. and pa.agreement_type =#{agreementType}
  1183. </if>
  1184. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1185. and a.signdate between #{signDateStart} and #{signDateEnd}
  1186. </if>
  1187. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1188. and a.handling_fees_status =#{handlingFeesStatus}
  1189. </if>
  1190. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1191. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1192. </if>
  1193. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1194. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1195. </if>
  1196. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  1197. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  1198. </if>
  1199. <if test="dockingPerson !=null and dockingPerson !=''">
  1200. and pa.docking_person =#{dockingPerson}
  1201. </if>
  1202. <if test="provinceId != null and provinceId != ''">
  1203. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  1204. </if>
  1205. <if test="cityId != null and cityId != ''">
  1206. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  1207. </if>
  1208. <if test="countyId != null and countyId != ''">
  1209. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  1210. </if>
  1211. <if test="taskId != null and taskId != ''">
  1212. and a.task_id = #{taskId}
  1213. </if>
  1214. <if test="orderno !=null and orderno !=''">
  1215. and a.orderno =#{orderno}
  1216. </if>
  1217. <if test="companyName !=null and companyName !=''">
  1218. and a.company_id =#{companyName}
  1219. </if>
  1220. <if test="isExternal !=null and isExternal != ''">
  1221. AND pa.is_external =#{isExternal}
  1222. </if>
  1223. <if test="policyno !=null and policyno !=''">
  1224. and a.policyno =#{policyno}
  1225. </if>
  1226. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1227. and a.documentary_fees_status =#{documentaryFeesStatus}
  1228. </if>
  1229. <if test="createTimeQuery != null and createTimeQuery != ''">
  1230. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1231. </if>
  1232. <if test="isNotCar !=null and isNotCar !=''">
  1233. and a.is_not_car =#{isNotCar}
  1234. </if>
  1235. <if test="deptId !=null and deptId !=''">
  1236. and pa.dept_id =#{deptId}
  1237. </if>
  1238. <if test="ids != null and ids != '' and ids.length > 0">
  1239. and a.id in
  1240. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1241. #{item}
  1242. </foreach>
  1243. </if>
  1244. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  1245. and a.id in
  1246. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  1247. #{item}
  1248. </foreach>
  1249. </if>
  1250. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1251. and a.id in
  1252. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1253. #{item}
  1254. </foreach>
  1255. </if>
  1256. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1257. and a.partner_companies_id in
  1258. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1259. #{item}
  1260. </foreach>
  1261. </if>
  1262. <if test="isOther !=null and isOther !=''">
  1263. and a.is_not_documentary =#{isOther}
  1264. </if>
  1265. <if test="licenseno != null and licenseno != ''">
  1266. and a.licenseno =#{licenseno}
  1267. </if>
  1268. <if test="syPolicyno != null and syPolicyno != ''">
  1269. and a.sy_policyno =#{syPolicyno}
  1270. </if>
  1271. <if test="noPolicyno != null and noPolicyno != ''">
  1272. and a.no_policyno =#{noPolicyno}
  1273. </if>
  1274. <if test="signdate !=null and signdate !=''">
  1275. AND a.signdate =#{signdate}
  1276. </if>
  1277. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1278. AND a.partner_companies_id =#{partnerCompaniesId}
  1279. </if>
  1280. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1281. AND a.partner_companies_name =#{partnerCompaniesName}
  1282. </if>
  1283. <if test="createTime !=null and createTime !=''">
  1284. AND a.create_time =#{createTime}
  1285. </if>
  1286. <if test="settlementTime !=null and settlementTime !=''">
  1287. AND a.settlement_time =#{settlementTime}
  1288. </if>
  1289. <if test="userId !=null and userId !=''">
  1290. and a.userId =#{userId}
  1291. </if>
  1292. <if test="companyId !=null and companyId !=''">
  1293. and a.company_id =#{companyId}
  1294. </if>
  1295. <if test="riskcode !=null and riskcode !=''">
  1296. and a.riskcode =#{riskcode}
  1297. </if>
  1298. <if test="year !=null and year !=''">
  1299. AND YEAR(a.signdate) =#{year}
  1300. </if>
  1301. <if test="month !=null and month !=''">
  1302. AND month(a.signdate) =#{month}
  1303. </if>
  1304. <if test="day !=null and day !=''">
  1305. AND day(a.signdate) =#{day}
  1306. </if>
  1307. <if test="insuredName !=null and insuredName !=''">
  1308. AND a.insured_name =#{insuredName}
  1309. </if>
  1310. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1311. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1312. </if>
  1313. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1314. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1315. </if>
  1316. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1317. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1318. </if>
  1319. </where>
  1320. GROUP BY a.partner_companies_id
  1321. </select>
  1322. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1323. select
  1324. a.partner_companies_id AS "partnerCompaniesId",
  1325. a.id as "id"
  1326. from ins_ply_income a
  1327. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1328. <where>
  1329. 1=1
  1330. and a.handling_fees_status ='2'
  1331. <if test="agreementType !=null and agreementType!='' ">
  1332. AND pa.agreement_type =#{agreementType}
  1333. </if>
  1334. <if test="year !=null and year !=''">
  1335. AND YEAR(a.signdate) =#{year}
  1336. </if>
  1337. <if test="isExternal !=null and isExternal != ''">
  1338. AND pa.is_external =#{isExternal}
  1339. </if>
  1340. <if test="isOther !=null and isOther !=''">
  1341. and a.is_not_documentary =#{isOther}
  1342. </if>
  1343. <if test="isNotCar !=null and isNotCar !=''">
  1344. and a.is_not_car =#{isNotCar}
  1345. </if>
  1346. <if test="month !=null and month !=''">
  1347. AND month(a.signdate) =#{month}
  1348. </if>
  1349. <if test="day !=null and day !=''">
  1350. AND day(a.signdate) =#{day}
  1351. </if>
  1352. </where>
  1353. </select>
  1354. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1355. SELECT
  1356. a.partner_companies_id AS "partnerCompaniesId",
  1357. MAX( a.company_name ) AS "companyName",
  1358. MAX( a.company_id ) AS "companyId",
  1359. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  1360. IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
  1361. IFNULL(max(f.settleMentAmount) , 0.00) + IFNULL(max(d.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  1362. IFNULL(max(d.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
  1363. sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  1364. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  1365. IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
  1366. IFNULL(max(f.expendAmount),0) as "expendAmount",
  1367. sum( a.other_feevalue ) AS "otherFeevalue"
  1368. FROM
  1369. ins_ply_income a
  1370. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1371. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1372. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1373. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1374. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  1375. and a.handling_fees_status ='1'
  1376. <if test="isNotCar !=null and isNotCar !=''">
  1377. and a.is_not_car =#{isNotCar}
  1378. </if>
  1379. GROUP BY partner_companies_id
  1380. ) c ON c.partnerCompaniesId = a.partner_companies_id
  1381. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1382. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1383. WHERE a.settlement_status = '1'
  1384. and a.handling_fees_status ='1'
  1385. <if test="isNotCar !=null and isNotCar !=''">
  1386. and a.is_not_car =#{isNotCar}
  1387. </if>
  1388. GROUP BY partner_companies_id
  1389. ) d ON d.partnerCompaniesId = a.partner_companies_id
  1390. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  1391. settlement_amount ) AS "settleMentAmount",
  1392. sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
  1393. sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
  1394. SUM(a.tax_points) as "taxPoints"
  1395. FROM settlement_documentary_fees a
  1396. WHERE a.settlement_status = '2'
  1397. and a.handling_fees_status ='1'
  1398. <if test="isNotCar !=null and isNotCar !=''">
  1399. and a.is_not_car =#{isNotCar}
  1400. </if>
  1401. GROUP BY partner_companies_id
  1402. ) f ON f.partnerCompaniesId = a.partner_companies_id
  1403. <where>
  1404. 1=1
  1405. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1406. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1407. </if>
  1408. <if test="agreementType !=null and agreementType !=''">
  1409. and pa.agreement_type =#{agreementType}
  1410. </if>
  1411. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1412. and a.signdate between #{signDateStart} and #{signDateEnd}
  1413. </if>
  1414. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1415. and a.handling_fees_status =#{handlingFeesStatus}
  1416. </if>
  1417. <if test="dockingPerson !=null and dockingPerson !=''">
  1418. and pa.docking_person =#{dockingPerson}
  1419. </if>
  1420. <if test="orderno !=null and orderno !=''">
  1421. and a.orderno =#{orderno}
  1422. </if>
  1423. <if test="companyName !=null and companyName !=''">
  1424. and a.company_id =#{companyName}
  1425. </if>
  1426. <if test="policyno !=null and policyno !=''">
  1427. and a.policyno =#{policyno}
  1428. </if>
  1429. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1430. and a.documentary_fees_status =#{documentaryFeesStatus}
  1431. </if>
  1432. <if test="isNotCar !=null and isNotCar !=''">
  1433. and a.is_not_car =#{isNotCar}
  1434. </if>
  1435. <if test="isOther !=null and isOther !=''">
  1436. and a.is_not_documentary =#{isOther}
  1437. </if>
  1438. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1439. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1440. </if>
  1441. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1442. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1443. </if>
  1444. <if test="licenseno != null and licenseno != ''">
  1445. and a.licenseno =#{licenseno}
  1446. </if>
  1447. <if test="syPolicyno != null and syPolicyno != ''">
  1448. and a.sy_policyno =#{syPolicyno}
  1449. </if>
  1450. <if test="noPolicyno != null and noPolicyno != ''">
  1451. and a.no_policyno =#{noPolicyno}
  1452. </if>
  1453. <if test="signdate !=null and signdate !=''">
  1454. AND a.signdate =#{signdate}
  1455. </if>
  1456. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1457. AND a.partner_companies_id =#{partnerCompaniesId}
  1458. </if>
  1459. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1460. AND a.partner_companies_name =#{partnerCompaniesName}
  1461. </if>
  1462. <if test="createTime !=null and createTime !=''">
  1463. AND a.create_time =#{createTime}
  1464. </if>
  1465. <if test="settlementTime !=null and settlementTime !=''">
  1466. AND a.settlement_time =#{settlementTime}
  1467. </if>
  1468. <if test="createTimeQuery != null and createTimeQuery != ''">
  1469. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1470. </if>
  1471. <if test="userId !=null and userId !=''">
  1472. and a.userId =#{userId}
  1473. </if>
  1474. <if test="companyId !=null and companyId !=''">
  1475. and a.company_id =#{companyId}
  1476. </if>
  1477. <if test="riskcode !=null and riskcode !=''">
  1478. and a.riskcode =#{riskcode}
  1479. </if>
  1480. <if test="year !=null and year !=''">
  1481. AND YEAR(a.signdate) =#{year}
  1482. </if>
  1483. <if test="month !=null and month !=''">
  1484. AND month(a.signdate) =#{month}
  1485. </if>
  1486. <if test="day !=null and day !=''">
  1487. AND day(a.signdate) =#{day}
  1488. </if>
  1489. <if test="insuredName !=null and insuredName !=''">
  1490. AND a.insured_name =#{insuredName}
  1491. </if>
  1492. </where>
  1493. GROUP BY
  1494. a.partner_companies_id
  1495. </select>
  1496. <select id="getOtherIds" resultType="java.util.HashMap">
  1497. SELECT
  1498. a.id as "id",
  1499. a.partner_companies_id AS "partnerCompaniesId"
  1500. FROM
  1501. ins_ply_income a
  1502. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1503. <where>
  1504. 1=1
  1505. <if test="agreementType !=null and agreementType!='' ">
  1506. AND pa.agreement_type =#{agreementType}
  1507. </if>
  1508. <if test="year !=null and year !=''">
  1509. AND YEAR(a.signdate) =#{year}
  1510. </if>
  1511. <if test="isOther !=null and isOther !=''">
  1512. and a.is_not_documentary =#{isOther}
  1513. </if>
  1514. <if test="isNotCar !=null and isNotCar !=''">
  1515. and a.is_not_car =#{isNotCar}
  1516. </if>
  1517. <if test="month !=null and month !=''">
  1518. AND month(a.signdate) =#{month}
  1519. </if>
  1520. <if test="day !=null and day !=''">
  1521. AND day(a.signdate) =#{day}
  1522. </if>
  1523. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1524. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1525. </if>
  1526. </where>
  1527. </select>
  1528. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1529. select
  1530. pa.agreement_name as "agreementName",
  1531. su.name as "userName",
  1532. <include refid="income_com"/>
  1533. from ins_ply_income a
  1534. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1535. LEFT JOIN sys_user su on su.id=a.user_id
  1536. <where>
  1537. <if test="id !=null and id !=''">
  1538. a.id=#{id}
  1539. </if>
  1540. </where>
  1541. </select>
  1542. <select id="groupByInvoic" resultType="java.util.HashMap">
  1543. select
  1544. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  1545. MAX(invoic_id) as "invoicId",
  1546. MAX(invoic_time) as "invoicTime",
  1547. GROUP_CONCAT(a.id) as "ids"
  1548. from ins_ply_income a
  1549. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1550. LEFT JOIN sys_user su on su.id=a.user_id
  1551. <where>
  1552. 1=1
  1553. AND a.invoic_id is not null
  1554. <if test="idArr !=null and idArr!=''">
  1555. a.id IN
  1556. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  1557. #{item}
  1558. </foreach>
  1559. </if>
  1560. <if test="agreementType !=null and agreementType!='' ">
  1561. AND pa.agreement_type =#{agreementType}
  1562. </if>
  1563. <if test="year !=null and year !=''">
  1564. AND YEAR(a.signdate) =#{year}
  1565. </if>
  1566. <if test="isOther !=null and isOther !=''">
  1567. and a.is_not_documentary =#{isOther}
  1568. </if>
  1569. <if test="isNotCar !=null and isNotCar !=''">
  1570. and a.is_not_car =#{isNotCar}
  1571. </if>
  1572. <if test="isExternal !=null and isExternal != ''">
  1573. AND pa.is_external =#{isExternal}
  1574. </if>
  1575. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1576. and a.handling_fees_status =#{handlingFeesStatus}
  1577. </if>
  1578. <if test="month !=null and month !=''">
  1579. AND month(a.signdate) =#{month}
  1580. </if>
  1581. <if test="day !=null and day !=''">
  1582. AND day(a.signdate) =#{day}
  1583. </if>
  1584. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1585. AND a.partner_companies_id =#{partnerCompaniesId}
  1586. </if>
  1587. </where>
  1588. group by a.invoic_id
  1589. </select>
  1590. <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1591. update ins_ply_income
  1592. set handling_fees_status ='1',
  1593. settlement_time =NOW()
  1594. <where>
  1595. 1=1
  1596. <if test="split != null and split != '' and split.length > 0">
  1597. and id in
  1598. <foreach collection="split" item="item" open="(" separator="," close=")">
  1599. #{item}
  1600. </foreach>
  1601. </if>
  1602. </where>
  1603. </update>
  1604. <select id="otherTimeDetail" resultType="java.util.HashMap">
  1605. SELECT
  1606. i.YEAR as "year",
  1607. LPAD(i.monthNumber, 2, '0') as "monthNumber",
  1608. i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
  1609. IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
  1610. CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
  1611. IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
  1612. FROM (
  1613. SELECT
  1614. YEAR(a.signdate) AS YEAR,
  1615. MONTH(a.signdate) AS monthNumber,
  1616. SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
  1617. FROM ins_ply_income a
  1618. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1619. <where>
  1620. YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1621. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1622. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1623. </if>
  1624. <if test="agreementType !=null and agreementType !=''">
  1625. and pa.agreement_type =#{agreementType}
  1626. </if>
  1627. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1628. and a.signdate between #{signDateStart} and #{signDateEnd}
  1629. </if>
  1630. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1631. and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1632. </if>
  1633. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1634. and a.handling_fees_status =#{handlingFeesStatus}
  1635. </if>
  1636. <if test="dockingPerson !=null and dockingPerson !=''">
  1637. and pa.docking_person =#{dockingPerson}
  1638. </if>
  1639. <if test="cityId != null and cityId != ''">
  1640. and a.dept_id LIKE CONCAT(#{cityId}, '%')
  1641. </if>
  1642. <if test="countyId != null and countyId != ''">
  1643. and a.dept_id LIKE CONCAT(#{countyId}, '%')
  1644. </if>
  1645. <if test="orderno !=null and orderno !=''">
  1646. and a.orderno =#{orderno}
  1647. </if>
  1648. <if test="companyName !=null and companyName !=''">
  1649. and a.company_id =#{companyName}
  1650. </if>
  1651. <if test="policyno !=null and policyno !=''">
  1652. and a.policyno =#{policyno}
  1653. </if>
  1654. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1655. and a.documentary_fees_status =#{documentaryFeesStatus}
  1656. </if>
  1657. <if test="isNotCar !=null and isNotCar !=''">
  1658. and a.is_not_car =#{isNotCar}
  1659. </if>
  1660. <if test="deptId !=null and deptId !=''">
  1661. and pa.dept_id =#{deptId}
  1662. </if>
  1663. <if test="ids != null and ids != '' and ids.length > 0">
  1664. and a.id in
  1665. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1666. #{item}
  1667. </foreach>
  1668. </if>
  1669. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1670. and a.id in
  1671. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1672. #{item}
  1673. </foreach>
  1674. </if>
  1675. <if test="createTimeQuery != null and createTimeQuery != ''">
  1676. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1677. </if>
  1678. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1679. and a.partner_companies_id in
  1680. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1681. #{item}
  1682. </foreach>
  1683. </if>
  1684. <if test="isOther !=null and isOther !=''">
  1685. and a.is_not_documentary =#{isOther}
  1686. </if>
  1687. <if test="licenseno != null and licenseno != ''">
  1688. and a.licenseno =#{licenseno}
  1689. </if>
  1690. <if test="syPolicyno != null and syPolicyno != ''">
  1691. and a.sy_policyno =#{syPolicyno}
  1692. </if>
  1693. <if test="noPolicyno != null and noPolicyno != ''">
  1694. and a.no_policyno =#{noPolicyno}
  1695. </if>
  1696. <if test="signdate !=null and signdate !=''">
  1697. AND a.signdate =#{signdate}
  1698. </if>
  1699. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1700. AND a.partner_companies_id =#{partnerCompaniesId}
  1701. </if>
  1702. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1703. AND a.partner_companies_name =#{partnerCompaniesName}
  1704. </if>
  1705. <if test="createTime !=null and createTime !=''">
  1706. AND a.create_time =#{createTime}
  1707. </if>
  1708. <if test="settlementTime !=null and settlementTime !=''">
  1709. AND a.settlement_time =#{settlementTime}
  1710. </if>
  1711. <if test="userId !=null and userId !=''">
  1712. and a.userId =#{userId}
  1713. </if>
  1714. <if test="companyId !=null and companyId !=''">
  1715. and a.company_id =#{companyId}
  1716. </if>
  1717. <if test="riskcode !=null and riskcode !=''">
  1718. and a.riskcode =#{riskcode}
  1719. </if>
  1720. <if test="year !=null and year !=''">
  1721. AND YEAR(a.signdate) =#{year}
  1722. </if>
  1723. <if test="month !=null and month !=''">
  1724. AND month(a.signdate) =#{month}
  1725. </if>
  1726. <if test="day !=null and day !=''">
  1727. AND day(a.signdate) =#{day}
  1728. </if>
  1729. <if test="insuredName !=null and insuredName !=''">
  1730. AND a.insured_name =#{insuredName}
  1731. </if>
  1732. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1733. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1734. </if>
  1735. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1736. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1737. </if>
  1738. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1739. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1740. </if>
  1741. </where>
  1742. GROUP BY YEAR(a.signdate), MONTH(a.signdate)
  1743. ) i
  1744. LEFT JOIN (
  1745. SELECT
  1746. YEAR(a.signing_time) AS YEAR,
  1747. MONTH(a.signing_time) AS monthNumber,
  1748. SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
  1749. FROM settlement_documentary_fees a
  1750. <where>
  1751. YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1752. <if test="isNotCar !=null and isNotCar !=''">
  1753. and a.is_not_car =#{isNotCar}
  1754. </if>
  1755. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1756. and a.partner_companies_id in
  1757. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1758. #{item}
  1759. </foreach>
  1760. </if>
  1761. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1762. AND a.partner_companies_id =#{partnerCompaniesId}
  1763. </if>
  1764. <if test="companyName !=null and companyName !=''">
  1765. and a.company_id =#{companyName}
  1766. </if>
  1767. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1768. and a.handling_fees_status =#{handlingFeesStatus}
  1769. </if>
  1770. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1771. and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1772. </if>
  1773. </where>
  1774. GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
  1775. ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
  1776. ORDER BY i.YEAR, i.monthNumber;
  1777. </select>
  1778. <select id="platformSettlementRecord" resultType="com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto">
  1779. SELECT
  1780. DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
  1781. MAX(upf.url) as "imageUrl",
  1782. sum(a.commission_feevalue + a.other_feevalue) AS "settlementAmount"
  1783. FROM
  1784. ins_ply_income a
  1785. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1786. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  1787. <where>
  1788. pa.agreement_type ='1'
  1789. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1790. AND a.partner_companies_id =#{partnerCompaniesId}
  1791. </if>
  1792. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1793. and a.handling_fees_status =#{handlingFeesStatus}
  1794. </if>
  1795. <if test="dockingPerson !=null and dockingPerson !=''">
  1796. and pa.docking_person =#{dockingPerson}
  1797. </if>
  1798. </where>
  1799. group by a.settlement_time
  1800. </select>
  1801. <select id="getTotalPtReceivables" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1802. select
  1803. pa.agreement_type as "agreementType",
  1804. sum(a.all_fee_value) as "allFeeValue"
  1805. from ins_ply_income a
  1806. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1807. LEFT JOIN sys_user su on su.id=a.user_id
  1808. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  1809. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  1810. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  1811. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1812. LEFT JOIN sys_dept b on pa.dept_id=b.id
  1813. <where>
  1814. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1815. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1816. </if>
  1817. <if test="agreementType !=null and agreementType !=''">
  1818. and pa.agreement_type =#{agreementType}
  1819. </if>
  1820. <if test="isExternal !=null and isExternal != ''">
  1821. AND pa.is_external =#{isExternal}
  1822. </if>
  1823. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1824. and a.signdate between #{signDateStart} and #{signDateEnd}
  1825. </if>
  1826. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1827. and a.handling_fees_status =#{handlingFeesStatus}
  1828. </if>
  1829. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  1830. and a.jq_receivable_proportion =#{jqReceivableProportion}
  1831. </if>
  1832. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  1833. and a.sy_receivable_proportion =#{syReceivableProportion}
  1834. </if>
  1835. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  1836. and a.no_receivable_proportion =#{noReceivableProportion}
  1837. </if>
  1838. <if test="id !=null and id !=''">
  1839. and a.id =#{id}
  1840. </if>
  1841. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1842. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1843. </if>
  1844. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1845. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1846. </if>
  1847. <if test="dockingPerson !=null and dockingPerson !=''">
  1848. and pa.docking_person =#{dockingPerson}
  1849. </if>
  1850. <if test="provinceId != null and provinceId != ''">
  1851. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  1852. </if>
  1853. <if test="cityId != null and cityId != ''">
  1854. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  1855. </if>
  1856. <if test="createTimeQuery != null and createTimeQuery != ''">
  1857. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1858. </if>
  1859. <if test="countyId != null and countyId != ''">
  1860. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  1861. </if>
  1862. <if test="taskId != null and taskId != ''">
  1863. and a.task_id = #{taskId}
  1864. </if>
  1865. <if test="orderno !=null and orderno !=''">
  1866. and a.orderno =#{orderno}
  1867. </if>
  1868. <if test="companyName !=null and companyName !=''">
  1869. and a.company_id =#{companyName}
  1870. </if>
  1871. <if test="policyno !=null and policyno !=''">
  1872. and a.policyno =#{policyno}
  1873. </if>
  1874. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1875. and a.documentary_fees_status =#{documentaryFeesStatus}
  1876. </if>
  1877. <if test="isNotCar !=null and isNotCar !=''">
  1878. and a.is_not_car =#{isNotCar}
  1879. </if>
  1880. <if test="deptId !=null and deptId !=''">
  1881. and pa.dept_id =#{deptId}
  1882. </if>
  1883. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  1884. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  1885. </if>
  1886. <if test="ids != null and ids != '' and ids.length > 0">
  1887. and a.id in
  1888. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1889. #{item}
  1890. </foreach>
  1891. </if>
  1892. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  1893. and a.id in
  1894. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  1895. #{item}
  1896. </foreach>
  1897. </if>
  1898. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1899. and a.id in
  1900. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1901. #{item}
  1902. </foreach>
  1903. </if>
  1904. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1905. and a.partner_companies_id in
  1906. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1907. #{item}
  1908. </foreach>
  1909. </if>
  1910. <if test="isOther !=null and isOther !=''">
  1911. and a.is_not_documentary =#{isOther}
  1912. </if>
  1913. <if test="licenseno != null and licenseno != ''">
  1914. and a.licenseno =#{licenseno}
  1915. </if>
  1916. <if test="syPolicyno != null and syPolicyno != ''">
  1917. and a.sy_policyno =#{syPolicyno}
  1918. </if>
  1919. <if test="noPolicyno != null and noPolicyno != ''">
  1920. and a.no_policyno =#{noPolicyno}
  1921. </if>
  1922. <if test="signdate !=null and signdate !=''">
  1923. AND a.signdate =#{signdate}
  1924. </if>
  1925. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1926. AND a.partner_companies_id =#{partnerCompaniesId}
  1927. </if>
  1928. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1929. AND a.partner_companies_name =#{partnerCompaniesName}
  1930. </if>
  1931. <if test="createTime !=null and createTime !=''">
  1932. AND a.create_time =#{createTime}
  1933. </if>
  1934. <if test="settlementTime !=null and settlementTime !=''">
  1935. AND a.settlement_time =#{settlementTime}
  1936. </if>
  1937. <if test="settlementDate !=null and settlementDate !=''">
  1938. AND a.settlement_time =#{settlementDate}
  1939. </if>
  1940. <if test="userId !=null and userId !=''">
  1941. and a.userId =#{userId}
  1942. </if>
  1943. <if test="companyId !=null and companyId !=''">
  1944. and a.company_id =#{companyId}
  1945. </if>
  1946. <if test="riskcode !=null and riskcode !=''">
  1947. and a.riskcode =#{riskcode}
  1948. </if>
  1949. <if test="year !=null and year !=''">
  1950. AND YEAR(a.signdate) =#{year}
  1951. </if>
  1952. <if test="month !=null and month !=''">
  1953. AND month(a.signdate) =#{month}
  1954. </if>
  1955. <if test="day !=null and day !=''">
  1956. AND day(a.signdate) =#{day}
  1957. </if>
  1958. <if test="insuredName !=null and insuredName !=''">
  1959. AND a.insured_name =#{insuredName}
  1960. </if>
  1961. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1962. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1963. </if>
  1964. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1965. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1966. </if>
  1967. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1968. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1969. </if>
  1970. </where>
  1971. group by pa.agreement_type
  1972. </select>
  1973. <select id="ptSumGroupByMonth" resultType="java.util.HashMap">
  1974. SELECT
  1975. DATE_FORMAT( a.signdate, '%m') as "month",
  1976. sum(a.all_fee_value) as "commissionFeevalue"
  1977. FROM
  1978. ins_ply_income a
  1979. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1980. LEFT JOIN sys_user su ON su.id = a.user_id
  1981. LEFT JOIN sys_user su1 ON su1.id = a.settlement_user_id
  1982. LEFT JOIN sys_user su2 ON su2.id = a.update_user_id
  1983. LEFT JOIN ins_upload_files upf ON a.settlement_image_id = upf.id
  1984. LEFT JOIN esm_ins_company eic ON eic.id = a.partner_companies_id
  1985. LEFT JOIN sys_dept b ON pa.dept_id = b.id
  1986. <where>
  1987. 1=1
  1988. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1989. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1990. </if>
  1991. <if test="agreementType !=null and agreementType !=''">
  1992. and pa.agreement_type =#{agreementType}
  1993. </if>
  1994. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1995. and a.signdate between #{signDateStart} and #{signDateEnd}
  1996. </if>
  1997. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1998. and a.handling_fees_status =#{handlingFeesStatus}
  1999. </if>
  2000. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  2001. and a.jq_receivable_proportion =#{jqReceivableProportion}
  2002. </if>
  2003. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  2004. and a.sy_receivable_proportion =#{syReceivableProportion}
  2005. </if>
  2006. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  2007. and a.no_receivable_proportion =#{noReceivableProportion}
  2008. </if>
  2009. <if test="id !=null and id !=''">
  2010. and a.id =#{id}
  2011. </if>
  2012. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  2013. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  2014. </if>
  2015. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  2016. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  2017. </if>
  2018. <if test="dockingPerson !=null and dockingPerson !=''">
  2019. and pa.docking_person =#{dockingPerson}
  2020. </if>
  2021. <if test="provinceId != null and provinceId != ''">
  2022. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  2023. </if>
  2024. <if test="cityId != null and cityId != ''">
  2025. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  2026. </if>
  2027. <if test="createTimeQuery != null and createTimeQuery != ''">
  2028. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  2029. </if>
  2030. <if test="countyId != null and countyId != ''">
  2031. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  2032. </if>
  2033. <if test="taskId != null and taskId != ''">
  2034. and a.task_id = #{taskId}
  2035. </if>
  2036. <if test="orderno !=null and orderno !=''">
  2037. and a.orderno =#{orderno}
  2038. </if>
  2039. <if test="companyName !=null and companyName !=''">
  2040. and a.company_id =#{companyName}
  2041. </if>
  2042. <if test="isExternal !=null and isExternal != ''">
  2043. AND pa.is_external =#{isExternal}
  2044. </if>
  2045. <if test="policyno !=null and policyno !=''">
  2046. and a.policyno =#{policyno}
  2047. </if>
  2048. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  2049. and a.documentary_fees_status =#{documentaryFeesStatus}
  2050. </if>
  2051. <if test="isNotCar !=null and isNotCar !=''">
  2052. and a.is_not_car =#{isNotCar}
  2053. </if>
  2054. <if test="deptId !=null and deptId !=''">
  2055. and pa.dept_id =#{deptId}
  2056. </if>
  2057. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  2058. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  2059. </if>
  2060. <if test="ids != null and ids != '' and ids.length > 0">
  2061. and a.id in
  2062. <foreach collection="ids" item="item" open="(" separator="," close=")">
  2063. #{item}
  2064. </foreach>
  2065. </if>
  2066. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  2067. and a.id in
  2068. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  2069. #{item}
  2070. </foreach>
  2071. </if>
  2072. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  2073. and a.id in
  2074. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  2075. #{item}
  2076. </foreach>
  2077. </if>
  2078. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  2079. and a.partner_companies_id in
  2080. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  2081. #{item}
  2082. </foreach>
  2083. </if>
  2084. <if test="isOther !=null and isOther !=''">
  2085. and a.is_not_documentary =#{isOther}
  2086. </if>
  2087. <if test="licenseno != null and licenseno != ''">
  2088. and a.licenseno =#{licenseno}
  2089. </if>
  2090. <if test="syPolicyno != null and syPolicyno != ''">
  2091. and a.sy_policyno =#{syPolicyno}
  2092. </if>
  2093. <if test="noPolicyno != null and noPolicyno != ''">
  2094. and a.no_policyno =#{noPolicyno}
  2095. </if>
  2096. <if test="signdate !=null and signdate !=''">
  2097. AND a.signdate =#{signdate}
  2098. </if>
  2099. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  2100. AND a.partner_companies_id =#{partnerCompaniesId}
  2101. </if>
  2102. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  2103. AND a.partner_companies_name =#{partnerCompaniesName}
  2104. </if>
  2105. <if test="createTime !=null and createTime !=''">
  2106. AND a.create_time =#{createTime}
  2107. </if>
  2108. <if test="settlementTime !=null and settlementTime !=''">
  2109. AND a.settlement_time =#{settlementTime}
  2110. </if>
  2111. <if test="settlementDate !=null and settlementDate !=''">
  2112. AND a.settlement_time =#{settlementDate}
  2113. </if>
  2114. <if test="userId !=null and userId !=''">
  2115. and a.userId =#{userId}
  2116. </if>
  2117. <if test="companyId !=null and companyId !=''">
  2118. and a.company_id =#{companyId}
  2119. </if>
  2120. <if test="riskcode !=null and riskcode !=''">
  2121. and a.riskcode =#{riskcode}
  2122. </if>
  2123. <if test="year !=null and year !=''">
  2124. AND YEAR(a.signdate) =#{year}
  2125. </if>
  2126. <if test="month !=null and month !=''">
  2127. AND month(a.signdate) =#{month}
  2128. </if>
  2129. <if test="day !=null and day !=''">
  2130. AND day(a.signdate) =#{day}
  2131. </if>
  2132. <if test="insuredName !=null and insuredName !=''">
  2133. AND a.insured_name =#{insuredName}
  2134. </if>
  2135. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  2136. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  2137. </if>
  2138. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  2139. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  2140. </if>
  2141. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  2142. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  2143. </if>
  2144. </where>
  2145. GROUP BY
  2146. DATE_FORMAT( a.signdate, '%m')
  2147. </select>
  2148. <select id="queryPage" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
  2149. SELECT
  2150. c.years AS yearAndMonth,
  2151. c.sumpremium AS sumpremium,
  2152. IFNULL( a.sumcount, 0 ) AS sumcount,
  2153. IFNULL( a.paid, 0 ) AS paid,
  2154. IFNULL( a.unpaid, 0 ) AS unpaid,
  2155. (IFNULL( a.sumcount, 0 ) - IFNULL( a.paid, 0 )) grossProfit,
  2156. IFNULL( b.labor_cost, 0 ) AS laborCost,
  2157. IFNULL( b.fixed_cost, 0 ) AS fixedCost,
  2158. IFNULL( b.variable_cost, 0 ) AS variableCost,
  2159. IFNULL( b.operating_profit, 0 ) AS operatingProfit,
  2160. IFNULL( b.taxation, 0 ) AS taxation,
  2161. IFNULL( b.net_profit, 0 ) AS netProfit
  2162. FROM
  2163. (
  2164. SELECT
  2165. DATE_FORMAT( createtime, '%Y-%m' ) AS years,
  2166. sum( sumpremium ) AS sumpremium
  2167. FROM
  2168. ins_area_company
  2169. <where>
  2170. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2171. AND signing_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2172. </if>
  2173. <if test="vo.days !=null and vo.days !='' ">
  2174. and signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2175. </if>
  2176. </where>
  2177. GROUP BY
  2178. DATE_FORMAT( signing_time, '%Y-%m' )
  2179. ORDER BY
  2180. DATE_FORMAT( signing_time, '%Y-%m' )
  2181. ) c
  2182. LEFT JOIN (
  2183. SELECT
  2184. DATE_FORMAT( create_time, '%Y-%m' ) AS years,
  2185. sum( all_fee_value ) AS sumcount,
  2186. SUM( CASE WHEN handling_fees_status = '2' THEN ifnull( invoic_amount, 0 ) ELSE 0 END ) AS paid,
  2187. SUM( CASE WHEN handling_fees_status != '2' THEN ifnull(( all_fee_value - ifnull( invoic_amount, 0 )), 0 ) ELSE 0 END ) AS unpaid
  2188. FROM
  2189. ins_ply_income
  2190. <where>
  2191. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2192. AND signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2193. </if>
  2194. <if test="vo.days !=null and vo.days !='' ">
  2195. and signdate >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2196. </if>
  2197. </where>
  2198. GROUP BY
  2199. DATE_FORMAT( signdate, '%Y-%m' )
  2200. ) a ON c.years = a.years
  2201. LEFT JOIN ins_labor_cost b ON a.years = b.year_and_month
  2202. </select>
  2203. <select id="queryDateByTypeSumAmount" resultType="java.math.BigDecimal">
  2204. select
  2205. IFNULL( sum(a.readyCommissionFeevalue),0) as "noSettlementAmount"
  2206. from (
  2207. SELECT
  2208. a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
  2209. FROM
  2210. (
  2211. SELECT
  2212. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  2213. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  2214. FROM
  2215. ins_ply_income a
  2216. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2217. <where>
  2218. pa.agreement_type = '2'
  2219. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2220. and a.is_not_car =#{vo.isNotCar}
  2221. </if>
  2222. </where>
  2223. GROUP BY
  2224. DATE_FORMAT( a.signdate, '%Y-%m' )
  2225. ) a
  2226. LEFT JOIN (
  2227. SELECT
  2228. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  2229. sum( a.settlement_amount ) AS "settCommAmount",
  2230. sum(a.remaining_amount) as "remainingAmount",
  2231. sum(a.total_amount) as "invoicComm"
  2232. FROM
  2233. sys_insurance_handling_settlement_month a
  2234. <where>
  2235. 1=1
  2236. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2237. and a.is_not_car =#{vo.isNotCar}
  2238. </if>
  2239. </where>
  2240. GROUP BY
  2241. DATE_FORMAT( a.signing_time, '%Y-%m' )
  2242. ) b ON a.subSigndate = b.subSigndate
  2243. left join (
  2244. 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"
  2245. from
  2246. settlement_documentary_fees a
  2247. where a.settlement_status='1'
  2248. and handling_fees_status ='1'
  2249. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2250. and a.is_not_car =#{vo.isNotCar}
  2251. </if>
  2252. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  2253. ) c on c.subSigndate=a.subSigndate
  2254. order by a.subSigndate
  2255. ) a
  2256. </select>
  2257. <select id="queryDateByType"
  2258. resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2259. SELECT
  2260. a.subSigndate as "yearAndMonth",
  2261. a.allAmount as "commissionFeevalue",
  2262. IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
  2263. IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
  2264. (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
  2265. a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
  2266. FROM
  2267. (
  2268. SELECT
  2269. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  2270. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  2271. FROM
  2272. ins_ply_income a
  2273. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2274. <where>
  2275. pa.agreement_type = '2'
  2276. <if test="vo.year !=null and vo.year !=''">
  2277. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2278. </if>
  2279. </where>
  2280. GROUP BY
  2281. DATE_FORMAT( a.signdate, '%Y-%m' )
  2282. ) a
  2283. LEFT JOIN (
  2284. SELECT
  2285. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  2286. sum( a.settlement_amount ) AS "settCommAmount",
  2287. sum(a.remaining_amount) as "remainingAmount",
  2288. sum(a.total_amount) as "invoicComm"
  2289. FROM
  2290. sys_insurance_handling_settlement_month a
  2291. <where>
  2292. <if test="vo.year !=null and vo.year !=''">
  2293. DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  2294. </if>
  2295. </where>
  2296. GROUP BY
  2297. DATE_FORMAT( a.signing_time, '%Y-%m' )
  2298. ) b ON a.subSigndate = b.subSigndate
  2299. left join (
  2300. 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"
  2301. from
  2302. settlement_documentary_fees a
  2303. <where>
  2304. a.settlement_status='1'
  2305. and handling_fees_status ='1'
  2306. <if test="vo.year !=null and vo.year !=''">
  2307. and DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  2308. </if>
  2309. </where>
  2310. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  2311. ) c on c.subSigndate=a.subSigndate
  2312. ORDER BY a.subSigndate
  2313. </select>
  2314. <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
  2315. SELECT
  2316. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
  2317. FROM
  2318. ins_ply_income a
  2319. LEFT JOIN
  2320. ptl_agreement pa ON pa.id = a.agreement_id
  2321. <where>
  2322. <if test="vo.type !=null and vo.type !=''">
  2323. and pa.agreement_type =#{vo.type}
  2324. </if>
  2325. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2326. AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2327. </if>
  2328. </where>
  2329. </select>
  2330. <select id="queryDateByTypeByMonth"
  2331. resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
  2332. SELECT
  2333. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
  2334. SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
  2335. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
  2336. FROM
  2337. ins_ply_income a
  2338. LEFT JOIN
  2339. ptl_agreement pa ON pa.id = a.agreement_id
  2340. <where>
  2341. 1=1
  2342. <if test="vo.type !=null and vo.type !=''">
  2343. and pa.agreement_type =#{vo.type}
  2344. </if>
  2345. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2346. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2347. </if>
  2348. <if test="vo.yearAndMonth != null and vo.yearAndMonth!=''">
  2349. AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
  2350. </if>
  2351. </where>
  2352. </select>
  2353. <select id="queryDateByTypeByMonthList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2354. SELECT
  2355. a.subPathner,
  2356. sa.area_cname as "areaName",
  2357. eic.namesimple as "companyName",
  2358. a.partnerCompaniesId as "partnerCompaniesId",
  2359. IFNULL(a.allAmount,0) as "commissionFeevalue",
  2360. a.companyId as "companyId",
  2361. IFNULL(b.noSettHandlingFee,0) as "settlementAmount",
  2362. IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0) as "noSettlementAmount",
  2363. (IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)) +IFNULL(b.noSettHandlingFee,0) as "noInvoicCommissionFeevalue",
  2364. "手续费" as "isHand",
  2365. IFNULL( b.settAmount,0) as "readyCommissionFeevalue"
  2366. FROM
  2367. (
  2368. SELECT
  2369. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2370. a.company_id AS "companyId",
  2371. a.partner_companies_id AS "partnerCompaniesId" ,
  2372. sum(a.commission_feevalue) as "allAmount"
  2373. FROM
  2374. ins_ply_income a
  2375. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2376. <where>
  2377. pa.agreement_type = '2'
  2378. AND a.is_not_documentary = '0'
  2379. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2380. and a.is_not_car =#{vo.isNoCar}
  2381. </if>
  2382. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2383. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2384. </if>
  2385. </where>
  2386. GROUP BY
  2387. a.partner_companies_id,
  2388. a.company_id
  2389. ) a
  2390. LEFT JOIN (
  2391. select
  2392. sum( a.invoicAmount ) AS "invoicAmount",
  2393. sum( a.noSettHandlingFee ) AS "noSettHandlingFee",
  2394. sum( a.settAmount ) AS "settAmount",
  2395. a.subPathner AS "subPathner"
  2396. from (
  2397. SELECT
  2398. sum( a.total_amount ) AS "invoicAmount",
  2399. sum( a.remaining_amount ) AS "noSettHandlingFee",
  2400. sum( a.settlement_amount ) AS "settAmount",
  2401. a.partner_companies_id AS "subPathner"
  2402. FROM
  2403. sys_insurance_handling_settlement_month a
  2404. <where>
  2405. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2406. and a.is_not_car =#{vo.isNoCar}
  2407. </if>
  2408. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2409. and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
  2410. </if>
  2411. </where>
  2412. GROUP BY
  2413. a.partner_companies_id,
  2414. DATE_FORMAT( a.signing_time, '%Y-%m' ),
  2415. a.task_id
  2416. ) a group by a.subPathner
  2417. ) b ON b.subPathner = a.partnerCompaniesId
  2418. LEFT JOIN esm_ins_company eic on eic.id = a.companyId
  2419. LEFT JOIN sys_area sa on sa.area_code = a.subPathner
  2420. </select>
  2421. <select id="queryDateByTypeByMonthOtherList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2422. SELECT
  2423. a.partner_companies_id,
  2424. sa.area_cname as "areaName",
  2425. eic.namesimple as "companyName",
  2426. sum(a.other_feevalue) as "commissionFeevalue",
  2427. IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
  2428. sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
  2429. IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "settlementAmount",
  2430. sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
  2431. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2432. "跟单费" as "isHand",
  2433. a.company_id AS "companyId"
  2434. FROM
  2435. ins_ply_income a
  2436. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2437. LEFT JOIN (
  2438. SELECT
  2439. a.partner_companies_id,
  2440. sum(a.invoiced_settled_amount) as "invoicedSettledAmount",
  2441. sum(a.Invoiced_not_settled_amount) as "invoicedNotSettledAmount"
  2442. FROM
  2443. settlement_documentary_fees a
  2444. <where>
  2445. a.handling_fees_status ='1'
  2446. AND settlement_status = '1'
  2447. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2448. and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
  2449. </if>
  2450. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2451. and a.is_not_car =#{vo.isNoCar}
  2452. </if>
  2453. </where>
  2454. GROUP BY
  2455. a.partner_companies_id
  2456. ) b on b.partner_companies_id =a.partner_companies_id
  2457. LEFT JOIN esm_ins_company eic on eic.id = a.company_Id
  2458. LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
  2459. <where>
  2460. pa.agreement_type = '2'
  2461. AND a.is_not_documentary = '1'
  2462. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2463. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2464. </if>
  2465. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2466. and a.is_not_car =#{vo.isNoCar}
  2467. </if>
  2468. </where>
  2469. group by
  2470. a.partner_companies_id,a.company_id,sa.area_cname
  2471. </select>
  2472. <select id="queryPlatHanding" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2473. SELECT
  2474. 1 as orderNumber,
  2475. '手续费' AS isHand,
  2476. sa.area_cname AS areaName,
  2477. eic.namesimple AS companyName,
  2478. a.partner_companies_id AS partnerCompaniesId,
  2479. SUM(a.commission_feevalue) AS commissionFeevalue,
  2480. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2481. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  2482. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2483. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2484. FROM
  2485. ins_ply_income a
  2486. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2487. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2488. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2489. <where>
  2490. pa.agreement_type = '1'
  2491. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2492. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2493. </if>
  2494. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2495. and a.is_not_car =#{vo.isNoCar}
  2496. </if>
  2497. </where>
  2498. GROUP BY
  2499. a.partner_companies_id, eic.namesimple, sa.area_cname
  2500. UNION ALL
  2501. SELECT
  2502. 2 as orderNumber,
  2503. '跟单费' AS isHand,
  2504. sa.area_cname AS areaName,
  2505. eic.namesimple AS companyName,
  2506. a.partner_companies_id AS partnerCompaniesId,
  2507. SUM(a.other_feevalue) AS commissionFeevalue,
  2508. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2509. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  2510. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2511. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2512. FROM
  2513. ins_ply_income a
  2514. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2515. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2516. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2517. <where>
  2518. pa.agreement_type = '1'
  2519. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2520. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2521. </if>
  2522. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2523. and a.is_not_car =#{vo.isNoCar}
  2524. </if>
  2525. </where>
  2526. GROUP BY
  2527. a.partner_companies_id, eic.namesimple, sa.area_cname
  2528. UNION ALL
  2529. SELECT
  2530. 3 as orderNumber,
  2531. '合计' AS isHand,
  2532. sa.area_cname AS areaName,
  2533. eic.namesimple AS companyName,
  2534. a.partner_companies_id AS partnerCompaniesId,
  2535. SUM(a.all_fee_value) AS commissionFeevalue,
  2536. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2537. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
  2538. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2539. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2540. FROM
  2541. ins_ply_income a
  2542. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2543. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2544. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2545. <where>
  2546. pa.agreement_type = '1'
  2547. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2548. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2549. </if>
  2550. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2551. and a.is_not_car =#{vo.isNoCar}
  2552. </if>
  2553. </where>
  2554. GROUP BY
  2555. a.partner_companies_id, eic.namesimple, sa.area_cname
  2556. ORDER BY
  2557. companyName,
  2558. areaName,
  2559. orderNumber;
  2560. </select>
  2561. <select id="queryPrivateCar" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2562. SELECT
  2563. a.subSigndate as "yearAndMonth",
  2564. a.allAmount as "commissionFeevalue",
  2565. IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
  2566. IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
  2567. (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
  2568. a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
  2569. FROM
  2570. (
  2571. SELECT
  2572. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  2573. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  2574. FROM
  2575. ins_ply_income a
  2576. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2577. <where>
  2578. pa.agreement_type = '2'
  2579. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2580. and a.is_not_car =#{vo.isNotCar}
  2581. </if>
  2582. </where>
  2583. GROUP BY
  2584. DATE_FORMAT( a.signdate, '%Y-%m' )
  2585. ) a
  2586. LEFT JOIN (
  2587. SELECT
  2588. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  2589. sum( a.settlement_amount ) AS "settCommAmount",
  2590. sum(a.remaining_amount) as "remainingAmount",
  2591. sum(a.total_amount) as "invoicComm"
  2592. FROM
  2593. sys_insurance_handling_settlement_month a
  2594. <where>
  2595. 1=1
  2596. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2597. and a.is_not_car =#{vo.isNotCar}
  2598. </if>
  2599. </where>
  2600. GROUP BY
  2601. DATE_FORMAT( a.signing_time, '%Y-%m' )
  2602. ) b ON a.subSigndate = b.subSigndate
  2603. left join (
  2604. 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"
  2605. from
  2606. settlement_documentary_fees a
  2607. where a.settlement_status='1'
  2608. and handling_fees_status ='1'
  2609. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2610. and a.is_not_car =#{vo.isNotCar}
  2611. </if>
  2612. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  2613. ) c on c.subSigndate=a.subSigndate
  2614. order by a.subSigndate
  2615. </select>
  2616. <select id="getProfitAnalysisQueryList" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
  2617. SELECT
  2618. a.signingTime as "yearAndMonth",
  2619. IFNULL(a.sumpremium,0) as "sumpremium",
  2620. IFNULL(b.allAmount,0) as "sumcount",
  2621. IFNULL(d.settlement,0) as "meet",
  2622. IFNULL(c.actualPayment,0) as "paid",
  2623. ifnull(d.settlement,0) - IFNULL(c.actualPayment,0) as "unpaid",
  2624. IFNULL(b.allAmount,0)- IFNULL (d.settlement,0) as "grossProfit",
  2625. IFNULL(e.applyAmount,0) as "laborCost",
  2626. IFNULL(f.applyAmount,0) as "fixedCost",
  2627. IFNULL(j.applyAmount,0) as "variableCost",
  2628. (IFNULL (b.allAmount,0) - IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) as "operatingProfit",
  2629. IFNULL(g.applyAmount,0) as "taxation",
  2630. (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"
  2631. FROM
  2632. (
  2633. SELECT
  2634. IFNULL(sum( iac.jqpremium ),0) +IFNULL(sum( iac.sypremium ),0) + IFNULL(sum(iac.jypremium),0) as "sumpremium",
  2635. DATE_FORMAT( iac.signing_time, '%Y-%m' ) AS "signingTime"
  2636. FROM
  2637. `ins_fee_audit` ifa
  2638. LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
  2639. <where>
  2640. ifa.auditstatus = '1'
  2641. AND iac.signing_time IS NOT NULL
  2642. <if test="vo.year !=null and vo.year !=''">
  2643. and DATE_FORMAT( iac.signing_time, '%Y') =#{vo.year}
  2644. </if>
  2645. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2646. AND iac.signing_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2647. </if>
  2648. <if test="vo.days !=null and vo.days !='' ">
  2649. and iac.signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2650. </if>
  2651. </where>
  2652. GROUP BY
  2653. DATE_FORMAT( iac.signing_time, '%Y-%m' )
  2654. ) a
  2655. LEFT JOIN (
  2656. SELECT
  2657. sum( ipi.commission_feevalue) + sum(ipi.other_feevalue ) as "allAmount",
  2658. DATE_FORMAT( ipi.signdate, '%Y-%m' ) AS "signingTime"
  2659. FROM
  2660. ins_ply_income ipi
  2661. <where>
  2662. 1=1
  2663. </where>
  2664. GROUP BY
  2665. DATE_FORMAT( ipi.signdate, '%Y-%m' )
  2666. ) b ON a.signingTime = b.signingTime
  2667. left join (
  2668. select
  2669. sum(a.amount) as "actualPayment",DATE_FORMAT( a.auditing_time, '%Y-%m' ) as "auditingTime"
  2670. from sys_amount_auditing a
  2671. left join sys_user_account_history b on a.id = b.auditiing_id
  2672. left join sys_user su on su.id =a.user_id
  2673. <where>
  2674. a.auditing_status= '3'
  2675. </where>
  2676. GROUP BY DATE_FORMAT( a.auditing_time, '%Y-%m' )
  2677. ) c on c.auditingTime =a.signingTime
  2678. left join (
  2679. SELECT
  2680. sum(
  2681. 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
  2682. ) AS "settlement",
  2683. DATE_FORMAT( iac.signing_time, '%Y-%m' ) as "signingTime"
  2684. FROM
  2685. ins_fee_order_new ifo
  2686. LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
  2687. LEFT JOIN ins_area_company iac ON ifa.ins_order_no = iac.id
  2688. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  2689. <where>
  2690. ifa.auditstatus = '1'
  2691. AND iac.orderstatus = '3'
  2692. AND io.orderstatus = '3'
  2693. </where>
  2694. GROUP BY
  2695. DATE_FORMAT( iac.signing_time, '%Y-%m' )
  2696. ) d on d.signingTime =a.signingTime
  2697. left join (
  2698. SELECT
  2699. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2700. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2701. b.expenditureDetails
  2702. FROM
  2703. inv_account_operate a
  2704. left join (
  2705. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2706. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2707. where b.category is not null
  2708. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2709. <where>
  2710. a.out_card_num IN (
  2711. SELECT
  2712. bank_card_num
  2713. FROM
  2714. inv_account_card iac
  2715. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2716. WHERE
  2717. ia.del_flag = '0'
  2718. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2719. )
  2720. AND a.revenue_outlay = '1'
  2721. AND a.del_flag = '0'
  2722. AND b.expenditureDetails = '1'
  2723. </where>
  2724. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2725. ) e on e.createTime =a.signingTime
  2726. left join (
  2727. SELECT
  2728. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2729. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2730. b.expenditureDetails
  2731. FROM
  2732. inv_account_operate a
  2733. left join (
  2734. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails"
  2735. from inv_account_expenses a
  2736. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2737. where b.category is not null
  2738. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2739. <where>
  2740. a.out_card_num IN (
  2741. SELECT
  2742. bank_card_num
  2743. FROM
  2744. inv_account_card iac
  2745. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2746. WHERE
  2747. ia.del_flag = '0'
  2748. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2749. )
  2750. AND a.revenue_outlay = '1'
  2751. AND a.del_flag = '0'
  2752. AND b.expenditureDetails = '2'
  2753. </where>
  2754. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2755. ) f on f.createTime =a.signingTime
  2756. left join (
  2757. SELECT
  2758. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2759. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2760. b.expenditureDetails
  2761. FROM
  2762. inv_account_operate a
  2763. left join (
  2764. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2765. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2766. where b.category is not null
  2767. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2768. <where>
  2769. a.out_card_num IN (
  2770. SELECT
  2771. bank_card_num
  2772. FROM
  2773. inv_account_card iac
  2774. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2775. WHERE
  2776. ia.del_flag = '0'
  2777. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2778. )
  2779. AND a.revenue_outlay = '1'
  2780. AND a.del_flag = '0'
  2781. AND b.expenditureDetails = '3'
  2782. </where>
  2783. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2784. ) j on j.createTime =a.signingTime
  2785. left join (
  2786. SELECT
  2787. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2788. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2789. b.expenditureDetails
  2790. FROM
  2791. inv_account_operate a
  2792. left join (
  2793. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2794. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2795. where b.category is not null
  2796. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2797. <where>
  2798. a.out_card_num IN (
  2799. SELECT
  2800. bank_card_num
  2801. FROM
  2802. inv_account_card iac
  2803. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2804. WHERE
  2805. ia.del_flag = '0'
  2806. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2807. )
  2808. AND a.revenue_outlay = '1'
  2809. AND a.del_flag = '0'
  2810. AND b.expenditureDetails = '4'
  2811. </where>
  2812. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2813. ) g on g.createTime =a.signingTime
  2814. </select>
  2815. <select id="changeAmount" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
  2816. SELECT
  2817. a.apply_amount as "applyAmount",
  2818. a.enter_card_num as "enterCardNum",
  2819. a.out_card_num as "outCardNum",
  2820. b.expensesId as "expensesId",
  2821. b.category as "category",
  2822. b.parentId as "parentId"
  2823. FROM
  2824. inv_account_operate a
  2825. left join (
  2826. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" ,
  2827. a.expenses_id as "expensesId",a.category as "category",a.parent_id as "parentId"
  2828. from inv_account_expenses a
  2829. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2830. where b.category is not null
  2831. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2832. where
  2833. a.out_card_num IN (
  2834. SELECT
  2835. bank_card_num
  2836. FROM
  2837. inv_account_card iac
  2838. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2839. WHERE
  2840. ia.del_flag = '0'
  2841. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2842. )
  2843. AND a.del_flag = '0'
  2844. AND b.expenditureDetails = '3'
  2845. AND a.revenue_outlay = '0'
  2846. <if test="vo.yearAndMonth != null and vo.yearAndMonth !=''">
  2847. AND DATE_FORMAT( a.create_time, '%Y-%m' ) =#{vo.yearAndMonth}
  2848. </if>
  2849. </select>
  2850. <select id="getInvociAmount" resultType="com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto" >
  2851. select
  2852. DATE_FORMAT( a.signdate, '%Y-%m' ) as "incomeSigningTime",
  2853. a.task_id as "taskId",
  2854. sum(a.commission_feevalue) as "totalAmount"
  2855. from ins_ply_income a
  2856. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  2857. LEFT JOIN sys_user su on su.id=a.user_id
  2858. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  2859. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  2860. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  2861. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  2862. LEFT JOIN sys_dept b on pa.dept_id=b.id
  2863. <where>
  2864. 1=1
  2865. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2866. and a.is_not_car =#{vo.isNotCar}
  2867. </if>
  2868. <if test="vo.isNotDocumentary !=null and vo.isNotDocumentary !=''">
  2869. and a.is_not_documentary =#{vo.isNotDocumentary}
  2870. </if>
  2871. <if test="vo.taskId != null and vo.taskId != ''">
  2872. and a.task_id = #{vo.taskId}
  2873. </if>
  2874. </where>
  2875. group by a.task_id , DATE_FORMAT( a.signdate, '%Y-%m' )
  2876. </select>
  2877. <select id="queryDateByTypePt" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2878. SELECT IFNULL(a.signingTime, 0) as "yearAndMonth",
  2879. IFNULL(a.allAmount, 0) as "commissionFeevalue",
  2880. IFNULL(c.settAmount, 0) as "noInvoicCommissionFeevalue",
  2881. IFNULL(b.notInvoicAmount, 0) as "noSettlementAmount",
  2882. IFNULL(c.settAmount, 0) as "readyCommissionFeevalue"
  2883. FROM (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "allAmount",
  2884. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2885. FROM ins_ply_income a
  2886. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2887. <where>
  2888. pa.agreement_type = '1'
  2889. <if test="vo.year !=null and vo.year !=''">
  2890. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2891. </if>
  2892. </where>
  2893. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) a
  2894. left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount",
  2895. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2896. FROM ins_ply_income a
  2897. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2898. <where>
  2899. pa.agreement_type = '1'
  2900. and a.handling_fees_status = '0'
  2901. <if test="vo.year !=null and vo.year !=''">
  2902. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2903. </if>
  2904. </where>
  2905. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) b on a.signingTime = b.signingTime
  2906. left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "settAmount",
  2907. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2908. FROM ins_ply_income a
  2909. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2910. <where>
  2911. pa.agreement_type = '1'
  2912. and a.handling_fees_status = '1'
  2913. <if test="vo.year !=null and vo.year !=''">
  2914. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2915. </if>
  2916. </where>
  2917. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) c on c.signingTime = a.signingTime
  2918. ORDER BY IFNULL( a.signingTime, 0 )
  2919. </select>
  2920. <select id="getPatherId" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2921. SELECT
  2922. sa.area_cname as "areaName",
  2923. eic.namesimple as "companyName",
  2924. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2925. a.company_id AS "companyId",
  2926. a.partner_companies_id AS "partnerCompaniesId"
  2927. FROM
  2928. ins_ply_income a
  2929. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2930. LEFT JOIN esm_ins_company eic on eic.id = a.company_id
  2931. LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
  2932. <where>
  2933. <if test="vo.type !=null and vo.type!=''">
  2934. pa.agreement_type =#{vo.type}
  2935. </if>
  2936. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2937. and a.is_not_car =#{vo.isNoCar}
  2938. </if>
  2939. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2940. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2941. </if>
  2942. </where>
  2943. GROUP BY
  2944. a.partner_companies_id,
  2945. a.company_id,
  2946. eic.namesimple,
  2947. sa.area_cname
  2948. </select>
  2949. <select id="totalBxAmountNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  2950. select
  2951. a.companyId as "companyId",
  2952. a.companyName as "companyName",
  2953. a.partnerCompaniesName as "partnerCompaniesName",
  2954. a.partner_companies_id as "partnerCompaniesId",
  2955. IFNULL(a.allInvoicCommissionFeevalue,0) AS "allInvoicCommissionFeevalue",
  2956. IFNULL(a.commissionFeevalue,0) as "commissionFeevalue",
  2957. IFNULL(b.settlementAmount,0) as "readyCommissionFeevalue",
  2958. IFNULL(a.allInvoicCommissionFeevalue,0) -IFNULL(b.settlementAmount,0) as "invoicCommissionFeevalue",
  2959. IFNULL(a.commissionFeevalue,0) - IFNULL(a.allInvoicCommissionFeevalue,0) as "noInvoicCommissionFeevalue",
  2960. (IFNULL(a.allInvoicCommissionFeevalue,0) -IFNULL(b.settlementAmount,0)) +(IFNULL(a.commissionFeevalue,0) - IFNULL(a.allInvoicCommissionFeevalue,0)) as "unSettledAmount",
  2961. CASE WHEN IFNULL( a.allInvoicCommissionFeevalue, 0 ) = IFNULL( b.settlementAmount, 0 ) THEN '1' ELSE 0 END as "status"
  2962. from (
  2963. select a.partner_companies_id,
  2964. sum(a.commission_feevalue) as "commissionFeevalue",
  2965. SUM(CASE WHEN a.handling_fees_status != '0' and a.task_id is not null THEN IFNULL(a.commission_feevalue, 0) ELSE 0 END) AS "allInvoicCommissionFeevalue",
  2966. MAX( a.company_name ) AS "companyName",
  2967. MAX( a.company_id ) AS "companyId",
  2968. MAX( a.partner_companies_name ) AS "partnerCompaniesName"
  2969. from ins_ply_income a
  2970. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2971. LEFT JOIN esm_ins_company eic on eic.id = a.partner_companies_id
  2972. <where>
  2973. 1=1
  2974. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  2975. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  2976. </if>
  2977. <if test="agreementType !=null and agreementType !=''">
  2978. and pa.agreement_type =#{agreementType}
  2979. </if>
  2980. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  2981. and a.signdate between #{signDateStart} and #{signDateEnd}
  2982. </if>
  2983. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  2984. and a.handling_fees_status =#{handlingFeesStatus}
  2985. </if>
  2986. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  2987. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  2988. </if>
  2989. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  2990. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  2991. </if>
  2992. <if test="createTimeStart !=null and createTimeStart != '' and createTimeEnd != null and createTimeEnd !=''">
  2993. AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
  2994. </if>
  2995. <if test="dockingPerson !=null and dockingPerson !=''">
  2996. and pa.docking_person =#{dockingPerson}
  2997. </if>
  2998. <if test="provinceId != null and provinceId != ''">
  2999. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  3000. </if>
  3001. <if test="cityId != null and cityId != ''">
  3002. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  3003. </if>
  3004. <if test="countyId != null and countyId != ''">
  3005. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  3006. </if>
  3007. <if test="taskId != null and taskId != ''">
  3008. and a.task_id = #{taskId}
  3009. </if>
  3010. <if test="orderno !=null and orderno !=''">
  3011. and a.orderno =#{orderno}
  3012. </if>
  3013. <if test="companyName !=null and companyName !=''">
  3014. and a.company_id =#{companyName}
  3015. </if>
  3016. <if test="isExternal !=null and isExternal != ''">
  3017. AND pa.is_external =#{isExternal}
  3018. </if>
  3019. <if test="policyno !=null and policyno !=''">
  3020. and a.policyno =#{policyno}
  3021. </if>
  3022. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  3023. and a.documentary_fees_status =#{documentaryFeesStatus}
  3024. </if>
  3025. <if test="createTimeQuery != null and createTimeQuery != ''">
  3026. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  3027. </if>
  3028. <if test="isNotCar !=null and isNotCar !=''">
  3029. and a.is_not_car =#{isNotCar}
  3030. </if>
  3031. <if test="deptId !=null and deptId !=''">
  3032. and pa.dept_id =#{deptId}
  3033. </if>
  3034. <if test="ids != null and ids != '' and ids.length > 0">
  3035. and a.id in
  3036. <foreach collection="ids" item="item" open="(" separator="," close=")">
  3037. #{item}
  3038. </foreach>
  3039. </if>
  3040. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  3041. and a.id in
  3042. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  3043. #{item}
  3044. </foreach>
  3045. </if>
  3046. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  3047. and a.id in
  3048. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  3049. #{item}
  3050. </foreach>
  3051. </if>
  3052. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  3053. and a.partner_companies_id in
  3054. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  3055. #{item}
  3056. </foreach>
  3057. </if>
  3058. <if test="isOther !=null and isOther !=''">
  3059. and a.is_not_documentary =#{isOther}
  3060. </if>
  3061. <if test="licenseno != null and licenseno != ''">
  3062. and a.licenseno =#{licenseno}
  3063. </if>
  3064. <if test="syPolicyno != null and syPolicyno != ''">
  3065. and a.sy_policyno =#{syPolicyno}
  3066. </if>
  3067. <if test="noPolicyno != null and noPolicyno != ''">
  3068. and a.no_policyno =#{noPolicyno}
  3069. </if>
  3070. <if test="signdate !=null and signdate !=''">
  3071. AND a.signdate =#{signdate}
  3072. </if>
  3073. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  3074. AND a.partner_companies_id =#{partnerCompaniesId}
  3075. </if>
  3076. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  3077. AND a.partner_companies_name =#{partnerCompaniesName}
  3078. </if>
  3079. <if test="createTime !=null and createTime !=''">
  3080. AND a.create_time =#{createTime}
  3081. </if>
  3082. <if test="settlementTime !=null and settlementTime !=''">
  3083. AND a.settlement_time =#{settlementTime}
  3084. </if>
  3085. <if test="userId !=null and userId !=''">
  3086. and a.userId =#{userId}
  3087. </if>
  3088. <if test="companyId !=null and companyId !=''">
  3089. and a.company_id =#{companyId}
  3090. </if>
  3091. <if test="riskcode !=null and riskcode !=''">
  3092. and a.riskcode =#{riskcode}
  3093. </if>
  3094. <if test="year !=null and year !=''">
  3095. AND YEAR(a.signdate) =#{year}
  3096. </if>
  3097. <if test="month !=null and month !=''">
  3098. AND month(a.signdate) =#{month}
  3099. </if>
  3100. <if test="day !=null and day !=''">
  3101. AND day(a.signdate) =#{day}
  3102. </if>
  3103. <if test="insuredName !=null and insuredName !=''">
  3104. AND a.insured_name =#{insuredName}
  3105. </if>
  3106. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  3107. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  3108. </if>
  3109. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  3110. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  3111. </if>
  3112. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  3113. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  3114. </if>
  3115. </where>
  3116. group by a.partner_companies_id) a
  3117. left join (select sum(settlement_amount) as "settlementAmount",
  3118. a.partner_companies_id
  3119. from sys_insurance_handling_settlement_month a
  3120. <where>
  3121. 1=1
  3122. <if test="year !=null and year !=''">
  3123. AND YEAR(a.signing_time) =#{year}
  3124. </if>
  3125. <if test="month !=null and month !=''">
  3126. AND month(a.signing_time) =#{month}
  3127. </if>
  3128. <if test="day !=null and day !=''">
  3129. AND day(a.signing_time) =#{day}
  3130. </if>
  3131. <if test="isNotCar !=null and isNotCar !=''">
  3132. and a.is_not_car =#{isNotCar}
  3133. </if>
  3134. </where>
  3135. group by a.partner_companies_id) b on b.partner_companies_id = a.partner_companies_id
  3136. <where>
  3137. <if test="status !=null and status !=''">
  3138. <choose>
  3139. <when test="status==0">
  3140. and IFNULL(a.allInvoicCommissionFeevalue,0) != IFNULL(b.settlementAmount,0)
  3141. </when>
  3142. <when test="status==1">
  3143. and IFNULL(a.allInvoicCommissionFeevalue,0) = IFNULL(b.settlementAmount,0)
  3144. </when>
  3145. </choose>
  3146. </if>
  3147. </where>
  3148. </select>
  3149. <select id="totalPTAmount" resultType="com.ydtech.modules.fnc.dto.InsPlyIncomePTDto">
  3150. SELECT
  3151. pa.docking_person AS "dockingPerson",
  3152. sum( a.all_fee_value ) AS "sumAmount",
  3153. sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) ysAmount,
  3154. sum( a.all_fee_value ) - sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) wsAmount
  3155. FROM
  3156. ins_ply_income a
  3157. LEFT JOIN esm_ins_company ec ON ec.id = a.company_id
  3158. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  3159. <where>
  3160. pa.agreement_type = 1
  3161. AND a.is_not_car = '0'
  3162. <if test="vo.dockingPerson !=null and vo.dockingPerson !=''">
  3163. and pa.docking_person =#{vo.dockingPerson}
  3164. </if>
  3165. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  3166. AND date(a.signdate) BETWEEN #{vo.beginDate} AND #{vo.endDate}
  3167. </if>
  3168. </where>
  3169. GROUP BY
  3170. pa.docking_person
  3171. order by sum( a.all_fee_value ) - sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) desc
  3172. </select>
  3173. <select id="findListByDockingPerson" resultType="com.ydtech.modules.fnc.dto.InsPlyIncomePTCompanyDto">
  3174. select
  3175. a.company_name AS "companyName",
  3176. a.partner_companies_name AS "partnerCompaniesName",
  3177. sum( a.all_fee_value ) AS "sumAmount",
  3178. sum( CASE WHEN a.handling_fees_status = 1 THEN a.all_fee_value ELSE 0 END ) ysAmount,
  3179. sum( a.all_fee_value ) - sum( CASE WHEN a.handling_fees_status = 1 THEN a.all_fee_value ELSE 0 END ) wsAmount
  3180. from ins_ply_income a
  3181. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  3182. <where>
  3183. pa.agreement_type = 1
  3184. AND a.is_not_car = '0'
  3185. <if test="vo.dockingPerson !=null and vo.dockingPerson !=''">
  3186. and pa.docking_person =#{vo.dockingPerson}
  3187. </if>
  3188. </where>
  3189. GROUP BY
  3190. a.company_name,
  3191. a.partner_companies_name,
  3192. pa.docking_person
  3193. order by sum( a.all_fee_value ) - sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) desc
  3194. </select>
  3195. <select id="queryDateByNotTypeSumAmount" resultType="java.math.BigDecimal">
  3196. select IFNULL(sum(a.noSettlementAmount),0) as "sySumAmount"
  3197. from (
  3198. SELECT
  3199. (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount"
  3200. FROM
  3201. (
  3202. SELECT
  3203. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  3204. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  3205. FROM
  3206. ins_ply_income a
  3207. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  3208. <where>
  3209. pa.agreement_type = '2'
  3210. <if test="vo.year !=null and vo.year !=''">
  3211. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  3212. </if>
  3213. </where>
  3214. GROUP BY
  3215. DATE_FORMAT( a.signdate, '%Y-%m' )
  3216. ) a
  3217. LEFT JOIN (
  3218. SELECT
  3219. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  3220. sum( a.settlement_amount ) AS "settCommAmount",
  3221. sum(a.remaining_amount) as "remainingAmount",
  3222. sum(a.total_amount) as "invoicComm"
  3223. FROM
  3224. sys_insurance_handling_settlement_month a
  3225. <where>
  3226. <if test="vo.year !=null and vo.year !=''">
  3227. DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  3228. </if>
  3229. </where>
  3230. GROUP BY
  3231. DATE_FORMAT( a.signing_time, '%Y-%m' )
  3232. ) b ON a.subSigndate = b.subSigndate
  3233. left join (
  3234. 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"
  3235. from
  3236. settlement_documentary_fees a
  3237. <where>
  3238. a.settlement_status='1'
  3239. and handling_fees_status ='1'
  3240. <if test="vo.year !=null and vo.year !=''">
  3241. and DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  3242. </if>
  3243. </where>
  3244. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  3245. ) c on c.subSigndate=a.subSigndate
  3246. ORDER BY a.subSigndate
  3247. ) a
  3248. </select>
  3249. <select id="queryDateByTypeNotSumAmount" resultType="java.math.BigDecimal">
  3250. SELECT
  3251. IFNULL(a.notInvoicAmount, 0) as "noSettlementAmount"
  3252. FROM (
  3253. SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount"
  3254. FROM ins_ply_income a
  3255. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  3256. <where>
  3257. pa.agreement_type = '1'
  3258. and a.handling_fees_status = '0'
  3259. <if test="vo.year !=null and vo.year !=''">
  3260. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  3261. </if>
  3262. </where>
  3263. ) a
  3264. </select>
  3265. </mapper>