| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417 |
- <?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.protocols.dao.InsFeeOrderNewMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- <id column="id" property="id"/>
- <result column="ins_order_no" property="insOrderNo"/>
- <result column="agreement_id" property="agreementId"/>
- <result column="costs_id" property="costsId"/>
- <result column="dept_id" property="deptId"/>
- <result column="user_id" property="userId"/>
- <result column="jq_premium" property="jqPremium"/>
- <result column="sy_premium" property="syPremium"/>
- <result column="no_premium" property="noPremium"/>
- <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
- <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
- <result column="no_no_tax_premium" property="noNoTaxPremium"/>
- <result column="jq_costs_proportion" property="jqCostsProportion"/>
- <result column="jq_costs_premiums" property="jqCostsPremiums"/>
- <result column="sy_costs_proportion" property="syCostsProportion"/>
- <result column="sy_costs_premiums" property="syCostsPremiums"/>
- <result column="no_costs_proportion" property="noCostsProportion"/>
- <result column="no_costs_premiums" property="noCostsPremiums"/>
- <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
- <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
- <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
- <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
- <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
- <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
- <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
- <result column="jq_other_costs_premiums" property="jqOtherCostsPremiums"/>
- <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
- <result column="sy_other_costs_premiums" property="syOtherCostsPremiums"/>
- <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
- <result column="no_other_costs_premiums" property="noOtherCostsPremiums"/>
- <result column="jq_investment_costs_proportion" property="jqInvestmentCostsProportion"/>
- <result column="jq_investment_costs_premiums" property="jqInvestmentCostsPremiums"/>
- <result column="sy_investment_costs_proportion" property="syInvestmentCostsProportion"/>
- <result column="sy_investment_costs_premiums" property="syInvestmentCostsPremiums"/>
- <result column="jq_dept_proportion_level_1" property="jqDeptProportionLevel1"/>
- <result column="jq_dept_premiums_level_1" property="jqDeptPremiumsLevel1"/>
- <result column="sy_dept_proportion_level_1" property="syDeptProportionLevel1"/>
- <result column="sy_dept_premiums_level_1" property="syDeptPremiumsLevel1"/>
- <result column="no_dept_proportion_level_1" property="noDeptProportionLevel1"/>
- <result column="no_dept_premiums_level_1" property="noDeptPremiumsLevel1"/>
- <result column="jq_dept_proportion_level_2" property="jqDeptProportionLevel2"/>
- <result column="jq_dept_premiums_level_2" property="jqDeptPremiumsLevel2"/>
- <result column="sy_dept_proportion_level_2" property="syDeptProportionLevel2"/>
- <result column="sy_dept_premiums_level_2" property="syDeptPremiumsLevel2"/>
- <result column="no_dept_proportion_level_2" property="noDeptProportionLevel2"/>
- <result column="no_dept_premiums_level_2" property="noDeptPremiumsLevel2"/>
- <result column="jq_dept_proportion_level_3" property="jqDeptProportionLevel3"/>
- <result column="jq_dept_premiums_level_3" property="jqDeptPremiumsLevel3"/>
- <result column="sy_dept_proportion_level_3" property="syDeptProportionLevel3"/>
- <result column="sy_dept_premiums_level_3" property="syDeptPremiumsLevel3"/>
- <result column="no_dept_proportion_level_3" property="noDeptProportionLevel3"/>
- <result column="no_dept_premiums_level_3" property="noDeptPremiumsLevel3"/>
- <result column="jq_dept_proportion_level_4" property="jqDeptProportionLevel4"/>
- <result column="jq_dept_premiums_level_4" property="jqDeptPremiumsLevel4"/>
- <result column="sy_dept_proportion_level_4" property="syDeptProportionLevel4"/>
- <result column="sy_dept_premiums_level_4" property="syDeptPremiumsLevel4"/>
- <result column="no_dept_proportion_level_4" property="noDeptProportionLevel4"/>
- <result column="no_dept_premiums_level_4" property="noDeptPremiumsLevel4"/>
- <result column="jq_dept_proportion_level_5" property="jqDeptProportionLevel5"/>
- <result column="jq_dept_premiums_level_5" property="jqDeptPremiumsLevel5"/>
- <result column="sy_dept_proportion_level_5" property="syDeptProportionLevel5"/>
- <result column="sy_dept_premiums_level_5" property="syDeptPremiumsLevel5"/>
- <result column="no_dept_proportion_level_5" property="noDeptProportionLevel5"/>
- <result column="no_dept_premiums_level_5" property="noDeptPremiumsLevel5"/>
- <result column="jq_costs_export_proportion" property="jqCostsExportProportion"/>
- <result column="sy_costs_export_proportion" property="syCostsExportProportion"/>
- <result column="no_costs_export_proportion" property="noCostsExportProportion"/>
- <result column="jq_export_investment_proportion" property="jqExportInvestmentProportion"/>
- <result column="jq_export_investment_premiums" property="jqExportInvestmentPremiums"/>
- <result column="sy_export_investment_proportion" property="syExportInvestmentProportion"/>
- <result column="sy_export_investment_premiums" property="syExportInvestmentPremiums"/>
- <result column="first_detail_proportion" property="firstDetailProportion"/>
- <result column="first_detail_premiums" property="firstDetailPremiums"/>
- <result column="second_detail_proportion" property="secondDetailProportion"/>
- <result column="second_detail_premiums" property="secondDetailPremiums"/>
- <result column="third_detail_proportion" property="thirdDetailProportion"/>
- <result column="third_detail_premiums" property="thirdDetailPremiums"/>
- <result column="create_time" property="createTime"/>
- <result column="first_level_user_id" property="firstLevelUserId"/>
- <result column="two_level_user_id" property="twoLevelUserId"/>
- <result column="three_level_user_id" property="threeLevelUserId"/>
- <result column="distribution_status" property="distributionStatus"/>
- <result column="dept_distribution" property="deptDistribution"/>
- </resultMap>
- <select id="getInsFeeOrderEntity" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select
- a.id as "id",
- a.ins_order_no as "insOrderNo",
- a.agreement_id as "agreementId",
- a.costs_id as "costsId",
- a.dept_id as "deptId",
- a.user_id as "userId",
- a.jq_premium as "jqPremium",
- a.sy_premium as "syPremium",
- a.no_premium as "noPremium",
- a.jq_no_tax_premium as "jqNoTaxPremium",
- a.sy_no_tax_premium as "syNoTaxPremium",
- a.no_no_tax_premium as "noNoTaxPremium",
- a.jq_costs_proportion as "jqCostsProportion",
- a.jq_costs_premiums as "jqCostsPremiums",
- a.sy_costs_proportion as "syCostsProportion",
- a.sy_costs_premiums as "syCostsPremiums",
- a.no_costs_proportion as "noCostsProportion",
- a.no_costs_premiums as "noCostsPremiums",
- a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
- a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
- a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
- a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
- a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
- a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
- a.jq_other_costs_proportion as "jqOtherCostsProportion",
- a.jq_other_costs_premiums as "jqOtherCostsPremiums",
- a.sy_other_costs_proportion as "syOtherCostsProportion",
- a.sy_other_costs_premiums as "syOtherCostsPremiums",
- a.no_other_costs_proportion as "noOtherCostsProportion",
- a.no_other_costs_premiums as "noOtherCostsPremiums",
- a.jq_investment_costs_proportion as "jqInvestmentCostsProportion",
- a.jq_investment_costs_premiums as "jqInvestmentCostsPremiums",
- a.sy_investment_costs_proportion as "syInvestmentCostsProportion",
- a.sy_investment_costs_premiums as "syInvestmentCostsPremiums",
- a.jq_dept_proportion_level_1 as "jqDeptProportionLevel1",
- a.jq_dept_premiums_level_1 as "jqDeptPremiumsLevel1",
- a.sy_dept_proportion_level_1 as "syDeptProportionLevel1",
- a.sy_dept_premiums_level_1 as "syDeptPremiumsLevel1",
- a.no_dept_proportion_level_1 as "noDeptProportionLevel1",
- a.no_dept_premiums_level_1 as "noDeptPremiumsLevel1",
- a.jq_dept_proportion_level_2 as "jqDeptProportionLevel2",
- a.jq_dept_premiums_level_2 as "jqDeptPremiumsLevel2",
- a.sy_dept_proportion_level_2 as "syDeptProportionLevel2",
- a.sy_dept_premiums_level_2 as "syDeptPremiumsLevel2",
- a.no_dept_proportion_level_2 as "noDeptProportionLevel2",
- a.no_dept_premiums_level_2 as "noDeptPremiumsLevel2",
- a.jq_dept_proportion_level_3 as "jqDeptProportionLevel3",
- a.jq_dept_premiums_level_3 as "jqDeptPremiumsLevel3",
- a.sy_dept_proportion_level_3 as "syDeptProportionLevel3",
- a.sy_dept_premiums_level_3 as "syDeptPremiumsLevel3",
- a.no_dept_proportion_level_3 as "noDeptProportionLevel3",
- a.no_dept_premiums_level_3 as "noDeptPremiumsLevel3",
- a.jq_dept_proportion_level_4 as "jqDeptProportionLevel4",
- a.jq_dept_premiums_level_4 as "jqDeptPremiumsLevel4",
- a.sy_dept_proportion_level_4 as "syDeptProportionLevel4",
- a.sy_dept_premiums_level_4 as "syDeptPremiumsLevel4",
- a.no_dept_proportion_level_4 as "noDeptProportionLevel4",
- a.no_dept_premiums_level_4 as "noDeptPremiumsLevel4",
- a.jq_dept_proportion_level_5 as "jqDeptProportionLevel5",
- a.jq_dept_premiums_level_5 as "jqDeptPremiumsLevel5",
- a.sy_dept_proportion_level_5 as "syDeptProportionLevel5",
- a.sy_dept_premiums_level_5 as "syDeptPremiumsLevel5",
- a.no_dept_proportion_level_5 as "noDeptProportionLevel5",
- a.no_dept_premiums_level_5 as "noDeptPremiumsLevel5",
- a.jq_costs_export_proportion as "jqCostsExportProportion",
- a.sy_costs_export_proportion as "syCostsExportProportion",
- a.no_costs_export_proportion as "noCostsExportProportion",
- a.jq_export_investment_proportion as "jqExportInvestmentProportion",
- a.jq_export_investment_premiums as "jqExportInvestmentPremiums",
- a.sy_export_investment_proportion as "syExportInvestmentProportion",
- a.sy_export_investment_premiums as "syExportInvestmentPremiums",
- a.first_detail_proportion as "firstDetailProportion",
- a.first_detail_premiums as "firstDetailPremiums",
- a.second_detail_proportion as "secondDetailProportion",
- a.second_detail_premiums as "secondDetailPremiums",
- a.third_detail_proportion as "thirdDetailProportion",
- a.third_detail_premiums as "thirdDetailPremiums",
- a.create_time as "createTime",
- a.first_level_user_id as "firstLevelUserId",
- a.two_level_user_id as "twoLevelUserId",
- a.three_level_user_id as "threeLevelUserId",
- a.distribution_status as "distributionStatus",
- a.dept_distribution as "deptDistribution",
- iac.signing_time as "signingTime",
- io.licenseno as "licenseno"
- from ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- LEFT JOIN ins_orders io on io.quoteno =iac.id
- <where>
- 1=1
- <if test="id !=null and id !=''">
- AND a.ins_order_no=#{id}
- </if>
- </where>
- </select>
- <select id="getByUserId" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select a.* from ins_fee_order_new a
- <where>
- <if test="userId !=null and userId !=''">
- a.user_id =#{userId}
- </if>
- </where>
- </select>
- <select id="getByUserIdAndOrderStatusAndNoCheck" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select a.* from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- a.user_id = #{userId}
- and ins.orderstatus ='3'
- and iff.auditstatus=0
- </select>
- <select id="getSumWillAmount" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select
- a.ins_order_no as "id",
- a.user_id as "userId",
- ins.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
- from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_orders o ON o.orderno=ins.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <if test="userId !=null and userId !=''">
- a.user_id = #{userId}
- </if>
- and ins.orderstatus ='3'
- and iff.auditstatus=0
- <if test="timeFiltering!= null and timeFiltering !=''">
- AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
- </if>
- <if test="amountType !=null and amountType !='' and amountType == 3 ">
- and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
- </if>
- </where>
- </select>
- <select id="getSumWillAmountGeneralization" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- SELECT
- fee.id,
- fee.userId,
- fee.signingTime,
- fee.licenseno,
- fee.jqExportSuperviseCostsPremiums,
- fee.syExportSuperviseCostsPremiums,
- fee.noExportSuperviseCostsPremiums,
- fee.jqExportOtherCostsPremiums,
- fee.syExportOtherCostsPremiums,
- fee.noExportOtherCostsPremiums,
- fee.willAmount
- FROM
- (
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.first_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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>
- </where>
- UNION
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.third_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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>
- </where>
- UNION
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.second_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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>
- </where>
- ) AS fee
- </select>
- <select id="getByUserIdAndOrderStatusAndNoCheckType"
- resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
- from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- a.user_id = #{userId}
- and ins.orderstatus ='3'
- <choose>
- <when test='type == "1"'>
- and iff.auditstatus=0
- </when>
- <otherwise>
- and iff.auditstatus=1
- </otherwise>
- </choose>
- </select>
- <select id="getSumWillAmountGeneralizationNew"
- resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- SELECT
- fee.id,
- fee.userId,
- fee.signingTime,
- fee.licenseno,
- fee.jqExportSuperviseCostsPremiums,
- fee.syExportSuperviseCostsPremiums,
- fee.noExportSuperviseCostsPremiums,
- fee.jqExportOtherCostsPremiums,
- fee.syExportOtherCostsPremiums,
- fee.noExportOtherCostsPremiums,
- fee.willAmount
- FROM
- (
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.first_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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="timeFiltering!= null and timeFiltering !=''">
- <choose>
- <when test='type == "1"'>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </when>
- <otherwise>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </otherwise>
- </choose>
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.third_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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="timeFiltering!= null and timeFiltering !=''">
- <choose>
- <when test='type == "1"'>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </when>
- <otherwise>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </otherwise>
- </choose>
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "id",
- a.user_id as "userId",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
- a.second_detail_premiums as "willAmount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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="timeFiltering!= null and timeFiltering !=''">
- <choose>
- <when test='type == "1"'>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </when>
- <otherwise>
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </otherwise>
- </choose>
- </if>
- </where>
- ) AS fee
- </select>
- <select id="getSumWillAmountNew" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
- select
- a.ins_order_no as "id",
- a.user_id as "userId",
- ins.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
- a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
- a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
- a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
- a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
- a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
- from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_orders o ON o.orderno=ins.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <if test="userId !=null and userId !=''">
- a.user_id = #{userId}
- </if>
- and ins.orderstatus ='3'
- <choose>
- <when test='type == "1"'>
- and iff.auditstatus=0
- </when>
- <otherwise>
- and iff.auditstatus=1
- </otherwise>
- </choose>
- <if test="timeFiltering!= null and timeFiltering !=''">
- <choose>
- <when test='type == "1"'>
- AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </when>
- <otherwise>
- AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
- </otherwise>
- </choose>
- </if>
- <if test="amountType !=null and amountType !='' and amountType == 3 ">
- and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
- </if>
- </where>
- </select>
- <select id="findMyCollectInAdvanceWillAmountByUserId"
- resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
- SELECT
- fee.subOrderNo,
- fee.signingTime,
- fee.licenseno,
- fee.amount,
- "1" as businessSegmentsType,
- "2" as transactionType,
- fee.createTime
- FROM
- (
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.first_detail_premiums as "amount",
- iac.createtime as "createTime"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.third_detail_premiums as "amount",
- iac.createtime as "createTime"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.second_detail_premiums as "amount",
- iac.createtime as "createTime"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- 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="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="findMyCollectInAdvanceSumByUserId"
- resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
- select
- a.ins_order_no as "subOrderNo",
- ins.signing_time as "signingTime",
- o.licenseno as "licenseno",
- (ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
- +
- (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
- as "amount",
- "1" as businessSegmentsType,
- "1" as transactionType,
- ins.createtime as "createTime"
- from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_orders o ON o.orderno=ins.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- ins.orderstatus ='3'
- and a.user_id = #{myCollectInAdvanceQueryDto.userId}
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- </select>
- <select id="findMyCollectInAdvanceWillAmountByUserIdCount" resultType="java.lang.Long">
- SELECT
- count(0)
- FROM
- (
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.first_detail_premiums as "amount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.third_detail_premiums as "amount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.ins_order_no as "subOrderNo",
- iac.signing_time as "signingTime",
- o.licenseno as "licenseno",
- a.second_detail_premiums as "amount"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders o ON o.orderno=iac.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="findMyCollectInAdvanceSumByUserIdCount" resultType="java.lang.Long">
- select
- count(0)
- from
- ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
- left join ins_orders o ON o.orderno=ins.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- and a.user_id = #{myCollectInAdvanceQueryDto.userId}
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- </select>
- <select id="findSumWillAmount" resultType="java.math.BigDecimal">
- SELECT
- sum(fee.amount)
- FROM
- (
- SELECT
- a.first_detail_premiums as "amount"
- 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>
- iac.orderstatus = '3'
- AND iff.auditstatus =0
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.third_detail_premiums as "amount"
- 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>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- UNION
- SELECT
- a.second_detail_premiums as "amount"
- 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>
- iac.orderstatus = '3'
- <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
- AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
- </if>
- <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
- AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
- </if>
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="findSumAmount" resultType="java.math.BigDecimal">
- select
- ifnull(sum((ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
- +
- (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
- ),0)
- as "amount"
- from
- ins_fee_order_new a left join ins_area_company iac on a.ins_order_no=iac.id
- left join ins_orders o ON o.orderno=iac.orderno
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iac.orderstatus = '3'
- AND iff.auditstatus = 0
- and a.user_id = #{myCollectInAdvanceQueryDto.userId}
- <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
- AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
- </if>
- </where>
- </select>
- <select id="findMyInsuranceByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
- <include refid="common_List_sql"/>
- </select>
- <select id="exportMyInsuranceByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
- <include refid="common_List_sql"/>
- </select>
- <sql id="common_List_sql">
- SELECT
- a.ins_order_no AS "subOrderNo",
- DATE_FORMAT(iac.signing_time, '%Y-%m-%d %H:%i:%s') AS "signingTime",
- DATE_FORMAT(iac.signing_time, '%Y-%m-%d') AS "signingTimeDay",
- DATE_FORMAT(iff.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
- DATE_FORMAT(iff.audittime, '%Y-%m-%d') AS "auditTimeDay",
- CASE iff.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
- o.licenseno AS "licenseno",
- (
- ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 )) + (
- ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )) AS "amount",
- a.user_id AS userId,
- iac.jqapplyno AS jqapplyno,
- iac.syapplyno AS syapplyno,
- iac.inscompany AS companyName,
- JSON_UNQUOTE(json_extract(o.applyinfo, '$.name')) as insuredName,
- ins.NAME AS partnerCompaniesName,
- o.username as userName,
- o.orderno as orderno,
- o.frameno as frameNo,
- JSON_EXTRACT( o.carinfo, '$.engineNo' ) as engineNo,
- iac.product as productId,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- a.jq_costs_export_proportion+a.jq_export_other_costs_proportion as jq_export_proportion,
- a.sy_costs_export_proportion+a.sy_export_other_costs_proportion as sy_export_proportion,
- a.no_costs_export_proportion+a.no_export_other_costs_proportion as no_export_proportion
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN esm_ins_company ins ON ins.id = agree.partner_companies_id
- WHERE
- iac.orderstatus = '3'
- and iff.auditstatus !=2
- <choose>
- <when test="userList != null and userList.size>0">
- AND ( a.user_id = #{vo.userId} or a.user_id in
- <foreach collection="userList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- )
- </when>
- <otherwise>
- AND a.user_id = #{vo.userId}
- </otherwise>
- </choose>
- <if test="vo.orderNo!=null and vo.orderNo!= ''">
- AND o.orderno = #{vo.orderNo}
- </if>
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.userDLId!=null and vo.userDLId!= ''">
- AND a.user_id = #{vo.userDLId}
- </if>
- <if test="vo.userDLName!=null and vo.userDLName!= ''">
- AND o.username= #{vo.userDLName}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- <if test="vo.salesmanId!=null and vo.salesmanId!= ''">
- AND o.user_id = #{vo.salesmanId}
- </if>
- <if test="vo.salesmanName!=null and vo.salesmanName!= ''">
- AND o.username = #{vo.salesmanName}
- </if>
- <if test="vo.jqapplyno!=null and vo.jqapplyno!= ''">
- AND iac.jqapplyno like concat('%', #{vo.jqapplyno},'%')
- </if>
- <if test="vo.syapplyno!=null and vo.syapplyno!= ''">
- AND iac.syapplyno like concat('%', #{vo.syapplyno},'%')
- </if>
- <if test="vo.frameNo!=null and vo.frameNo!= ''">
- AND o.frameno = #{vo.frameNo}
- </if>
- <if test="vo.engineNo!=null and vo.engineNo!= ''">
- and JSON_EXTRACT( o.carinfo, '$.engineNo' ) = #{vo.engineNo}
- </if>
- <if test="vo.productId!=null and vo.productId!= ''">
- AND iac.productid = #{vo.productId}
- </if>
- <if test="vo.insuredName!=null and vo.insuredName!= ''">
- AND o.insuredname = #{vo.insuredName}
- </if>
- <if test="vo.companyId!=null and vo.companyId!= ''">
- AND iac.company_id = #{vo.companyId}
- </if>
- </sql>
- <select id="findMyInsuranceTGByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
- <include refid="common_List_sql_tg"/>
- </select>
- <select id="exportMyInsuranceTGByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
- <include refid="common_List_sql_tg"/>
- </select>
- <sql id="common_List_sql_tg">
- SELECT
- fee.subOrderNo,
- DATE_FORMAT(fee.signingTime, '%Y-%m-%d %H:%i:%s') AS "signingTime",
- DATE_FORMAT(fee.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
- CASE fee.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
- fee.licenseno,
- fee.amount,
- fee.userId,
- fee.userName,
- fee.jqpremium,
- fee.sypremium,
- fee.jypremium,
- fee.sumpremium,
- fee.userLevel
- FROM
- (
- SELECT
- a.ins_order_no AS "subOrderNo",
- iac.signing_time AS "signingTime",
- o.licenseno AS "licenseno",
- iff.audittime AS "auditTime",
- iff.auditstatus AS auditstatus,
- o.username AS userName,
- o.userid AS userId,
- iac.jqpremium AS jqpremium,
- iac.sypremium AS sypremium,
- iac.jypremium AS jypremium,
- iac.sumpremium AS sumpremium,
- a.first_detail_premiums AS "amount",
- "一级代理" AS userLevel
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- WHERE
- iac.orderstatus = '3'
- AND a.first_level_user_id = #{vo.userId}
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.userDLId!=null and vo.userDLId!= ''">
- AND o.userid = #{vo.userDLId}
- </if>
- <if test="vo.userDLName!=null and vo.userDLName!= ''">
- AND o.username= #{vo.userDLName}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- UNION
- SELECT
- a.ins_order_no AS "subOrderNo",
- iac.signing_time AS "signingTime",
- o.licenseno AS "licenseno",
- iff.audittime AS "auditTime",
- iff.auditstatus AS auditstatus,
- o.username AS userName,
- o.userid AS userId,
- iac.jqpremium AS jqpremium,
- iac.sypremium AS sypremium,
- iac.jypremium AS jypremium,
- iac.sumpremium AS sumpremium,
- a.third_detail_premiums AS "amount",
- "三级级代理" AS userLevel
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- WHERE
- iac.orderstatus = '3'
- AND iff.auditstatus = 0
- AND a.three_level_user_id = #{vo.userId}
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.userDLId!=null and vo.userDLId!= ''">
- AND o.userid = #{vo.userDLId}
- </if>
- <if test="vo.userDLName!=null and vo.userDLName!= ''">
- AND o.username= #{vo.userDLName}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- UNION
- SELECT
- a.ins_order_no AS "subOrderNo",
- iac.signing_time AS "signingTime",
- o.licenseno AS "licenseno",
- iff.audittime AS "auditTime",
- iff.auditstatus AS auditstatus,
- o.username AS userName,
- o.userid AS userId,
- iac.jqpremium AS jqpremium,
- iac.sypremium AS sypremium,
- iac.jypremium AS jypremium,
- iac.sumpremium AS sumpremium,
- a.second_detail_premiums AS "amount",
- "二级代理" AS userLevel
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- WHERE
- iac.orderstatus = '3'
- AND a.two_level_user_id = #{vo.userId}
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.userDLId!=null and vo.userDLId!= ''">
- AND o.userid = #{vo.userDLId}
- </if>
- <if test="vo.userDLName!=null and vo.userDLName!= ''">
- AND o.username= #{vo.userDLName}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- ) AS fee
- ORDER BY
- fee.signingTime DESC
- </sql>
- <select id="findMyAmountYSOrSSCXAmount" resultType="java.math.BigDecimal">
- SELECT
- ifnull(sum(
- ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) +
- ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )
- ),0)
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_orders io on iac.orderno =io.orderno
- WHERE
- iac.orderstatus = '3'
- and iff.auditstatus=#{vo.auditstatus}
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <choose>
- <when test="vo.deptId!=null and vo.deptId!= '' ">
- and io.deptid like "${vo.deptId}%"
- </when>
- <otherwise>
- AND a.user_id = #{vo.userId}
- </otherwise>
- </choose>
- </select>
- <select id="findMyAmountYSOrSSTGAmount" resultType="java.math.BigDecimal">
- SELECT
- ifnull(sum(fee.amount),0)
- FROM
- (
- SELECT
- a.first_detail_premiums AS "amount"
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- WHERE
- iac.orderstatus = '3'
- AND a.first_level_user_id = #{vo.userId}
- and iff.auditstatus = #{vo.auditstatus}
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- UNION
- SELECT
- a.third_detail_premiums AS "amount"
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- WHERE
- iac.orderstatus = '3'
- AND a.three_level_user_id = #{vo.userId}
- and iff.auditstatus = #{vo.auditstatus}
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- UNION
- SELECT
- a.second_detail_premiums AS "amount"
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- WHERE
- iac.orderstatus = '3'
- AND a.two_level_user_id = #{vo.userId}
- and iff.auditstatus = #{vo.auditstatus}
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- ) AS fee
- </select>
- <select id="findMyAmountYTXmount" resultType="java.math.BigDecimal">
- SELECT
- ifnull( sum( au.amount ), 0 )
- FROM
- sys_amount_auditing au
- WHERE
- au.user_id = #{userId}
- AND auditing_status = #{status}
- </select>
- <select id="queryAdvanceAndActualDataPage"
- resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDataDto">
- SELECT
- a.ins_order_no AS subOrderNo,
- iac.signing_time AS signingTime,
- o.licenseno AS licenseNo,
- CASE
- iff.auditstatus
- WHEN '0' THEN
- '未审核'
- WHEN '1' THEN
- '已审核' ELSE ''
- END AS auditstatus,
- o.username AS userName,
- o.userid AS userId,
- ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) AS haldingAmount,
- ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 ) AS documentaryAmount,
- ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS promotionAmount,
- ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) + ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 ) + ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS sumAmount,
- CASE
- dept.management_source
- WHEN '1' THEN
- '渠道'
- WHEN '2' THEN
- '代理人' ELSE ''
- END deptType
- FROM
- ins_fee_audit iff
- LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- LEFT JOIN sys_dept dept ON o.deptid = dept.id
- WHERE
- iac.orderstatus = '3'
- AND (
- dept.management_source = 1
- OR dept.management_source = 2)
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.userId!=null and vo.userId!= ''">
- AND o.userid = #{vo.userId}
- </if>
- <if test="vo.userName!=null and vo.userName!= ''">
- AND o.username= #{vo.userName}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- <if test="vo.deptType!=null and vo.deptType!= ''">
- AND dept.management_source = #{vo.deptType}
- </if>
- order by iac.signing_time desc
- </select>
- <select id="queryAdvanceAndActualDeptDataPage"
- resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDeptDataDto">
- SELECT
- b.suborder AS subOrderNo,
- iac.signing_time AS signingTime,
- o.licenseno AS licenseNo,
- CASE
- iff.auditstatus
- WHEN '0' THEN
- '未审核'
- WHEN '1' THEN
- '已审核' ELSE ''
- END AS auditstatus,
- o.username AS userName,
- o.userid AS userId,
- b.deptId AS deptId,
- b.sumAmount AS sumAmount,
- dept.NAME AS deptName
- FROM
- ins_fee_audit iff
- LEFT JOIN (
- SELECT
- ins_order_no AS suborder,
- LEFT ( dept_id, 2 ) AS deptId,
- ( jq_dept_premiums_level_1 + sy_dept_premiums_level_1 + no_dept_premiums_level_1 ) AS sumAmount
- FROM
- ins_fee_order_new UNION ALL
- SELECT
- ins_order_no AS suborder,
- LEFT ( dept_id, 4 ) AS deptId,
- ( jq_dept_premiums_level_2 + sy_dept_premiums_level_2 + no_dept_premiums_level_2 ) AS sumAmount
- FROM
- ins_fee_order_new UNION ALL
- SELECT
- ins_order_no AS suborder,
- LEFT ( dept_id, 6 ) AS deptId,
- ( jq_dept_premiums_level_3 + sy_dept_premiums_level_3 + no_dept_premiums_level_3 ) AS sumAmount
- FROM
- ins_fee_order_new UNION ALL
- SELECT
- ins_order_no AS suborder,
- LEFT ( dept_id, 8 ) AS deptId,
- ( jq_dept_premiums_level_4 + sy_dept_premiums_level_4 + no_dept_premiums_level_4 ) AS sumAmount
- FROM
- ins_fee_order_new UNION ALL
- SELECT
- ins_order_no AS suborder,
- LEFT ( dept_id, 11 ) AS deptId,
- ( jq_dept_premiums_level_5 + sy_dept_premiums_level_5 + no_dept_premiums_level_5 ) AS sumAmount
- FROM
- ins_fee_order_new
- ) b ON iff.ins_order_no = b.suborder
- LEFT JOIN ins_area_company iac ON iac.id = b.suborder
- LEFT JOIN ins_orders o ON o.orderno = iac.orderno
- LEFT JOIN sys_dept dept ON b.deptid = dept.id
- WHERE
- iac.orderstatus = '3'
- <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
- AND iac.id = #{vo.subOrderNo}
- </if>
- <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
- AND o.licenseno = #{vo.licenseNo}
- </if>
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
- AND iff.auditstatus = #{vo.auditstatus}
- </if>
- <if test="vo.deptId!=null and vo.deptId!= ''">
- AND dept.id = #{vo.deptId}
- </if>
- order by iac.signing_time desc
- </select>
- <select id="getCostSettlementExcel" resultType="com.ydtech.modules.order.entity.vo.CostSettlementExcelVo">
- SELECT
- io.ins_company,
- sum( ifon.jq_premium ) AS jq_premium,
- sum( ifon.sy_premium ) AS sy_premium,
- sum( ifon.no_premium ) AS no_premium,
- sum( ifon.jq_supervise_costs_premiums ) AS jq_supervise_costs_premiums,
- sum( ifon.jq_other_costs_premiums ) AS jq_other_costs_premiums,
- sum( ifon.sy_supervise_costs_premiums ) AS sy_supervise_costs_premiums,
- sum( ifon.sy_other_costs_premiums ) AS sy_other_costs_premiums,
- sum( ifon.no_supervise_costs_premiums ) AS no_supervise_costs_premiums,
- sum( ifon.no_other_costs_premiums ) AS no_other_costs_premiums,
- sum( ifon.jq_export_supervise_costs_premiums ) AS jq_export_supervise_costs_premiums,
- sum( ifon.jq_export_other_costs_premiums ) AS jq_export_other_costs_premiums,
- sum( ifon.sy_export_supervise_costs_premiums ) AS sy_export_supervise_costs_premiums,
- sum( ifon.sy_export_other_costs_premiums ) AS sy_export_other_costs_premiums,
- sum( ifon.no_export_supervise_costs_premiums ) AS no_export_supervise_costs_premiums,
- sum( ifon.no_export_other_costs_premiums ) AS no_export_other_costs_premiums,
- sum( ifon.first_detail_premiums + ifon.second_detail_premiums + ifon.third_detail_premiums) as distributing_premiums,
- SUM(
- ifon.jq_export_supervise_costs_premiums +
- ifon.jq_export_other_costs_premiums +
- ifon.sy_export_supervise_costs_premiums +
- ifon.sy_export_other_costs_premiums +
- ifon.no_export_supervise_costs_premiums +
- ifon.no_export_other_costs_premiums +
- ifon.first_detail_premiums +
- ifon.second_detail_premiums +
- ifon.third_detail_premiums
- ) AS total_premiums
- 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 ins_fee_order_new ifon on ifon.ins_order_no = iac.id
- 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
- and ifa.auditstatus = 1
- <if test="param.companyId !=null and param.companyId != ''">
- AND iac.company_id = #{param.companyId}
- </if>
- <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
- and iac.signing_time between #{param.startTime} and #{param.endTime}
- </if>
- group by ins_company
- </select>
- <select id="getFeeReceivable" resultType="com.ydtech.modules.order.entity.vo.FeeReceivableVo">
- SELECT
- io.ins_company,
- sum( ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 ) AS dept_premiums_level_1,
- sum( ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 ) AS dept_premiums_level_2,
- sum( ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 ) AS dept_premiums_level_3,
- sum( ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 ) AS dept_premiums_level_4,
- sum( ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 ) AS dept_premiums_level_5,
- sum( ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums ) AS profit_margin_premiums,
- SUM(
- ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 + ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 + ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 + ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 + ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 + ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums
- ) AS total_premiums
- 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 ins_fee_order_new ifon ON ifon.ins_order_no = iac.id
- 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
- AND ifa.auditstatus = 1
- <if test="param.companyId !=null and param.companyId != ''">
- AND iac.company_id = #{param.companyId}
- </if>
- <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
- AND iac.signing_time BETWEEN #{param.startTime}
- AND #{param.endTime}
- </if>
- GROUP BY
- ins_company
- </select>
- </mapper>
|