InsAreaCompanyMapper.xml 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ydtech.modules.order.dao.InsAreaCompanyMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
  9. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  10. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  11. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  12. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  13. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  14. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  15. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  16. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  17. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  18. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  19. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  20. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  21. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  22. <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
  23. <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
  24. <result property="apiType" column="api_type" jdbcType="TINYINT"/>
  25. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  26. <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
  27. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  28. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  29. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  30. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  31. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  32. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  33. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  34. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  35. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  36. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  37. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  38. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  39. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  40. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  41. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  42. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  43. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  44. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  45. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  46. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  47. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  48. <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
  49. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  50. <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
  51. <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
  52. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  53. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  54. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  55. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  56. <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
  57. <result property="score" column="score" jdbcType="VARCHAR"/>
  58. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  59. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  60. <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
  61. <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
  62. <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
  63. <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
  64. <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
  65. <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
  66. <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
  67. <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
  68. <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
  69. <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
  70. <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
  71. <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
  72. <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
  73. <result property="feeMatchErrMsg" column="fee_match_err_msg" jdbcType="VARCHAR"/>
  74. <result property="quoteErrMsg" column="quote_err_msg" jdbcType="VARCHAR"/>
  75. </resultMap>
  76. <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
  77. extends="BaseResultMap">
  78. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  79. <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
  80. </resultMap>
  81. <sql id="Base_Column_List">
  82. id,orderno,inscompany,
  83. reqtxt,reptxt,jqapplyno,
  84. jqpolicyno,syapplyno,sypolicyno,
  85. riskinfo,kindinfo,jqpremium,
  86. sypremium,taxamount,sumpremium,
  87. jqdiscountrate,sydiscountrate,feerate,
  88. disrate,auditid,auditname,
  89. audittime,auditopinion,jqappoint,
  90. syappoint,createtime,payment_link
  91. </sql>
  92. <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
  93. SELECT iac.*, pa.agreement_name,
  94. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  95. FROM ins_area_company as iac
  96. left join ptl_agreement as pa on pa.id = iac.agreement_id
  97. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  98. FROM ins_area_company
  99. WHERE orderno = #{orderNo}
  100. GROUP BY company_id) t ON t.company_id = iac.company_id
  101. AND t.max_createtime = iac.createtime
  102. WHERE iac.orderno = #{orderNo}
  103. </select>
  104. <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
  105. SELECT iac.*, pa.agreement_name,io.is_external,
  106. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  107. FROM ins_area_company as iac
  108. left join ptl_agreement as pa on pa.id = iac.agreement_id
  109. left join ins_orders io on iac.orderno=io.orderno
  110. WHERE iac.orderstatus = 3
  111. and iac.orderno = #{orderNo};
  112. </select>
  113. <select id="queryLatestStatus" resultType="java.lang.String">
  114. SELECT iac.orderstatus
  115. FROM ins_area_company as iac
  116. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  117. FROM ins_area_company
  118. WHERE orderno = #{orderNo}
  119. GROUP BY company_id) t ON t.company_id = iac.company_id
  120. AND t.max_createtime = iac.createtime
  121. WHERE iac.orderno = #{orderNo}
  122. ORDER BY orderstatus DESC
  123. LIMIT 1
  124. </select>
  125. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  126. SELECT a.id as "id",
  127. a.orderno as "orderno"
  128. FROM ins_area_company a
  129. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  130. WHERE a.orderstatus = '3'
  131. or a.orderstatus = '2'
  132. and b.id is not null
  133. </select>
  134. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  135. SELECT
  136. iac.id as orderno,
  137. io.quoteno,
  138. io.orderstatus,
  139. io.company_id,
  140. io.ins_company,
  141. io.carinfo,
  142. io.userid,
  143. io.username,
  144. io.deptid,
  145. io.deptname,
  146. io.agreeid,
  147. iac.productid,
  148. iac.product,
  149. iac.createtime,
  150. io.frameno,
  151. io.licenseno,
  152. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  153. io.is_external,
  154. iac.jq_start_date as jqstartdate,
  155. iac.jq_end_date as jqenddate,
  156. iac.sy_start_date as systartdate,
  157. iac.sy_end_date as syenddate,
  158. io.vehicle_and_vessel_tax,
  159. io.operatorid,
  160. iac.operator_name,
  161. sd.management_source,
  162. iac.problem_order,
  163. CASE ifa.audituser
  164. WHEN '自动审核' THEN ifa.audituser
  165. ELSE su2.name END
  166. AS auditUser,
  167. CASE ifa.audituser
  168. WHEN '自动审核' THEN '2'
  169. ELSE '1' END
  170. AS checkType,
  171. ifa.audittime as auditTime,
  172. ifa.auditstatus as auditStatus,
  173. eic.namesimple as partnerCompaniesName,
  174. iac.id as subOrderId,
  175. iac.signing_time as signingTime,
  176. iac.pay_date as payDate,
  177. pa.agreement_code as agreementCode,
  178. pa.agreement_name as agreementName,
  179. pa.business_description as businessDescription,
  180. pa.job_description as jobDescription,
  181. pa.agreement_title as agreementTitle,
  182. pa.docking_person as dockingPerson,
  183. io.entry_status
  184. FROM
  185. ins_fee_audit ifa
  186. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  187. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  188. AND iac.orderstatus = 3
  189. LEFT JOIN sys_user su ON su.id = io.userid
  190. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  191. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  192. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  193. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  194. WHERE
  195. iac.id = ifa.ins_order_no
  196. AND iac.orderstatus = 3
  197. <if test="params.auditStatus != null and params.auditStatus != ''">
  198. and ifa.auditstatus = #{params.auditStatus}
  199. </if>
  200. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  201. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  202. #{params.quoteEndDateStr}
  203. </if>
  204. <if test="params.orderNo != null and params.orderNo != ''">
  205. AND iac.id= #{params.orderNo}
  206. </if>
  207. <if test="params.licenseNo != null and params.licenseNo != ''">
  208. AND io.licenseno = #{params.licenseNo}
  209. </if>
  210. <if test="params.frameNo != null and params.frameNo != ''">
  211. AND io.frameno = #{params.frameNo}
  212. </if>
  213. <if test="params.insuredName != null and params.insuredName != ''">
  214. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  215. </if>
  216. <if test="params.companyId != null and params.companyId != ''">
  217. AND io.company_id = #{params.companyId}
  218. </if>
  219. <if test="params.engineNo != null and params.engineNo != ''">
  220. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  221. </if>
  222. <if test="params.riskCode != null and params.riskCode != ''">
  223. and iac.product = #{params.riskCode}
  224. </if>
  225. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  226. and ((
  227. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  228. AND #{params.attachEndDateStr}
  229. )
  230. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  231. #{params.attachEndDateStr} )
  232. )
  233. </if>
  234. <if test="params.provinceId != null and params.provinceId != ''">
  235. and io.deptid like "${params.provinceId}%"
  236. </if>
  237. <if test="params.problemOrder != null and params.problemOrder != ''">
  238. and iac.problem_order like "${params.problemOrder}%"
  239. </if>
  240. <if test="params.cityId != null and params.cityId != ''">
  241. and io.deptid like "${params.cityId}%"
  242. </if>
  243. <if test="params.countyId != null and params.countyId != ''">
  244. and io.deptid like "${params.countyId}%"
  245. </if>
  246. <if test="params.houseId != null and params.houseId != ''">
  247. and io.deptid like "${params.houseId}%"
  248. </if>
  249. <if test="params.operatorId != null and params.operatorId != ''">
  250. and io.userid = #{params.operatorId}
  251. </if>
  252. <if test="params.operatorName != null and params.operatorName != ''">
  253. and io.username = #{params.operatorName}
  254. </if>
  255. <if test="params.auditId != null and params.auditId != ''">
  256. and iac.new_operator_id = #{params.auditId}
  257. </if>
  258. <if test="params.agreeId != null and params.agreeId != ''">
  259. and iac.agreement_id = #{params.agreeId}
  260. </if>
  261. <if test="params.managementSource != null and params.managementSource != ''">
  262. and sd.management_source = #{params.managementSource}
  263. </if>
  264. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  265. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  266. #{params.signEndDateStr}
  267. </if>
  268. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  269. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  270. </if>
  271. <if test="params.isExternal != null and params.isExternal != ''">
  272. and io.is_external = #{params.isExternal}
  273. </if>
  274. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  275. and iac.jqpolicyno = #{params.jqPolicyNo}
  276. </if>
  277. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  278. and iac.sypolicyno = #{params.syPolicyNo}
  279. </if>
  280. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  281. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  282. </if>
  283. <if test="params.checkUser != null and params.checkUser != ''">
  284. and CASE ifa.audituser WHEN '自动审核' THEN ifa.audituser
  285. ELSE su2.name END = #{params.checkUser}
  286. </if>
  287. <if test="params.checkType != null and params.checkType != ''">
  288. and CASE ifa.audituser
  289. WHEN '自动审核' THEN '2'
  290. ELSE '1' END = #{params.checkType}
  291. </if>
  292. order by iac.createtime desc
  293. </select>
  294. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  295. SELECT
  296. io.*,
  297. sd.management_source
  298. FROM
  299. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  300. WHERE
  301. orderno IN (
  302. SELECT
  303. orderno
  304. FROM
  305. ins_area_company
  306. WHERE
  307. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  308. AND orderstatus = 3
  309. )
  310. AND
  311. io.orderstatus= 3
  312. <if test="orderNo != null and orderNo != ''">
  313. AND orderno = #{orderNo}
  314. </if>
  315. <if test="licenseNo != null and licenseNo != ''">
  316. AND licenseno = #{licenseNo}
  317. </if>
  318. <if test="frameNo != null and frameNo != ''">
  319. AND frameno = #{frameNo}
  320. </if>
  321. <if test="userId != null and userId != ''">
  322. AND userid = #{userId}
  323. </if>
  324. <if test="insuredname != null and insuredname != ''">
  325. AND insuredname = #{insuredname}
  326. </if>
  327. <if test="startDateStr != null and startDateStr != ''">
  328. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  329. </if>
  330. </select>
  331. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  332. SELECT
  333. sum(a.first_detail_premiums) as "willFirstPremiums"
  334. FROM
  335. ins_fee_order_new a
  336. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  337. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  338. WHERE
  339. iff.auditstatus=0
  340. AND iac.orderstatus =3
  341. <if test="firstUserId != null and firstUserId != ''">
  342. AND a.first_level_user_id = #{firstUserId}
  343. </if>
  344. <if test="secondUserId != null and secondUserId != ''">
  345. AND a.two_level_user_id = #{secondUserId}
  346. </if>
  347. <if test="thirdUserId != null and thirdUserId != ''">
  348. AND a.three_level_user_id = #{thirdUserId}
  349. </if>
  350. <if test="id != null and id != ''">
  351. AND a.id = #{id}
  352. </if>
  353. </select>
  354. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  355. SELECT
  356. sum( fee.p ) as "willFirstPremiums"
  357. FROM
  358. (
  359. SELECT
  360. sum( a.first_detail_premiums ) AS p
  361. FROM
  362. ins_fee_order_new a
  363. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  364. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  365. <where>
  366. iff.auditstatus=0
  367. and iac.orderstatus = '3'
  368. <if test="userId!=null and userId!= ''">
  369. AND a.first_level_user_id = #{userId}
  370. </if>
  371. <if test="id != null and id!=''">
  372. AND a.id =#{id}
  373. </if>
  374. </where>
  375. UNION
  376. SELECT
  377. sum( a.third_detail_premiums ) AS p
  378. FROM
  379. ins_fee_order_new a
  380. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  381. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  382. <where>
  383. iff.auditstatus=0
  384. and iac.orderstatus = '3'
  385. <if test="userId!=null and userId!= ''">
  386. AND a.three_level_user_id = #{userId}
  387. </if>
  388. <if test="id != null and id!=''">
  389. AND a.id =#{id}
  390. </if>
  391. </where>
  392. UNION
  393. SELECT
  394. sum( a.second_detail_premiums ) AS p
  395. FROM
  396. ins_fee_order_new a
  397. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  398. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  399. <where>
  400. iff.auditstatus=0
  401. and iac.orderstatus = '3'
  402. <if test="userId!=null and userId!= ''">
  403. AND a.two_level_user_id = #{userId}
  404. </if>
  405. <if test="id != null and id!=''">
  406. AND a.id =#{id}
  407. </if>
  408. </where>
  409. ) AS fee
  410. </select>
  411. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  412. SELECT
  413. sum(a.third_detail_premiums) as "willThreePremiums"
  414. FROM
  415. ins_fee_order_new a
  416. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  417. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  418. WHERE
  419. iff.auditstatus=0
  420. AND iac.orderstatus =3
  421. <if test="firstUserId != null and firstUserId != ''">
  422. AND a.first_level_user_id = #{firstUserId}
  423. </if>
  424. <if test="secondUserId != null and secondUserId != ''">
  425. AND a.two_level_user_id = #{secondUserId}
  426. </if>
  427. <if test="thirdUserId != null and thirdUserId != ''">
  428. AND a.three_level_user_id = #{thirdUserId}
  429. </if>
  430. <if test="id != null and id != ''">
  431. AND a.id = #{id}
  432. </if>
  433. </select>
  434. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  435. SELECT
  436. io.*,
  437. sd.management_source,
  438. su2.name AS auditUser,
  439. ifa.audittime as auditTime
  440. FROM
  441. ins_orders io
  442. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  443. LEFT JOIN sys_user su ON su.id = io.userid
  444. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  445. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  446. WHERE
  447. io.orderno IN (
  448. SELECT
  449. orderno
  450. FROM
  451. ins_area_company
  452. WHERE
  453. id IN (
  454. SELECT
  455. ifon.ins_order_no
  456. FROM
  457. ins_fee_order_new ifon
  458. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  459. WHERE
  460. ifa.auditstatus = #{params.auditStatus}
  461. )
  462. )
  463. AND orderstatus = 3
  464. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  465. <!-- AND orderno = #{params.orderNo}-->
  466. <!-- </if>-->
  467. <if test="params.licenseNo != null and params.licenseNo != ''">
  468. AND licenseno = #{params.licenseNo}
  469. </if>
  470. <if test="params.frameNo != null and params.frameNo != ''">
  471. AND frameno = #{params.frameNo}
  472. </if>
  473. <if test="params.insuredName != null and params.insuredName != ''">
  474. AND insuredname = #{params.insuredName}
  475. </if>
  476. <if test="params.companyId != null and params.companyId != ''">
  477. AND company_id = #{params.companyId}
  478. </if>
  479. <if test="params.startDateStr != null and params.startDateStr != ''">
  480. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  481. </if>
  482. </select>
  483. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  484. -- 查询订单信息
  485. SELECT
  486. iac.*
  487. FROM
  488. ins_area_company iac
  489. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  490. WHERE
  491. 1=1
  492. <if test="dateStr != null and dateStr != ''">
  493. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  494. </if>
  495. </select>
  496. <select id="selectListById" resultMap="BaseResultMap">
  497. SELECT
  498. iac.*
  499. FROM
  500. ins_area_company iac
  501. WHERE
  502. 1=1
  503. <if test="id != null and id != ''">
  504. AND iac.id =#{id}
  505. </if>
  506. </select>
  507. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  508. SELECT
  509. sum( fee.p ) as "willFirstPremiums"
  510. FROM
  511. (
  512. SELECT
  513. sum( a.first_detail_premiums ) AS p
  514. FROM
  515. ins_fee_order_new a
  516. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  517. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  518. <where>
  519. <choose>
  520. <when test='type == "1"'>
  521. iff.auditstatus=0
  522. </when>
  523. <otherwise>
  524. iff.auditstatus=1
  525. </otherwise>
  526. </choose>
  527. and iac.orderstatus = '3'
  528. <if test="userId!=null and userId!= ''">
  529. AND a.first_level_user_id = #{userId}
  530. </if>
  531. <if test="id != null and id!=''">
  532. AND a.id =#{id}
  533. </if>
  534. </where>
  535. UNION
  536. SELECT
  537. sum( a.third_detail_premiums ) AS p
  538. FROM
  539. ins_fee_order_new a
  540. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  541. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  542. <where>
  543. <choose>
  544. <when test='type == "1"'>
  545. iff.auditstatus=0
  546. </when>
  547. <otherwise>
  548. iff.auditstatus=1
  549. </otherwise>
  550. </choose>
  551. and iac.orderstatus = '3'
  552. <if test="userId!=null and userId!= ''">
  553. AND a.three_level_user_id = #{userId}
  554. </if>
  555. <if test="id != null and id!=''">
  556. AND a.id =#{id}
  557. </if>
  558. </where>
  559. UNION
  560. SELECT
  561. sum( a.second_detail_premiums ) AS p
  562. FROM
  563. ins_fee_order_new a
  564. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  565. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  566. <where>
  567. <choose>
  568. <when test='type == "1"'>
  569. iff.auditstatus=0
  570. </when>
  571. <otherwise>
  572. iff.auditstatus=1
  573. </otherwise>
  574. </choose>
  575. and iac.orderstatus = '3'
  576. <if test="userId!=null and userId!= ''">
  577. AND a.two_level_user_id = #{userId}
  578. </if>
  579. <if test="id != null and id!=''">
  580. AND a.id =#{id}
  581. </if>
  582. </where>
  583. ) AS fee
  584. </select>
  585. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  586. SELECT
  587. iac.id as subOrderId,
  588. iac.signing_time as signingTime,
  589. iac.jqpremium as jqpremium,
  590. iac.sypremium as sypremium,
  591. iac.jypremium as jypremium,
  592. io.licenseno as licenseno,
  593. io.userid as userId
  594. FROM
  595. ins_area_company iac
  596. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  597. WHERE
  598. iac.id=#{subOrderId}
  599. </select>
  600. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  601. SELECT
  602. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  603. sum(jqpremium) jqpremium,
  604. sum(sypremium) sypremium,
  605. sum(sumpremium) sumpremium
  606. FROM
  607. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  608. WHERE
  609. iac.orderstatus = 3 and
  610. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  611. and io.userid=#{userId}
  612. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  613. </select>
  614. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  615. SELECT
  616. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  617. sum(jqpremium) jqpremium,
  618. sum(sypremium) sypremium,
  619. sum(sumpremium) sumpremium
  620. FROM
  621. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  622. WHERE
  623. iac.orderstatus = 3 and
  624. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  625. and io.userid=#{userId}
  626. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  627. </select>
  628. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  629. SELECT
  630. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  631. reportDate,
  632. sum( jqpremium ) jqpremium,
  633. sum( sypremium ) sypremium,
  634. sum( sumpremium ) sumpremium
  635. FROM
  636. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  637. WHERE
  638. iac.orderstatus = 3 and
  639. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  640. and io.userid=#{userId}
  641. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  642. </select>
  643. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  644. SELECT
  645. ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
  646. count( 0 ) as sumCount
  647. FROM
  648. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  649. WHERE
  650. iac.orderstatus = 3
  651. and io.userid=#{userId}
  652. AND YEAR (iac.createtime) = #{year}
  653. </select>
  654. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  655. select
  656. iac.id,
  657. iac.orderno,
  658. iac.agreement_id,
  659. iac.jqpremium,
  660. iac.sypremium,
  661. iac.jypremium,
  662. iac.taxamount,
  663. iac.sumpremium,
  664. io.licenseno,
  665. ifa.audittime,
  666. ifa.audituser as auditname,
  667. ifa.rejectinfo,
  668. "1" as orderExternalStatus
  669. FROM
  670. ins_fee_audit ifa
  671. LEFT JOIN
  672. ins_area_company iac on iac.id = ifa.ins_order_no
  673. LEFT JOIN
  674. ins_orders io on iac.orderno = io.orderno
  675. left join
  676. sys_user su on su.id= ifa.audituser
  677. WHERE
  678. iac.operator_id = #{userId}
  679. AND
  680. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  681. <if test="vo.id != null and vo.id!=''">
  682. and iac.id = #{vo.id}
  683. </if>
  684. <if test="vo.licenseno != null and vo.licenseno!='' ">
  685. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  686. </if>
  687. <if test="vo.auditname != null and vo.auditname!='' ">
  688. and su.name like CONCAT('%', #{vo.auditname}, '%')
  689. </if>
  690. </select>
  691. <select id="queryBusinessDataPage"
  692. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  693. SELECT
  694. <if test="flag != null and flag!='' and flag='1'">
  695. o.userid as userId,
  696. o.username as userName,
  697. </if>
  698. sum( iac.sumpremium ) as signeSumPremiumAmount,
  699. sum( iac.jqpremium ) as jqPremiumAmount,
  700. sum( iac.sypremium ) as syPremiumAmount,
  701. sum( iac.taxamount ) as taxAmount,
  702. sum( ion.no_premium ) as fcFeeAmount
  703. FROM
  704. ins_area_company iac
  705. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  706. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  707. where iac.orderstatus = 3 and ion.id is not null
  708. <if test="userList != null and userList.size()>0 ">
  709. and o.userid IN
  710. <foreach item="item" collection="userList" open="(" separator="," close=")">
  711. #{item}
  712. </foreach>
  713. </if>
  714. <if test="flag != null and flag!='' and flag='1'">
  715. group by o.userid,o.username
  716. </if>
  717. </select>
  718. <select id="queryQuotationSubOrderCountDataPage"
  719. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  720. SELECT
  721. <if test="flag != null and flag!='' and flag='1'">
  722. o.userid as userId,
  723. o.username as userName,
  724. </if>
  725. iac.orderstatus as orderStatus
  726. FROM
  727. ins_area_company iac
  728. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  729. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  730. <if test="userList != null and userList.size()>0 ">
  731. and o.userid IN
  732. <foreach item="item" collection="userList" open="(" separator="," close=")">
  733. #{item}
  734. </foreach>
  735. </if>
  736. <if test="flag != null and flag!='' and flag='1'">
  737. group by o.userid,o.username,iac.orderstatus
  738. </if>
  739. </select>
  740. <select id="queryQuotationOrderCountDataPage"
  741. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  742. SELECT
  743. a.userId as userId,
  744. a.userName as userName,
  745. b.qutationCount AS insOrderQutationCount,
  746. b.qutationInsureCount as insOrderQutationInsureCount,
  747. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  748. a.qutationCount as subOrderQutationCount,
  749. a.underwritingCount as subOrderUnderwritingCount,
  750. a.qutationInsureCount as subOrderQutationInsureCount,
  751. a.passRate as subOrderCloseRate,
  752. a.closeRate as subOrderPassRate,
  753. a.contributionRate as subOrderContributionRate
  754. FROM
  755. (
  756. SELECT
  757. inso.userid AS userId,
  758. inso.username AS userName,
  759. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  760. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  761. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  762. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  763. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  764. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
  765. FROM
  766. ins_area_company iac
  767. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  768. <where>
  769. <if test="userList != null and userList.size()>0 ">
  770. and o.userid IN
  771. <foreach item="item" collection="userList" open="(" separator="," close=")">
  772. #{item}
  773. </foreach>
  774. </if>
  775. </where>
  776. GROUP BY
  777. inso.userid,
  778. inso.username
  779. ) a
  780. LEFT JOIN (
  781. SELECT
  782. inso.userid AS userId,
  783. inso.username AS userName,
  784. count( inso.orderstatus ) AS qutationCount,
  785. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  786. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  787. FROM
  788. ins_orders inso
  789. <where>
  790. <if test="userList != null and userList.size()>0 ">
  791. and o.userid IN
  792. <foreach item="item" collection="userList" open="(" separator="," close=")">
  793. #{item}
  794. </foreach>
  795. </if>
  796. </where>
  797. GROUP BY
  798. inso.userid,
  799. inso.username
  800. ) b ON a.userId = b.userId
  801. </select>
  802. <select id="queryCompanyPremiumDataPage"
  803. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  804. SELECT
  805. agree.insurance_company_id AS companyId,
  806. agree.insurance_company AS companyName,
  807. agree.partner_companies_id AS parterCompanyId,
  808. ins.NAME AS parterCompanyName,
  809. sum( iac.sumpremium ) AS signeSumPremiumAmount
  810. FROM
  811. ins_area_company iac
  812. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  813. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  814. WHERE
  815. iac.orderstatus = 3
  816. and
  817. agree.id is not null
  818. <if test="vo.companyId != null and vo.companyId!='' ">
  819. agree.insurance_company_id = #{vo.companyId}
  820. </if>
  821. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  822. agree.insurance_company_id = #{vo.parterCompanyId}
  823. </if>
  824. GROUP BY
  825. agree.insurance_company_id,
  826. agree.insurance_company,
  827. agree.partner_companies_id,
  828. ins.NAME
  829. </select>
  830. <select id="queryCompanyQutationCountDataPage"
  831. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  832. SELECT
  833. a.* ,
  834. (select ins.namesimple from esm_ins_company
  835. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  836. FROM
  837. (
  838. SELECT
  839. agree.insurance_company AS companyName,
  840. agree.partner_companies_id AS parterCompanyId,
  841. iac.company_id as "companyId",
  842. count( iac.orderstatus ) AS qutationCount,
  843. count( iac.id ) AS allNumber,
  844. count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) AS orderSuccessNumber,
  845. count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) / count( iac.id ) as "orderSuccessNumberRate",
  846. count( CASE WHEN iac.orderstatus = '10' THEN 1 END ) AS areaCompanyErrNumber,
  847. COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
  848. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) AS qutationInsureCount,
  849. (COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
  850. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) / (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) AS closeRate,
  851. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) / count( iac.orderstatus ) AS contributionRate,
  852. COUNT(CASE WHEN agree.audit_type ='1' and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
  853. FROM
  854. ins_area_company iac
  855. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  856. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  857. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  858. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  859. WHERE
  860. agree.id IS NOT NULL
  861. <if test="vo.companyId != null and vo.companyId!='' ">
  862. AND agree.insurance_company_id = #{vo.companyId}
  863. </if>
  864. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  865. AND agree.partner_companies_id = #{vo.parterCompanyId}
  866. </if>
  867. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  868. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  869. </if>
  870. <if test="vo.managementSource != null and vo.managementSource!=''">
  871. AND sd.management_source =#{vo.managementSource}
  872. </if>
  873. <if test="vo.userId != null and vo.userId !=''">
  874. AND io.userid =#{vo.userId}
  875. </if>
  876. <if test="vo.deptId != null and vo.deptId !=''">
  877. AND io.deptId like concat('%',#{vo.deptId},'%')
  878. </if>
  879. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  880. AND sd.id in
  881. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  882. #{item}
  883. </foreach>
  884. </if>
  885. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  886. AND io.userid in
  887. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  888. #{item}
  889. </foreach>
  890. </if>
  891. GROUP BY
  892. agree.insurance_company,
  893. iac.company_id,
  894. agree.partner_companies_id
  895. ) a
  896. order by a.parterCompanyId
  897. </select>
  898. <select id="getInsAreaCompanyError"
  899. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  900. SELECT
  901. count(iace.id) as "areaCompanyErrNumber"
  902. FROM
  903. ins_area_company_error iace
  904. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  905. <where>
  906. 1=1
  907. <if test="vo.companyId != null and vo.companyId!='' ">
  908. AND agree.insurance_company_id = #{vo.companyId}
  909. </if>
  910. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  911. AND agree.partner_companies_id = #{vo.parterCompanyId}
  912. </if>
  913. <if test="vo.userId != null and vo.userId!=''">
  914. AND iace.user_id =#{vo.userId}
  915. </if>
  916. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  917. AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  918. </if>
  919. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  920. AND iace.dept_id in
  921. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  922. #{item}
  923. </foreach>
  924. </if>
  925. <if test="vo.deptId != null and vo.deptId !=''">
  926. AND iace.dept_id like concat('%',#{vo.deptId},'%')
  927. </if>
  928. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  929. AND iace.user_id in
  930. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  931. #{item}
  932. </foreach>
  933. </if>
  934. </where>
  935. </select>
  936. <select id="queryCompanyQutationCountDataPageTotal"
  937. resultType="java.lang.Long">
  938. SELECT
  939. count(0)
  940. FROM
  941. (
  942. SELECT
  943. agree.partner_companies_id
  944. FROM
  945. ins_area_company iac
  946. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  947. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  948. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  949. WHERE
  950. agree.id IS NOT NULL
  951. <if test="vo.companyId != null and vo.companyId!='' ">
  952. AND agree.insurance_company_id = #{vo.companyId}
  953. </if>
  954. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  955. AND agree.partner_companies_id = #{vo.parterCompanyId}
  956. </if>
  957. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  958. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  959. </if>
  960. <if test="vo.managementSource != null and vo.managementSource!=''">
  961. AND sd.management_source =#{vo.managementSource}
  962. </if>
  963. <if test="vo.userId != null and vo.userId !=''">
  964. AND io.userid =#{vo.userId}
  965. </if>
  966. <if test="vo.deptId != null and vo.deptId !=''">
  967. AND io.deptId like concat('%',#{vo.deptId},'%')
  968. </if>
  969. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  970. AND sd.id in
  971. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  972. #{item}
  973. </foreach>
  974. </if>
  975. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  976. AND io.userid in
  977. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  978. #{item}
  979. </foreach>
  980. </if>
  981. GROUP BY
  982. agree.partner_companies_id
  983. ) a
  984. </select>
  985. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  986. select
  987. iac.id,
  988. iac.orderno,
  989. iac.agreement_id,
  990. iac.jqpremium,
  991. iac.sypremium,
  992. iac.jypremium,
  993. iac.taxamount,
  994. iac.sumpremium,
  995. io.licenseno,
  996. iac.createtime,
  997. "0" as orderExternalStatus
  998. FROM
  999. ins_area_company iac
  1000. LEFT JOIN
  1001. ins_orders io on iac.orderno = io.orderno
  1002. left join ptl_agreement agree on iac.agreement_id =agree.id
  1003. WHERE
  1004. iac.operator_id = #{userId}
  1005. AND
  1006. iac.orderstatus = 0
  1007. and agree.is_external =1
  1008. <if test="vo.id != null and vo.id!='' ">
  1009. and iac.id = #{vo.id}
  1010. </if>
  1011. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1012. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  1013. </if>
  1014. </select>
  1015. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1016. select a.*, su.name as "userName",
  1017. inf.url as "logo",
  1018. sui.sex as "sex",
  1019. su.leader_name as "leaderName",
  1020. su2.mobile as "leaderMobile"
  1021. from (
  1022. SELECT
  1023. sd.NAME AS "deptName",
  1024. io.userid AS "userId",
  1025. sd.parent_id as "deptId",
  1026. sd.management_source as "managementSource",
  1027. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1028. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  1029. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1030. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1031. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
  1032. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
  1033. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/ COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
  1034. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
  1035. COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
  1036. COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
  1037. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
  1038. FROM
  1039. (
  1040. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1041. GROUP BY iot.suborder ,iot.order_status
  1042. ) iot
  1043. left join ins_area_company iac ON iac.id = iot.suborder
  1044. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1045. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1046. <where>
  1047. sd.management_source = '1'
  1048. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1049. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1050. </if>
  1051. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1052. and io.deptid like "${taskStatisticsVo.cityId}%"
  1053. </if>
  1054. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1055. and io.deptid like "${taskStatisticsVo.countyId}%"
  1056. </if>
  1057. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1058. and io.deptid like "${taskStatisticsVo.houseId}%"
  1059. </if>
  1060. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1061. and io.userid =#{taskStatisticsVo.userId}
  1062. </if>
  1063. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1064. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1065. </if>
  1066. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1067. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1068. </if>
  1069. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1070. AND sd.id in
  1071. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1072. #{item}
  1073. </foreach>
  1074. </if>
  1075. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1076. AND io.userid in
  1077. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1078. #{item}
  1079. </foreach>
  1080. </if>
  1081. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1082. <choose>
  1083. <when test="taskStatisticsVo.days =='1'">
  1084. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1085. </when>
  1086. <when test="taskStatisticsVo.days =='7'">
  1087. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1088. </when>
  1089. <when test="taskStatisticsVo.days =='30'">
  1090. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1091. </when>
  1092. </choose>
  1093. </if>
  1094. </where>
  1095. GROUP BY
  1096. io.userid,
  1097. sd.NAME,
  1098. sd.id,
  1099. sd.management_source
  1100. ) a
  1101. left join sys_user su on su.id =a.userId
  1102. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1103. LEFT JOIN sys_user_info sui on sui .id =su.id
  1104. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1105. <where>
  1106. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1107. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1108. </if>
  1109. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1110. and su.leader_id =#{taskStatisticsVo.leaderId}
  1111. </if>
  1112. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1113. and su.id =#{taskStatisticsVo.userId}
  1114. </if>
  1115. </where>
  1116. </select>
  1117. <select id="queryPageElectric" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1118. select a.*, su.name as "userName",
  1119. inf.url as "logo",
  1120. sui.sex as "sex",
  1121. su.leader_name as "leaderName",
  1122. su2.mobile as "leaderMobile"
  1123. from (
  1124. SELECT
  1125. sd.NAME AS "deptName",
  1126. io.userid AS "userId",
  1127. sd.parent_id as "deptId",
  1128. sd.management_source as "managementSource",
  1129. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1130. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  1131. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1132. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1133. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  1134. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "closeRate",
  1135. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/ COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
  1136. COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
  1137. COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
  1138. COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
  1139. COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
  1140. FROM
  1141. (
  1142. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1143. GROUP BY iot.suborder ,iot.order_status
  1144. ) iot
  1145. left join ins_area_company iac ON iac.id = iot.suborder
  1146. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1147. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1148. <where>
  1149. sd.management_source = '3'
  1150. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1151. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1152. </if>
  1153. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1154. and io.deptid like "${taskStatisticsVo.cityId}%"
  1155. </if>
  1156. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1157. and io.deptid like "${taskStatisticsVo.countyId}%"
  1158. </if>
  1159. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1160. and io.deptid like "${taskStatisticsVo.houseId}%"
  1161. </if>
  1162. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1163. and io.userid =#{taskStatisticsVo.userId}
  1164. </if>
  1165. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1166. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1167. </if>
  1168. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1169. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1170. </if>
  1171. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1172. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1173. </if>
  1174. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1175. AND sd.id in
  1176. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1177. #{item}
  1178. </foreach>
  1179. </if>
  1180. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1181. AND io.userid in
  1182. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1183. #{item}
  1184. </foreach>
  1185. </if>
  1186. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1187. <choose>
  1188. <when test="taskStatisticsVo.days =='1'">
  1189. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1190. </when>
  1191. <when test="taskStatisticsVo.days =='7'">
  1192. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1193. </when>
  1194. <when test="taskStatisticsVo.days =='30'">
  1195. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1196. </when>
  1197. </choose>
  1198. </if>
  1199. </where>
  1200. GROUP BY
  1201. io.userid,
  1202. sd.NAME,
  1203. sd.id,
  1204. sd.management_source
  1205. ) a
  1206. left join sys_user su on su.id =a.userId
  1207. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1208. LEFT JOIN sys_user_info sui on sui .id =su.id
  1209. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1210. <where>
  1211. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1212. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1213. </if>
  1214. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1215. and su.leader_id =#{taskStatisticsVo.leaderId}
  1216. </if>
  1217. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1218. and su.id =#{taskStatisticsVo.userId}
  1219. </if>
  1220. </where>
  1221. </select>
  1222. <select id="queryPageElectricTotal" resultType="java.lang.Long">
  1223. select count(0) from (
  1224. SELECT
  1225. io.userid
  1226. FROM
  1227. ins_area_company iac
  1228. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1229. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1230. <where>
  1231. sd.management_source = '3'
  1232. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1233. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1234. </if>
  1235. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1236. and io.deptid like "${taskStatisticsVo.cityId}%"
  1237. </if>
  1238. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1239. and io.deptid like "${taskStatisticsVo.countyId}%"
  1240. </if>
  1241. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1242. and io.deptid like "${taskStatisticsVo.houseId}%"
  1243. </if>
  1244. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1245. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1246. </if>
  1247. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1248. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1249. </if>
  1250. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1251. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1252. </if>
  1253. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1254. and io.userid =#{taskStatisticsVo.userId}
  1255. </if>
  1256. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1257. AND sd.id in
  1258. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1259. #{item}
  1260. </foreach>
  1261. </if>
  1262. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1263. AND io.userid in
  1264. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1265. #{item}
  1266. </foreach>
  1267. </if>
  1268. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1269. <choose>
  1270. <when test="taskStatisticsVo.days =='1'">
  1271. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1272. </when>
  1273. <when test="taskStatisticsVo.days =='7'">
  1274. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1275. </when>
  1276. <when test="taskStatisticsVo.days =='30'">
  1277. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1278. </when>
  1279. </choose>
  1280. </if>
  1281. </where>
  1282. GROUP BY
  1283. io.userid
  1284. ) a
  1285. </select>
  1286. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1287. select count(0) from (
  1288. SELECT
  1289. io.userid
  1290. FROM
  1291. ins_area_company iac
  1292. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1293. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1294. <where>
  1295. sd.management_source = '1'
  1296. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1297. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1298. </if>
  1299. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1300. and io.deptid like "${taskStatisticsVo.cityId}%"
  1301. </if>
  1302. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1303. and io.deptid like "${taskStatisticsVo.countyId}%"
  1304. </if>
  1305. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1306. and io.deptid like "${taskStatisticsVo.houseId}%"
  1307. </if>
  1308. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1309. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1310. </if>
  1311. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1312. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1313. </if>
  1314. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1315. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1316. </if>
  1317. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1318. and io.userid =#{taskStatisticsVo.userId}
  1319. </if>
  1320. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1321. AND sd.id in
  1322. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1323. #{item}
  1324. </foreach>
  1325. </if>
  1326. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1327. AND io.userid in
  1328. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1329. #{item}
  1330. </foreach>
  1331. </if>
  1332. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1333. <choose>
  1334. <when test="taskStatisticsVo.days =='1'">
  1335. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1336. </when>
  1337. <when test="taskStatisticsVo.days =='7'">
  1338. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1339. </when>
  1340. <when test="taskStatisticsVo.days =='30'">
  1341. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1342. </when>
  1343. </choose>
  1344. </if>
  1345. </where>
  1346. GROUP BY
  1347. io.userid
  1348. ) a
  1349. </select>
  1350. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1351. select
  1352. a.*,
  1353. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1354. FROM
  1355. (
  1356. SELECT
  1357. pa.insurance_company_id,
  1358. pa.partner_companies_id,
  1359. pa.insurance_company AS "insuranceCompanyName",
  1360. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1361. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  1362. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  1363. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1364. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1365. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  1366. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
  1367. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) / COUNT( iot.order_status ) AS "contributionRate",
  1368. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  1369. FROM
  1370. (
  1371. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1372. GROUP BY iot.suborder ,iot.order_status
  1373. ) iot
  1374. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1375. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1376. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1377. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1378. <where>
  1379. pa.insurance_company_id IS NOT NULL
  1380. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1381. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1382. </if>
  1383. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1384. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1385. </if>
  1386. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1387. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1388. </if>
  1389. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1390. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1391. </if>
  1392. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1393. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1394. </if>
  1395. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1396. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1397. </if>
  1398. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1399. AND iac.company_id =#{taskStatisticsVo.companyId}
  1400. </if>
  1401. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1402. AND io.deptid in
  1403. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1404. #{item}
  1405. </foreach>
  1406. </if>
  1407. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1408. AND io.userid in
  1409. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1410. #{item}
  1411. </foreach>
  1412. </if>
  1413. </where>
  1414. GROUP BY
  1415. pa.insurance_company_id,
  1416. pa.partner_companies_id,
  1417. pa.insurance_company
  1418. ) a
  1419. </select>
  1420. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1421. SELECT
  1422. COUNT(0)
  1423. FROM
  1424. (
  1425. SELECT
  1426. pa.insurance_company_id,
  1427. pa.partner_companies_id
  1428. FROM
  1429. ins_area_company iac
  1430. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1431. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1432. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1433. <where>
  1434. pa.insurance_company_id IS NOT NULL
  1435. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1436. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1437. </if>
  1438. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1439. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1440. </if>
  1441. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1442. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1443. </if>
  1444. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1445. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1446. </if>
  1447. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1448. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1449. </if>
  1450. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1451. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1452. </if>
  1453. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1454. AND io.deptid in
  1455. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1456. #{item}
  1457. </foreach>
  1458. </if>
  1459. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1460. AND io.userid in
  1461. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1462. #{item}
  1463. </foreach>
  1464. </if>
  1465. </where>
  1466. GROUP BY
  1467. pa.insurance_company_id,
  1468. pa.partner_companies_id
  1469. ) total
  1470. </select>
  1471. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1472. SELECT
  1473. sd.name as "deptName",
  1474. su.name as "userName",
  1475. io.userid as "userId",
  1476. sd.id as "deptId",
  1477. suLeader.name as "leaderName",
  1478. suLeader.mobile as "leaderMobile",
  1479. sd.management_source as "managementSource",
  1480. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1481. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  1482. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1483. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1484. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) as "passingRate",
  1485. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) as "closeRate",
  1486. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) as "contributionRate",
  1487. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) as "quotationRate",
  1488. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) as "auditOrder"
  1489. FROM
  1490. (
  1491. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1492. GROUP BY iot.suborder ,iot.order_status
  1493. ) iot
  1494. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1495. left join ins_orders io on io.orderno = iac.orderno
  1496. left join sys_dept sd on sd.id=io.deptid
  1497. left join sys_user su on su.id=io.userid
  1498. left join sys_user suLeader on suLeader.id =su.leader_id
  1499. <where>
  1500. sd.management_source = '2'
  1501. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1502. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1503. </if>
  1504. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1505. and io.deptid like "${taskStatisticsVo.cityId}%"
  1506. </if>
  1507. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1508. and io.deptid like "${taskStatisticsVo.countyId}%"
  1509. </if>
  1510. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1511. and io.deptid like "${taskStatisticsVo.houseId}%"
  1512. </if>
  1513. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1514. and io.userid =#{taskStatisticsVo.userId}
  1515. </if>
  1516. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1517. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1518. </if>
  1519. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1520. and su.leader_id =#{taskStatisticsVo.leaderId}
  1521. </if>
  1522. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1523. and su.id =#{taskStatisticsVo.userId}
  1524. </if>
  1525. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1526. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1527. </if>
  1528. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1529. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1530. </if>
  1531. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1532. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1533. </if>
  1534. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1535. AND sd.id in
  1536. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1537. #{item}
  1538. </foreach>
  1539. </if>
  1540. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1541. AND io.userid in
  1542. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1543. #{item}
  1544. </foreach>
  1545. </if>
  1546. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1547. <choose>
  1548. <when test="taskStatisticsVo.days =='1'">
  1549. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1550. </when>
  1551. <when test="taskStatisticsVo.days =='7'">
  1552. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1553. </when>
  1554. <when test="taskStatisticsVo.days =='30'">
  1555. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1556. </when>
  1557. </choose>
  1558. </if>
  1559. </where>
  1560. GROUP BY io.userid , su.name, sd.id , sd.name,suLeader.name,suLeader.mobile,sd.management_source
  1561. </select>
  1562. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1563. select count(0) from (
  1564. SELECT
  1565. io.userid as "userId"
  1566. FROM
  1567. ins_area_company iac
  1568. left join ins_orders io on io.orderno = iac.orderno
  1569. left join sys_dept sd on sd.id=io.deptid
  1570. left join sys_user su on su.id=io.userid
  1571. <where>
  1572. sd.management_source = '2'
  1573. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1574. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1575. </if>
  1576. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1577. and io.deptid like "${taskStatisticsVo.cityId}%"
  1578. </if>
  1579. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1580. and io.deptid like "${taskStatisticsVo.countyId}%"
  1581. </if>
  1582. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1583. and io.deptid like "${taskStatisticsVo.houseId}%"
  1584. </if>
  1585. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1586. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1587. </if>
  1588. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1589. and su.leader_id =#{taskStatisticsVo.leaderId}
  1590. </if>
  1591. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1592. and su.id =#{taskStatisticsVo.userId}
  1593. </if>
  1594. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1595. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1596. </if>
  1597. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1598. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1599. </if>
  1600. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1601. and io.userid =#{taskStatisticsVo.userId}
  1602. </if>
  1603. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1604. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1605. </if>
  1606. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1607. <choose>
  1608. <when test="taskStatisticsVo.days =='1'">
  1609. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1610. </when>
  1611. <when test="taskStatisticsVo.days =='7'">
  1612. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1613. </when>
  1614. <when test="taskStatisticsVo.days =='30'">
  1615. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1616. </when>
  1617. </choose>
  1618. </if>
  1619. </where>
  1620. GROUP BY io.userid
  1621. ) a
  1622. </select>
  1623. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1624. SELECT
  1625. iac.company_id,
  1626. iac.inscompany as "insuranceCompanyName",
  1627. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1628. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1629. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1630. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1631. FROM
  1632. ins_fee_audit ifa
  1633. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1634. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1635. AND iac.orderstatus = 3
  1636. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1637. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1638. left join sys_user su on su.id =ifa.audituser
  1639. <where>
  1640. 1=1
  1641. and iac.id = ifa.ins_order_no
  1642. AND iac.orderstatus = 3
  1643. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1644. and su.name =#{taskStatisticsVo.reviewer}
  1645. </if>
  1646. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1647. and ifa.audittime =#{taskStatisticsVo.audittime}
  1648. </if>
  1649. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1650. and iac.company_id =#{taskStatisticsVo.companyId}
  1651. </if>
  1652. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1653. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1654. </if>
  1655. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1656. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1657. </if>
  1658. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1659. AND io.deptid in
  1660. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1661. #{item}
  1662. </foreach>
  1663. </if>
  1664. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1665. AND su.id in
  1666. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1667. #{item}
  1668. </foreach>
  1669. </if>
  1670. <choose>
  1671. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1672. and iac.product = #{taskStatisticsVo.riskCode}
  1673. </when>
  1674. </choose>
  1675. </where>
  1676. GROUP BY
  1677. iac.company_id,
  1678. iac.inscompany
  1679. </select>
  1680. <select id="costCenterDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1681. SELECT
  1682. ifa.audituser as "audituser",
  1683. su.name as "audituserName",
  1684. su.mobile as "audituserMobile",
  1685. iac.inscompany as "insuranceCompanyName",
  1686. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1687. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1688. FROM
  1689. ins_fee_audit ifa
  1690. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1691. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1692. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1693. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1694. left join sys_user su on su.id =ifa.audituser
  1695. <where>
  1696. 1=1
  1697. and iac.id = ifa.ins_order_no
  1698. AND iac.orderstatus = 3
  1699. AND ifa.audituser != '自动审核'
  1700. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1701. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1702. and su.name =#{taskStatisticsVo.reviewer}
  1703. </if>
  1704. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1705. and iac.company_id =#{taskStatisticsVo.companyId}
  1706. </if>
  1707. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1708. and ifa.audittime =#{taskStatisticsVo.audittime}
  1709. </if>
  1710. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1711. and iac.company_id =#{taskStatisticsVo.companyId}
  1712. </if>
  1713. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1714. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1715. </if>
  1716. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1717. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1718. </if>
  1719. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1720. AND io.deptid in
  1721. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1722. #{item}
  1723. </foreach>
  1724. </if>
  1725. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1726. AND su.id in
  1727. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1728. #{item}
  1729. </foreach>
  1730. </if>
  1731. <choose>
  1732. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1733. and iac.product = #{taskStatisticsVo.riskCode}
  1734. </when>
  1735. </choose>
  1736. </where>
  1737. GROUP BY
  1738. ifa.audituser,su.name,su.mobile,iac.inscompany
  1739. </select>
  1740. <select id="costCenterDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoExcel">
  1741. SELECT
  1742. ifa.audituser as "audituser",
  1743. su.name as "audituserName",
  1744. su.mobile as "audituserMobile",
  1745. iac.inscompany as "insuranceCompanyName",
  1746. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1747. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1748. FROM
  1749. ins_fee_audit ifa
  1750. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1751. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1752. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1753. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1754. left join sys_user su on su.id =ifa.audituser
  1755. <where>
  1756. 1=1
  1757. and iac.id = ifa.ins_order_no
  1758. AND iac.orderstatus = 3
  1759. AND ifa.audituser != '自动审核'
  1760. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1761. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1762. and su.name =#{taskStatisticsVo.reviewer}
  1763. </if>
  1764. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1765. and iac.company_id =#{taskStatisticsVo.companyId}
  1766. </if>
  1767. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1768. and ifa.audittime =#{taskStatisticsVo.audittime}
  1769. </if>
  1770. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1771. and iac.company_id =#{taskStatisticsVo.companyId}
  1772. </if>
  1773. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1774. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1775. </if>
  1776. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1777. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1778. </if>
  1779. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1780. AND io.deptid in
  1781. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1782. #{item}
  1783. </foreach>
  1784. </if>
  1785. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1786. AND su.id in
  1787. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1788. #{item}
  1789. </foreach>
  1790. </if>
  1791. <choose>
  1792. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1793. and iac.product = #{taskStatisticsVo.riskCode}
  1794. </when>
  1795. </choose>
  1796. </where>
  1797. GROUP BY
  1798. ifa.audituser,su.name,su.mobile,iac.inscompany
  1799. </select>
  1800. <select id="costCenterDetailsLicense" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1801. SELECT
  1802. io.licenseno as "licenseno",
  1803. iac.createtime as "createTime",
  1804. ifa.audittime as "auditTime",
  1805. IFNULL(TIMESTAMPDIFF(SECOND, iac.createtime, ifa.audittime),0) as "timeDifference"
  1806. FROM
  1807. ins_fee_audit ifa
  1808. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1809. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1810. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1811. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1812. left join sys_user su on su.id =ifa.audituser
  1813. <where>
  1814. 1=1
  1815. and iac.id = ifa.ins_order_no
  1816. AND iac.orderstatus = 3
  1817. AND io.orderstatus = 3
  1818. AND ifa.audituser != '自动审核'
  1819. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1820. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1821. and su.name =#{taskStatisticsVo.reviewer}
  1822. </if>
  1823. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1824. and ifa.audituser =#{taskStatisticsVo.audituser}
  1825. </if>
  1826. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1827. and iac.company_id =#{taskStatisticsVo.companyId}
  1828. </if>
  1829. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1830. and ifa.audittime =#{taskStatisticsVo.audittime}
  1831. </if>
  1832. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1833. and iac.company_id =#{taskStatisticsVo.companyId}
  1834. </if>
  1835. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1836. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1837. </if>
  1838. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1839. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1840. </if>
  1841. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1842. AND io.deptid in
  1843. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1844. #{item}
  1845. </foreach>
  1846. </if>
  1847. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1848. AND su.id in
  1849. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1850. #{item}
  1851. </foreach>
  1852. </if>
  1853. <choose>
  1854. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1855. and iac.product = #{taskStatisticsVo.riskCode}
  1856. </when>
  1857. </choose>
  1858. </where>
  1859. </select>
  1860. <select id="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
  1861. SELECT
  1862. IFNULL(count(io.licenseno),0) as "orderNumber",
  1863. IFNULL(sum(TIMESTAMPDIFF(SECOND, iac.createtime, iac.audittime)),0) as "sumSecond",
  1864. ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iac.createtime, iac.audittime)),0) / count(io.licenseno),2) as "averageSecond"
  1865. FROM
  1866. ins_fee_audit ifa
  1867. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1868. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1869. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1870. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1871. left join sys_user su on su.id =ifa.audituser
  1872. <where>
  1873. 1=1
  1874. and iac.id = ifa.ins_order_no
  1875. AND iac.orderstatus = 3
  1876. AND io.orderstatus = 3
  1877. AND ifa.audituser != '自动审核'
  1878. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1879. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1880. and su.name =#{taskStatisticsVo.reviewer}
  1881. </if>
  1882. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1883. and ifa.audituser =#{taskStatisticsVo.audituser}
  1884. </if>
  1885. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1886. and iac.company_id =#{taskStatisticsVo.companyId}
  1887. </if>
  1888. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1889. and ifa.audittime =#{taskStatisticsVo.audittime}
  1890. </if>
  1891. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1892. and iac.company_id =#{taskStatisticsVo.companyId}
  1893. </if>
  1894. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1895. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1896. </if>
  1897. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1898. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1899. </if>
  1900. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1901. AND io.deptid in
  1902. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1903. #{item}
  1904. </foreach>
  1905. </if>
  1906. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1907. AND su.id in
  1908. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1909. #{item}
  1910. </foreach>
  1911. </if>
  1912. <choose>
  1913. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1914. and iac.product = #{taskStatisticsVo.riskCode}
  1915. </when>
  1916. </choose>
  1917. </where>
  1918. </select>
  1919. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1920. SELECT
  1921. count( a.numberUserId ) as "orderManpower",
  1922. sum( a.orderAmount ) as "totalPremium",
  1923. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1924. FROM
  1925. (
  1926. SELECT
  1927. count( io.userid ) AS "numberUserId",
  1928. SUM(IFNULL(iac.jqpremium, 0)) +
  1929. SUM(IFNULL(iac.sypremium, 0)) +
  1930. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1931. FROM
  1932. `ins_area_company` iac
  1933. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1934. <where>
  1935. iac.orderstatus = '3'
  1936. <if test="ids != null and ids.size()>0 ">
  1937. AND io.userid IN
  1938. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1939. #{item}
  1940. </foreach>
  1941. </if>
  1942. </where>
  1943. GROUP BY
  1944. io.userid
  1945. ) a
  1946. </select>
  1947. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1948. SELECT
  1949. count( a.numberUserId ) as "orderManpower",
  1950. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1951. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1952. FROM
  1953. (
  1954. SELECT
  1955. count( io.userid ) AS "numberUserId",
  1956. count( iac.orderno ) AS "ordernoNumber",
  1957. SUM(IFNULL(iac.jqpremium, 0)
  1958. +IFNULL(iac.sypremium, 0)
  1959. +IFNULL(iac.jypremium, 0)
  1960. ) AS "orderAmount"
  1961. FROM
  1962. `ins_area_company` iac
  1963. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1964. <where>
  1965. iac.orderstatus = '3'
  1966. <if test="vo.ids != null and vo.ids.size()>0 ">
  1967. AND io.userid IN
  1968. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1969. #{item}
  1970. </foreach>
  1971. </if>
  1972. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1973. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1974. </if>
  1975. </where>
  1976. GROUP BY
  1977. io.userid
  1978. ) a
  1979. <where>
  1980. <if test="vo.outThere != null and vo.outThere!=''">
  1981. <choose>
  1982. <when test=" vo.outThere == 0">
  1983. AND IFNULL(a.orderAmount,0) = 0
  1984. </when>
  1985. <when test="vo.outThere == 1">
  1986. AND IFNULL(a.orderAmount,0) > 0
  1987. </when>
  1988. </choose>
  1989. </if>
  1990. </where>
  1991. order by sum( a.orderAmount ) desc
  1992. </select>
  1993. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1994. SELECT
  1995. a.userId as "userId",
  1996. a.userName as "name",
  1997. a.orderNumber as "orderNumber",
  1998. a.underwritingCount as "underwritingCount",
  1999. a.qutationInsureCount as "qutationInsureCount",
  2000. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  2001. a.isFactorVerify as "isFactorVerify",
  2002. a.isNotFactorVerify as "isNotFactorVerify"
  2003. FROM
  2004. (
  2005. SELECT
  2006. io.userid as "userId",
  2007. io.username as "userName",
  2008. count( iac.orderno ) AS "orderNumber",
  2009. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  2010. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  2011. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  2012. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2013. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2014. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  2015. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  2016. FROM
  2017. `ins_area_company` iac
  2018. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2019. left join sys_user su on su.id=io.userid
  2020. <where>
  2021. <if test="vo.ids != null and vo.ids.size()>0 ">
  2022. AND io.userid IN
  2023. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2024. #{item}
  2025. </foreach>
  2026. </if>
  2027. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2028. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2029. </if>
  2030. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2031. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2032. </if>
  2033. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2034. AND io.deptid in
  2035. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2036. #{item}
  2037. </foreach>
  2038. </if>
  2039. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2040. AND io.userid in
  2041. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2042. #{item}
  2043. </foreach>
  2044. </if>
  2045. </where>
  2046. GROUP BY
  2047. io.userid,
  2048. io.username
  2049. ) a
  2050. left join sys_user su on su.id=a.userId
  2051. </select>
  2052. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2053. SELECT
  2054. count(iac.id) as "orderNumber",
  2055. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2056. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2057. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2058. FROM
  2059. ins_area_company iac
  2060. left join ins_orders io on io.orderno = iac.orderno
  2061. left join sys_dept sd on sd.id=io.deptid
  2062. left join sys_user su on su.id=io.userid
  2063. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  2064. <where>
  2065. sd.management_source = '2'
  2066. <if test="userId !=null and userId !=''">
  2067. and io.userId =#{userId}
  2068. </if>
  2069. </where>
  2070. </select>
  2071. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2072. SELECT
  2073. agree.insurance_company_id AS companyId,
  2074. agree.insurance_company AS companyName,
  2075. agree.partner_companies_id AS parterCompanyId,
  2076. ins.namesimple AS parterCompanyName,
  2077. count(iac.orderstatus) AS orderNumber,
  2078. '-' as bigQutationCount,
  2079. '-' as bigUnderwritingCount,
  2080. '-' as bigCloseRate,
  2081. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2082. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2083. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  2084. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  2085. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  2086. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  2087. contributionRate
  2088. FROM
  2089. ins_area_company iac
  2090. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2091. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2092. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2093. WHERE
  2094. agree.id IS NOT NULL
  2095. <if test="vo.companyId != null and vo.companyId!='' ">
  2096. agree.insurance_company_id = #{vo.companyId}
  2097. </if>
  2098. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2099. agree.partner_companies_id = #{vo.parterCompanyId}
  2100. </if>
  2101. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2102. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2103. </if>
  2104. <if test="vo.provinceId != null and vo.provinceId != ''">
  2105. and io.deptid like "${vo.provinceId}%"
  2106. </if>
  2107. <if test="vo.cityId != null and vo.cityId != ''">
  2108. and io.deptid like "${vo.cityId}%"
  2109. </if>
  2110. <if test="vo.countyId != null and vo.countyId != ''">
  2111. and io.deptid like "${vo.countyId}%"
  2112. </if>
  2113. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  2114. and io.deptid like "${vo.houseId}%"
  2115. </if>
  2116. GROUP BY
  2117. agree.insurance_company_id,
  2118. agree.insurance_company,
  2119. agree.partner_companies_id,
  2120. ins.NAME
  2121. </select>
  2122. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2123. select
  2124. a.companyId as "companyId",
  2125. a.insuranceCompanyName as "insuranceCompanyName",
  2126. a.parterCompanyId as "parterCompanyId",
  2127. a.partnerCompaniesName as "partnerCompaniesName",
  2128. a.totalPremium as "totalPremium",
  2129. a.qutationInsureCount as "qutationInsureCount",
  2130. ROUND(a.averagePremium, 2) as "averagePremium",
  2131. a.userNumber as "userNumber",
  2132. ROUND(a.perCapitaAmount, 2) as "perCapitaAmount",
  2133. c.docking_person as "dockingPerson",
  2134. c.docking_phone as "dockingPhone",
  2135. c.agreement_type as "agreementType",
  2136. b.logo as "logo"
  2137. from (
  2138. SELECT
  2139. agree.insurance_company_id AS "companyId",
  2140. agree.insurance_company AS "insuranceCompanyName",
  2141. agree.partner_companies_id AS "parterCompanyId",
  2142. ins.namesimple AS "partnerCompaniesName",
  2143. agree.id as "agreeId",
  2144. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2145. COUNT(0 ) AS "qutationInsureCount",
  2146. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  2147. COUNT(DISTINCT io.userId) AS "userNumber",
  2148. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  2149. FROM
  2150. ins_area_company iac
  2151. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2152. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2153. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2154. WHERE
  2155. agree.id IS NOT NULL
  2156. and iac.orderstatus = '3'
  2157. <if test="vo.companyId != null and vo.companyId!='' ">
  2158. and agree.insurance_company_id = #{vo.companyId}
  2159. </if>
  2160. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2161. and agree.partner_companies_id = #{vo.parterCompanyId}
  2162. </if>
  2163. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2164. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  2165. </if>
  2166. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2167. and io.deptid like "${vo.provinceId}%"
  2168. </if>
  2169. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2170. and io.deptid like "${vo.cityId}%"
  2171. </if>
  2172. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2173. and io.deptid like "${vo.countyId}%"
  2174. </if>
  2175. <if test="vo.houseId != null and vo.houseId != ''">
  2176. and io.deptid like "${vo.houseId}%"
  2177. </if>
  2178. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2179. AND io.deptid in
  2180. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2181. #{item}
  2182. </foreach>
  2183. </if>
  2184. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2185. AND io.userid in
  2186. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2187. #{item}
  2188. </foreach>
  2189. </if>
  2190. GROUP BY
  2191. agree.insurance_company_id,
  2192. agree.insurance_company,
  2193. agree.partner_companies_id,
  2194. agree.id
  2195. <choose>
  2196. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  2197. order by
  2198. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2199. </when>
  2200. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  2201. order by
  2202. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  2203. </when>
  2204. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  2205. order by
  2206. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2207. </when>
  2208. </choose>
  2209. ) a
  2210. left join esm_ins_company b on b.id =a.companyId
  2211. left join ptl_agreement c on c.id =a.agreeId
  2212. </select>
  2213. <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2214. select
  2215. sum(a.totalPremium) as "totalPremium",
  2216. sum(a.qutationInsureCount) as "qutationInsureCount",
  2217. sum(ROUND(a.averagePremium, 2)) as "averagePremium",
  2218. sum(a.userNumber) as "userNumber",
  2219. count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
  2220. sum(ROUND(a.perCapitaAmount, 2)) as "perCapitaAmount"
  2221. from (
  2222. SELECT
  2223. agree.insurance_company AS "insuranceCompanyName",
  2224. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2225. COUNT(0 ) AS "qutationInsureCount",
  2226. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  2227. COUNT(DISTINCT io.userId) AS "userNumber",
  2228. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  2229. FROM
  2230. ins_area_company iac
  2231. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2232. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2233. WHERE
  2234. agree.id IS NOT NULL
  2235. and iac.orderstatus = '3'
  2236. <if test="vo.companyId != null and vo.companyId!='' ">
  2237. and agree.insurance_company_id = #{vo.companyId}
  2238. </if>
  2239. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2240. and agree.partner_companies_id = #{vo.parterCompanyId}
  2241. </if>
  2242. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2243. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  2244. </if>
  2245. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2246. and io.deptid like "${vo.provinceId}%"
  2247. </if>
  2248. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2249. and io.deptid like "${vo.cityId}%"
  2250. </if>
  2251. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2252. and io.deptid like "${vo.countyId}%"
  2253. </if>
  2254. <if test="vo.houseId != null and vo.houseId != ''">
  2255. and io.deptid like "${vo.houseId}%"
  2256. </if>
  2257. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2258. AND io.deptid in
  2259. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2260. #{item}
  2261. </foreach>
  2262. </if>
  2263. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2264. AND io.userid in
  2265. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2266. #{item}
  2267. </foreach>
  2268. </if>
  2269. group by
  2270. agree.insurance_company,
  2271. agree.partner_companies_id
  2272. ) a
  2273. </select>
  2274. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2275. SELECT
  2276. agree.insurance_company_id AS "companyId",
  2277. agree.insurance_company AS "insuranceCompanyName",
  2278. agree.partner_companies_id AS "parterCompanyId",
  2279. ins.namesimple AS "partnerCompaniesName",
  2280. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2281. COUNT(0) AS "qutationInsureCount",
  2282. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2) AS "averagePremium",
  2283. COUNT(DISTINCT io.userId) AS "userNumber",
  2284. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
  2285. FROM
  2286. ins_area_company iac
  2287. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2288. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2289. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2290. WHERE
  2291. agree.id IS NOT NULL
  2292. <if test="vo.companyId != null and vo.companyId!='' ">
  2293. and agree.insurance_company_id = #{vo.companyId}
  2294. </if>
  2295. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2296. and agree.partner_companies_id = #{vo.parterCompanyId}
  2297. </if>
  2298. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2299. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  2300. </if>
  2301. <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
  2302. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2303. </if>
  2304. <if test="vo.provinceId != null and vo.provinceId != ''">
  2305. and io.deptid like "${vo.provinceId}%"
  2306. </if>
  2307. <if test="vo.cityId != null and vo.cityId != ''">
  2308. and io.deptid like "${vo.cityId}%"
  2309. </if>
  2310. <if test="vo.countyId != null and vo.countyId != ''">
  2311. and io.deptid like "${vo.countyId}%"
  2312. </if>
  2313. <if test="vo.houseId != null and vo.houseId != ''">
  2314. and io.deptid like "${vo.houseId}%"
  2315. </if>
  2316. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  2317. and iac.orderstatus =#{vo.quotationStatus}
  2318. </if>
  2319. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2320. AND io.deptid in
  2321. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2322. #{item}
  2323. </foreach>
  2324. </if>
  2325. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2326. AND io.userid in
  2327. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2328. #{item}
  2329. </foreach>
  2330. </if>
  2331. <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
  2332. and iac.product = #{vo.riskCode}
  2333. </if>
  2334. GROUP BY
  2335. agree.insurance_company_id,
  2336. agree.insurance_company,
  2337. agree.partner_companies_id,
  2338. ins.namesimple
  2339. </select>
  2340. <select id="getOrderPremiumByUserIds" resultType="Double">
  2341. SELECT
  2342. IFNULL(
  2343. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  2344. 0
  2345. ) AS "totalPremium"
  2346. FROM
  2347. `ins_area_company` iac
  2348. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2349. <where>
  2350. iac.orderstatus = '3'
  2351. <if test="vo.ids != null and vo.ids.size()>0 ">
  2352. AND io.userid IN
  2353. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2354. #{item}
  2355. </foreach>
  2356. </if>
  2357. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2358. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2359. </if>
  2360. </where>
  2361. </select>
  2362. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2363. SELECT
  2364. count( 0 ) AS "orderNumber",
  2365. b.licenseno as "licenseno",
  2366. b.frameno as "frameno",
  2367. b.modelCode as "modelCode",
  2368. b.modelcname as "modelcname"
  2369. FROM
  2370. (
  2371. SELECT
  2372. io.orderstatus AS orderstatus,
  2373. io.frameno AS frameno,
  2374. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2375. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2376. ifnull(io.licenseno, '') AS licenseno
  2377. FROM
  2378. ins_orders io
  2379. LEFT JOIN sys_user su on io.userid=su.id
  2380. <where>
  2381. 1=1
  2382. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2383. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2384. </if>
  2385. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2386. AND io.licenseno =#{vo.licenseno}
  2387. </if>
  2388. <if test="vo.userId != null and vo.userId!='' ">
  2389. AND io.userid =#{vo.userId}
  2390. </if>
  2391. <if test="vo.userName != null and vo.userName!='' ">
  2392. AND su.name =#{vo.userName}
  2393. </if>
  2394. <if test="vo.mobile != null and vo.mobile!='' ">
  2395. AND su.mobile =#{vo.mobile}
  2396. </if>
  2397. <if test="vo.frameno != null and vo.frameno!='' ">
  2398. AND io.frameno =#{vo.frameno}
  2399. </if>
  2400. <if test="vo.deptId != null and vo.deptId!='' ">
  2401. and io.deptid like concat('%', #{vo.deptId}, '%')
  2402. </if>
  2403. <if test="vo.year != null and vo.year!='' ">
  2404. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2405. </if>
  2406. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2407. AND io.deptid in
  2408. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2409. #{item}
  2410. </foreach>
  2411. </if>
  2412. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2413. AND io.userid in
  2414. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2415. #{item}
  2416. </foreach>
  2417. </if>
  2418. </where>
  2419. ) b
  2420. GROUP BY
  2421. b.licenseno,
  2422. b.frameno,
  2423. b.modelCode,
  2424. b.modelcname
  2425. </select>
  2426. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2427. SELECT
  2428. io.licenseno AS "licenseno",
  2429. io.frameno AS "frameno",
  2430. io.orderstatus as "orderstatus",
  2431. io.orderno as "orderno"
  2432. FROM
  2433. ins_orders io
  2434. LEFT JOIN sys_user su on io.userid=su.id
  2435. <where>
  2436. io.licenseno is not null
  2437. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2438. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2439. </if>
  2440. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2441. AND io.licenseno =#{vo.licenseno}
  2442. </if>
  2443. <if test="vo.userId != null and vo.userId!='' ">
  2444. AND io.userId =#{vo.userId}
  2445. </if>
  2446. <if test="vo.userName != null and vo.userName!='' ">
  2447. AND su.name =#{vo.userName}
  2448. </if>
  2449. <if test="vo.mobile != null and vo.mobile!='' ">
  2450. AND su.mobile =#{vo.mobile}
  2451. </if>
  2452. <if test="vo.frameno != null and vo.frameno!='' ">
  2453. AND su.frameno =#{vo.frameno}
  2454. </if>
  2455. <if test="vo.deptId != null and vo.deptId!='' ">
  2456. and io.deptid like concat('%', #{vo.deptId}, '%')
  2457. </if>
  2458. </where>
  2459. </select>
  2460. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2461. select sum(a.orderNumber) as "orderNumber",
  2462. count(a.licenseno) as "b.frameno"
  2463. from (
  2464. SELECT
  2465. count( 0 ) AS "orderNumber",
  2466. b.licenseno as "licenseno",
  2467. b.frameno as "frameno"
  2468. FROM
  2469. (
  2470. SELECT
  2471. io.orderstatus AS orderstatus,
  2472. io.frameno AS frameno,
  2473. ifnull(io.licenseno, '') AS licenseno
  2474. FROM
  2475. ins_orders io
  2476. LEFT JOIN sys_user su on io.userid=su.id
  2477. <where>
  2478. 1=1
  2479. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2480. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2481. </if>
  2482. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2483. AND io.licenseno =#{vo.licenseno}
  2484. </if>
  2485. <if test="vo.userId != null and vo.userId!='' ">
  2486. AND io.userid =#{vo.userId}
  2487. </if>
  2488. <if test="vo.userName != null and vo.userName!='' ">
  2489. AND su.name =#{vo.userName}
  2490. </if>
  2491. <if test="vo.mobile != null and vo.mobile!='' ">
  2492. AND su.mobile =#{vo.mobile}
  2493. </if>
  2494. <if test="vo.frameno != null and vo.frameno!='' ">
  2495. AND io.frameno =#{vo.frameno}
  2496. </if>
  2497. <if test="vo.deptId != null and vo.deptId!='' ">
  2498. and io.deptid like concat('%', #{vo.deptId}, '%')
  2499. </if>
  2500. </where>
  2501. ) b
  2502. GROUP BY
  2503. b.licenseno,
  2504. b.frameno
  2505. ) a
  2506. </select>
  2507. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2508. SELECT
  2509. count( io.orderno ) AS "orderNumber",
  2510. IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0) / (IFNULL(count(CASE WHEN io.orderstatus = '2' THEN 1 ELSE 0 END),0) + IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0)) AS "closeRate"
  2511. FROM
  2512. ins_orders io
  2513. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2514. LEFT JOIN sys_user su ON io.userid = su.id
  2515. <where>
  2516. 1=1
  2517. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2518. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2519. </if>
  2520. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2521. AND io.licenseno =#{vo.licenseno}
  2522. </if>
  2523. <if test="vo.userId != null and vo.userId!='' ">
  2524. AND io.userid =#{vo.userId}
  2525. </if>
  2526. <if test="vo.userName != null and vo.userName!='' ">
  2527. AND su.name =#{vo.userName}
  2528. </if>
  2529. <if test="vo.mobile != null and vo.mobile!='' ">
  2530. AND su.mobile =#{vo.mobile}
  2531. </if>
  2532. <if test="vo.frameno != null and vo.frameno!='' ">
  2533. AND su.frameno =#{vo.frameno}
  2534. </if>
  2535. <if test="vo.deptId != null and vo.deptId!='' ">
  2536. and io.deptid like concat('%', #{vo.deptId}, '%')
  2537. </if>
  2538. </where>
  2539. </select>
  2540. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2541. SELECT
  2542. count(iac.id) as "orderNumber",
  2543. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2544. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2545. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2546. FROM
  2547. ins_area_company iac
  2548. left join ins_orders io on io.orderno = iac.orderno
  2549. <where>
  2550. <if test="ids != null and ids.size()>0 ">
  2551. AND io.userid IN
  2552. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2553. #{item}
  2554. </foreach>
  2555. </if>
  2556. <if test="month != null and month!='' ">
  2557. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  2558. </if>
  2559. </where>
  2560. </select>
  2561. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2562. select
  2563. iac.inscompany as "namesimple"
  2564. from
  2565. ins_area_company iac
  2566. <where>
  2567. 1=1
  2568. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  2569. AND iac.orderstatus =#{vo.orderstatus}
  2570. </if>
  2571. <if test="vo.orderno !=null and vo.orderno !='' ">
  2572. AND iac.orderno =#{vo.orderno}
  2573. </if>
  2574. </where>
  2575. </select>
  2576. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  2577. select a.*,(select name from sys_user where id =a.userId) as "userName"
  2578. from (
  2579. SELECT
  2580. sd.NAME AS "deptName",
  2581. io.userid AS "userId",
  2582. sd.parent_id as "deptId",
  2583. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  2584. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2585. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2586. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  2587. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
  2588. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
  2589. ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
  2590. (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
  2591. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  2592. FROM
  2593. ins_area_company iac
  2594. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2595. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  2596. <where>
  2597. 1=1
  2598. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2599. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2600. </if>
  2601. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2602. and io.deptid like "${taskStatisticsVo.cityId}%"
  2603. </if>
  2604. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2605. and io.deptid like "${taskStatisticsVo.countyId}%"
  2606. </if>
  2607. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2608. and io.deptid like "${taskStatisticsVo.houseId}%"
  2609. </if>
  2610. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2611. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  2612. </if>
  2613. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2614. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2615. </if>
  2616. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2617. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  2618. </if>
  2619. <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
  2620. and sd.management_source=#{taskStatisticsVo.managementSource}
  2621. </if>
  2622. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2623. <choose>
  2624. <when test="taskStatisticsVo.days =='1'">
  2625. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  2626. </when>
  2627. <when test="taskStatisticsVo.days =='7'">
  2628. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  2629. </when>
  2630. <when test="taskStatisticsVo.days =='30'">
  2631. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  2632. </when>
  2633. </choose>
  2634. </if>
  2635. </where>
  2636. GROUP BY
  2637. io.userid,
  2638. sd.NAME,
  2639. sd.id
  2640. ) a
  2641. </select>
  2642. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  2643. SELECT
  2644. a.*,
  2645. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  2646. FROM
  2647. (
  2648. SELECT
  2649. pa.insurance_company_id,
  2650. pa.partner_companies_id,
  2651. pa.insurance_company AS "insuranceCompanyName",
  2652. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  2653. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCountRate,
  2654. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2655. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  2656. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  2657. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  2658. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  2659. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  2660. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  2661. FROM
  2662. ins_area_company iac
  2663. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2664. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2665. <where>
  2666. pa.insurance_company_id IS NOT NULL
  2667. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2668. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2669. </if>
  2670. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2671. and io.deptid like "${taskStatisticsVo.cityId}%"
  2672. </if>
  2673. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2674. and io.deptid like "${taskStatisticsVo.countyId}%"
  2675. </if>
  2676. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2677. and io.deptid like "${taskStatisticsVo.houseId}%"
  2678. </if>
  2679. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2680. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  2681. </if>
  2682. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2683. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2684. </if>
  2685. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  2686. AND iac.company_id =#{taskStatisticsVo.companyId}
  2687. </if>
  2688. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2689. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  2690. </if>
  2691. </where>
  2692. GROUP BY
  2693. pa.insurance_company_id,
  2694. pa.partner_companies_id,
  2695. pa.insurance_company
  2696. ) a
  2697. </select>
  2698. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2699. select count(0) as "orderNumber",
  2700. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  2701. from ins_area_company iac
  2702. left join ins_orders io on io.orderno = iac.orderno
  2703. <where>
  2704. 1=1
  2705. and iac.orderstatus ='3'
  2706. and io.orderstatus ='3'
  2707. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2708. AND io.licenseno =#{vo.licenseno}
  2709. </if>
  2710. <if test="vo.frameno !=null and vo.frameno!=''">
  2711. AND io.frameno =#{vo.frameno}
  2712. </if>
  2713. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2714. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2715. </if>
  2716. <if test="vo.year != null and vo.year!='' ">
  2717. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2718. </if>
  2719. </where>
  2720. limit 10
  2721. </select>
  2722. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2723. select
  2724. io.userid as userId,
  2725. io.username as userName,
  2726. io.licenseno as licenseno,
  2727. iac.id as companyId,
  2728. iac.jqpremium as jqpremium,
  2729. iac.sypremium as sypremium,
  2730. iac.jypremium as jypremium,
  2731. iac.createtime as createtime,
  2732. iac.orderstatus as orderstatus
  2733. from ins_area_company iac
  2734. left join ins_orders io on io.orderno = iac.orderno
  2735. <where>
  2736. iac.orderstatus=3
  2737. <if test="dto.userId !=null and dto.userId !=''">
  2738. and io.userid = #{dto.userId}
  2739. </if>
  2740. <if test="dto.deptId !=null and dto.deptId !=''">
  2741. and io.deptid like concat( #{dto.deptId}, '%')
  2742. </if>
  2743. <if test="dto.startTime !=null and dto.startTime !=''">
  2744. and io.createtime >= #{dto.startTime}
  2745. </if>
  2746. </where>
  2747. ORDER BY iac.createtime
  2748. </select>
  2749. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2750. SELECT
  2751. count( 0 ) AS "orderNumber",
  2752. b.licenseno as "licenseno",
  2753. b.frameno as "frameno",
  2754. b.modelCode as "modelCode",
  2755. b.modelcname as "modelcname"
  2756. FROM
  2757. (
  2758. SELECT
  2759. io.orderstatus AS orderstatus,
  2760. io.frameno AS frameno,
  2761. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2762. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2763. ifnull(io.licenseno, '') AS licenseno
  2764. FROM
  2765. ins_orders io
  2766. LEFT JOIN sys_user su on io.userid=su.id
  2767. <where>
  2768. 1=1
  2769. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2770. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2771. </if>
  2772. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2773. AND io.licenseno =#{vo.licenseno}
  2774. </if>
  2775. <if test="vo.userId != null and vo.userId!='' ">
  2776. AND io.userid =#{vo.userId}
  2777. </if>
  2778. <if test="vo.userName != null and vo.userName!='' ">
  2779. AND su.name =#{vo.userName}
  2780. </if>
  2781. <if test="vo.mobile != null and vo.mobile!='' ">
  2782. AND su.mobile =#{vo.mobile}
  2783. </if>
  2784. <if test="vo.frameno != null and vo.frameno!='' ">
  2785. AND io.frameno =#{vo.frameno}
  2786. </if>
  2787. <if test="vo.deptId != null and vo.deptId!='' ">
  2788. and io.deptid like concat('%', #{vo.deptId}, '%')
  2789. </if>
  2790. <if test="vo.year != null and vo.year!='' ">
  2791. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2792. </if>
  2793. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2794. AND io.deptid in
  2795. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2796. #{item}
  2797. </foreach>
  2798. </if>
  2799. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2800. AND io.userid in
  2801. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2802. #{item}
  2803. </foreach>
  2804. </if>
  2805. </where>
  2806. ) b
  2807. GROUP BY
  2808. b.licenseno,
  2809. b.frameno,
  2810. b.modelCode,
  2811. b.modelcname
  2812. </select>
  2813. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2814. select
  2815. iac.id,
  2816. iac.orderno,
  2817. iac.agreement_id,
  2818. iac.jqpremium,
  2819. iac.sypremium,
  2820. iac.jypremium,
  2821. iac.taxamount,
  2822. iac.sumpremium,
  2823. io.licenseno,
  2824. iac.createtime,
  2825. su.name as auditname
  2826. FROM
  2827. ins_area_company iac
  2828. LEFT JOIN
  2829. ins_orders io on iac.orderno = io.orderno
  2830. left join ptl_agreement agree on iac.agreement_id =agree.id
  2831. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  2832. left join sys_user su on su.id= ifa.audituser
  2833. WHERE
  2834. iac.operator_id = #{userId}
  2835. AND
  2836. iac.orderstatus = 3
  2837. and agree.is_external =1
  2838. and auditstatus =1
  2839. <if test="vo.id != null and vo.id!='' ">
  2840. and iac.id = #{vo.id}
  2841. </if>
  2842. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2843. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  2844. </if>
  2845. </select>
  2846. <select id="costCenterTotal" resultType="java.util.HashMap">
  2847. SELECT
  2848. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
  2849. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
  2850. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
  2851. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
  2852. FROM
  2853. ins_fee_audit ifa
  2854. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  2855. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2856. AND iac.orderstatus = 3
  2857. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2858. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  2859. left join sys_user su on su.id =ifa.audituser
  2860. <where>
  2861. 1=1
  2862. and iac.id = ifa.ins_order_no
  2863. AND iac.orderstatus = 3
  2864. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  2865. and su.name =#{taskStatisticsVo.reviewer}
  2866. </if>
  2867. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  2868. and ifa.audittime =#{taskStatisticsVo.audittime}
  2869. </if>
  2870. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  2871. and iac.company_id =#{taskStatisticsVo.companyId}
  2872. </if>
  2873. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2874. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  2875. </if>
  2876. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2877. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2878. </if>
  2879. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2880. AND io.deptid in
  2881. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2882. #{item}
  2883. </foreach>
  2884. </if>
  2885. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2886. AND su.id in
  2887. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2888. #{item}
  2889. </foreach>
  2890. </if>
  2891. <choose>
  2892. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  2893. and iac.product = #{taskStatisticsVo.riskCode}
  2894. </when>
  2895. </choose>
  2896. </where>
  2897. </select>
  2898. <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
  2899. select orderno, orderstatus, count(*)as count
  2900. from (select orderno, company_id, orderstatus
  2901. from ins_area_company
  2902. where orderno in
  2903. <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
  2904. #{item,jdbcType=VARCHAR}
  2905. </foreach>
  2906. and del_flag = '1'
  2907. group by orderno, company_id, orderstatus) as iac
  2908. group by orderno, orderstatus
  2909. </select>
  2910. <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2911. select
  2912. iac.id,
  2913. iac.orderno,
  2914. iac.agreement_id,
  2915. iac.jqpremium,
  2916. iac.sypremium,
  2917. iac.jypremium,
  2918. iac.taxamount,
  2919. iac.sumpremium,
  2920. io.licenseno,
  2921. ifa.audittime,
  2922. ifa.audituser as auditname,
  2923. ifa.rejectinfo,
  2924. "1" as orderExternalStatus
  2925. FROM
  2926. ins_fee_audit ifa
  2927. LEFT JOIN
  2928. ins_area_company iac on iac.id = ifa.ins_order_no
  2929. LEFT JOIN
  2930. ins_orders io on iac.orderno = io.orderno
  2931. left join
  2932. sys_user su on su.id= ifa.audituser
  2933. WHERE
  2934. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  2935. <if test="vo.id != null and vo.id!=''">
  2936. and iac.id = #{vo.id}
  2937. </if>
  2938. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2939. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  2940. </if>
  2941. <if test="vo.auditname != null and vo.auditname!='' ">
  2942. and su.name like CONCAT('%', #{vo.auditname}, '%')
  2943. </if>
  2944. order by io.createtime
  2945. </select>
  2946. <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
  2947. SELECT
  2948. iac.id as orderno,
  2949. io.quoteno,
  2950. iac.orderstatus,
  2951. iac.company_id,
  2952. iac.inscompany,
  2953. io.carinfo,
  2954. io.userid,
  2955. io.username,
  2956. io.deptid,
  2957. io.deptname,
  2958. io.agreeid,
  2959. iac.productid,
  2960. iac.product,
  2961. iac.createtime,
  2962. io.frameno,
  2963. io.licenseno,
  2964. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  2965. io.is_external,
  2966. iac.jq_start_date as jqstartdate,
  2967. iac.jq_end_date as jqenddate,
  2968. iac.sy_start_date as systartdate,
  2969. iac.sy_end_date as syenddate,
  2970. io.vehicle_and_vessel_tax,
  2971. io.operatorid,
  2972. iac.operator_name,
  2973. sd.management_source,
  2974. iac.problem_order,
  2975. eic.namesimple as partnerCompaniesName,
  2976. iac.id as subOrderId,
  2977. iac.signing_time as signingTime,
  2978. iac.pay_date as payDate,
  2979. pa.agreement_code as agreementCode,
  2980. pa.agreement_name as agreementName,
  2981. pa.business_description as businessDescription,
  2982. pa.job_description as jobDescription,
  2983. pa.agreement_title as agreementTitle,
  2984. pa.docking_person as dockingPerson,
  2985. io.entry_status
  2986. FROM
  2987. ins_area_company iac
  2988. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  2989. LEFT JOIN sys_user su ON su.id = io.userid
  2990. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  2991. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2992. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  2993. WHERE
  2994. iac.orderstatus = 3
  2995. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  2996. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  2997. #{params.quoteEndDateStr}
  2998. </if>
  2999. <if test="params.orderNo != null and params.orderNo != ''">
  3000. AND iac.id= #{params.orderNo}
  3001. </if>
  3002. <if test="params.licenseNo != null and params.licenseNo != ''">
  3003. AND io.licenseno = #{params.licenseNo}
  3004. </if>
  3005. <if test="params.frameNo != null and params.frameNo != ''">
  3006. AND io.frameno = #{params.frameNo}
  3007. </if>
  3008. <if test="params.insuredName != null and params.insuredName != ''">
  3009. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  3010. </if>
  3011. <if test="params.companyId != null and params.companyId != ''">
  3012. AND iac.company_id = #{params.companyId}
  3013. </if>
  3014. <if test="params.engineNo != null and params.engineNo != ''">
  3015. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  3016. </if>
  3017. <if test="params.riskCode != null and params.riskCode != ''">
  3018. and iac.product = #{params.riskCode}
  3019. </if>
  3020. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  3021. and ((
  3022. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  3023. AND #{params.attachEndDateStr}
  3024. )
  3025. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  3026. #{params.attachEndDateStr} )
  3027. )
  3028. </if>
  3029. <if test="params.provinceId != null and params.provinceId != ''">
  3030. and io.deptid like "${params.provinceId}%"
  3031. </if>
  3032. <if test="params.problemOrder != null and params.problemOrder != ''">
  3033. and iac.problem_order like "${params.problemOrder}%"
  3034. </if>
  3035. <if test="params.cityId != null and params.cityId != ''">
  3036. and io.deptid like "${params.cityId}%"
  3037. </if>
  3038. <if test="params.countyId != null and params.countyId != ''">
  3039. and io.deptid like "${params.countyId}%"
  3040. </if>
  3041. <if test="params.houseId != null and params.houseId != ''">
  3042. and io.deptid like "${params.houseId}%"
  3043. </if>
  3044. <if test="params.operatorId != null and params.operatorId != ''">
  3045. and io.userid = #{params.operatorId}
  3046. </if>
  3047. <if test="params.operatorName != null and params.operatorName != ''">
  3048. and io.username = #{params.operatorName}
  3049. </if>
  3050. <if test="params.auditId != null and params.auditId != ''">
  3051. and iac.new_operator_id = #{params.auditId}
  3052. </if>
  3053. <if test="params.agreeId != null and params.agreeId != ''">
  3054. and iac.agreement_id = #{params.agreeId}
  3055. </if>
  3056. <if test="params.managementSource != null and params.managementSource != ''">
  3057. and sd.management_source = #{params.managementSource}
  3058. </if>
  3059. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  3060. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  3061. #{params.signEndDateStr}
  3062. </if>
  3063. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  3064. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  3065. </if>
  3066. <if test="params.isExternal != null and params.isExternal != ''">
  3067. and io.is_external = #{params.isExternal}
  3068. </if>
  3069. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  3070. and iac.jqpolicyno = #{params.jqPolicyNo}
  3071. </if>
  3072. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  3073. and iac.sypolicyno = #{params.syPolicyNo}
  3074. </if>
  3075. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  3076. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  3077. </if>
  3078. order by iac.createtime desc
  3079. </select>
  3080. <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3081. select
  3082. sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL (ifon.no_costs_premiums,0)) as "entranceAllFee",
  3083. sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0) +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
  3084. +IFNULL(no_export_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ) as "exportAllFee",
  3085. sum(IFNULL(b.distributionAmount,0)) as "distributionAmount"
  3086. from ins_area_company iac
  3087. left join ins_orders io on io.orderno = iac.orderno
  3088. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3089. LEFT JOIN (
  3090. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3091. a.firstLevelUserId
  3092. from (
  3093. select
  3094. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3095. ifon.first_level_user_id as "firstLevelUserId"
  3096. from ins_area_company iac
  3097. left join ins_orders io on io.orderno = iac.orderno
  3098. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3099. <where>
  3100. <if test="vo.userId !=null and vo.userId !=''">
  3101. ifon.first_level_user_id =#{vo.userId}
  3102. </if>
  3103. <if test="vo.ids != null and vo.ids.size()>0 ">
  3104. AND ifon.first_level_user_id IN
  3105. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3106. #{item}
  3107. </foreach>
  3108. </if>
  3109. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3110. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3111. </if>
  3112. </where>
  3113. group by ifon.first_level_user_id
  3114. ) a
  3115. left join (
  3116. select
  3117. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3118. ifon.two_level_user_id as "twoLevelUserId"
  3119. from ins_area_company iac
  3120. left join ins_orders io on io.orderno = iac.orderno
  3121. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3122. <where>
  3123. <if test="vo.userId !=null and vo.userId !=''">
  3124. ifon.two_level_user_id =#{vo.userId}
  3125. </if>
  3126. <if test="vo.ids != null and vo.ids.size()>0 ">
  3127. AND ifon.two_level_user_id IN
  3128. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3129. #{item}
  3130. </foreach>
  3131. </if>
  3132. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3133. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3134. </if>
  3135. </where>
  3136. group by ifon.two_level_user_id
  3137. ) b on b.twoLevelUserId =a.firstLevelUserId
  3138. left join (
  3139. select
  3140. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3141. ifon.three_level_user_id as "threeLevelUserId"
  3142. from ins_area_company iac
  3143. left join ins_orders io on io.orderno = iac.orderno
  3144. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3145. <where>
  3146. <if test="vo.userId !=null and vo.userId !=''">
  3147. ifon.three_level_user_id =#{vo.userId}
  3148. </if>
  3149. <if test="vo.ids != null and vo.ids.size()>0 ">
  3150. AND ifon.three_level_user_id IN
  3151. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3152. #{item}
  3153. </foreach>
  3154. </if>
  3155. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3156. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3157. </if>
  3158. </where>
  3159. group by ifon.three_level_user_id
  3160. ) c on c.threeLevelUserId = a.firstLevelUserId
  3161. ) b on b.firstLevelUserId =iac.leader_id
  3162. <where>
  3163. <if test="vo.userId !=null and vo.userId !=''">
  3164. io.userid =#{vo.userId}
  3165. </if>
  3166. <if test="vo.ids != null and vo.ids.size()>0 ">
  3167. AND io.userid IN
  3168. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3169. #{item}
  3170. </foreach>
  3171. </if>
  3172. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3173. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3174. </if>
  3175. </where>
  3176. </select>
  3177. <select id="getDistributionAllAmount" resultType="java.util.HashMap">
  3178. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3179. a.firstLevelUserId
  3180. from (
  3181. select
  3182. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3183. ifon.first_level_user_id as "firstLevelUserId"
  3184. from ins_area_company iac
  3185. left join ins_orders io on io.orderno = iac.orderno
  3186. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3187. <where>
  3188. <if test="vo.userId !=null and vo.userId !=''">
  3189. ifon.first_level_user_id =#{vo.userId}
  3190. </if>
  3191. <if test="vo.ids != null and vo.ids.size()>0 ">
  3192. AND io.userid IN
  3193. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3194. #{item}
  3195. </foreach>
  3196. </if>
  3197. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3198. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3199. </if>
  3200. </where>
  3201. group by ifon.first_level_user_id
  3202. ) a
  3203. left join (
  3204. select
  3205. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3206. ifon.two_level_user_id as "twoLevelUserId"
  3207. from ins_area_company iac
  3208. left join ins_orders io on io.orderno = iac.orderno
  3209. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3210. <where>
  3211. <if test="vo.userId !=null and vo.userId !=''">
  3212. ifon.two_level_user_id =#{vo.userId}
  3213. </if>
  3214. <if test="vo.ids != null and vo.ids.size()>0 ">
  3215. AND io.userid IN
  3216. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3217. #{item}
  3218. </foreach>
  3219. </if>
  3220. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3221. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3222. </if>
  3223. </where>
  3224. group by ifon.two_level_user_id
  3225. ) b on b.twoLevelUserId =a.firstLevelUserId
  3226. left join (
  3227. select
  3228. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3229. ifon.three_level_user_id as "threeLevelUserId"
  3230. from ins_area_company iac
  3231. left join ins_orders io on io.orderno = iac.orderno
  3232. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3233. <where>
  3234. <if test="vo.userId !=null and vo.userId !=''">
  3235. ifon.three_level_user_id =#{vo.userId}
  3236. </if>
  3237. <if test="vo.ids != null and vo.ids.size()>0 ">
  3238. AND io.userid IN
  3239. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3240. #{item}
  3241. </foreach>
  3242. </if>
  3243. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3244. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3245. </if>
  3246. </where>
  3247. group by ifon.three_level_user_id
  3248. ) c on c.threeLevelUserId = a.firstLevelUserId
  3249. </select>
  3250. <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3251. SELECT
  3252. iac.*
  3253. FROM ins_area_company as iac
  3254. <where>
  3255. iac.orderstatus = 3
  3256. <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
  3257. AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
  3258. </if>
  3259. </where>
  3260. order by iac.createtime
  3261. </select>
  3262. </mapper>