| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134 |
- <?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"/>
- </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
- 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
- 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
- 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
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.NAME AS parterCompanyName,
- count(iac.orderstatus) AS qutationCount,
- '-' 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 = 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 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>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </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
- sd.name as "deptName",
- su.name as "userName",
- io.userid as "userId",
- 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( CASE WHEN iac.orderstatus = 2 THEN 1 END ) 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_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 = '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.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="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- pa.insurance_company_id,
- pa.insurance_company as "insuranceCompanyName",
- eic.namesimple as "partnerCompaniesName",
- 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( CASE WHEN iac.orderstatus = 2 THEN 1 END ) 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_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- 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 esm_ins_company eic ON eic.id = pa.partner_companies_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.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
- pa.insurance_company_id,
- pa.insurance_company,
- eic.namesimple,
- pa.insurance_company
- </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",
- 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( CASE WHEN iac.orderstatus = 2 THEN 1 END ) 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_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="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.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="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 pa.audit_type = 1 AND ifa.auditstatus = 1 THEN 1 END ) AS "persionAudit",
- COUNT( CASE WHEN pa.audit_type = 2 AND ifa.auditstatus = 1 THEN 1 END ) AS "automaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_fee_order_new ion ON ion.ins_order_no = iac.id
- <where>
- 1=1
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and ifa.audittime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and ifa.audittime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and ifa.audittime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- <if test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != ''">
- and iac.product = #{taskStatisticsVo.riskCode}
- </if>
- </where>
- GROUP BY
- iac.company_id,
- iac.inscompany
- </select>
- </mapper>
|