| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.order.dao.InsAreaCompanyMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
- <id property="id" column="id" jdbcType="VARCHAR"/>
- <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
- <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
- <result property="apiType" column="api_type" jdbcType="TINYINT"/>
- <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
- <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
- <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
- <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
- <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
- <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
- <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
- <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
- <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
- <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
- <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
- <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
- <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
- <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
- <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
- <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
- <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
- <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
- <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
- <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
- <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
- <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
- <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
- <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
- <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
- <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
- <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
- <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
- <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
- <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
- <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
- <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
- <result property="score" column="score" jdbcType="VARCHAR"/>
- <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
- <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
- <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
- <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
- <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
- <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
- <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
- <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
- <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
- <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
- <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
- <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
- <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
- <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
- <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
- </resultMap>
- <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
- extends="BaseResultMap">
- <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
- <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,orderno,inscompany,
- reqtxt,reptxt,jqapplyno,
- jqpolicyno,syapplyno,sypolicyno,
- riskinfo,kindinfo,jqpremium,
- sypremium,taxamount,sumpremium,
- jqdiscountrate,sydiscountrate,feerate,
- disrate,auditid,auditname,
- audittime,auditopinion,jqappoint,
- syappoint,createtime,payment_link
- </sql>
- <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- </select>
- <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,io.is_external,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- left join ins_orders io on iac.orderno=io.orderno
- WHERE iac.orderstatus = 3
- and iac.orderno = #{orderNo};
- </select>
- <select id="queryLatestStatus" resultType="java.lang.String">
- SELECT iac.orderstatus
- FROM ins_area_company as iac
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- ORDER BY orderstatus DESC
- LIMIT 1
- </select>
- <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- SELECT a.id as "id",
- a.orderno as "orderno"
- FROM ins_area_company a
- LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
- WHERE a.orderstatus = '3'
- or a.orderstatus = '2'
- and b.id is not null
- </select>
- <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- iac.id as orderno,
- io.quoteno,
- io.orderstatus,
- io.company_id,
- io.ins_company,
- io.carinfo,
- io.userid,
- io.username,
- io.deptid,
- io.deptname,
- io.agreeid,
- iac.productid,
- iac.product,
- iac.createtime,
- io.frameno,
- io.licenseno,
- io.insuredname,
- io.is_external,
- iac.jq_start_date as jqstartdate,
- iac.jq_end_date as jqenddate,
- iac.sy_start_date as systartdate,
- iac.sy_end_date as syenddate,
- io.vehicle_and_vessel_tax,
- io.operatorid,
- iac.operator_name,
- sd.management_source,
- iac.problem_order,
- CASE ifa.audituser
- WHEN '自动审核' THEN ifa.audituser
- ELSE su2.name END
- AS auditUser,
- ifa.audittime as auditTime,
- ifa.auditstatus as auditStatus,
- eic.namesimple as partnerCompaniesName,
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.pay_date as payDate,
- pa.agreement_code as agreementCode,
- pa.agreement_name as agreementName,
- pa.business_description as businessDescription,
- pa.job_description as jobDescription,
- pa.agreement_title as agreementTitle,
- pa.docking_person as dockingPerson,
- io.entry_status
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- WHERE
- iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="params.auditStatus != null and params.auditStatus != ''">
- and ifa.auditstatus = #{params.auditStatus}
- </if>
- <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
- and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
- #{params.quoteEndDateStr}
- </if>
- <if test="params.orderNo != null and params.orderNo != ''">
- AND iac.id= #{params.orderNo}
- </if>
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND io.licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND io.frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND io.insuredname = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND io.company_id = #{params.companyId}
- </if>
- <if test="params.engineNo != null and params.engineNo != ''">
- and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
- </if>
- <if test="params.riskCode != null and params.riskCode != ''">
- and iac.product = #{params.riskCode}
- </if>
- <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
- and ((
- DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
- AND #{params.attachEndDateStr}
- )
- OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
- #{params.attachEndDateStr} )
- )
- </if>
- <if test="params.provinceId != null and params.provinceId != ''">
- and io.deptid like "${params.provinceId}%"
- </if>
- <if test="params.problemOrder != null and params.problemOrder != ''">
- and iac.problem_order like "${params.problemOrder}%"
- </if>
- <if test="params.cityId != null and params.cityId != ''">
- and io.deptid like "${params.cityId}%"
- </if>
- <if test="params.countyId != null and params.countyId != ''">
- and io.deptid like "${params.countyId}%"
- </if>
- <if test="params.houseId != null and params.houseId != ''">
- and io.deptid like "${params.houseId}%"
- </if>
- <if test="params.operatorId != null and params.operatorId != ''">
- and io.userid = #{params.operatorId}
- </if>
- <if test="params.operatorName != null and params.operatorName != ''">
- and io.username = #{params.operatorName}
- </if>
- <if test="params.auditId != null and params.auditId != ''">
- and iac.new_operator_id = #{params.auditId}
- </if>
- <if test="params.agreeId != null and params.agreeId != ''">
- and iac.agreement_id = #{params.agreeId}
- </if>
- <if test="params.managementSource != null and params.managementSource != ''">
- and sd.management_source = #{params.managementSource}
- </if>
- <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
- and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
- #{params.signEndDateStr}
- </if>
- <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
- and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
- </if>
- <if test="params.isExternal != null and params.isExternal != ''">
- and io.is_external = #{params.isExternal}
- </if>
- <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
- and iac.jqpolicyno = #{params.jqPolicyNo}
- </if>
- <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
- and iac.sypolicyno = #{params.syPolicyNo}
- </if>
- <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
- and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
- </if>
- order by iac.createtime desc
- </select>
- <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source
- FROM
- ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
- WHERE
- orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
- AND orderstatus = 3
- )
- AND
- io.orderstatus= 3
- <if test="orderNo != null and orderNo != ''">
- AND orderno = #{orderNo}
- </if>
- <if test="licenseNo != null and licenseNo != ''">
- AND licenseno = #{licenseNo}
- </if>
- <if test="frameNo != null and frameNo != ''">
- AND frameno = #{frameNo}
- </if>
- <if test="userId != null and userId != ''">
- AND userid = #{userId}
- </if>
- <if test="insuredname != null and insuredname != ''">
- AND insuredname = #{insuredname}
- </if>
- <if test="startDateStr != null and startDateStr != ''">
- AND createtime BETWEEN #{startDateStr} and #{endDateStr}
- </if>
- </select>
- <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.first_detail_premiums) as "willFirstPremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.third_detail_premiums) as "willThreePremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source,
- su2.name AS auditUser,
- ifa.audittime as auditTime
- FROM
- ins_orders io
- LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 on ifa.audituser = su2.id
- WHERE
- io.orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN (
- SELECT
- ifon.ins_order_no
- FROM
- ins_fee_order_new ifon
- RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
- WHERE
- ifa.auditstatus = #{params.auditStatus}
- )
- )
- AND orderstatus = 3
- <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
- <!-- AND orderno = #{params.orderNo}-->
- <!-- </if>-->
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND insuredname = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND company_id = #{params.companyId}
- </if>
- <if test="params.startDateStr != null and params.startDateStr != ''">
- AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
- </if>
- </select>
- <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- -- 查询订单信息
- SELECT
- iac.*
- FROM
- ins_area_company iac
- left JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- 1=1
- <if test="dateStr != null and dateStr != ''">
- AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
- </if>
- </select>
- <select id="selectListById" resultMap="BaseResultMap">
- SELECT
- iac.*
- FROM
- ins_area_company iac
- WHERE
- 1=1
- <if test="id != null and id != ''">
- AND iac.id =#{id}
- </if>
- </select>
- <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
- SELECT
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- io.licenseno as licenseno,
- io.userid as userId
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- iac.id=#{subOrderId}
- </select>
- <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- reportDate,
- sum( jqpremium ) jqpremium,
- sum( sypremium ) sypremium,
- sum( sumpremium ) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- </select>
- <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
- SELECT
- ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
- count( 0 ) as sumCount
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3
- and io.userid=#{userId}
- AND YEAR (iac.createtime) = #{year}
- </select>
- <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- ifa.audittime,
- ifa.audituser as auditname,
- ifa.rejectinfo,
- "1" as orderExternalStatus
- FROM
- ins_fee_audit ifa
- LEFT JOIN
- ins_area_company iac on iac.id = ifa.ins_order_no
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join
- sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- ifa.auditstatus = 2
- <if test="vo.id != null and vo.id!=''">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- <if test="vo.auditname != null and vo.auditname!='' ">
- and su.name like CONCAT('%', #{vo.auditname}, '%')
- </if>
- </select>
- <select id="queryBusinessDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- sum( iac.sumpremium ) as signeSumPremiumAmount,
- sum( iac.jqpremium ) as jqPremiumAmount,
- sum( iac.sypremium ) as syPremiumAmount,
- sum( iac.taxamount ) as taxAmount,
- sum( ion.no_premium ) as fcFeeAmount
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
- where iac.orderstatus = 3 and ion.id is not null
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username
- </if>
- </select>
- <select id="queryQuotationSubOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- iac.orderstatus as orderStatus
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username,iac.orderstatus
- </if>
- </select>
- <select id="queryQuotationOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- a.userId as userId,
- a.userName as userName,
- b.qutationCount AS insOrderQutationCount,
- b.qutationInsureCount as insOrderQutationInsureCount,
- b.closeRate AS insOrderCloseRate as insOrderCloseRate,
- a.qutationCount as subOrderQutationCount,
- a.underwritingCount as subOrderUnderwritingCount,
- a.qutationInsureCount as subOrderQutationInsureCount,
- a.passRate as subOrderCloseRate,
- a.closeRate as subOrderPassRate,
- a.contributionRate as subOrderContributionRate
- FROM
- (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) a
- LEFT JOIN (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- count( inso.orderstatus ) AS qutationCount,
- count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
- FROM
- ins_orders inso
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) b ON a.userId = b.userId
- </select>
- <select id="queryCompanyPremiumDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.NAME AS parterCompanyName,
- sum( iac.sumpremium ) AS signeSumPremiumAmount
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- iac.orderstatus = 3
- and
- agree.id is not null
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.insurance_company_id = #{vo.parterCompanyId}
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="queryCompanyQutationCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- a.* ,
- (select ins.namesimple from esm_ins_company
- ins where a.parterCompanyId = ins.id) as "parterCompanyName"
- FROM
- (
- SELECT
- count(agree.partner_companies_id) as "orderSuccessNumber",
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- iac.company_id as "companyId",
- count( iac.orderstatus ) AS qutationCount,
- count( iac.id ) AS orderSuccessNumberRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
- COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.leaderName},'%')
- </if>
- GROUP BY
- agree.insurance_company,
- iac.company_id,
- agree.partner_companies_id
- ) a
- </select>
- <select id="getInsAreaCompanyError"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- count(iace.id) as "areaCompanyErrNumber"
- FROM
- ins_area_company_error iace
- LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
- <where>
- 1=1
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.userId != null and vo.userId!=''">
- AND iace.user_id =#{vo.userId}
- </if>
- </where>
- </select>
- <select id="queryCompanyQutationCountDataPageTotal"
- resultType="java.lang.Long">
- SELECT
- count(0)
- FROM
- (
- SELECT
- agree.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.leaderName},'%')
- </if>
- GROUP BY
- agree.partner_companies_id
- ) a
- </select>
- <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- "0" as orderExternalStatus
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 0
- and agree.is_external =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select a.*, su.name as "userName",
- inf.url as "logo",
- sui.sex as "sex",
- su.leader_name as "leaderName"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
- (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id
- ) a
- left join sys_user su on su.id =a.userId
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info sui on sui .id =su.id
- </select>
- <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
- SELECT
- COUNT(0)
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id
- ) total
- </select>
- <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- sd.name as "deptName",
- su.name as "userName",
- io.userid as "userId",
- sd.id as "deptId",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / COUNT(iac.orderstatus) as "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) as "auditOrder"
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid , su.name, sd.id , sd.name
- </select>
- <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid as "userId"
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid
- ) a
- </select>
- <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- iac.company_id,
- iac.inscompany as "insuranceCompanyName",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
- COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- GROUP BY
- iac.company_id,
- iac.inscompany
- </select>
- <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- sum( a.orderAmount ) as "totalPremium",
- sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- SUM(IFNULL(iac.jqpremium, 0)) +
- SUM(IFNULL(iac.sypremium, 0)) +
- SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- IFNULL(sum( a.orderAmount ),0) as "totalPremium",
- ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- count( iac.orderno ) AS "ordernoNumber",
- SUM(IFNULL(iac.jqpremium, 0)
- +IFNULL(iac.sypremium, 0)
- +IFNULL(iac.jypremium, 0)
- ) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- order by sum( a.orderAmount ) desc
- </select>
- <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- a.userId as "userId",
- a.userName as "name",
- a.orderNumber as "orderNumber",
- a.underwritingCount as "underwritingCount",
- a.qutationInsureCount as "qutationInsureCount",
- IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
- a.isFactorVerify as "isFactorVerify",
- a.isNotFactorVerify as "isNotFactorVerify"
- FROM
- (
- SELECT
- io.userid as "userId",
- io.username as "userName",
- count( iac.orderno ) AS "orderNumber",
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
- COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- left join sys_user su on su.id=io.userid
- <where>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- </where>
- GROUP BY
- io.userid,
- io.username
- ) a
- left join sys_user su on su.id=a.userId
- </select>
- <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
- <where>
- sd.management_source = '2'
- <if test="userId !=null and userId !=''">
- and io.userId =#{userId}
- </if>
- </where>
- </select>
- <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.namesimple AS parterCompanyName,
- count(iac.orderstatus) AS orderNumber,
- '-' as bigQutationCount,
- '-' as bigUnderwritingCount,
- '-' as bigCloseRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
- contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- a.totalPremium as "totalPremium",
- a.qutationInsureCount as "qutationInsureCount",
- a.averagePremium as "averagePremium",
- a.userNumber as "userNumber",
- a.perCapitaAmount as "perCapitaAmount",
- c.docking_person as "dockingPerson",
- c.docking_phone as "dockingPhone",
- c.agreement_type as "agreementType",
- b.logo as "logo"
- from (
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- agree.id as "agreeId",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0 ) AS "qutationInsureCount",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(0 ) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- agree.id
- <choose>
- <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
- order by
- sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- </choose>
- ) a
- left join esm_ins_company b on b.id =a.companyId
- left join ptl_agreement c on c.id =a.agreeId
- </select>
- <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0) AS "qutationInsureCount",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
- and iac.orderstatus =#{vo.quotationStatus}
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.namesimple
- </select>
- <select id="getOrderPremiumByUserIds" resultType="Double">
- SELECT
- IFNULL(
- SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
- 0
- ) AS "totalPremium"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- </select>
- <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- io.licenseno AS "licenseno",
- io.frameno AS "frameno",
- io.orderstatus as "orderstatus",
- io.orderno as "orderno"
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- io.licenseno is not null
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userId =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select sum(a.orderNumber) as "orderNumber",
- count(a.licenseno) as "b.frameno"
- from (
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno
- ) a
- </select>
- <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( io.orderno ) AS "orderNumber",
- IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0) / (IFNULL(count(CASE WHEN io.orderstatus = '2' THEN 1 ELSE 0 END),0) + IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0)) AS "closeRate"
- FROM
- ins_orders io
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN sys_user su ON io.userid = su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="month != null and month!='' ">
- AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
- </if>
- </where>
- </select>
- <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select
- iac.inscompany as "namesimple"
- from
- ins_area_company iac
- <where>
- 1=1
- <if test="vo.orderstatus != null and vo.orderstatus != '' ">
- AND iac.orderstatus =#{vo.orderstatus}
- </if>
- <if test="vo.orderno !=null and vo.orderno !='' ">
- AND iac.orderno =#{vo.orderno}
- </if>
- </where>
- </select>
- <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
- select a.*,(select name from sys_user where id =a.userId) as "userName"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
- (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
- ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
- (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- 1=1
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
- and sd.management_source=#{taskStatisticsVo.managementSource}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id
- ) a
- </select>
- <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
- SELECT
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select count(0) as "orderNumber",
- GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- 1=1
- and iac.orderstatus ='3'
- and io.orderstatus ='3'
- <if test="vo.licenseno !=null and vo.licenseno!=''">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.frameno !=null and vo.frameno!=''">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- </select>
- <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
- select
- io.userid as userId,
- io.username as userName,
- io.licenseno as licenseno,
- iac.id as companyId,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- iac.createtime as createtime,
- iac.orderstatus as orderstatus
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- iac.orderstatus=3
- <if test="dto.userId !=null and dto.userId !=''">
- and io.userid = #{dto.userId}
- </if>
- <if test="dto.deptId !=null and dto.deptId !=''">
- and io.deptid = #{dto.deptId}
- </if>
- <if test="dto.startTime !=null and dto.startTime !=''">
- and io.createtime >= #{dto.startTime}
- </if>
- </where>
- ORDER BY iac.createtime
- </select>
- <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
- select a.*,
- IFNULL(b.orderNumber,0)/IFNULL(a.orderNumber ,0)
- from (
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname",
- b.frameno as "frameno"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- ) a
- left join (
- select count(0) as "orderNumber",
- GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple",
- io.licenseno as "licenseno"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- 1=1
- and iac.orderstatus ='3'
- and io.orderstatus ='3'
- <if test="vo.licenseno !=null and vo.licenseno!=''">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.frameno !=null and vo.frameno!=''">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- group by
- io.licenseno
- ) b on b.licenseno =a.licenseno
- </select>
- <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- su.name as auditname
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
- left join sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 3
- and agree.is_external =1
- and auditstatus =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- </mapper>
|