InsPlyIncomeMapper.xml 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173
  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 signing_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2165. </if>
  2166. <if test="vo.days !=null and vo.days !='' ">
  2167. and signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2168. </if>
  2169. </where>
  2170. GROUP BY
  2171. DATE_FORMAT( signing_time, '%Y-%m' )
  2172. ORDER BY
  2173. DATE_FORMAT( signing_time, '%Y-%m' )
  2174. ) c
  2175. LEFT JOIN (
  2176. SELECT
  2177. DATE_FORMAT( create_time, '%Y-%m' ) AS years,
  2178. sum( all_fee_value ) AS sumcount,
  2179. SUM( CASE WHEN handling_fees_status = '2' THEN ifnull( invoic_amount, 0 ) ELSE 0 END ) AS paid,
  2180. SUM( CASE WHEN handling_fees_status != '2' THEN ifnull(( all_fee_value - ifnull( invoic_amount, 0 )), 0 ) ELSE 0 END ) AS unpaid
  2181. FROM
  2182. ins_ply_income
  2183. <where>
  2184. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2185. AND signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2186. </if>
  2187. <if test="vo.days !=null and vo.days !='' ">
  2188. and signdate >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2189. </if>
  2190. </where>
  2191. GROUP BY
  2192. DATE_FORMAT( signdate, '%Y-%m' )
  2193. ) a ON c.years = a.years
  2194. LEFT JOIN ins_labor_cost b ON a.years = b.year_and_month
  2195. </select>
  2196. <select id="queryDateByTypeSumAmount" resultType="java.math.BigDecimal">
  2197. SELECT
  2198. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
  2199. FROM
  2200. ins_ply_income a
  2201. LEFT JOIN
  2202. ptl_agreement pa ON pa.id = a.agreement_id
  2203. <where>
  2204. <if test="vo.type !=null and vo.type !=''">
  2205. and pa.agreement_type =#{vo.type}
  2206. </if>
  2207. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2208. and a.is_not_car =#{vo.isNotCar}
  2209. </if>
  2210. <if test="vo.year !=null and vo.year !=''">
  2211. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2212. </if>
  2213. </where>
  2214. </select>
  2215. <select id="queryDateByType"
  2216. resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2217. SELECT
  2218. a.subSigndate as "yearAndMonth",
  2219. a.allAmount as "commissionFeevalue",
  2220. IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
  2221. IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
  2222. (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
  2223. a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
  2224. FROM
  2225. (
  2226. SELECT
  2227. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  2228. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  2229. FROM
  2230. ins_ply_income a
  2231. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2232. <where>
  2233. pa.agreement_type = '2'
  2234. <if test="vo.year !=null and vo.year !=''">
  2235. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2236. </if>
  2237. </where>
  2238. GROUP BY
  2239. DATE_FORMAT( a.signdate, '%Y-%m' )
  2240. ) a
  2241. LEFT JOIN (
  2242. SELECT
  2243. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  2244. sum( a.settlement_amount ) AS "settCommAmount",
  2245. sum(a.remaining_amount) as "remainingAmount",
  2246. sum(a.total_amount) as "invoicComm"
  2247. FROM
  2248. sys_insurance_handling_settlement_month a
  2249. <where>
  2250. <if test="vo.year !=null and vo.year !=''">
  2251. DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  2252. </if>
  2253. </where>
  2254. GROUP BY
  2255. DATE_FORMAT( a.signing_time, '%Y-%m' )
  2256. ) b ON a.subSigndate = b.subSigndate
  2257. left join (
  2258. select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
  2259. from
  2260. settlement_documentary_fees a
  2261. <where>
  2262. a.settlement_status='1'
  2263. and handling_fees_status ='1'
  2264. <if test="vo.year !=null and vo.year !=''">
  2265. and DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
  2266. </if>
  2267. </where>
  2268. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  2269. ) c on c.subSigndate=a.subSigndate
  2270. </select>
  2271. <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
  2272. SELECT
  2273. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
  2274. FROM
  2275. ins_ply_income a
  2276. LEFT JOIN
  2277. ptl_agreement pa ON pa.id = a.agreement_id
  2278. <where>
  2279. <if test="vo.type !=null and vo.type !=''">
  2280. and pa.agreement_type =#{vo.type}
  2281. </if>
  2282. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2283. AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2284. </if>
  2285. </where>
  2286. </select>
  2287. <select id="queryDateByTypeByMonth"
  2288. resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
  2289. SELECT
  2290. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
  2291. SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
  2292. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
  2293. FROM
  2294. ins_ply_income a
  2295. LEFT JOIN
  2296. ptl_agreement pa ON pa.id = a.agreement_id
  2297. <where>
  2298. 1=1
  2299. <if test="vo.type !=null and vo.type !=''">
  2300. and pa.agreement_type =#{vo.type}
  2301. </if>
  2302. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2303. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2304. </if>
  2305. <if test="vo.yearAndMonth != null and vo.yearAndMonth!=''">
  2306. AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
  2307. </if>
  2308. </where>
  2309. </select>
  2310. <select id="queryDateByTypeByMonthList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2311. SELECT
  2312. a.subPathner,
  2313. sa.area_cname as "areaName",
  2314. eic.namesimple as "companyName",
  2315. a.partnerCompaniesId as "partnerCompaniesId",
  2316. IFNULL(a.allAmount,0) as "commissionFeevalue",
  2317. a.companyId as "companyId",
  2318. IFNULL(b.noSettHandlingFee,0) as "settlementAmount",
  2319. IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0) as "noSettlementAmount",
  2320. (IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)) +IFNULL(b.noSettHandlingFee,0) as "noInvoicCommissionFeevalue",
  2321. "手续费" as "isHand",
  2322. IFNULL( b.settAmount,0) as "readyCommissionFeevalue"
  2323. FROM
  2324. (
  2325. SELECT
  2326. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2327. a.company_id AS "companyId",
  2328. a.partner_companies_id AS "partnerCompaniesId" ,
  2329. sum(a.commission_feevalue) as "allAmount"
  2330. FROM
  2331. ins_ply_income a
  2332. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2333. <where>
  2334. pa.agreement_type = '2'
  2335. AND a.is_not_documentary = '0'
  2336. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2337. and a.is_not_car =#{vo.isNoCar}
  2338. </if>
  2339. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2340. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2341. </if>
  2342. </where>
  2343. GROUP BY
  2344. a.partner_companies_id,
  2345. a.company_id
  2346. ) a
  2347. LEFT JOIN (
  2348. SELECT
  2349. sum( a.total_amount ) AS "invoicAmount",
  2350. sum( a.remaining_amount ) AS "noSettHandlingFee",
  2351. sum( a.settlement_amount ) AS "settAmount",
  2352. a.task_id AS "taskId",
  2353. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigne",
  2354. a.partner_companies_id AS "subPathner"
  2355. FROM
  2356. sys_insurance_handling_settlement_month a
  2357. <where>
  2358. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2359. and a.is_not_car =#{vo.isNoCar}
  2360. </if>
  2361. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2362. and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
  2363. </if>
  2364. </where>
  2365. GROUP BY
  2366. a.partner_companies_id,
  2367. DATE_FORMAT( a.signing_time, '%Y-%m' ),
  2368. a.task_id
  2369. ) b ON b.subPathner = a.partnerCompaniesId
  2370. LEFT JOIN esm_ins_company eic on eic.id = a.companyId
  2371. LEFT JOIN sys_area sa on sa.area_code = a.subPathner
  2372. </select>
  2373. <select id="queryDateByTypeByMonthOtherList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2374. SELECT
  2375. a.partner_companies_id,
  2376. sa.area_cname as "areaName",
  2377. eic.namesimple as "companyName",
  2378. sum(a.other_feevalue) as "commissionFeevalue",
  2379. IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
  2380. sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
  2381. IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "settlementAmount",
  2382. sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
  2383. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2384. "跟单费" as "isHand",
  2385. a.company_id AS "companyId"
  2386. FROM
  2387. ins_ply_income a
  2388. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2389. LEFT JOIN (
  2390. SELECT
  2391. a.partner_companies_id,
  2392. sum(a.invoiced_settled_amount) as "invoicedSettledAmount",
  2393. sum(a.Invoiced_not_settled_amount) as "invoicedNotSettledAmount"
  2394. FROM
  2395. settlement_documentary_fees a
  2396. <where>
  2397. a.handling_fees_status ='1'
  2398. AND settlement_status = '1'
  2399. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2400. and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
  2401. </if>
  2402. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2403. and a.is_not_car =#{vo.isNoCar}
  2404. </if>
  2405. </where>
  2406. GROUP BY
  2407. a.partner_companies_id
  2408. ) b on b.partner_companies_id =a.partner_companies_id
  2409. LEFT JOIN esm_ins_company eic on eic.id = a.company_Id
  2410. LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
  2411. <where>
  2412. pa.agreement_type = '2'
  2413. AND a.is_not_documentary = '1'
  2414. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2415. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2416. </if>
  2417. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2418. and a.is_not_car =#{vo.isNoCar}
  2419. </if>
  2420. </where>
  2421. group by
  2422. a.partner_companies_id,a.company_id,sa.area_cname
  2423. </select>
  2424. <select id="queryPlatHanding" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2425. SELECT
  2426. 1 as orderNumber,
  2427. '手续费' AS isHand,
  2428. sa.area_cname AS areaName,
  2429. eic.namesimple AS companyName,
  2430. a.partner_companies_id AS partnerCompaniesId,
  2431. SUM(a.commission_feevalue) AS commissionFeevalue,
  2432. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2433. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  2434. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2435. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2436. FROM
  2437. ins_ply_income a
  2438. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2439. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2440. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2441. <where>
  2442. pa.agreement_type = '1'
  2443. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2444. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2445. </if>
  2446. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2447. and a.is_not_car =#{vo.isNoCar}
  2448. </if>
  2449. </where>
  2450. GROUP BY
  2451. a.partner_companies_id, eic.namesimple, sa.area_cname
  2452. UNION ALL
  2453. SELECT
  2454. 2 as orderNumber,
  2455. '跟单费' AS isHand,
  2456. sa.area_cname AS areaName,
  2457. eic.namesimple AS companyName,
  2458. a.partner_companies_id AS partnerCompaniesId,
  2459. SUM(a.other_feevalue) AS commissionFeevalue,
  2460. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2461. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  2462. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2463. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2464. FROM
  2465. ins_ply_income a
  2466. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2467. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2468. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2469. <where>
  2470. pa.agreement_type = '1'
  2471. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2472. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2473. </if>
  2474. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2475. and a.is_not_car =#{vo.isNoCar}
  2476. </if>
  2477. </where>
  2478. GROUP BY
  2479. a.partner_companies_id, eic.namesimple, sa.area_cname
  2480. UNION ALL
  2481. SELECT
  2482. 3 as orderNumber,
  2483. '合计' AS isHand,
  2484. sa.area_cname AS areaName,
  2485. eic.namesimple AS companyName,
  2486. a.partner_companies_id AS partnerCompaniesId,
  2487. SUM(a.all_fee_value) AS commissionFeevalue,
  2488. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2489. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
  2490. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue",
  2491. SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
  2492. FROM
  2493. ins_ply_income a
  2494. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2495. LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
  2496. LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
  2497. <where>
  2498. pa.agreement_type = '1'
  2499. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2500. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2501. </if>
  2502. <if test="vo.isNoCar !=null and vo.isNoCar !=''">
  2503. and a.is_not_car =#{vo.isNoCar}
  2504. </if>
  2505. </where>
  2506. GROUP BY
  2507. a.partner_companies_id, eic.namesimple, sa.area_cname
  2508. ORDER BY
  2509. companyName,
  2510. areaName,
  2511. orderNumber;
  2512. </select>
  2513. <select id="queryPrivateCar" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2514. SELECT
  2515. a.subSigndate as "yearAndMonth",
  2516. a.allAmount as "commissionFeevalue",
  2517. IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
  2518. IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
  2519. (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
  2520. a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
  2521. FROM
  2522. (
  2523. SELECT
  2524. DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
  2525. IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
  2526. FROM
  2527. ins_ply_income a
  2528. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2529. <where>
  2530. pa.agreement_type = '2'
  2531. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2532. and a.is_not_car =#{vo.isNotCar}
  2533. </if>
  2534. </where>
  2535. GROUP BY
  2536. DATE_FORMAT( a.signdate, '%Y-%m' )
  2537. ) a
  2538. LEFT JOIN (
  2539. SELECT
  2540. DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
  2541. sum( a.settlement_amount ) AS "settCommAmount",
  2542. sum(a.remaining_amount) as "remainingAmount",
  2543. sum(a.total_amount) as "invoicComm"
  2544. FROM
  2545. sys_insurance_handling_settlement_month a
  2546. <where>
  2547. 1=1
  2548. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2549. and a.is_not_car =#{vo.isNotCar}
  2550. </if>
  2551. </where>
  2552. GROUP BY
  2553. DATE_FORMAT( a.signing_time, '%Y-%m' )
  2554. ) b ON a.subSigndate = b.subSigndate
  2555. left join (
  2556. select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
  2557. from
  2558. settlement_documentary_fees a
  2559. where a.settlement_status='1'
  2560. and handling_fees_status ='1'
  2561. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2562. and a.is_not_car =#{vo.isNotCar}
  2563. </if>
  2564. GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
  2565. ) c on c.subSigndate=a.subSigndate
  2566. </select>
  2567. <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
  2568. SELECT
  2569. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
  2570. FROM
  2571. ins_ply_income a
  2572. LEFT JOIN
  2573. ptl_agreement pa ON pa.id = a.agreement_id
  2574. <where>
  2575. <if test="vo.type !=null and vo.type !=''">
  2576. and pa.agreement_type =#{vo.type}
  2577. </if>
  2578. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2579. AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2580. </if>
  2581. </where>
  2582. </select>
  2583. <select id="queryDateByTypeByMonth"
  2584. resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
  2585. SELECT
  2586. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
  2587. SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
  2588. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
  2589. FROM
  2590. ins_ply_income a
  2591. LEFT JOIN
  2592. ptl_agreement pa ON pa.id = a.agreement_id
  2593. <where>
  2594. 1=1
  2595. <if test="vo.type !=null and vo.type !=''">
  2596. and pa.agreement_type =#{vo.type}
  2597. </if>
  2598. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2599. AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2600. </if>
  2601. <if test="vo.yearAndMonth != null and vo.yearAndMonth!=''">
  2602. AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
  2603. </if>
  2604. </where>
  2605. </select>
  2606. <select id="getProfitAnalysisQueryList" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
  2607. SELECT
  2608. a.signingTime as "yearAndMonth",
  2609. IFNULL(a.sumpremium,0) as "sumpremium",
  2610. IFNULL(b.allAmount,0) as "sumcount",
  2611. IFNULL(d.settlement,0) as "meet",
  2612. IFNULL(c.actualPayment,0) as "paid",
  2613. ifnull(d.settlement,0) - IFNULL(c.actualPayment,0) as "unpaid",
  2614. IFNULL(b.allAmount,0)- IFNULL (d.settlement,0) as "grossProfit",
  2615. IFNULL(e.applyAmount,0) as "laborCost",
  2616. IFNULL(f.applyAmount,0) as "fixedCost",
  2617. IFNULL(j.applyAmount,0) as "variableCost",
  2618. (IFNULL (b.allAmount,0) - IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) as "operatingProfit",
  2619. IFNULL(g.applyAmount,0) as "taxation",
  2620. (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"
  2621. FROM
  2622. (
  2623. SELECT
  2624. IFNULL(sum( iac.jqpremium ),0) +IFNULL(sum( iac.sypremium ),0) + IFNULL(sum(iac.jypremium),0) as "sumpremium",
  2625. DATE_FORMAT( iac.signing_time, '%Y-%m' ) AS "signingTime"
  2626. FROM
  2627. `ins_fee_audit` ifa
  2628. LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
  2629. <where>
  2630. ifa.auditstatus = '1'
  2631. AND iac.signing_time IS NOT NULL
  2632. <if test="vo.year !=null and vo.year !=''">
  2633. and DATE_FORMAT( iac.signing_time, '%Y') =#{vo.year}
  2634. </if>
  2635. <if test="vo.days !=null and vo.days !='' ">
  2636. and iac.signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2637. </if>
  2638. </where>
  2639. GROUP BY
  2640. DATE_FORMAT( iac.signing_time, '%Y-%m' )
  2641. ) a
  2642. LEFT JOIN (
  2643. SELECT
  2644. sum( ipi.commission_feevalue) + sum(ipi.other_feevalue ) as "allAmount",
  2645. DATE_FORMAT( ipi.signdate, '%Y-%m' ) AS "signingTime"
  2646. FROM
  2647. ins_ply_income ipi
  2648. <where>
  2649. 1=1
  2650. </where>
  2651. GROUP BY
  2652. DATE_FORMAT( ipi.signdate, '%Y-%m' )
  2653. ) b ON a.signingTime = b.signingTime
  2654. left join (
  2655. select
  2656. sum(a.amount) as "actualPayment",DATE_FORMAT( a.auditing_time, '%Y-%m' ) as "auditingTime"
  2657. from sys_amount_auditing a
  2658. left join sys_user_account_history b on a.id = b.auditiing_id
  2659. left join sys_user su on su.id =a.user_id
  2660. <where>
  2661. a.auditing_status= '3'
  2662. </where>
  2663. GROUP BY DATE_FORMAT( a.auditing_time, '%Y-%m' )
  2664. ) c on c.auditingTime =a.signingTime
  2665. left join (
  2666. SELECT
  2667. sum(
  2668. 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
  2669. ) AS "settlement",
  2670. DATE_FORMAT( iac.signing_time, '%Y-%m' ) as "signingTime"
  2671. FROM
  2672. ins_fee_order_new ifo
  2673. LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
  2674. LEFT JOIN ins_area_company iac ON ifa.ins_order_no = iac.id
  2675. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  2676. <where>
  2677. ifa.auditstatus = '1'
  2678. AND iac.orderstatus = '3'
  2679. AND io.orderstatus = '3'
  2680. </where>
  2681. GROUP BY
  2682. DATE_FORMAT( iac.signing_time, '%Y-%m' )
  2683. ) d on d.signingTime =a.signingTime
  2684. left join (
  2685. SELECT
  2686. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2687. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2688. b.expenditureDetails
  2689. FROM
  2690. inv_account_operate a
  2691. left join (
  2692. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2693. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2694. where b.category is not null
  2695. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2696. <where>
  2697. a.out_card_num IN (
  2698. SELECT
  2699. bank_card_num
  2700. FROM
  2701. inv_account_card iac
  2702. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2703. WHERE
  2704. ia.del_flag = '0'
  2705. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2706. )
  2707. AND a.revenue_outlay = '1'
  2708. AND a.del_flag = '0'
  2709. AND b.expenditureDetails = '1'
  2710. </where>
  2711. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2712. ) e on e.createTime =a.signingTime
  2713. left join (
  2714. SELECT
  2715. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2716. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2717. b.expenditureDetails
  2718. FROM
  2719. inv_account_operate a
  2720. left join (
  2721. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2722. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2723. where b.category is not null
  2724. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2725. <where>
  2726. a.out_card_num IN (
  2727. SELECT
  2728. bank_card_num
  2729. FROM
  2730. inv_account_card iac
  2731. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2732. WHERE
  2733. ia.del_flag = '0'
  2734. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2735. )
  2736. AND a.revenue_outlay = '1'
  2737. AND a.del_flag = '0'
  2738. AND b.expenditureDetails = '2'
  2739. </where>
  2740. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2741. ) f on f.createTime =a.signingTime
  2742. left join (
  2743. SELECT
  2744. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2745. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2746. b.expenditureDetails
  2747. FROM
  2748. inv_account_operate a
  2749. left join (
  2750. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2751. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2752. where b.category is not null
  2753. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2754. <where>
  2755. a.out_card_num IN (
  2756. SELECT
  2757. bank_card_num
  2758. FROM
  2759. inv_account_card iac
  2760. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2761. WHERE
  2762. ia.del_flag = '0'
  2763. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2764. )
  2765. AND a.revenue_outlay = '1'
  2766. AND a.del_flag = '0'
  2767. AND b.expenditureDetails = '3'
  2768. </where>
  2769. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2770. ) j on j.createTime =a.signingTime
  2771. left join (
  2772. SELECT
  2773. sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
  2774. DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
  2775. b.expenditureDetails
  2776. FROM
  2777. inv_account_operate a
  2778. left join (
  2779. select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
  2780. left join inv_account_expenses b on a.parent_id =b.expenses_id
  2781. where b.category is not null
  2782. ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
  2783. <where>
  2784. a.out_card_num IN (
  2785. SELECT
  2786. bank_card_num
  2787. FROM
  2788. inv_account_card iac
  2789. LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
  2790. WHERE
  2791. ia.del_flag = '0'
  2792. AND ia.outer_flag LIKE concat( '%', '0', '%' )
  2793. )
  2794. AND a.revenue_outlay = '1'
  2795. AND a.del_flag = '0'
  2796. AND b.expenditureDetails = '4'
  2797. </where>
  2798. GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
  2799. ) g on g.createTime =a.signingTime
  2800. </select>
  2801. <select id="getInvociAmount" resultType="com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto" >
  2802. select
  2803. DATE_FORMAT( a.signdate, '%Y-%m' ) as "incomeSigningTime",
  2804. a.task_id as "taskId",
  2805. sum(a.commission_feevalue) as "totalAmount"
  2806. from ins_ply_income a
  2807. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  2808. LEFT JOIN sys_user su on su.id=a.user_id
  2809. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  2810. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  2811. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  2812. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  2813. LEFT JOIN sys_dept b on pa.dept_id=b.id
  2814. <where>
  2815. 1=1
  2816. <if test="vo.isNotCar !=null and vo.isNotCar !=''">
  2817. and a.is_not_car =#{vo.isNotCar}
  2818. </if>
  2819. <if test="vo.isNotDocumentary !=null and vo.isNotDocumentary !=''">
  2820. and a.is_not_documentary =#{vo.isNotDocumentary}
  2821. </if>
  2822. <if test="vo.taskId != null and vo.taskId != ''">
  2823. and a.task_id = #{vo.taskId}
  2824. </if>
  2825. </where>
  2826. group by a.task_id , DATE_FORMAT( a.signdate, '%Y-%m' )
  2827. </select>
  2828. <select id="queryDateByTypePt" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
  2829. SELECT IFNULL(a.signingTime, 0) as "yearAndMonth",
  2830. IFNULL(a.allAmount, 0) as "commissionFeevalue",
  2831. IFNULL(c.settAmount, 0) as "noInvoicCommissionFeevalue",
  2832. IFNULL(b.notInvoicAmount, 0) as "noSettlementAmount",
  2833. IFNULL(c.settAmount, 0) as "readyCommissionFeevalue"
  2834. FROM (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "allAmount",
  2835. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2836. FROM ins_ply_income a
  2837. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2838. <where>
  2839. pa.agreement_type = '1'
  2840. <if test="vo.year !=null and vo.year !=''">
  2841. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2842. </if>
  2843. </where>
  2844. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) a
  2845. left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount",
  2846. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2847. FROM ins_ply_income a
  2848. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2849. <where>
  2850. pa.agreement_type = '1'
  2851. and a.handling_fees_status = '0'
  2852. <if test="vo.year !=null and vo.year !=''">
  2853. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2854. </if>
  2855. </where>
  2856. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) b on a.signingTime = b.signingTime
  2857. left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "settAmount",
  2858. DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
  2859. FROM ins_ply_income a
  2860. LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
  2861. <where>
  2862. pa.agreement_type = '1'
  2863. and a.handling_fees_status = '1'
  2864. <if test="vo.year !=null and vo.year !=''">
  2865. and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
  2866. </if>
  2867. </where>
  2868. GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) c on c.signingTime = a.signingTime
  2869. </select>
  2870. <select id="getPatherId" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
  2871. SELECT
  2872. sa.area_cname as "areaName",
  2873. eic.namesimple as "companyName",
  2874. SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
  2875. a.company_id AS "companyId",
  2876. a.partner_companies_id AS "partnerCompaniesId"
  2877. FROM
  2878. ins_ply_income a
  2879. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  2880. LEFT JOIN esm_ins_company eic on eic.id = a.company_id
  2881. LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
  2882. <where>
  2883. <if test="vo.type !=null and vo.type!=''">
  2884. pa.agreement_type =#{vo.type}
  2885. </if>
  2886. <if test="vo.isNoCar != null and vo.isNoCar !='' ">
  2887. and a.is_not_car =#{vo.isNoCar}
  2888. </if>
  2889. <if test="vo.yearAndMonth !=null and vo.yearAndMonth != ''">
  2890. and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
  2891. </if>
  2892. </where>
  2893. GROUP BY
  2894. a.partner_companies_id,
  2895. a.company_id,
  2896. eic.namesimple,
  2897. sa.area_cname
  2898. </select>
  2899. </mapper>