InsPlyIncomeMapper.xml 140 KB

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