123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088 |
- <?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.dayou.mapper.FinanceRealFundMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.FinanceRealFund">
- <result column="id" property="id" />
- <result column="deleted" property="deleted" />
- <result column="modified" property="modified" />
- <result column="created" property="created" />
- <result column="payer" property="payer" />
- <result column="payer_bank" property="payerBank" />
- <result column="payer_account" property="payerAccount" />
- <result column="amount" property="amount" />
- <result column="pay_datetime" property="payDatetime" />
- <result column="remark" property="remark" />
- <result column="creator_id" property="creatorId" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- deleted,
- modified,
- created,
- payer, payer_bank, payer_account, amount, pay_datetime, remark, creator_id
- </sql>
- <sql id="pageListSql">
- SELECT
- frf.id,
- frf.created,
- frf.payer,
- frf.payer_bank,
- frf.payer_account,
- frf.amount,
- frf.pay_datetime,
- frf.remark,
- frf.creator_id,
- u.name AS creator,
- ifnull(t.ca,0) AS claimAmount,
- ( frf.amount - ifnull(t.ca,0) ) AS notClaimAmount
- FROM
- finance_real_fund frf
- LEFT JOIN user u ON u.id = frf.creator_id
- LEFT JOIN ( SELECT real_fund_id, sum(ifnull(claim_amount,0)) ca FROM finance_claim WHERE deleted = 0 GROUP BY real_fund_id ) t ON t.real_fund_id = frf.id
- WHERE
- frf.deleted = 0
- <if test="vo!=null and vo.notFinished">
- and ifnull(t.ca,0) < frf.amount
- </if>
- <if test="vo!=null and !vo.notFinished">
- and ifnull(t.ca,0) >= frf.amount
- </if>
- <if test="keyword!=null and keyword!='' ">
- and (
- frf.payer like concat ('%',#{keyword},'%')
- or frf.payer_bank like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or frf.payer_account like concat('%',#{keyword},'%')
- or frf.amount like concat('%',#{keyword},'%')
- or frf.remark like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and frf.pay_datetime >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and frf.pay_datetime <= #{vo.endDate}
- </if>
- <if test="vo!=null and vo.xStartDate!=null and vo.xStartDate!=''">
- and frf.created >= #{vo.xStartDate}
- </if>
- <if test="vo!=null and vo.xEndDate!=null and vo.xEndDate!=''">
- and frf.created <= #{vo.xEndDate}
- </if>
- </sql>
- <sql id="pageListSql1">
- SELECT
- #{userId} as userId,
- frf.id,
- frf.created,
- frf.payer,
- frf.payer_bank,
- frf.payer_account,
- frf.amount,
- frf.pay_datetime,
- frf.remark,
- frf.creator_id,
- u.name AS creator,
- ifnull(t.ca,0) AS claimAmount,
- ( frf.amount - ifnull(t.ca,0) ) AS notClaimAmount
- FROM
- finance_real_fund frf
- LEFT JOIN user u ON u.id = frf.creator_id
- LEFT JOIN ( SELECT real_fund_id, sum(ifnull(claim_amount,0)) ca FROM finance_claim WHERE deleted = 0 GROUP BY real_fund_id ) t ON t.real_fund_id = frf.id
- WHERE
- frf.deleted = 0
- <if test="vo!=null and vo.notFinished">
- and ifnull(t.ca,0) < frf.amount
- </if>
- <if test="vo!=null and !vo.notFinished">
- and ifnull(t.ca,0) >= frf.amount
- </if>
- <if test="keyword!=null and keyword!='' ">
- and (
- frf.payer like concat ('%',#{keyword},'%')
- or frf.payer_bank like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or frf.payer_account like concat('%',#{keyword},'%')
- or frf.amount like concat('%',#{keyword},'%')
- or frf.remark like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and frf.pay_datetime >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and frf.pay_datetime <= #{vo.endDate}
- </if>
- <if test="vo!=null and vo.xStartDate!=null and vo.xStartDate!=''">
- and frf.created >= #{vo.xStartDate}
- </if>
- <if test="vo!=null and vo.xEndDate!=null and vo.xEndDate!=''">
- and frf.created <= #{vo.xEndDate}
- </if>
- ORDER BY
- ifnull(t.ca,0) ASC ,frf.created DESC
- </sql>
- <resultMap id="realAmountClaimMap" type="com.dayou.vo.FinanceRealFundVO">
- <result column="userId" property="userId" />
- <result column="id" property="id" />
- <result column="created" property="created" />
- <result column="payer" property="payer" />
- <result column="payer_bank" property="payerBank" />
- <result column="payer_account" property="payerAccount" />
- <result column="amount" property="amount" />
- <result column="pay_datetime" property="payDatetime" />
- <result column="remark" property="remark" />
- <result column="creator_id" property="creatorId" />
- <result column="creator" property="creator" />
- <result column="claimAmount" property="claimAmount" />
- <result column="notClaimAmount" property="notClaimAmount" />
- <collection property="recommends" select="findRecommends" ofType="java.lang.String" column="{amount=amount,userId=userId}" />
- </resultMap>
- <select id="getPage" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.vo.FinanceRealFundVO">
- <include refid="pageListSql" />
- ORDER BY
- ifnull(t.ca,0) ASC ,frf.created DESC
- </select>
- <select id="claimPage" resultMap="realAmountClaimMap">
- SELECT
- #{userId} as userId,
- frf.id,
- frf.created,
- frf.payer,
- frf.payer_bank,
- frf.payer_account,
- frf.amount,
- frf.pay_datetime,
- frf.remark,
- frf.creator_id,
- u.name AS creator,
- ifnull(t.ca,0) AS claimAmount,
- ( frf.amount - ifnull(t.ca,0) ) AS notClaimAmount
- FROM
- finance_real_fund frf
- LEFT JOIN user u ON u.id = frf.creator_id
- LEFT JOIN ( SELECT real_fund_id, sum(ifnull(claim_amount,0)) ca FROM finance_claim WHERE deleted = 0 GROUP BY real_fund_id ) t ON t.real_fund_id = frf.id
- WHERE
- frf.deleted = 0
- <if test="vo!=null and vo.notFinished">
- and ifnull(t.ca,0) < frf.amount
- </if>
- <if test="vo!=null and !vo.notFinished">
- and ifnull(t.ca,0) >= frf.amount
- </if>
- <if test="keyword!=null and keyword!='' ">
- and (
- frf.payer like concat ('%',#{keyword},'%')
- or frf.payer_bank like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or frf.payer_account like concat('%',#{keyword},'%')
- or frf.amount like concat('%',#{keyword},'%')
- or frf.remark like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and frf.pay_datetime >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and frf.pay_datetime <= #{vo.endDate}
- </if>
- <if test="vo!=null and vo.xStartDate!=null and vo.xStartDate!=''">
- and frf.created >= #{vo.xStartDate}
- </if>
- <if test="vo!=null and vo.xEndDate!=null and vo.xEndDate!=''">
- and frf.created <= #{vo.xEndDate}
- </if>
- ORDER BY
- frf.created DESC
- </select>
- <select id="findRecommends" resultType="java.lang.String">
- SELECT
- tt1.business_type
- FROM
- (
- SELECT
- order_fund.real_amount,
- order_fund.business_type,
- temp.invoiceAmount
- FROM
- (
- SELECT
- order_fund_id,
- sum( real_amount ) AS invoiceAmount
- FROM
- finance_invoice
- WHERE
- state = '已开票'
- AND deleted = 0
- AND production_fund_id IS NULL
- <if test="userId!=null">
- and apply_id = #{userId}
- </if>
- GROUP BY
- order_fund_id UNION ALL
- SELECT
- order_fund_id,
- sum( real_amount ) AS invoiceAmount
- FROM
- finance_invoice
- WHERE
- state = '已开票'
- AND deleted = 0
- AND production_fund_id IS NOT NULL
- <if test="userId!=null">
- and apply_id = #{userId}
- </if>
- GROUP BY
- production_fund_id
- ) temp
- LEFT JOIN order_fund ON order_fund.id = temp.order_fund_id
- ) tt1
- WHERE
- tt1.invoiceAmount = #{amount}
- AND tt1.real_amount IS NULL
- </select>
- <select id="getNotClaimAmount" parameterType="java.lang.Long" resultType="java.math.BigDecimal">
- SELECT ( frf.amount -( SELECT ifnull( sum( claim_amount ), 0 ) AS ca FROM finance_claim WHERE deleted = 0 AND real_fund_id = #{realFundId} )
- ) AS notClaimAmount
- FROM
- finance_real_fund frf
- WHERE
- frf.id = #{realFundId}
- AND frf.deleted = 0
- </select>
- <sql id="majorOverdueSql">
- SELECT
- DATEDIFF(
- CURDATE(),
- DATE( mp.repertory_out_time )) AS overdueDay,
- pf.production,
- m.allot_type,
- m.order_id,
- m.business_object_type,
- u.NAME AS clientManager,
- u1.NAME AS principal,
- cc1.NAME AS clientName,
- cc2.NAME AS clientSubName,
- pf.production_should_amount as shouldAmount,
- mp.*
- FROM
- ( SELECT business_id, production_no,
- ( CASE production_type WHEN 'STATEMENT' THEN '意见书' WHEN 'REPORT' THEN '报告' WHEN 'LETTER' THEN '复评函' ELSE '' END ) production,
- production_type
- , production_should_amount, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS'
- AND deleted = 0 and production_should_amount is not null and production_should_amount!=0 and real_amount is null) pf
- inner join
- (
- SELECT
- id,
- major_id,
- report_no,
- production as productionType,
- NAME,
- evaluate_amount,
- repertory_out_time,
- standard_amount
- FROM
- major_production mp
- WHERE
- deleted = 0
- AND repertory_out_time IS NOT NULL
- ) mp
- ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no and mp.productionType = pf.production_type )
- LEFT JOIN major m ON m.id = mp.major_id
- LEFT JOIN user u ON u.id = m.client_manager_id
- LEFT JOIN user u1 ON u1.id = m.principal_id
- LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
- LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
- LEFT JOIN production_return AS `return` ON `return`.deleted = 0 AND business_type = 'MAJOR_BUSINESS' AND `return`.status = 'APPROVE' AND `return`.business_id = mp.major_id AND `return`.production_id = mp.id AND `return`.production_no = mp.report_no
- <where>
- and mp.repertory_out_time>'2024-01-01 00:00:00'
- # 退产品后超期也不预警,所以审核通过的退产品记录必须为null
- AND `return`.id IS NULL
- <if test="overdueVO!=null and overdueVO.overdueMin!=null">
- AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) >= #{overdueVO.overdueMin}
- </if>
- <if test="overdueVO!=null and overdueVO.overdueMax!=null">
- AND DATEDIFF(CURDATE(),DATE( mp.repertory_out_time )) <= #{overdueVO.overdueMax}
- </if>
- <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
- and m.order_id = #{overdueVO.orderId}
- </if>
- <if test="overdueVO!=null and overdueVO.reportNo!=null and overdueVO.reportNo!=''">
- and mp.report_no like concat ('%',#{overdueVO.reportNo},'%')
- </if>
- <if test="overdueVO!=null and overdueVO.principal!=null and overdueVO.principal!=''">
- and u1.NAME like concat ('%',#{overdueVO.principal},'%')
- </if>
- <if test="overdueVO!=null and overdueVO.userIds!=null and overdueVO.userIds.size!=0">
- and m.client_manager_id in
- <foreach collection="overdueVO.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- </where>
- order by overdueDay ASC
- </sql>
- <select id="overdueMajor" parameterType="com.dayou.vo.MajorProdOverdueVO" resultType="com.dayou.vo.MajorProdOverdueVO">
- <include refid="majorOverdueSql" />
- </select>
- <select id="overdueMajorExport" parameterType="com.dayou.vo.MajorProdOverdueVO" resultType="com.dayou.vo.MajorProdOverdueVO">
- <include refid="majorOverdueSql" />
- </select>
- <resultMap id="settleeMajorProductionVOMap" type="com.dayou.vo.SettleMajorProductionVO">
- <id property="id" column="id" />
- <result property="id" column="id" />
- <result property="claimAmount" column="claim_amount" />
- <result property="orderId" column="order_id" />
- <result property="reportNo" column="report_no" />
- <result property="claimDate" column="claimDate" />
- <result property="saveFileDate" column="save_file_date" />
- <result property="settleDate" column="settleDate" />
- <result property="deliveryDate" column="deliveryDate" />
- <result property="name" column="name" />
- <result property="bailor" column="bailor" />
- <result property="evaluateAmount" column="evaluate_amount" />
- <result property="principal" column="principal" />
- <result property="clientManager" column="clientManager" />
- <result property="clientName" column="clientName" />
- <result property="clientSubName" column="clientSubName" />
- <result property="evaluateDepartmentName" column="evaluateDepartmentName" />
- <result property="marketDepartmentName" column="marketDepartmentName" />
- <result property="payDateTime" column="pay_datetime" />
- <result property="members" column="members" />
- <!-- <collection property="invoices" ofType="com.dayou.vo.SettleProInvoiceVo">-->
- <!-- <result property="invoiceDate" column="invoiceDate" />-->
- <!-- <result property="invoiceUser" column="invoiceUser" />-->
- <!-- <result property="invoiceNo" column="invoiceNo" />-->
- <!-- </collection>-->
- </resultMap>
- <sql id="majorEvaluatorSettleSql">
- SELECT
- fc.id,
- fc.claim_amount,
- m.order_id,
- mp.report_no,
- fc.claim_datetime as claimDate,
- mp.save_file_date,
- IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date ) AS settleDate,
- mp.name,
- m.bailor,
- m.members,
- mp.evaluate_amount,
- u.name AS principal,
- u1.name AS clientManager,
- cc.name AS clientName,
- cc1.name AS clientSubName,
- d.name AS evaluateDepartmentName,
- (
- SELECT
- GROUP_CONCAT( name )
- FROM
- department
- WHERE
- id IN (
- SELECT
- department_id
- FROM
- post
- WHERE
- id IN ( SELECT post_id FROM user_post WHERE user_id = m.client_manager_id ))) AS marketDepartmentName,
- frf.pay_datetime
- FROM
- (
- SELECT
- id,
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime,
- real_fund_id
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, pay_datetime FROM finance_real_fund WHERE deleted = 0
- <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
- AND pay_datetime >= #{settleVO.payStartDate}
- </if>
- <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
- AND pay_datetime <= #{settleVO.payEndDate}
- </if>
- ) frf ON frf.id = fc.real_fund_id
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no ,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- save_file_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.save_file_date IS NOT NULL
- ) mp ON (mp.report_no = pf.production_no and mp.major_id = pf.business_id and mp.production = pf.production_type)
- LEFT JOIN major m ON m.id = mp.major_id
- LEFT JOIN user u ON u.id = m.principal_id
- LEFT JOIN user u1 ON u1.id = m.client_manager_id
- LEFT JOIN customer_company cc ON cc.id = m.clientele_id
- LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_sub_id
- LEFT JOIN department d ON d.id = m.department_id
- <where>
- m.financial is not null
- <if test="keyword!=null and keyword!='' ">
- and (
- mp.report_no like concat ('%',#{keyword},'%')
- or fc.claim_amount =#{keyword}
- or m.order_id like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or u1.name like concat('%',#{keyword},'%')
- )
- </if>
- <if test="settleVO!=null and settleVO.startDate!=null and settleVO.startDate!='' ">
- AND (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) >= #{settleVO.startDate}
- </if>
- <if test="settleVO!=null and settleVO.endDate!=null and settleVO.endDate!='' ">
- AND (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) <= #{settleVO.endDate}
- </if>
- <if test="settleVO!=null and settleVO.evaluateDepartmentName!=null and settleVO.evaluateDepartmentName!=''">
- and d.name = #{settleVO.evaluateDepartmentName}
- </if>
- </where>
- order by fc.claim_datetime ASC
- </sql>
- <select id="majorEvaluatorSettleProd" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
- <include refid="majorEvaluatorSettleSql" />
- </select>
- <select id="majorEvaluatorSettleExport" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
- <include refid="majorEvaluatorSettleSql" />
- </select>
- <sql id="majorMarketerSettleSql">
- SELECT
- fc.id,
- fc.claim_amount,
- m.order_id,
- mp.report_no,
- fc.claim_datetime AS claimDate,
- mp.delivery_date AS deliveryDate,
- IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date ) AS settleDate,
- mp.NAME,
- m.bailor,
- m.members,
- mp.evaluate_amount,
- u.NAME AS principal,
- u1.NAME AS clientManager,
- cc.NAME AS clientName,
- cc1.NAME AS clientSubName,
- d.NAME AS evaluateDepartmentName,
- (
- SELECT
- GROUP_CONCAT( NAME )
- FROM
- department
- WHERE
- id IN (
- SELECT
- department_id
- FROM
- post
- WHERE
- id IN ( SELECT post_id FROM user_post WHERE user_id = m.client_manager_id and deleted = 0 ))) AS marketDepartmentName,
- frf.pay_datetime
- FROM
- (
- SELECT
- id,
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime,
- real_fund_id
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, pay_datetime FROM finance_real_fund WHERE deleted = 0
- <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
- AND pay_datetime >= #{settleVO.payStartDate}
- </if>
- <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
- AND pay_datetime <= #{settleVO.payEndDate}
- </if>
- ) frf ON frf.id = fc.real_fund_id
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no ,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- delivery_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.delivery_date IS NOT NULL
- ) mp ON (mp.report_no = pf.production_no and mp.major_id = pf.business_id and mp.production = pf.production_type )
- LEFT JOIN major m ON m.id = mp.major_id
- LEFT JOIN user u ON u.id = m.principal_id
- LEFT JOIN user u1 ON u1.id = m.client_manager_id
- LEFT JOIN customer_company cc ON cc.id = m.clientele_id
- LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_sub_id
- LEFT JOIN department d ON d.id = m.department_id
- <where>
- m.financial is not null
- <if test="keyword!=null and keyword!='' ">
- and (
- mp.report_no like concat ('%',#{keyword},'%')
- or fc.claim_amount =#{keyword}
- or m.order_id like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or u1.name like concat('%',#{keyword},'%')
- )
- </if>
- <if test="settleVO!=null and settleVO.startDate!=null and settleVO.startDate!='' ">
- AND (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) >= #{settleVO.startDate}
- </if>
- <if test="settleVO!=null and settleVO.endDate!=null and settleVO.endDate!='' ">
- AND (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) <= #{settleVO.endDate}
- </if>
- </where>
- order by fc.claim_datetime ASC
- </sql>
- <select id="majorMarketerSettleProd" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
- <include refid="majorMarketerSettleSql" />
- </select>
- <select id="majorMarketSettleExport" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
- <include refid="majorMarketerSettleSql" />
- </select>
- <select id="majorEvaluatorCommission" parameterType="com.dayou.vo.UserCommissionTotalAmountVO" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT mpa.user_id as id, u.name as userName, sum(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio )) AS commissionTotalAmount
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- save_file_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.save_file_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN (select * from major where financial is not null) m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'EVALUATE'
- ) mpa ON ( mpa.major_id = m.id AND mpa.major_production_id = mp.id)
- LEFT JOIN user u ON u.id = mpa.user_id
- <where>
- (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) >= #{vo.startDate}
- AND (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) <= #{vo.endDate}
- <if test="vo!=null and vo.userIds!=null and vo.userIds.size!=0">
- and mpa.user_id in
- <foreach collection="vo.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- </where>
- GROUP BY
- mpa.user_id
- having 1=1
- <if test="vo!=null and vo.userName!=null and vo.userName!=''">
- and u.name like concat ('%',#{vo.userName},'%')
- </if>
- order by commissionTotalAmount DESC
- </select>
- <select id="majorEvaluatorCommissionDetail" parameterType="com.dayou.vo.UserCommissionProdVO" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- mp.id,
- fc.claim_amount as realAmount,
- mp.report_no,
- IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date ) AS settleDate,
- mp.NAME,
- mp.created,
- dd.NAME AS businessCate,
- bcr.min_ratio AS ratio,
- mpa.user_id,
- mpa.ratio AS allotRatio,
- ( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio ) AS commissionAmount,
- ( fc.claim_amount * ( bcr.min_ratio / 100 ) ) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- save_file_date,
- fund.real_amount,
- created
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.save_file_date IS NOT NULL
- ) mp ON (mp.report_no = pf.production_no and mp.production = pf.production_type)
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'EVALUATE' ) mpa ON ( mpa.major_id = m.id AND mpa.major_production_id = mp.id)
- LEFT JOIN user u on u.id = mpa.user_id
- WHERE
- m.financial is not null and
- mpa.user_id = #{vo.userId} and
- (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) >= #{vo.startDate}
- AND (select IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date )) <= #{vo.endDate}
- order by settleDate DESC
- </select>
- <select id="majorEvaluatorTotalAmountExport" parameterType="com.dayou.vo.UserCommissionTotalAmountVO" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT mpa.user_id as id, u.name as userName, ROUND(sum(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio )),2) AS commissionTotalAmount,
- '评估人员' as userType,
- '大中型业务' as businessType,
- #{vo.startDate} as startDate,
- #{vo.endDate} as endDate
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- save_file_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.save_file_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'EVALUATE'
- ) mpa ON ( mpa.major_id = m.id AND mpa.major_production_id = mp.id)
- LEFT JOIN user u ON u.id = mpa.user_id
- GROUP BY
- mpa.user_id
- </select>
- <select id="evaluatorUserDetailExport" parameterType="com.dayou.vo.UserCommissionProdVO" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- mp.id,
- ROUND(fc.claim_amount,2) as realAmount,
- mp.report_no,
- IF
- ( fc.claim_datetime > mp.save_file_date, fc.claim_datetime, mp.save_file_date ) AS settleDate,
- mp.NAME,
- mp.created,
- dd.NAME AS businessCate,
- ROUND(bcr.min_ratio,2) AS ratio,
- mpa.user_id,
- ROUND(mpa.ratio*100,2) AS allotRatio,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio ),2) AS commissionAmount,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 ) ),2) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- save_file_date,
- fund.real_amount,
- created
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.save_file_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'EVALUATE' ) mpa ON ( mpa.major_id = m.id AND mpa.major_production_id = mp.id)
- LEFT JOIN user u on u.id = mpa.user_id
- <where>
- <if test="vo!=null and vo.userId!=null">
- and mpa.user_id = #{vo.userId}
- </if>
- </where>
- order by mpa.user_id
- </select>
- <select id="majorMarketCommission" parameterType="com.dayou.vo.UserCommissionTotalAmountVO" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT mpa.user_id as id, u.name as userName, sum(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio )) AS commissionTotalAmount
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- delivery_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.delivery_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN (select * from major where financial is not null) m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id,declare_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'MARKET'
- ) mpa ON ( mpa.major_id = m.id AND cd.id = mpa.declare_id AND (mpa.major_production_id is null or mpa.major_production_id = mp.id ))
- LEFT JOIN user u ON u.id = mpa.user_id
- <where>
- (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) >= #{vo.startDate}
- AND (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) <= #{vo.endDate}
- <if test="vo!=null and vo.userIds!=null and vo.userIds.size!=0">
- and mpa.user_id in
- <foreach collection="vo.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- </where>
- GROUP BY
- mpa.user_id
- having 1=1
- <if test="vo!=null and vo.userName!=null and vo.userName!=''">
- and u.name like concat ('%',#{vo.userName},'%')
- </if>
- order by commissionTotalAmount DESC
- </select>
- <select id="majorMarketCommissionDetail" parameterType="com.dayou.vo.UserCommissionProdVO" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- mp.id,
- fc.claim_amount as realAmount,
- mp.report_no,
- IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date ) AS settleDate,
- mp.NAME,
- mp.created,
- dd.NAME AS businessCate,
- bcr.min_ratio AS ratio,
- mpa.user_id,
- mpa.ratio AS allotRatio,
- ( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio ) AS commissionAmount,
- ( fc.claim_amount * ( bcr.min_ratio / 100 ) ) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no,production_type FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- delivery_date,
- fund.real_amount,
- created
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.delivery_date IS NOT NULL
- ) mp ON (mp.report_no = pf.production_no and mp.production = pf.production_type)
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio,declare_id FROM major_production_allot WHERE deleted = 0 AND user_type = 'MARKET' ) mpa ON ( mpa.major_id = m.id AND cd.id = mpa.declare_id AND (mpa.major_production_id is null or mpa.major_production_id = mp.id ))
- LEFT JOIN user u on u.id = mpa.user_id
- WHERE
- m.financial is not null and
- mpa.user_id = #{vo.userId} and
- (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) >= #{vo.startDate}
- AND (select IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date )) <= #{vo.endDate}
- order by settleDate DESC
- </select>
- <select id="majorMarketTotalAmountExport" parameterType="com.dayou.vo.UserCommissionTotalAmountVO" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT mpa.user_id as id, u.name as userName, ROUND(sum(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio )),2) AS commissionTotalAmount,
- '市场人员' as userType,
- '大中型业务' as businessType,
- #{vo.startDate} as startDate,
- #{vo.endDate} as endDate
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- delivery_date,
- fund.real_amount
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.delivery_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id,declare_id, user_id, ratio FROM major_production_allot WHERE deleted = 0 AND user_type = 'MARKET'
- ) mpa ON ( mpa.major_id = m.id AND cd.id = mpa.declare_id AND (mpa.major_production_id is null or mpa.major_production_id = mp.id ))
- LEFT JOIN user u ON u.id = mpa.user_id
- GROUP BY
- mpa.user_id
- order by commissionTotalAmount DESC
- </select>
- <select id="marketUserDetailExport" parameterType="com.dayou.vo.UserCommissionProdVO" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- mp.id,
- ROUND(fc.claim_amount,2) as realAmount,
- mp.report_no,
- IF
- ( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date ) AS settleDate,
- mp.NAME,
- mp.created,
- dd.NAME AS businessCate,
- ROUND(bcr.min_ratio,2) AS ratio,
- mpa.user_id,
- ROUND(mpa.ratio*100,2) AS allotRatio,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 )* mpa.ratio ),2) AS commissionAmount,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 ) ),2) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN (
- SELECT
- id,
- major_id,
- NAME,
- report_no,
- production,
- evaluate_amount,
- delivery_date,
- fund.real_amount,
- created
- FROM
- major_production mpr
- INNER JOIN ( SELECT production_no, real_amount, production_type FROM production_fund WHERE deleted = 0 AND business_type = 'MAJOR_BUSINESS' ) fund ON ( fund.production_no = mpr.report_no AND fund.production_type = mpr.production )
- WHERE
- fund.real_amount IS NOT NULL
- AND mpr.delivery_date IS NOT NULL
- ) mp ON mp.report_no = pf.production_no
- LEFT JOIN major m ON m.id = mp.major_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_MAJOR_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = m.id
- AND cd.production_id = mp.id )
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT major_id, major_production_id, user_id, ratio,declare_id FROM major_production_allot WHERE deleted = 0 AND user_type = 'MARKET' ) mpa ON ( mpa.major_id = m.id AND cd.id = mpa.declare_id AND (mpa.major_production_id is null or mpa.major_production_id = mp.id ))
- LEFT JOIN user u on u.id = mpa.user_id
- <where>
- <if test="vo!=null and vo.userId!=null">
- and mpa.user_id = #{vo.userId}
- </if>
- </where>
- order by mpa.user_id
- </select>
- <sql id="personalOverdueSql">
- SELECT
- DATEDIFF(
- CURDATE(),
- DATE ( pp.rot )) AS overdueDay,
- p.*,
- pt.acreage,
- pt.price,
- pt.amount,
- cc1.NAME AS clientName,
- cc2.NAME AS clientSubName,
- cl1.NAME AS contactName,
- cl1.mobile AS contactTel,
- u.NAME AS clientManager,
- u1.NAME AS outwardStaffName,
- u2.NAME AS inwardStaffName,
- u3.NAME AS pricingStaffName,
- pp.rot
- FROM
- (
- SELECT
- id,
- location,
- order_id,
- agent,
- bailorA,
- bailorB,
- clientele_id,
- clientele_sub_id,
- clientele_contact_id,
- client_manager_id,
- outward_staff,
- inward_staff,
- pricing_staff
- FROM
- personal
- WHERE
- deleted = 0
- ) p
- inner JOIN personal_target pt ON pt.personal_id = p.id
- inner JOIN ( SELECT business_id, should_amount, real_amount FROM order_fund WHERE business_type = 'PERSONAL_BUSINESS' AND deleted = 0 AND real_amount IS NULL ) ofu ON ofu.business_id = p.id
- inner JOIN ( SELECT target_id,( repertory_out_time ) rot FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) pp ON pp.target_id = pt.id
- LEFT JOIN customer_company cc1 ON cc1.id = p.clientele_id
- LEFT JOIN customer_company cc2 ON cc2.id = p.clientele_sub_id
- LEFT JOIN customer_linkman cl1 ON cl1.id = p.clientele_contact_id
- LEFT JOIN `user` u ON u.id = p.client_manager_id
- LEFT JOIN `user` u1 ON u1.id = p.outward_staff
- LEFT JOIN `user` u2 ON u2.id = p.inward_staff
- LEFT JOIN `user` u3 ON u3.id = p.pricing_staff
- LEFT JOIN production_return AS `return` ON `return`.deleted = 0 AND business_type = 'PERSONAL_BUSINESS' AND `return`.status = 'APPROVE' AND `return`.business_id = p.id AND `return`.production_id IS NULL
- <where>
- AND pp.rot>'2024-01-01 00:00:00'
- AND `return`.id IS NULL
- <if test="overdueVO!=null and overdueVO.overdueMin!=null">
- AND DATEDIFF(CURDATE(),DATE ( pp.rot )) >= #{overdueVO.overdueMin}
- </if>
- <if test="overdueVO!=null and overdueVO.overdueMax!=null">
- AND DATEDIFF(CURDATE(),DATE( pp.rot )) <= #{overdueVO.overdueMax}
- </if>
- <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
- and p.order_id = #{overdueVO.orderId}
- </if>
- <if test="overdueVO!=null and overdueVO.userIds!=null and overdueVO.userIds.size!=0">
- and p.client_manager_id in
- <foreach collection="overdueVO.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- </where>
- ORDER BY
- overdueDay ASC
- </sql>
- <select id="overduePersonal" parameterType="com.dayou.vo.PersonalOverdueVO" resultType="com.dayou.vo.PersonalOverdueVO">
- <include refid="personalOverdueSql" />
- </select>
- <select id="overduePersonalList" parameterType="com.dayou.vo.PersonalOverdueVO" resultType="com.dayou.vo.PersonalOverdueVO">
- <include refid="personalOverdueSql" />
- </select>
- <!--资产评估人员提成计算-->
- <select id="assetsEvaluatorCommission" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT bpd.member_id as id,
- u.name as userName,
- SUM(IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- )) AS allCommissionTotalAmount,
- SUM(IF(ap.save_file_date IS NOT NULL, (IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- )), 0)) AS commissionTotalAmount
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT
- allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM
- order_fund_allot
- WHERE
- deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type =
- 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id
- )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM
- assets_production
- WHERE deleted = 0) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id, ratio, defined_low_limit_amount FROM
- commission_declare WHERE
- business_type = 'COMMISSION_DECLARE_ASSET_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no, member_id, performance_distribution FROM
- business_performance_distribution WHERE deleted = 0
- AND user_type = '评估人员'
- ) bpd ON ( bpd.business_id = a.id AND bpd.report_no = ap.production_no)
- LEFT JOIN user u ON u.id = bpd.member_id
- GROUP BY
- bpd.member_id
- having 1=1
- <if test="vo!=null and vo.userName!=null and vo.userName!=''">
- and u.name like concat ('%',#{vo.userName},'%')
- </if>
- order by commissionTotalAmount DESC
- </select>
- <!--资产评估人员提成计算详情-->
- <select id="assetsEvaluatorCommissionDetail" resultType="com.dayou.vo.UserCommissionProdAssetsVO">
- SELECT
- ap.id,
- fc.claim_amount as realAmount,
- ap.production_no AS reportNo,
- IF
- ( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
- ap.assets_name AS name,
- ap.created,
- dd.name AS businessCate,
- IFNULL(cd.ratio,bcr.min_ratio) AS ratio,
- cd.defined_low_limit_amount AS lowLimitAmount,
- bpd.member_id,
- bpd.performance_distribution AS allotRatio,
- IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- ) AS commissionAmount,
- IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100)
- ) AS totalAmount,
- u.name AS userName,
- pf.modified AS realFundDateTime
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT
- allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM
- order_fund_allot
- WHERE
- deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no,modified FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM assets_production WHERE deleted = 0) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id, ratio,defined_low_limit_amount FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_ASSET_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no, member_id, performance_distribution FROM business_performance_distribution WHERE deleted = 0 AND user_type = '评估人员' ) bpd ON ( bpd.business_id = a.id AND bpd.report_no = ap.production_no)
- LEFT JOIN user u on u.id = bpd.member_id
- WHERE
- bpd.member_id = #{vo.userId}
- order by settleDate DESC
- </select>
- <!--资产评估人员合计导出-->
- <select id="assetsEvaluatorTotalAmountExport" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT bpd.member_id as id,
- u.name as userName,
- ROUND(SUM(IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- )), 2) AS allCommissionTotalAmount,
- ROUND(SUM(IF(ap.save_file_date IS NOT NULL, (IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- )), 0)), 2) AS commissionTotalAmount,
- '评估人员' as userType,
- '资产业务' as businessType,
- #{vo.startDate} as startDate,
- #{vo.endDate} as endDate
- FROM (SELECT claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM finance_claim
- WHERE deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM order_fund_allot
- WHERE deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}) fc
- INNER JOIN (SELECT id, order_fund_id, business_id, production_no
- FROM production_fund
- WHERE business_type = 'ASSET_BUSINESS'
- AND deleted = 0) pf
- ON (pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id)
- INNER JOIN (SELECT id,
- business_id,
- assets_name,
- production_no,
- production_type,
- save_file_date,
- created
- FROM assets_production
- WHERE deleted = 0) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN (SELECT id, business_id, production_id, commission_rate_id, defined_low_limit_amount, ratio
- FROM commission_declare
- WHERE business_type = 'COMMISSION_DECLARE_ASSET_EVALUATE'
- AND deleted = 0
- AND declare_result = '审核通过') cd ON (
- cd.business_id = a.id
- AND (cd.production_id IS NULL OR cd.production_id = ap.id))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN (SELECT business_id, report_no, member_id, performance_distribution
- FROM business_performance_distribution
- WHERE deleted = 0
- AND user_type = '评估人员') bpd
- ON (bpd.business_id = a.id AND bpd.report_no = ap.production_no)
- LEFT JOIN user u ON u.id = bpd.member_id
- GROUP BY bpd.member_id
- </select>
- <!--资产评估人员提成信息导出-->
- <select id="assetsEvaluatorUserDetailExport" resultType="com.dayou.vo.UserCommissionProdAssetsVO">
- SELECT
- ap.id,
- ROUND(fc.claim_amount,2) as realAmount,
- ap.production_no AS reportNo,
- IF
- ( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
- ap.assets_name AS name,
- ap.created,
- dd.NAME AS businessCate,
- IFNULL(cd.ratio,bcr.min_ratio) AS ratio,
- cd.defined_low_limit_amount AS lowLimitAmount,
- ROUND(bcr.min_ratio,2) AS ratio,
- bpd.member_id AS userId,
- ROUND(bpd.performance_distribution,2) AS allotRatio,
- ROUND(IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100) * (bpd.performance_distribution / 100)
- ),2) AS commissionAmount,
- ROUND(IF(cd.defined_low_limit_amount < fc.claim_amount,
- fc.claim_amount * (cd.ratio / 100),
- cd.defined_low_limit_amount * (cd.ratio / 100)
- ),2) AS totalAmount,
- u.name as userName,
- pf.modified AS realFundDateTime
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT
- allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM
- order_fund_allot
- WHERE
- deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no,modified FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM assets_production WHERE deleted = 0 ) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id, ratio, defined_low_limit_amount FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_ASSET_EVALUATE' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no, member_id, performance_distribution FROM business_performance_distribution WHERE deleted = 0 AND user_type = '评估人员' ) bpd ON ( bpd.business_id = a.id AND bpd.report_no = ap.production_no)
- LEFT JOIN user u on u.id = bpd.member_id
- <where>
- <if test="vo!=null and vo.userId!=null">
- and bpd.member_id = #{vo.userId}
- </if>
- </where>
- order by bpd.member_id
- </select>
- <!--资产市场人员提成计算-->
- <select id="assetsMarketCommission" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT bpd.member_id as id,
- u.name as userName,
- SUM(( fc.claim_amount * ( bcr.min_ratio / 100 ) * (bpd.performance_distribution / 100))) AS commissionTotalAmount
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime FROM order_fund_allot WHERE deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM assets_production WHERE deleted = 0 AND delivery = TRUE ) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_ASSET_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no,declare_id, member_id, performance_distribution FROM business_performance_distribution WHERE deleted = 0 AND user_type = '市场人员'
- ) bpd ON ( bpd.business_id = a.id AND cd.id = bpd.declare_id AND (bpd.report_no is null or bpd.report_no = ap.production_no ))
- LEFT JOIN user u ON u.id = bpd.member_id
- GROUP BY
- bpd.member_id
- having 1=1
- <if test="vo!=null and vo.userName!=null and vo.userName!=''">
- and u.name like concat ('%',#{vo.userName},'%')
- </if>
- order by commissionTotalAmount DESC
- </select>
- <!--资产市场人员提成计算详情-->
- <select id="assetsMarketCommissionDetail" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- ap.id,
- fc.claim_amount as realAmount,
- ap.production_no AS reportNo,
- IF
- ( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
- ap.assets_name AS name,
- ap.created,
- dd.NAME AS businessCate,
- bcr.min_ratio AS ratio,
- bpd.member_id AS userId,
- bpd.performance_distribution AS allotRatio,
- ( fc.claim_amount * ( bcr.min_ratio / 100 ) * (bpd.performance_distribution / 100) ) AS commissionAmount,
- ( fc.claim_amount * ( bcr.min_ratio / 100 ) ) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT
- allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM
- order_fund_allot
- WHERE
- deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM assets_production WHERE deleted = 0 AND delivery = TRUE ) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE business_type = 'COMMISSION_DECLARE_ASSET_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no, member_id, performance_distribution,declare_id FROM business_performance_distribution WHERE deleted = 0 AND user_type = '市场人员' ) bpd
- ON ( bpd.business_id = a.id AND cd.id = bpd.declare_id AND (bpd.report_no is null or bpd.report_no = ap.production_no ))
- LEFT JOIN user u on u.id = bpd.member_id
- WHERE
- bpd.member_id = #{vo.userId}
- order by settleDate DESC
- </select>
- <!--资产市场人员提成合计导出-->
- <select id="assetsMarketTotalAmountExport" resultType="com.dayou.vo.UserCommissionTotalAmountVO">
- SELECT bpd.member_id as id,
- u.name as userName,
- ROUND(SUM((fc.claim_amount * (bcr.min_ratio / 100) * (bpd.performance_distribution / 100))),
- 2) AS commissionTotalAmount,
- '市场人员' as userType,
- '资产业务' as businessType,
- #{vo.startDate} as startDate,
- #{vo.endDate} as endDate
- FROM (SELECT claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM finance_claim
- WHERE deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime
- FROM order_fund_allot
- WHERE deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}) fc
- INNER JOIN (SELECT id, order_fund_id, business_id, production_no
- FROM production_fund
- WHERE business_type = 'ASSET_BUSINESS'
- AND deleted = 0) pf
- ON (pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id)
- INNER JOIN (SELECT id,
- business_id,
- assets_name,
- production_no,
- production_type,
- save_file_date,
- created
- FROM assets_production
- WHERE deleted = 0
- AND delivery = true) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN (SELECT id, business_id, production_id, commission_rate_id
- FROM commission_declare
- WHERE business_type = 'COMMISSION_DECLARE_ASSET_MARKET'
- AND deleted = 0
- AND declare_result = '审核通过') cd ON (
- cd.business_id = a.id
- AND (cd.production_id IS NULL OR cd.production_id = ap.id))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN (SELECT business_id, report_no, declare_id, member_id, performance_distribution
- FROM business_performance_distribution
- WHERE deleted = 0
- AND user_type = '市场人员') bpd ON (bpd.business_id = a.id AND cd.id = bpd.declare_id AND
- (bpd.report_no is null or bpd.report_no = ap.production_no))
- LEFT JOIN user u ON u.id = bpd.member_id
- GROUP BY bpd.member_id
- ORDER BY commissionTotalAmount DESC
- </select>
- <!--资产市场人员提成信息导出-->
- <select id="assetsMarketUserDetailExport" resultType="com.dayou.vo.UserCommissionProdVO">
- SELECT
- ap.id,
- ROUND(fc.claim_amount,2) as realAmount,
- ap.production_no AS reportNo,
- IF
- ( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
- ap.assets_name AS name,
- ap.created,
- dd.`name` AS businessCate,
- ROUND(bcr.min_ratio,2) AS ratio,
- bpd.member_id AS userId,
- ROUND(bpd.performance_distribution,2) AS allotRatio,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 ) * (bpd.performance_distribution / 100) ),2) AS
- commissionAmount,
- ROUND(( fc.claim_amount * ( bcr.min_ratio / 100 ) ),2) AS totalAmount,
- u.name as userName
- FROM
- (
- SELECT
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- AND claim_datetime >= #{vo.startDate}
- AND claim_datetime <= #{vo.endDate}
- UNION ALL
- SELECT
- allot_amount AS claim_amount,
- order_fund_id,
- production_fund_id,
- created AS claim_datetime
- FROM
- order_fund_allot
- WHERE
- deleted = 0
- AND created >= #{vo.startDate}
- AND created <= #{vo.endDate}
- ) fc
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type =
- 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id
- )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, save_file_date, created FROM
- assets_production WHERE deleted = 0 AND delivery = true ) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- INNER JOIN ( SELECT id, business_id, production_id, commission_rate_id FROM commission_declare WHERE
- business_type = 'COMMISSION_DECLARE_ASSET_MARKET' AND deleted = 0 AND declare_result = '审核通过' ) cd ON (
- cd.business_id = a.id
- AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
- LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
- LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
- LEFT JOIN ( SELECT business_id, report_no, member_id, performance_distribution, declare_id FROM
- business_performance_distribution WHERE deleted = 0 AND user_type = '市场人员' ) bpd
- ON ( bpd.business_id = a.id AND cd.id = bpd.declare_id AND (bpd.report_no is null or bpd.report_no =
- ap.production_no ))
- LEFT JOIN user u on u.id = bpd.member_id
- <where>
- <if test="vo!=null and vo.userId!=null">
- and bpd.member_id = #{vo.userId}
- </if>
- </where>
- order by bpd.member_id
- </select>
- <!--资产收款逾期查询Sql-->
- <sql id="assetsOverdueSql">
- SELECT
- DATEDIFF(CURDATE(), DATE( ap.repertory_out_time )) AS overdueDay,
- a.allot_type,
- a.order_id,
- a.assets_business_gener,
- u.name AS clientManager,
- u1.name AS principal,
- cc1.name AS clientName,
- cc2.name AS clientSubName,
- pf.production_should_amount,
- `of`.should_amount,
- pf.standard_amount,
- a.name as projectName,
- ap.*
- FROM
- (
- SELECT
- id,
- business_id,
- production_no,
- ( CASE production_type WHEN 'STATEMENT' THEN '意见书' WHEN 'REPORT' THEN '评估报告' WHEN 'LETTER' THEN '意见函' WHEN 'CONSULT' THEN '咨询报告' ELSE '' END ) productionType,
- evaluate_amount,
- repertory_out_time
- FROM
- assets_production ap
- WHERE
- deleted = 0
- AND repertory_out_time IS NOT NULL
- AND production_type != 'STATEMENT'
- ) ap
- LEFT JOIN ( SELECT id, business_id, production_no, production_should_amount, real_amount, standard_amount FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf
- ON ( ap.business_id = pf.business_id AND ap.production_no = pf.production_no )
- LEFT JOIN ( SELECT id, business_id,should_amount FROM order_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) `of` ON `of`.business_id = ap.business_id
- LEFT JOIN assets a ON a.id = ap.business_id
- LEFT JOIN user u ON u.id = a.client_manager_id
- LEFT JOIN user u1 ON u1.id = a.principal_id
- LEFT JOIN customer_company cc1 ON cc1.id = a.clientele_id
- LEFT JOIN customer_company cc2 ON cc2.id = a.clientele_sub_id
- LEFT JOIN production_return AS `return` ON `return`.deleted = 0 AND business_type = 'ASSET_BUSINESS' AND `return`.status = 'APPROVE' AND `return`.business_id = ap.business_id AND `return`.production_id = ap.id AND `return`.production_no = ap.production_no
- WHERE
- ap.productionType != 'STATEMENT'
- AND ( pf.production_no IS NULL OR pf.real_amount IS NULL )
- # 退产品后超期也不预警,所以审核通过的退产品记录必须为null
- AND `return`.id IS NULL
- and ap.repertory_out_time>'2024-01-01 00:00:00'
- <if test="overdueVO!=null and overdueVO.overdueMin!=null">
- AND DATEDIFF(CURDATE(),DATE( ap.repertory_out_time )) >= #{overdueVO.overdueMin}
- </if>
- <if test="overdueVO!=null and overdueVO.overdueMax!=null">
- AND DATEDIFF(CURDATE(),DATE( ap.repertory_out_time )) <= #{overdueVO.overdueMax}
- </if>
- <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
- and a.order_id = #{overdueVO.orderId}
- </if>
- <if test="overdueVO!=null and overdueVO.productionNo!=null and overdueVO.productionNo!=''">
- and ap.production_no like concat ('%',#{overdueVO.productionNo},'%')
- </if>
- <if test="overdueVO!=null and overdueVO.principal!=null and overdueVO.principal!=''">
- and u1.name like concat ('%',#{overdueVO.principal},'%')
- </if>
- <if test="overdueVO!=null and overdueVO.userIds!=null and overdueVO.userIds.size!=0">
- and a.client_manager_id in
- <foreach collection="overdueVO.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- order by overdueDay asc
- </sql>
- <!--资产收款逾期列表-->
- <select id="overdueAssets" resultType="com.dayou.vo.AssetsProdOverdueVO">
- <include refid="assetsOverdueSql" />
- </select>
- <!--资产收款逾期列表导出-->
- <select id="overdueAssetsExport" resultType="com.dayou.vo.AssetsProdOverdueVO">
- <include refid="assetsOverdueSql" />
- </select>
- <resultMap id="settleAssetsProductionVOMap" type="com.dayou.vo.SettleAssetsProductionVO">
- <id property="id" column="id" />
- <result property="id" column="id" />
- <result property="claimAmount" column="claim_amount" />
- <result property="orderId" column="order_id" />
- <result property="projectName" column="name" />
- <result property="productionNo" column="production_no" />
- <result property="claimDate" column="claimDate" />
- <result property="saveFileDate" column="save_file_date" />
- <result property="settleDate" column="settleDate" />
- <result property="deliveryDate" column="deliveryDate" />
- <result property="projectName" column="projectName" />
- <result property="bailor" column="bailor" />
- <result property="evaluateAmount" column="evaluate_amount" />
- <result property="principal" column="principal" />
- <result property="clientManager" column="clientManager" />
- <result property="clientName" column="clientName" />
- <result property="clientSubName" column="clientSubName" />
- <result property="evaluateDepartmentName" column="evaluateDepartmentName" />
- <result property="marketDepartmentName" column="marketDepartmentName" />
- <result property="payDateTime" column="pay_datetime" />
- <result property="members" column="members" />
- <collection property="invoices" ofType="com.dayou.vo.SettleProInvoiceVo">
- <result property="invoiceDate" column="invoiceDate" />
- <result property="invoiceUser" column="invoiceUser" />
- <result property="invoiceNo" column="invoiceNo" />
- </collection>
- </resultMap>
- <!--资产市场人员结算项目Sql-->
- <sql id="assetsMarketerSettleSql">
- SELECT
- fc.id,
- fc.claim_amount,
- a.order_id,
- ap.production_no,
- fc.claim_datetime AS claimDate,
- ap.delivery_date AS deliveryDate,
- ap.save_file_date,
- IF
- ( fc.claim_datetime > ap.delivery_date, fc.claim_datetime, ap.delivery_date ) AS settleDate,
- ap.assets_name AS projectName,
- a.bailor,
- a.name,
- a.members,
- ap.evaluate_amount,
- u.NAME AS principal,
- u1.NAME AS clientManager,
- cc.NAME AS clientName,
- cc1.NAME AS clientSubName,
- d.NAME AS evaluateDepartmentName,
- (
- SELECT
- GROUP_CONCAT( department.NAME )
- FROM
- department
- WHERE
- id IN (
- SELECT
- department_id
- FROM
- post
- WHERE
- id IN ( SELECT post_id FROM user_post WHERE user_id = a.client_manager_id ))) AS marketDepartmentName,
- invoice.NAME AS invoiceUser,
- invoice.real_make_date AS invoiceDate,
- invoice.tax_no AS invoiceNo,
- frf.pay_datetime
- FROM
- (
- SELECT
- id,
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime,
- real_fund_id
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- inner join (
- select id,pay_datetime from finance_real_fund
- where deleted = 0
- <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
- AND pay_datetime >= #{settleVO.payStartDate}
- </if>
- <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
- AND pay_datetime <= #{settleVO.payEndDate}
- </if>
- ) frf on frf.id = fc.real_fund_id
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type =
- 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id
- )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, evaluate_amount,
- delivery_date, save_file_date FROM assets_production WHERE deleted = 0 AND delivery = true ) ap ON ap.production_no =
- pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- LEFT JOIN user u ON u.id = a.principal_id
- LEFT JOIN user u1 ON u1.id = a.client_manager_id
- LEFT JOIN customer_company cc ON cc.id = a.clientele_id
- LEFT JOIN customer_company cc1 ON cc1.id = a.clientele_sub_id
- LEFT JOIN department d ON d.id = a.department_id
- LEFT JOIN (
- SELECT real_make_date, name, tax_no, order_fund_id, production_fund_id
- FROM finance_invoice, user
- WHERE maker_id = user.id
- AND finance_invoice.deleted = 0
- AND state = '已开票' order by user.created desc limit 1
- ) AS invoice ON IF(invoice.production_fund_id IS NOT NULL ,invoice.order_fund_id = pf.order_fund_id AND invoice.production_fund_id = pf.id,invoice.order_fund_id = pf.order_fund_id)
- <where>
- IF( fc.claim_datetime > ap.delivery_date, fc.claim_datetime, ap.delivery_date ) >= #{settleVO.startDate}
- AND IF( fc.claim_datetime > ap.delivery_date, fc.claim_datetime, ap.delivery_date ) <= #{settleVO.endDate}
- <if test="keyword!=null and keyword!='' ">
- and (
- a.order_id = #{keyword}
- or ap.production_no like concat ('%',#{keyword},'%')
- or u.name like concat ('%',#{keyword},'%')
- or u1.name like concat ('%',#{keyword},'%')
- )
- </if>
- </where>
- order by fc.claim_datetime ASC
- </sql>
- <!--资产结算项目查询-->
- <select id="assetsMarketSettleProd" resultMap="settleAssetsProductionVOMap">
- <include refid="assetsMarketerSettleSql" />
- </select>
- <!--资产结算项目导出-->
- <select id="assetsMarketSettleExport" resultMap="settleAssetsProductionVOMap">
- <include refid="assetsMarketerSettleSql" />
- </select>
- <!--资产评估人员结算项目Sql-->
- <sql id="assetsEvaluatorSettleSql">
- SELECT
- fc.id,
- fc.claim_amount,
- a.order_id,
- ap.production_no,
- fc.claim_datetime as claimDate,
- ap.save_file_date,
- IF( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
- IF(ap.assets_name IS NOT NULL, ap.assets_name, a.name ) AS projectName,
- a.bailor,
- a.members,
- ap.evaluate_amount,
- u.name AS principal,
- u1.name AS clientManager,
- cc.name AS clientName,
- cc1.name AS clientSubName,
- d.name AS evaluateDepartmentName,
- (
- SELECT
- GROUP_CONCAT( NAME )
- FROM
- department
- WHERE
- id IN (
- SELECT
- department_id
- FROM
- post
- WHERE
- id IN ( SELECT post_id FROM user_post WHERE user_id = a.client_manager_id ))) AS marketDepartmentName,
- invoice.name AS invoiceUser,
- invoice.real_make_date AS invoiceDate,
- invoice.tax_no AS invoiceNo,
- frf.pay_datetime
- FROM
- (
- SELECT
- id,
- claim_amount,
- order_fund_id,
- production_fund_id,
- claim_datetime,
- real_fund_id
- FROM
- finance_claim
- WHERE
- deleted = 0
- AND production_fund_id IS NOT NULL
- ) fc
- inner join (
- select id,pay_datetime from finance_real_fund
- where deleted = 0
- <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
- AND pay_datetime >= #{settleVO.payStartDate}
- </if>
- <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
- AND pay_datetime <= #{settleVO.payEndDate}
- </if>
- ) frf on frf.id = fc.real_fund_id
- INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
- INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, evaluate_amount, save_file_date FROM assets_production WHERE deleted = 0 AND save_file_date IS NOT NULL ) ap ON ap.production_no = pf.production_no
- LEFT JOIN assets a ON a.id = ap.business_id
- LEFT JOIN user u ON u.id = a.principal_id
- LEFT JOIN user u1 ON u1.id = a.client_manager_id
- LEFT JOIN customer_company cc ON cc.id = a.clientele_id
- LEFT JOIN customer_company cc1 ON cc1.id = a.clientele_sub_id
- LEFT JOIN department d ON d.id = a.department_id
- LEFT JOIN (
- SELECT real_make_date, name, tax_no, order_fund_id, production_fund_id
- FROM finance_invoice, user
- WHERE maker_id = user.id
- AND finance_invoice.deleted = 0
- AND state = '已开票' order by user.created desc limit 1
- ) AS invoice ON IF(invoice.production_fund_id IS NOT NULL ,invoice.order_fund_id = pf.order_fund_id AND invoice.production_fund_id = pf.id,invoice.order_fund_id = pf.order_fund_id)
- <where>
- AND IF( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) >= #{settleVO.startDate}
- AND IF( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) <= #{settleVO.endDate}
- <if test="keyword!=null and keyword!='' ">
- and (
- a.order_id = #{keyword}
- or ap.production_no like concat ('%',#{keyword},'%')
- or u.name like concat ('%',#{keyword},'%')
- or u1.name like concat ('%',#{keyword},'%')
- )
- </if>
- </where>
- order by fc.claim_datetime ASC
- </sql>
- <!--资产评估人员结算项目查询-->
- <select id="assetsEvaluatorSettleProd" resultMap="settleAssetsProductionVOMap">
- <include refid="assetsEvaluatorSettleSql" />
- </select>
- <!--资产评估人员结算项目导出-->
- <select id="assetsEvaluatorSettleExport" resultMap="settleAssetsProductionVOMap">
- <include refid="assetsEvaluatorSettleSql" />
- </select>
- <select id="exportList" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.dto.FinanceRealFundExportDTO">
- <include refid="pageListSql" />
- ORDER BY frf.pay_datetime DESC
- </select>
- <sql id="realAmountClaimedSQL">
- SELECT
- claimd.id,
- fr.amount,
- fr.payer,
- fr.pay_datetime,
- fr.remark,
- claimd.claimAmount,
- claimd.claimDate,
- u.NAME AS creator,
- u1.NAME AS claimUser,
- (fr.amount-claimd.claimAmount) as notClaimAmount
- FROM
- (
- SELECT
- frf.id,
- sum( fc.claim_amount ) claimAmount,
- max( fc.claim_datetime ) claimDate,
- fc.claim_user_id
- FROM
- finance_claim fc
- LEFT JOIN finance_real_fund frf ON frf.id = fc.real_fund_id
- WHERE
- frf.deleted = 0
- AND fc.deleted = 0
- GROUP BY
- frf.id
- ) claimd
- LEFT JOIN finance_real_fund fr ON fr.id = claimd.id
- LEFT JOIN user u ON u.id = fr.creator_id
- LEFT JOIN user u1 ON u1.id = claimd.claim_user_id
- <where>
- <if test="keyword!=null and keyword!='' ">
- and (
- fr.payer like concat ('%',#{keyword},'%')
- or u1.name like concat('%',#{keyword},'%')
- or claimd.claimAmount = #{keyword}
- or fr.amount = #{keyword}
- or fr.remark like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.startDate!=null and vo.startDate!=''">
- and fr.pay_datetime >= #{vo.startDate}
- </if>
- <if test="vo!=null and vo.endDate!=null and vo.endDate!=''">
- and fr.pay_datetime <= #{vo.endDate}
- </if>
- <if test="vo!=null and vo.xStartDate!=null and vo.xStartDate!=''">
- and claimd.claimDate >= #{vo.xStartDate}
- </if>
- <if test="vo!=null and vo.xEndDate!=null and vo.xEndDate!=''">
- and claimd.claimDate <= #{vo.xEndDate}
- </if>
- </where>
- ORDER BY
- claimd.claimDate DESC
- </sql>
- <select id="realAmountClaimed" parameterType="com.dayou.vo.FinanceRealFundVO" resultType="com.dayou.vo.FinanceRealFundVO">
- <include refid="realAmountClaimedSQL" />
- </select>
- <select id="realClaimedExport" parameterType="com.dayou.vo.FinanceRealFundVO" resultType="com.dayou.dto.FinanceRealFundExportDTO">
- <include refid="realAmountClaimedSQL" />
- </select>
- <select id="financeRealFundNotClaimExport" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.dto.FinanceRealNotClaimDTO">
- <include refid="pageListSql" />
- ORDER BY
- ifnull(t.ca,0) ASC ,frf.created DESC
- </select>
- </mapper>
|