| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166 |
- <?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
- 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))
- )
- 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(iff.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
- 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,
- o.insuredname 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
- 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
- WHERE
- iac.orderstatus = '3'
- and iff.auditstatus=#{vo.auditstatus}
- AND a.user_id = #{vo.userId}
- <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
- AND iac.signingTime BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- </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.signingTime 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.signingTime 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.signingTime 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 = '3'
- </select>
- </mapper>
|