InsPlyIncomeMapper.xml 156 KB

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