| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416 |
- <?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'
- <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>
|