InsAreaCompanyMapper.xml 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294
  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. </resultMap>
  74. <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
  75. extends="BaseResultMap">
  76. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  77. <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
  78. </resultMap>
  79. <sql id="Base_Column_List">
  80. id,orderno,inscompany,
  81. reqtxt,reptxt,jqapplyno,
  82. jqpolicyno,syapplyno,sypolicyno,
  83. riskinfo,kindinfo,jqpremium,
  84. sypremium,taxamount,sumpremium,
  85. jqdiscountrate,sydiscountrate,feerate,
  86. disrate,auditid,auditname,
  87. audittime,auditopinion,jqappoint,
  88. syappoint,createtime,payment_link
  89. </sql>
  90. <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
  91. SELECT iac.*, pa.agreement_name,
  92. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  93. FROM ins_area_company as iac
  94. left join ptl_agreement as pa on pa.id = iac.agreement_id
  95. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  96. FROM ins_area_company
  97. WHERE orderno = #{orderNo}
  98. GROUP BY company_id) t ON t.company_id = iac.company_id
  99. AND t.max_createtime = iac.createtime
  100. WHERE iac.orderno = #{orderNo}
  101. </select>
  102. <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
  103. SELECT iac.*, pa.agreement_name,io.is_external,
  104. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  105. FROM ins_area_company as iac
  106. left join ptl_agreement as pa on pa.id = iac.agreement_id
  107. left join ins_orders io on iac.orderno=io.orderno
  108. WHERE iac.orderstatus = 3
  109. and iac.orderno = #{orderNo};
  110. </select>
  111. <select id="queryLatestStatus" resultType="java.lang.String">
  112. SELECT iac.orderstatus
  113. FROM ins_area_company as iac
  114. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  115. FROM ins_area_company
  116. WHERE orderno = #{orderNo}
  117. GROUP BY company_id) t ON t.company_id = iac.company_id
  118. AND t.max_createtime = iac.createtime
  119. WHERE iac.orderno = #{orderNo}
  120. ORDER BY orderstatus DESC
  121. LIMIT 1
  122. </select>
  123. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  124. SELECT a.id as "id",
  125. a.orderno as "orderno"
  126. FROM ins_area_company a
  127. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  128. WHERE a.orderstatus = '3'
  129. or a.orderstatus = '2'
  130. and b.id is not null
  131. </select>
  132. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  133. SELECT
  134. iac.id as orderno,
  135. io.quoteno,
  136. io.orderstatus,
  137. io.company_id,
  138. io.ins_company,
  139. io.carinfo,
  140. io.userid,
  141. io.username,
  142. io.deptid,
  143. io.deptname,
  144. io.agreeid,
  145. iac.productid,
  146. iac.product,
  147. iac.createtime,
  148. io.frameno,
  149. io.licenseno,
  150. io.insuredname,
  151. io.is_external,
  152. iac.jq_start_date as jqstartdate,
  153. iac.jq_end_date as jqenddate,
  154. iac.sy_start_date as systartdate,
  155. iac.sy_end_date as syenddate,
  156. io.vehicle_and_vessel_tax,
  157. io.operatorid,
  158. iac.operator_name,
  159. sd.management_source,
  160. iac.problem_order,
  161. CASE ifa.audituser
  162. WHEN '自动审核' THEN ifa.audituser
  163. ELSE su2.name END
  164. AS auditUser,
  165. ifa.audittime as auditTime,
  166. ifa.auditstatus as auditStatus,
  167. eic.namesimple as partnerCompaniesName,
  168. iac.id as subOrderId,
  169. iac.signing_time as signingTime,
  170. iac.pay_date as payDate,
  171. pa.agreement_code as agreementCode,
  172. pa.agreement_name as agreementName,
  173. pa.business_description as businessDescription,
  174. pa.job_description as jobDescription,
  175. pa.agreement_title as agreementTitle,
  176. pa.docking_person as dockingPerson,
  177. io.entry_status
  178. FROM
  179. ins_fee_audit ifa
  180. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  181. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  182. AND iac.orderstatus = 3
  183. LEFT JOIN sys_user su ON su.id = io.userid
  184. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  185. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  186. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  187. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  188. WHERE
  189. iac.id = ifa.ins_order_no
  190. AND iac.orderstatus = 3
  191. <if test="params.auditStatus != null and params.auditStatus != ''">
  192. and ifa.auditstatus = #{params.auditStatus}
  193. </if>
  194. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  195. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  196. #{params.quoteEndDateStr}
  197. </if>
  198. <if test="params.orderNo != null and params.orderNo != ''">
  199. AND iac.id= #{params.orderNo}
  200. </if>
  201. <if test="params.licenseNo != null and params.licenseNo != ''">
  202. AND io.licenseno = #{params.licenseNo}
  203. </if>
  204. <if test="params.frameNo != null and params.frameNo != ''">
  205. AND io.frameno = #{params.frameNo}
  206. </if>
  207. <if test="params.insuredName != null and params.insuredName != ''">
  208. AND io.insuredname = #{params.insuredName}
  209. </if>
  210. <if test="params.companyId != null and params.companyId != ''">
  211. AND io.company_id = #{params.companyId}
  212. </if>
  213. <if test="params.engineNo != null and params.engineNo != ''">
  214. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  215. </if>
  216. <if test="params.riskCode != null and params.riskCode != ''">
  217. and iac.product = #{params.riskCode}
  218. </if>
  219. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  220. and ((
  221. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  222. AND #{params.attachEndDateStr}
  223. )
  224. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  225. #{params.attachEndDateStr} )
  226. )
  227. </if>
  228. <if test="params.provinceId != null and params.provinceId != ''">
  229. and io.deptid like "${params.provinceId}%"
  230. </if>
  231. <if test="params.problemOrder != null and params.problemOrder != ''">
  232. and iac.problem_order like "${params.problemOrder}%"
  233. </if>
  234. <if test="params.cityId != null and params.cityId != ''">
  235. and io.deptid like "${params.cityId}%"
  236. </if>
  237. <if test="params.countyId != null and params.countyId != ''">
  238. and io.deptid like "${params.countyId}%"
  239. </if>
  240. <if test="params.houseId != null and params.houseId != ''">
  241. and io.deptid like "${params.houseId}%"
  242. </if>
  243. <if test="params.operatorId != null and params.operatorId != ''">
  244. and io.userid = #{params.operatorId}
  245. </if>
  246. <if test="params.operatorName != null and params.operatorName != ''">
  247. and io.username = #{params.operatorName}
  248. </if>
  249. <if test="params.auditId != null and params.auditId != ''">
  250. and iac.new_operator_id = #{params.auditId}
  251. </if>
  252. <if test="params.agreeId != null and params.agreeId != ''">
  253. and iac.agreement_id = #{params.agreeId}
  254. </if>
  255. <if test="params.managementSource != null and params.managementSource != ''">
  256. and sd.management_source = #{params.managementSource}
  257. </if>
  258. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  259. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  260. #{params.signEndDateStr}
  261. </if>
  262. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  263. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  264. </if>
  265. <if test="params.isExternal != null and params.isExternal != ''">
  266. and io.is_external = #{params.isExternal}
  267. </if>
  268. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  269. and iac.jqpolicyno = #{params.jqPolicyNo}
  270. </if>
  271. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  272. and iac.sypolicyno = #{params.syPolicyNo}
  273. </if>
  274. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  275. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  276. </if>
  277. order by iac.createtime desc
  278. </select>
  279. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  280. SELECT
  281. io.*,
  282. sd.management_source
  283. FROM
  284. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  285. WHERE
  286. orderno IN (
  287. SELECT
  288. orderno
  289. FROM
  290. ins_area_company
  291. WHERE
  292. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  293. AND orderstatus = 3
  294. )
  295. AND
  296. io.orderstatus= 3
  297. <if test="orderNo != null and orderNo != ''">
  298. AND orderno = #{orderNo}
  299. </if>
  300. <if test="licenseNo != null and licenseNo != ''">
  301. AND licenseno = #{licenseNo}
  302. </if>
  303. <if test="frameNo != null and frameNo != ''">
  304. AND frameno = #{frameNo}
  305. </if>
  306. <if test="userId != null and userId != ''">
  307. AND userid = #{userId}
  308. </if>
  309. <if test="insuredname != null and insuredname != ''">
  310. AND insuredname = #{insuredname}
  311. </if>
  312. <if test="startDateStr != null and startDateStr != ''">
  313. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  314. </if>
  315. </select>
  316. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  317. SELECT
  318. sum(a.first_detail_premiums) as "willFirstPremiums"
  319. FROM
  320. ins_fee_order_new a
  321. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  322. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  323. WHERE
  324. iff.auditstatus=0
  325. AND iac.orderstatus =3
  326. <if test="firstUserId != null and firstUserId != ''">
  327. AND a.first_level_user_id = #{firstUserId}
  328. </if>
  329. <if test="secondUserId != null and secondUserId != ''">
  330. AND a.two_level_user_id = #{secondUserId}
  331. </if>
  332. <if test="thirdUserId != null and thirdUserId != ''">
  333. AND a.three_level_user_id = #{thirdUserId}
  334. </if>
  335. <if test="id != null and id != ''">
  336. AND a.id = #{id}
  337. </if>
  338. </select>
  339. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  340. SELECT
  341. sum( fee.p ) as "willFirstPremiums"
  342. FROM
  343. (
  344. SELECT
  345. sum( a.first_detail_premiums ) AS p
  346. FROM
  347. ins_fee_order_new a
  348. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  349. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  350. <where>
  351. iff.auditstatus=0
  352. and iac.orderstatus = '3'
  353. <if test="userId!=null and userId!= ''">
  354. AND a.first_level_user_id = #{userId}
  355. </if>
  356. <if test="id != null and id!=''">
  357. AND a.id =#{id}
  358. </if>
  359. </where>
  360. UNION
  361. SELECT
  362. sum( a.third_detail_premiums ) AS p
  363. FROM
  364. ins_fee_order_new a
  365. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  366. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  367. <where>
  368. iff.auditstatus=0
  369. and iac.orderstatus = '3'
  370. <if test="userId!=null and userId!= ''">
  371. AND a.three_level_user_id = #{userId}
  372. </if>
  373. <if test="id != null and id!=''">
  374. AND a.id =#{id}
  375. </if>
  376. </where>
  377. UNION
  378. SELECT
  379. sum( a.second_detail_premiums ) AS p
  380. FROM
  381. ins_fee_order_new a
  382. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  383. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  384. <where>
  385. iff.auditstatus=0
  386. and iac.orderstatus = '3'
  387. <if test="userId!=null and userId!= ''">
  388. AND a.two_level_user_id = #{userId}
  389. </if>
  390. <if test="id != null and id!=''">
  391. AND a.id =#{id}
  392. </if>
  393. </where>
  394. ) AS fee
  395. </select>
  396. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  397. SELECT
  398. sum(a.third_detail_premiums) as "willThreePremiums"
  399. FROM
  400. ins_fee_order_new a
  401. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  402. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  403. WHERE
  404. iff.auditstatus=0
  405. AND iac.orderstatus =3
  406. <if test="firstUserId != null and firstUserId != ''">
  407. AND a.first_level_user_id = #{firstUserId}
  408. </if>
  409. <if test="secondUserId != null and secondUserId != ''">
  410. AND a.two_level_user_id = #{secondUserId}
  411. </if>
  412. <if test="thirdUserId != null and thirdUserId != ''">
  413. AND a.three_level_user_id = #{thirdUserId}
  414. </if>
  415. <if test="id != null and id != ''">
  416. AND a.id = #{id}
  417. </if>
  418. </select>
  419. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  420. SELECT
  421. io.*,
  422. sd.management_source,
  423. su2.name AS auditUser,
  424. ifa.audittime as auditTime
  425. FROM
  426. ins_orders io
  427. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  428. LEFT JOIN sys_user su ON su.id = io.userid
  429. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  430. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  431. WHERE
  432. io.orderno IN (
  433. SELECT
  434. orderno
  435. FROM
  436. ins_area_company
  437. WHERE
  438. id IN (
  439. SELECT
  440. ifon.ins_order_no
  441. FROM
  442. ins_fee_order_new ifon
  443. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  444. WHERE
  445. ifa.auditstatus = #{params.auditStatus}
  446. )
  447. )
  448. AND orderstatus = 3
  449. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  450. <!-- AND orderno = #{params.orderNo}-->
  451. <!-- </if>-->
  452. <if test="params.licenseNo != null and params.licenseNo != ''">
  453. AND licenseno = #{params.licenseNo}
  454. </if>
  455. <if test="params.frameNo != null and params.frameNo != ''">
  456. AND frameno = #{params.frameNo}
  457. </if>
  458. <if test="params.insuredName != null and params.insuredName != ''">
  459. AND insuredname = #{params.insuredName}
  460. </if>
  461. <if test="params.companyId != null and params.companyId != ''">
  462. AND company_id = #{params.companyId}
  463. </if>
  464. <if test="params.startDateStr != null and params.startDateStr != ''">
  465. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  466. </if>
  467. </select>
  468. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  469. -- 查询订单信息
  470. SELECT
  471. iac.*
  472. FROM
  473. ins_area_company iac
  474. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  475. WHERE
  476. 1=1
  477. <if test="dateStr != null and dateStr != ''">
  478. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  479. </if>
  480. </select>
  481. <select id="selectListById" resultMap="BaseResultMap">
  482. SELECT
  483. iac.*
  484. FROM
  485. ins_area_company iac
  486. WHERE
  487. 1=1
  488. <if test="id != null and id != ''">
  489. AND iac.id =#{id}
  490. </if>
  491. </select>
  492. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  493. SELECT
  494. sum( fee.p ) as "willFirstPremiums"
  495. FROM
  496. (
  497. SELECT
  498. sum( a.first_detail_premiums ) AS p
  499. FROM
  500. ins_fee_order_new a
  501. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  502. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  503. <where>
  504. <choose>
  505. <when test='type == "1"'>
  506. iff.auditstatus=0
  507. </when>
  508. <otherwise>
  509. iff.auditstatus=1
  510. </otherwise>
  511. </choose>
  512. and iac.orderstatus = '3'
  513. <if test="userId!=null and userId!= ''">
  514. AND a.first_level_user_id = #{userId}
  515. </if>
  516. <if test="id != null and id!=''">
  517. AND a.id =#{id}
  518. </if>
  519. </where>
  520. UNION
  521. SELECT
  522. sum( a.third_detail_premiums ) AS p
  523. FROM
  524. ins_fee_order_new a
  525. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  526. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  527. <where>
  528. <choose>
  529. <when test='type == "1"'>
  530. iff.auditstatus=0
  531. </when>
  532. <otherwise>
  533. iff.auditstatus=1
  534. </otherwise>
  535. </choose>
  536. and iac.orderstatus = '3'
  537. <if test="userId!=null and userId!= ''">
  538. AND a.three_level_user_id = #{userId}
  539. </if>
  540. <if test="id != null and id!=''">
  541. AND a.id =#{id}
  542. </if>
  543. </where>
  544. UNION
  545. SELECT
  546. sum( a.second_detail_premiums ) AS p
  547. FROM
  548. ins_fee_order_new a
  549. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  550. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  551. <where>
  552. <choose>
  553. <when test='type == "1"'>
  554. iff.auditstatus=0
  555. </when>
  556. <otherwise>
  557. iff.auditstatus=1
  558. </otherwise>
  559. </choose>
  560. and iac.orderstatus = '3'
  561. <if test="userId!=null and userId!= ''">
  562. AND a.two_level_user_id = #{userId}
  563. </if>
  564. <if test="id != null and id!=''">
  565. AND a.id =#{id}
  566. </if>
  567. </where>
  568. ) AS fee
  569. </select>
  570. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  571. SELECT
  572. iac.id as subOrderId,
  573. iac.signing_time as signingTime,
  574. iac.jqpremium as jqpremium,
  575. iac.sypremium as sypremium,
  576. iac.jypremium as jypremium,
  577. io.licenseno as licenseno,
  578. io.userid as userId
  579. FROM
  580. ins_area_company iac
  581. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  582. WHERE
  583. iac.id=#{subOrderId}
  584. </select>
  585. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  586. SELECT
  587. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  588. sum(jqpremium) jqpremium,
  589. sum(sypremium) sypremium,
  590. sum(sumpremium) sumpremium
  591. FROM
  592. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  593. WHERE
  594. iac.orderstatus = 3 and
  595. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  596. and io.userid=#{userId}
  597. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  598. </select>
  599. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  600. SELECT
  601. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  602. sum(jqpremium) jqpremium,
  603. sum(sypremium) sypremium,
  604. sum(sumpremium) sumpremium
  605. FROM
  606. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  607. WHERE
  608. iac.orderstatus = 3 and
  609. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  610. and io.userid=#{userId}
  611. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  612. </select>
  613. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  614. SELECT
  615. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  616. 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' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  627. </select>
  628. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  629. SELECT
  630. ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
  631. count( 0 ) as sumCount
  632. FROM
  633. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  634. WHERE
  635. iac.orderstatus = 3
  636. and io.userid=#{userId}
  637. AND YEAR (iac.createtime) = #{year}
  638. </select>
  639. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  640. select
  641. iac.id,
  642. iac.orderno,
  643. iac.agreement_id,
  644. iac.jqpremium,
  645. iac.sypremium,
  646. iac.jypremium,
  647. iac.taxamount,
  648. iac.sumpremium,
  649. io.licenseno,
  650. ifa.audittime,
  651. ifa.audituser as auditname,
  652. ifa.rejectinfo,
  653. "1" as orderExternalStatus
  654. FROM
  655. ins_fee_audit ifa
  656. LEFT JOIN
  657. ins_area_company iac on iac.id = ifa.ins_order_no
  658. LEFT JOIN
  659. ins_orders io on iac.orderno = io.orderno
  660. left join
  661. sys_user su on su.id= ifa.audituser
  662. WHERE
  663. iac.operator_id = #{userId}
  664. AND
  665. ifa.auditstatus = 2
  666. <if test="vo.id != null and vo.id!=''">
  667. and iac.id = #{vo.id}
  668. </if>
  669. <if test="vo.licenseno != null and vo.licenseno!='' ">
  670. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  671. </if>
  672. <if test="vo.auditname != null and vo.auditname!='' ">
  673. and su.name like CONCAT('%', #{vo.auditname}, '%')
  674. </if>
  675. </select>
  676. <select id="queryBusinessDataPage"
  677. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  678. SELECT
  679. <if test="flag != null and flag!='' and flag='1'">
  680. o.userid as userId,
  681. o.username as userName,
  682. </if>
  683. sum( iac.sumpremium ) as signeSumPremiumAmount,
  684. sum( iac.jqpremium ) as jqPremiumAmount,
  685. sum( iac.sypremium ) as syPremiumAmount,
  686. sum( iac.taxamount ) as taxAmount,
  687. sum( ion.no_premium ) as fcFeeAmount
  688. FROM
  689. ins_area_company iac
  690. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  691. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  692. where iac.orderstatus = 3 and ion.id is not null
  693. <if test="userList != null and userList.size()>0 ">
  694. and o.userid IN
  695. <foreach item="item" collection="userList" open="(" separator="," close=")">
  696. #{item}
  697. </foreach>
  698. </if>
  699. <if test="flag != null and flag!='' and flag='1'">
  700. group by o.userid,o.username
  701. </if>
  702. </select>
  703. <select id="queryQuotationSubOrderCountDataPage"
  704. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  705. SELECT
  706. <if test="flag != null and flag!='' and flag='1'">
  707. o.userid as userId,
  708. o.username as userName,
  709. </if>
  710. iac.orderstatus as orderStatus
  711. FROM
  712. ins_area_company iac
  713. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  714. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  715. <if test="userList != null and userList.size()>0 ">
  716. and o.userid IN
  717. <foreach item="item" collection="userList" open="(" separator="," close=")">
  718. #{item}
  719. </foreach>
  720. </if>
  721. <if test="flag != null and flag!='' and flag='1'">
  722. group by o.userid,o.username,iac.orderstatus
  723. </if>
  724. </select>
  725. <select id="queryQuotationOrderCountDataPage"
  726. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  727. SELECT
  728. a.userId as userId,
  729. a.userName as userName,
  730. b.qutationCount AS insOrderQutationCount,
  731. b.qutationInsureCount as insOrderQutationInsureCount,
  732. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  733. a.qutationCount as subOrderQutationCount,
  734. a.underwritingCount as subOrderUnderwritingCount,
  735. a.qutationInsureCount as subOrderQutationInsureCount,
  736. a.passRate as subOrderCloseRate,
  737. a.closeRate as subOrderPassRate,
  738. a.contributionRate as subOrderContributionRate
  739. FROM
  740. (
  741. SELECT
  742. inso.userid AS userId,
  743. inso.username AS userName,
  744. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  745. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  746. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  747. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  748. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  749. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
  750. FROM
  751. ins_area_company iac
  752. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  753. <where>
  754. <if test="userList != null and userList.size()>0 ">
  755. and o.userid IN
  756. <foreach item="item" collection="userList" open="(" separator="," close=")">
  757. #{item}
  758. </foreach>
  759. </if>
  760. </where>
  761. GROUP BY
  762. inso.userid,
  763. inso.username
  764. ) a
  765. LEFT JOIN (
  766. SELECT
  767. inso.userid AS userId,
  768. inso.username AS userName,
  769. count( inso.orderstatus ) AS qutationCount,
  770. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  771. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  772. FROM
  773. ins_orders inso
  774. <where>
  775. <if test="userList != null and userList.size()>0 ">
  776. and o.userid IN
  777. <foreach item="item" collection="userList" open="(" separator="," close=")">
  778. #{item}
  779. </foreach>
  780. </if>
  781. </where>
  782. GROUP BY
  783. inso.userid,
  784. inso.username
  785. ) b ON a.userId = b.userId
  786. </select>
  787. <select id="queryCompanyPremiumDataPage"
  788. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  789. SELECT
  790. agree.insurance_company_id AS companyId,
  791. agree.insurance_company AS companyName,
  792. agree.partner_companies_id AS parterCompanyId,
  793. ins.NAME AS parterCompanyName,
  794. sum( iac.sumpremium ) AS signeSumPremiumAmount
  795. FROM
  796. ins_area_company iac
  797. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  798. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  799. WHERE
  800. iac.orderstatus = 3
  801. and
  802. agree.id is not null
  803. <if test="vo.companyId != null and vo.companyId!='' ">
  804. agree.insurance_company_id = #{vo.companyId}
  805. </if>
  806. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  807. agree.insurance_company_id = #{vo.parterCompanyId}
  808. </if>
  809. GROUP BY
  810. agree.insurance_company_id,
  811. agree.insurance_company,
  812. agree.partner_companies_id,
  813. ins.NAME
  814. </select>
  815. <select id="queryCompanyQutationCountDataPage"
  816. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  817. SELECT
  818. a.* ,
  819. (select ins.namesimple from esm_ins_company
  820. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  821. FROM
  822. (
  823. SELECT
  824. count(agree.partner_companies_id) as "orderSuccessNumber",
  825. agree.insurance_company AS companyName,
  826. agree.partner_companies_id AS parterCompanyId,
  827. iac.company_id as "companyId",
  828. count( iac.orderstatus ) AS qutationCount,
  829. count( iac.id ) AS orderSuccessNumberRate,
  830. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
  831. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  832. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
  833. 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,
  834. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
  835. COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
  836. FROM
  837. ins_area_company iac
  838. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  839. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  840. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  841. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  842. WHERE
  843. agree.id IS NOT NULL
  844. <if test="vo.companyId != null and vo.companyId!='' ">
  845. AND agree.insurance_company_id = #{vo.companyId}
  846. </if>
  847. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  848. AND agree.partner_companies_id = #{vo.parterCompanyId}
  849. </if>
  850. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  851. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  852. </if>
  853. <if test="vo.managementSource != null and vo.managementSource!=''">
  854. AND sd.management_source =#{vo.managementSource}
  855. </if>
  856. <if test="vo.userId != null and vo.userId !=''">
  857. AND io.userid =#{vo.userId}
  858. </if>
  859. <if test="vo.deptId != null and vo.deptId !=''">
  860. AND io.deptId like concat('%',#{vo.leaderName},'%')
  861. </if>
  862. GROUP BY
  863. agree.insurance_company,
  864. iac.company_id,
  865. agree.partner_companies_id
  866. ) a
  867. </select>
  868. <select id="getInsAreaCompanyError"
  869. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  870. SELECT
  871. count(iace.id) as "areaCompanyErrNumber"
  872. FROM
  873. ins_area_company_error iace
  874. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  875. <where>
  876. 1=1
  877. <if test="vo.companyId != null and vo.companyId!='' ">
  878. AND agree.insurance_company_id = #{vo.companyId}
  879. </if>
  880. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  881. AND agree.partner_companies_id = #{vo.parterCompanyId}
  882. </if>
  883. <if test="vo.userId != null and vo.userId!=''">
  884. AND iace.user_id =#{vo.userId}
  885. </if>
  886. </where>
  887. </select>
  888. <select id="queryCompanyQutationCountDataPageTotal"
  889. resultType="java.lang.Long">
  890. SELECT
  891. count(0)
  892. FROM
  893. (
  894. SELECT
  895. agree.partner_companies_id
  896. FROM
  897. ins_area_company iac
  898. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  899. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  900. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  901. WHERE
  902. agree.id IS NOT NULL
  903. <if test="vo.companyId != null and vo.companyId!='' ">
  904. AND agree.insurance_company_id = #{vo.companyId}
  905. </if>
  906. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  907. AND agree.partner_companies_id = #{vo.parterCompanyId}
  908. </if>
  909. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  910. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  911. </if>
  912. <if test="vo.managementSource != null and vo.managementSource!=''">
  913. AND sd.management_source =#{vo.managementSource}
  914. </if>
  915. <if test="vo.userId != null and vo.userId !=''">
  916. AND io.userid =#{vo.userId}
  917. </if>
  918. <if test="vo.deptId != null and vo.deptId !=''">
  919. AND io.deptId like concat('%',#{vo.leaderName},'%')
  920. </if>
  921. GROUP BY
  922. agree.partner_companies_id
  923. ) a
  924. </select>
  925. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  926. select
  927. iac.id,
  928. iac.orderno,
  929. iac.agreement_id,
  930. iac.jqpremium,
  931. iac.sypremium,
  932. iac.jypremium,
  933. iac.taxamount,
  934. iac.sumpremium,
  935. io.licenseno,
  936. iac.createtime,
  937. "0" as orderExternalStatus
  938. FROM
  939. ins_area_company iac
  940. LEFT JOIN
  941. ins_orders io on iac.orderno = io.orderno
  942. left join ptl_agreement agree on iac.agreement_id =agree.id
  943. WHERE
  944. iac.operator_id = #{userId}
  945. AND
  946. iac.orderstatus = 0
  947. and agree.is_external =1
  948. <if test="vo.id != null and vo.id!='' ">
  949. and iac.id = #{vo.id}
  950. </if>
  951. <if test="vo.licenseno != null and vo.licenseno!='' ">
  952. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  953. </if>
  954. </select>
  955. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  956. select a.*, su.name as "userName",
  957. inf.url as "logo",
  958. sui.sex as "sex",
  959. su.leader_name as "leaderName"
  960. from (
  961. SELECT
  962. sd.NAME AS "deptName",
  963. io.userid AS "userId",
  964. sd.parent_id as "deptId",
  965. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  966. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  967. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  968. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  969. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  970. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
  971. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
  972. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  973. COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
  974. COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
  975. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  976. FROM
  977. ins_area_company iac
  978. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  979. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  980. <where>
  981. sd.management_source = '1'
  982. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  983. and io.deptid like "${taskStatisticsVo.provinceId}%"
  984. </if>
  985. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  986. and io.deptid like "${taskStatisticsVo.cityId}%"
  987. </if>
  988. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  989. and io.deptid like "${taskStatisticsVo.countyId}%"
  990. </if>
  991. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  992. and io.deptid like "${taskStatisticsVo.houseId}%"
  993. </if>
  994. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  995. and io.userid =#{taskStatisticsVo.userId}
  996. </if>
  997. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  998. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  999. </if>
  1000. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1001. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1002. </if>
  1003. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1004. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1005. </if>
  1006. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1007. <choose>
  1008. <when test="taskStatisticsVo.days =='1'">
  1009. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1010. </when>
  1011. <when test="taskStatisticsVo.days =='7'">
  1012. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1013. </when>
  1014. <when test="taskStatisticsVo.days =='30'">
  1015. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1016. </when>
  1017. </choose>
  1018. </if>
  1019. </where>
  1020. GROUP BY
  1021. io.userid,
  1022. sd.NAME,
  1023. sd.id
  1024. ) a
  1025. left join sys_user su on su.id =a.userId
  1026. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1027. LEFT JOIN sys_user_info sui on sui .id =su.id
  1028. </select>
  1029. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1030. select count(0) from (
  1031. SELECT
  1032. io.userid
  1033. FROM
  1034. ins_area_company iac
  1035. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1036. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1037. <where>
  1038. sd.management_source = '1'
  1039. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1040. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1041. </if>
  1042. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1043. and io.deptid like "${taskStatisticsVo.cityId}%"
  1044. </if>
  1045. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1046. and io.deptid like "${taskStatisticsVo.countyId}%"
  1047. </if>
  1048. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1049. and io.deptid like "${taskStatisticsVo.houseId}%"
  1050. </if>
  1051. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1052. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1053. </if>
  1054. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1055. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1056. </if>
  1057. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1058. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1059. </if>
  1060. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1061. and io.userid =#{taskStatisticsVo.userId}
  1062. </if>
  1063. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1064. <choose>
  1065. <when test="taskStatisticsVo.days =='1'">
  1066. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1067. </when>
  1068. <when test="taskStatisticsVo.days =='7'">
  1069. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1070. </when>
  1071. <when test="taskStatisticsVo.days =='30'">
  1072. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1073. </when>
  1074. </choose>
  1075. </if>
  1076. </where>
  1077. GROUP BY
  1078. io.userid
  1079. ) a
  1080. </select>
  1081. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1082. SELECT
  1083. a.*,
  1084. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1085. FROM
  1086. (
  1087. SELECT
  1088. pa.insurance_company_id,
  1089. pa.partner_companies_id,
  1090. pa.insurance_company AS "insuranceCompanyName",
  1091. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1092. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1093. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1094. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1095. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1096. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1097. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1098. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1099. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1100. FROM
  1101. ins_area_company iac
  1102. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1103. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1104. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1105. <where>
  1106. pa.insurance_company_id IS NOT NULL
  1107. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1108. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1109. </if>
  1110. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1111. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1112. </if>
  1113. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1114. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1115. </if>
  1116. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1117. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1118. </if>
  1119. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1120. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1121. </if>
  1122. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1123. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1124. </if>
  1125. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1126. AND iac.company_id =#{taskStatisticsVo.companyId}
  1127. </if>
  1128. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1129. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1130. </if>
  1131. </where>
  1132. GROUP BY
  1133. pa.insurance_company_id,
  1134. pa.partner_companies_id,
  1135. pa.insurance_company
  1136. ) a
  1137. </select>
  1138. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1139. SELECT
  1140. COUNT(0)
  1141. FROM
  1142. (
  1143. SELECT
  1144. pa.insurance_company_id,
  1145. pa.partner_companies_id
  1146. FROM
  1147. ins_area_company iac
  1148. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1149. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1150. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1151. <where>
  1152. pa.insurance_company_id IS NOT NULL
  1153. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1154. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1155. </if>
  1156. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1157. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1158. </if>
  1159. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1160. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1161. </if>
  1162. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1163. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1164. </if>
  1165. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1166. AND io.createtime 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 iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  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. </where>
  1175. GROUP BY
  1176. pa.insurance_company_id,
  1177. pa.partner_companies_id
  1178. ) total
  1179. </select>
  1180. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1181. SELECT
  1182. sd.name as "deptName",
  1183. su.name as "userName",
  1184. io.userid as "userId",
  1185. sd.id as "deptId",
  1186. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1187. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1188. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1189. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1190. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / COUNT(iac.orderstatus) as "passingRate",
  1191. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
  1192. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
  1193. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
  1194. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) as "auditOrder"
  1195. FROM
  1196. ins_area_company iac
  1197. left join ins_orders io on io.orderno = iac.orderno
  1198. left join sys_dept sd on sd.id=io.deptid
  1199. left join sys_user su on su.id=io.userid
  1200. <where>
  1201. sd.management_source = '2'
  1202. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1203. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1204. </if>
  1205. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1206. and io.deptid like "${taskStatisticsVo.cityId}%"
  1207. </if>
  1208. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1209. and io.deptid like "${taskStatisticsVo.countyId}%"
  1210. </if>
  1211. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1212. and io.deptid like "${taskStatisticsVo.houseId}%"
  1213. </if>
  1214. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1215. and io.userid =#{taskStatisticsVo.userId}
  1216. </if>
  1217. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1218. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1219. </if>
  1220. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1221. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1222. </if>
  1223. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1224. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1225. </if>
  1226. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1227. <choose>
  1228. <when test="taskStatisticsVo.days =='1'">
  1229. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1230. </when>
  1231. <when test="taskStatisticsVo.days =='7'">
  1232. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1233. </when>
  1234. <when test="taskStatisticsVo.days =='30'">
  1235. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1236. </when>
  1237. </choose>
  1238. </if>
  1239. </where>
  1240. GROUP BY io.userid , su.name, sd.id , sd.name
  1241. </select>
  1242. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1243. select count(0) from (
  1244. SELECT
  1245. io.userid as "userId"
  1246. FROM
  1247. ins_area_company iac
  1248. left join ins_orders io on io.orderno = iac.orderno
  1249. left join sys_dept sd on sd.id=io.deptid
  1250. <where>
  1251. sd.management_source = '2'
  1252. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1253. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1254. </if>
  1255. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1256. and io.deptid like "${taskStatisticsVo.cityId}%"
  1257. </if>
  1258. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1259. and io.deptid like "${taskStatisticsVo.countyId}%"
  1260. </if>
  1261. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1262. and io.deptid like "${taskStatisticsVo.houseId}%"
  1263. </if>
  1264. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1265. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1266. </if>
  1267. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1268. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1269. </if>
  1270. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1271. and io.userid =#{taskStatisticsVo.userId}
  1272. </if>
  1273. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1274. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1275. </if>
  1276. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1277. <choose>
  1278. <when test="taskStatisticsVo.days =='1'">
  1279. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1280. </when>
  1281. <when test="taskStatisticsVo.days =='7'">
  1282. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1283. </when>
  1284. <when test="taskStatisticsVo.days =='30'">
  1285. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1286. </when>
  1287. </choose>
  1288. </if>
  1289. </where>
  1290. GROUP BY io.userid
  1291. ) a
  1292. </select>
  1293. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1294. SELECT
  1295. iac.company_id,
  1296. iac.inscompany as "insuranceCompanyName",
  1297. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1298. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1299. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1300. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1301. FROM
  1302. ins_fee_audit ifa
  1303. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1304. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1305. AND iac.orderstatus = 3
  1306. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1307. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1308. <where>
  1309. 1=1
  1310. and iac.id = ifa.ins_order_no
  1311. AND iac.orderstatus = 3
  1312. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1313. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1314. </if>
  1315. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1316. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1317. </if>
  1318. <choose>
  1319. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1320. and iac.product = #{taskStatisticsVo.riskCode}
  1321. </when>
  1322. </choose>
  1323. </where>
  1324. GROUP BY
  1325. iac.company_id,
  1326. iac.inscompany
  1327. </select>
  1328. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1329. SELECT
  1330. count( a.numberUserId ) as "orderManpower",
  1331. sum( a.orderAmount ) as "totalPremium",
  1332. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1333. FROM
  1334. (
  1335. SELECT
  1336. count( io.userid ) AS "numberUserId",
  1337. SUM(IFNULL(iac.jqpremium, 0)) +
  1338. SUM(IFNULL(iac.sypremium, 0)) +
  1339. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1340. FROM
  1341. `ins_area_company` iac
  1342. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1343. <where>
  1344. iac.orderstatus = '3'
  1345. <if test="ids != null and ids.size()>0 ">
  1346. AND io.userid IN
  1347. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1348. #{item}
  1349. </foreach>
  1350. </if>
  1351. </where>
  1352. GROUP BY
  1353. io.userid
  1354. ) a
  1355. </select>
  1356. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1357. SELECT
  1358. count( a.numberUserId ) as "orderManpower",
  1359. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1360. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1361. FROM
  1362. (
  1363. SELECT
  1364. count( io.userid ) AS "numberUserId",
  1365. count( iac.orderno ) AS "ordernoNumber",
  1366. SUM(IFNULL(iac.jqpremium, 0)
  1367. +IFNULL(iac.sypremium, 0)
  1368. +IFNULL(iac.jypremium, 0)
  1369. ) AS "orderAmount"
  1370. FROM
  1371. `ins_area_company` iac
  1372. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1373. <where>
  1374. iac.orderstatus = '3'
  1375. <if test="vo.ids != null and vo.ids.size()>0 ">
  1376. AND io.userid IN
  1377. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1378. #{item}
  1379. </foreach>
  1380. </if>
  1381. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1382. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1383. </if>
  1384. </where>
  1385. GROUP BY
  1386. io.userid
  1387. ) a
  1388. order by sum( a.orderAmount ) desc
  1389. </select>
  1390. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1391. SELECT
  1392. a.userId as "userId",
  1393. a.userName as "name",
  1394. a.orderNumber as "orderNumber",
  1395. a.underwritingCount as "underwritingCount",
  1396. a.qutationInsureCount as "qutationInsureCount",
  1397. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  1398. a.isFactorVerify as "isFactorVerify",
  1399. a.isNotFactorVerify as "isNotFactorVerify"
  1400. FROM
  1401. (
  1402. SELECT
  1403. io.userid as "userId",
  1404. io.username as "userName",
  1405. count( iac.orderno ) AS "orderNumber",
  1406. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  1407. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  1408. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  1409. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1410. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1411. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  1412. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  1413. FROM
  1414. `ins_area_company` iac
  1415. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1416. left join sys_user su on su.id=io.userid
  1417. <where>
  1418. <if test="vo.ids != null and vo.ids.size()>0 ">
  1419. AND io.userid IN
  1420. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1421. #{item}
  1422. </foreach>
  1423. </if>
  1424. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1425. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1426. </if>
  1427. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1428. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1429. </if>
  1430. </where>
  1431. GROUP BY
  1432. io.userid,
  1433. io.username
  1434. ) a
  1435. left join sys_user su on su.id=a.userId
  1436. </select>
  1437. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1438. SELECT
  1439. count(iac.id) as "orderNumber",
  1440. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1441. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1442. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1443. FROM
  1444. ins_area_company iac
  1445. left join ins_orders io on io.orderno = iac.orderno
  1446. left join sys_dept sd on sd.id=io.deptid
  1447. left join sys_user su on su.id=io.userid
  1448. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  1449. <where>
  1450. sd.management_source = '2'
  1451. <if test="userId !=null and userId !=''">
  1452. and io.userId =#{userId}
  1453. </if>
  1454. </where>
  1455. </select>
  1456. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1457. SELECT
  1458. agree.insurance_company_id AS companyId,
  1459. agree.insurance_company AS companyName,
  1460. agree.partner_companies_id AS parterCompanyId,
  1461. ins.namesimple AS parterCompanyName,
  1462. count(iac.orderstatus) AS orderNumber,
  1463. '-' as bigQutationCount,
  1464. '-' as bigUnderwritingCount,
  1465. '-' as bigCloseRate,
  1466. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1467. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1468. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  1469. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  1470. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  1471. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  1472. contributionRate
  1473. FROM
  1474. ins_area_company iac
  1475. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1476. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1477. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1478. WHERE
  1479. agree.id IS NOT NULL
  1480. <if test="vo.companyId != null and vo.companyId!='' ">
  1481. agree.insurance_company_id = #{vo.companyId}
  1482. </if>
  1483. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1484. agree.partner_companies_id = #{vo.parterCompanyId}
  1485. </if>
  1486. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1487. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1488. </if>
  1489. <if test="vo.provinceId != null and vo.provinceId != ''">
  1490. and io.deptid like "${vo.provinceId}%"
  1491. </if>
  1492. <if test="vo.cityId != null and vo.cityId != ''">
  1493. and io.deptid like "${vo.cityId}%"
  1494. </if>
  1495. <if test="vo.countyId != null and vo.countyId != ''">
  1496. and io.deptid like "${vo.countyId}%"
  1497. </if>
  1498. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  1499. and io.deptid like "${vo.houseId}%"
  1500. </if>
  1501. GROUP BY
  1502. agree.insurance_company_id,
  1503. agree.insurance_company,
  1504. agree.partner_companies_id,
  1505. ins.NAME
  1506. </select>
  1507. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1508. select
  1509. a.companyId as "companyId",
  1510. a.insuranceCompanyName as "insuranceCompanyName",
  1511. a.parterCompanyId as "parterCompanyId",
  1512. a.partnerCompaniesName as "partnerCompaniesName",
  1513. a.totalPremium as "totalPremium",
  1514. a.qutationInsureCount as "qutationInsureCount",
  1515. a.averagePremium as "averagePremium",
  1516. a.userNumber as "userNumber",
  1517. a.perCapitaAmount as "perCapitaAmount",
  1518. c.docking_person as "dockingPerson",
  1519. c.docking_phone as "dockingPhone",
  1520. c.agreement_type as "agreementType",
  1521. b.logo as "logo"
  1522. from (
  1523. SELECT
  1524. agree.insurance_company_id AS "companyId",
  1525. agree.insurance_company AS "insuranceCompanyName",
  1526. agree.partner_companies_id AS "parterCompanyId",
  1527. ins.namesimple AS "partnerCompaniesName",
  1528. agree.id as "agreeId",
  1529. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1530. COUNT(0 ) AS "qutationInsureCount",
  1531. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(0 ) AS "averagePremium",
  1532. COUNT(DISTINCT io.userId) AS "userNumber",
  1533. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1534. FROM
  1535. ins_area_company iac
  1536. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1537. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1538. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1539. WHERE
  1540. agree.id IS NOT NULL
  1541. and iac.orderstatus = '3'
  1542. <if test="vo.companyId != null and vo.companyId!='' ">
  1543. and agree.insurance_company_id = #{vo.companyId}
  1544. </if>
  1545. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1546. and agree.partner_companies_id = #{vo.parterCompanyId}
  1547. </if>
  1548. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1549. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1550. </if>
  1551. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  1552. and io.deptid like "${vo.provinceId}%"
  1553. </if>
  1554. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  1555. and io.deptid like "${vo.cityId}%"
  1556. </if>
  1557. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  1558. and io.deptid like "${vo.countyId}%"
  1559. </if>
  1560. <if test="vo.houseId != null and vo.houseId != ''">
  1561. and io.deptid like "${vo.houseId}%"
  1562. </if>
  1563. GROUP BY
  1564. agree.insurance_company_id,
  1565. agree.insurance_company,
  1566. agree.partner_companies_id,
  1567. agree.id
  1568. <choose>
  1569. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  1570. order by
  1571. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1572. </when>
  1573. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  1574. order by
  1575. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  1576. </when>
  1577. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  1578. order by
  1579. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1580. </when>
  1581. </choose>
  1582. ) a
  1583. left join esm_ins_company b on b.id =a.companyId
  1584. left join ptl_agreement c on c.id =a.agreeId
  1585. </select>
  1586. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1587. SELECT
  1588. agree.insurance_company_id AS "companyId",
  1589. agree.insurance_company AS "insuranceCompanyName",
  1590. agree.partner_companies_id AS "parterCompanyId",
  1591. ins.namesimple AS "partnerCompaniesName",
  1592. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1593. COUNT(0) AS "qutationInsureCount",
  1594. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0) AS "averagePremium",
  1595. COUNT(DISTINCT io.userId) AS "userNumber",
  1596. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1597. FROM
  1598. ins_area_company iac
  1599. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1600. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1601. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1602. WHERE
  1603. agree.id IS NOT NULL
  1604. <if test="vo.companyId != null and vo.companyId!='' ">
  1605. and agree.insurance_company_id = #{vo.companyId}
  1606. </if>
  1607. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1608. and agree.partner_companies_id = #{vo.parterCompanyId}
  1609. </if>
  1610. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1611. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1612. </if>
  1613. <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
  1614. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  1615. </if>
  1616. <if test="vo.provinceId != null and vo.provinceId != ''">
  1617. and io.deptid like "${vo.provinceId}%"
  1618. </if>
  1619. <if test="vo.cityId != null and vo.cityId != ''">
  1620. and io.deptid like "${vo.cityId}%"
  1621. </if>
  1622. <if test="vo.countyId != null and vo.countyId != ''">
  1623. and io.deptid like "${vo.countyId}%"
  1624. </if>
  1625. <if test="vo.houseId != null and vo.houseId != ''">
  1626. and io.deptid like "${vo.houseId}%"
  1627. </if>
  1628. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  1629. and iac.orderstatus =#{vo.quotationStatus}
  1630. </if>
  1631. GROUP BY
  1632. agree.insurance_company_id,
  1633. agree.insurance_company,
  1634. agree.partner_companies_id,
  1635. ins.namesimple
  1636. </select>
  1637. <select id="getOrderPremiumByUserIds" resultType="Double">
  1638. SELECT
  1639. IFNULL(
  1640. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  1641. 0
  1642. ) AS "totalPremium"
  1643. FROM
  1644. `ins_area_company` iac
  1645. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1646. <where>
  1647. iac.orderstatus = '3'
  1648. <if test="ids != null and ids.size()>0 ">
  1649. AND io.userid IN
  1650. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1651. #{item}
  1652. </foreach>
  1653. </if>
  1654. </where>
  1655. </select>
  1656. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1657. SELECT
  1658. count( 0 ) AS "orderNumber",
  1659. b.licenseno as "licenseno",
  1660. b.frameno as "frameno",
  1661. b.modelCode as "modelCode",
  1662. b.modelcname as "modelcname"
  1663. FROM
  1664. (
  1665. SELECT
  1666. io.orderstatus AS orderstatus,
  1667. io.frameno AS frameno,
  1668. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  1669. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  1670. ifnull(io.licenseno, '') AS licenseno
  1671. FROM
  1672. ins_orders io
  1673. LEFT JOIN sys_user su on io.userid=su.id
  1674. <where>
  1675. 1=1
  1676. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1677. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1678. </if>
  1679. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1680. AND io.licenseno =#{vo.licenseno}
  1681. </if>
  1682. <if test="vo.userId != null and vo.userId!='' ">
  1683. AND io.userid =#{vo.userId}
  1684. </if>
  1685. <if test="vo.userName != null and vo.userName!='' ">
  1686. AND su.name =#{vo.userName}
  1687. </if>
  1688. <if test="vo.mobile != null and vo.mobile!='' ">
  1689. AND su.mobile =#{vo.mobile}
  1690. </if>
  1691. <if test="vo.frameno != null and vo.frameno!='' ">
  1692. AND io.frameno =#{vo.frameno}
  1693. </if>
  1694. <if test="vo.deptId != null and vo.deptId!='' ">
  1695. and io.deptid like concat('%', #{vo.deptId}, '%')
  1696. </if>
  1697. <if test="vo.year != null and vo.year!='' ">
  1698. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  1699. </if>
  1700. </where>
  1701. ) b
  1702. GROUP BY
  1703. b.licenseno,
  1704. b.frameno,
  1705. b.modelCode,
  1706. b.modelcname
  1707. </select>
  1708. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1709. SELECT
  1710. io.licenseno AS "licenseno",
  1711. io.frameno AS "frameno",
  1712. io.orderstatus as "orderstatus",
  1713. io.orderno as "orderno"
  1714. FROM
  1715. ins_orders io
  1716. LEFT JOIN sys_user su on io.userid=su.id
  1717. <where>
  1718. io.licenseno is not null
  1719. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1720. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1721. </if>
  1722. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1723. AND io.licenseno =#{vo.licenseno}
  1724. </if>
  1725. <if test="vo.userId != null and vo.userId!='' ">
  1726. AND io.userId =#{vo.userId}
  1727. </if>
  1728. <if test="vo.userName != null and vo.userName!='' ">
  1729. AND su.name =#{vo.userName}
  1730. </if>
  1731. <if test="vo.mobile != null and vo.mobile!='' ">
  1732. AND su.mobile =#{vo.mobile}
  1733. </if>
  1734. <if test="vo.frameno != null and vo.frameno!='' ">
  1735. AND su.frameno =#{vo.frameno}
  1736. </if>
  1737. <if test="vo.deptId != null and vo.deptId!='' ">
  1738. and io.deptid like concat('%', #{vo.deptId}, '%')
  1739. </if>
  1740. </where>
  1741. </select>
  1742. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1743. select sum(a.orderNumber) as "orderNumber",
  1744. count(a.licenseno) as "b.frameno"
  1745. from (
  1746. SELECT
  1747. count( 0 ) AS "orderNumber",
  1748. b.licenseno as "licenseno",
  1749. b.frameno as "frameno"
  1750. FROM
  1751. (
  1752. SELECT
  1753. io.orderstatus AS orderstatus,
  1754. io.frameno AS frameno,
  1755. ifnull(io.licenseno, '') AS licenseno
  1756. FROM
  1757. ins_orders io
  1758. LEFT JOIN sys_user su on io.userid=su.id
  1759. <where>
  1760. 1=1
  1761. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1762. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1763. </if>
  1764. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1765. AND io.licenseno =#{vo.licenseno}
  1766. </if>
  1767. <if test="vo.userId != null and vo.userId!='' ">
  1768. AND io.userid =#{vo.userId}
  1769. </if>
  1770. <if test="vo.userName != null and vo.userName!='' ">
  1771. AND su.name =#{vo.userName}
  1772. </if>
  1773. <if test="vo.mobile != null and vo.mobile!='' ">
  1774. AND su.mobile =#{vo.mobile}
  1775. </if>
  1776. <if test="vo.frameno != null and vo.frameno!='' ">
  1777. AND io.frameno =#{vo.frameno}
  1778. </if>
  1779. <if test="vo.deptId != null and vo.deptId!='' ">
  1780. and io.deptid like concat('%', #{vo.deptId}, '%')
  1781. </if>
  1782. </where>
  1783. ) b
  1784. GROUP BY
  1785. b.licenseno,
  1786. b.frameno
  1787. ) a
  1788. </select>
  1789. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1790. SELECT
  1791. count( io.orderno ) AS "orderNumber",
  1792. 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"
  1793. FROM
  1794. ins_orders io
  1795. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1796. LEFT JOIN sys_user su ON io.userid = su.id
  1797. <where>
  1798. 1=1
  1799. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1800. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1801. </if>
  1802. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1803. AND io.licenseno =#{vo.licenseno}
  1804. </if>
  1805. <if test="vo.userId != null and vo.userId!='' ">
  1806. AND io.userid =#{vo.userId}
  1807. </if>
  1808. <if test="vo.userName != null and vo.userName!='' ">
  1809. AND su.name =#{vo.userName}
  1810. </if>
  1811. <if test="vo.mobile != null and vo.mobile!='' ">
  1812. AND su.mobile =#{vo.mobile}
  1813. </if>
  1814. <if test="vo.frameno != null and vo.frameno!='' ">
  1815. AND su.frameno =#{vo.frameno}
  1816. </if>
  1817. <if test="vo.deptId != null and vo.deptId!='' ">
  1818. and io.deptid like concat('%', #{vo.deptId}, '%')
  1819. </if>
  1820. </where>
  1821. </select>
  1822. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1823. SELECT
  1824. count(iac.id) as "orderNumber",
  1825. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1826. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1827. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1828. FROM
  1829. ins_area_company iac
  1830. left join ins_orders io on io.orderno = iac.orderno
  1831. <where>
  1832. <if test="ids != null and ids.size()>0 ">
  1833. AND io.userid IN
  1834. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1835. #{item}
  1836. </foreach>
  1837. </if>
  1838. <if test="month != null and month!='' ">
  1839. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  1840. </if>
  1841. </where>
  1842. </select>
  1843. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1844. select
  1845. iac.inscompany as "namesimple"
  1846. from
  1847. ins_area_company iac
  1848. <where>
  1849. 1=1
  1850. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  1851. AND iac.orderstatus =#{vo.orderstatus}
  1852. </if>
  1853. <if test="vo.orderno !=null and vo.orderno !='' ">
  1854. AND iac.orderno =#{vo.orderno}
  1855. </if>
  1856. </where>
  1857. </select>
  1858. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  1859. select a.*,(select name from sys_user where id =a.userId) as "userName"
  1860. from (
  1861. SELECT
  1862. sd.NAME AS "deptName",
  1863. io.userid AS "userId",
  1864. sd.parent_id as "deptId",
  1865. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1866. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1867. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1868. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1869. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
  1870. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
  1871. ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
  1872. (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
  1873. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  1874. FROM
  1875. ins_area_company iac
  1876. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1877. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1878. <where>
  1879. 1=1
  1880. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1881. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1882. </if>
  1883. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1884. and io.deptid like "${taskStatisticsVo.cityId}%"
  1885. </if>
  1886. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1887. and io.deptid like "${taskStatisticsVo.countyId}%"
  1888. </if>
  1889. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1890. and io.deptid like "${taskStatisticsVo.houseId}%"
  1891. </if>
  1892. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1893. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1894. </if>
  1895. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1896. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1897. </if>
  1898. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1899. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1900. </if>
  1901. <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
  1902. and sd.management_source=#{taskStatisticsVo.managementSource}
  1903. </if>
  1904. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1905. <choose>
  1906. <when test="taskStatisticsVo.days =='1'">
  1907. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1908. </when>
  1909. <when test="taskStatisticsVo.days =='7'">
  1910. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1911. </when>
  1912. <when test="taskStatisticsVo.days =='30'">
  1913. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1914. </when>
  1915. </choose>
  1916. </if>
  1917. </where>
  1918. GROUP BY
  1919. io.userid,
  1920. sd.NAME,
  1921. sd.id
  1922. ) a
  1923. </select>
  1924. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  1925. SELECT
  1926. a.*,
  1927. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1928. FROM
  1929. (
  1930. SELECT
  1931. pa.insurance_company_id,
  1932. pa.partner_companies_id,
  1933. pa.insurance_company AS "insuranceCompanyName",
  1934. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1935. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1936. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1937. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1938. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1939. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1940. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1941. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1942. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1943. FROM
  1944. ins_area_company iac
  1945. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1946. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1947. <where>
  1948. pa.insurance_company_id IS NOT NULL
  1949. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1950. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1951. </if>
  1952. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1953. and io.deptid like "${taskStatisticsVo.cityId}%"
  1954. </if>
  1955. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1956. and io.deptid like "${taskStatisticsVo.countyId}%"
  1957. </if>
  1958. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1959. and io.deptid like "${taskStatisticsVo.houseId}%"
  1960. </if>
  1961. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1962. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1963. </if>
  1964. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1965. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1966. </if>
  1967. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1968. AND iac.company_id =#{taskStatisticsVo.companyId}
  1969. </if>
  1970. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1971. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1972. </if>
  1973. </where>
  1974. GROUP BY
  1975. pa.insurance_company_id,
  1976. pa.partner_companies_id,
  1977. pa.insurance_company
  1978. ) a
  1979. </select>
  1980. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1981. select count(0) as "orderNumber",
  1982. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  1983. from ins_area_company iac
  1984. left join ins_orders io on io.orderno = iac.orderno
  1985. <where>
  1986. 1=1
  1987. and iac.orderstatus ='3'
  1988. and io.orderstatus ='3'
  1989. <if test="vo.licenseno !=null and vo.licenseno!=''">
  1990. AND io.licenseno =#{vo.licenseno}
  1991. </if>
  1992. <if test="vo.frameno !=null and vo.frameno!=''">
  1993. AND io.frameno =#{vo.frameno}
  1994. </if>
  1995. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1996. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1997. </if>
  1998. <if test="vo.year != null and vo.year!='' ">
  1999. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2000. </if>
  2001. </where>
  2002. </select>
  2003. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2004. select
  2005. io.userid as userId,
  2006. io.username as userName,
  2007. io.licenseno as licenseno,
  2008. iac.id as companyId,
  2009. iac.jqpremium as jqpremium,
  2010. iac.sypremium as sypremium,
  2011. iac.jypremium as jypremium,
  2012. iac.createtime as createtime,
  2013. iac.orderstatus as orderstatus
  2014. from ins_area_company iac
  2015. left join ins_orders io on io.orderno = iac.orderno
  2016. <where>
  2017. iac.orderstatus=3
  2018. <if test="dto.userId !=null and dto.userId !=''">
  2019. and io.userid = #{dto.userId}
  2020. </if>
  2021. <if test="dto.deptId !=null and dto.deptId !=''">
  2022. and io.deptid = #{dto.deptId}
  2023. </if>
  2024. <if test="dto.startTime !=null and dto.startTime !=''">
  2025. and io.createtime >= #{dto.startTime}
  2026. </if>
  2027. </where>
  2028. ORDER BY iac.createtime
  2029. </select>
  2030. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2031. select a.*,
  2032. IFNULL(b.orderNumber,0)/IFNULL(a.orderNumber ,0)
  2033. from (
  2034. SELECT
  2035. count( 0 ) AS "orderNumber",
  2036. b.licenseno as "licenseno",
  2037. b.modelCode as "modelCode",
  2038. b.modelcname as "modelcname",
  2039. b.frameno as "frameno"
  2040. FROM
  2041. (
  2042. SELECT
  2043. io.orderstatus AS orderstatus,
  2044. io.frameno AS frameno,
  2045. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2046. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2047. ifnull(io.licenseno, '') AS licenseno
  2048. FROM
  2049. ins_orders io
  2050. LEFT JOIN sys_user su on io.userid=su.id
  2051. <where>
  2052. 1=1
  2053. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2054. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2055. </if>
  2056. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2057. AND io.licenseno =#{vo.licenseno}
  2058. </if>
  2059. <if test="vo.userId != null and vo.userId!='' ">
  2060. AND io.userid =#{vo.userId}
  2061. </if>
  2062. <if test="vo.userName != null and vo.userName!='' ">
  2063. AND su.name =#{vo.userName}
  2064. </if>
  2065. <if test="vo.mobile != null and vo.mobile!='' ">
  2066. AND su.mobile =#{vo.mobile}
  2067. </if>
  2068. <if test="vo.frameno != null and vo.frameno!='' ">
  2069. AND io.frameno =#{vo.frameno}
  2070. </if>
  2071. <if test="vo.deptId != null and vo.deptId!='' ">
  2072. and io.deptid like concat('%', #{vo.deptId}, '%')
  2073. </if>
  2074. <if test="vo.year != null and vo.year!='' ">
  2075. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2076. </if>
  2077. </where>
  2078. ) b
  2079. GROUP BY
  2080. b.licenseno,
  2081. b.frameno,
  2082. b.modelCode,
  2083. b.modelcname
  2084. ) a
  2085. left join (
  2086. select count(0) as "orderNumber",
  2087. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple",
  2088. io.licenseno as "licenseno"
  2089. from ins_area_company iac
  2090. left join ins_orders io on io.orderno = iac.orderno
  2091. <where>
  2092. 1=1
  2093. and iac.orderstatus ='3'
  2094. and io.orderstatus ='3'
  2095. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2096. AND io.licenseno =#{vo.licenseno}
  2097. </if>
  2098. <if test="vo.frameno !=null and vo.frameno!=''">
  2099. AND io.frameno =#{vo.frameno}
  2100. </if>
  2101. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2102. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2103. </if>
  2104. <if test="vo.year != null and vo.year!='' ">
  2105. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2106. </if>
  2107. </where>
  2108. group by
  2109. io.licenseno
  2110. ) b on b.licenseno =a.licenseno
  2111. </select>
  2112. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2113. select
  2114. iac.id,
  2115. iac.orderno,
  2116. iac.agreement_id,
  2117. iac.jqpremium,
  2118. iac.sypremium,
  2119. iac.jypremium,
  2120. iac.taxamount,
  2121. iac.sumpremium,
  2122. io.licenseno,
  2123. iac.createtime,
  2124. su.name as auditname
  2125. FROM
  2126. ins_area_company iac
  2127. LEFT JOIN
  2128. ins_orders io on iac.orderno = io.orderno
  2129. left join ptl_agreement agree on iac.agreement_id =agree.id
  2130. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  2131. left join sys_user su on su.id= ifa.audituser
  2132. WHERE
  2133. iac.operator_id = #{userId}
  2134. AND
  2135. iac.orderstatus = 3
  2136. and agree.is_external =1
  2137. and auditstatus =1
  2138. <if test="vo.id != null and vo.id!='' ">
  2139. and iac.id = #{vo.id}
  2140. </if>
  2141. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2142. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  2143. </if>
  2144. </select>
  2145. </mapper>