InsPlyIncomeMapper.xml 164 KB

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