InsAreaCompanyMapper.xml 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849
  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. io.entry_status
  174. FROM
  175. ins_fee_audit ifa
  176. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  177. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  178. AND iac.orderstatus = 3
  179. LEFT JOIN sys_user su ON su.id = io.userid
  180. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  181. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  182. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  183. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  184. WHERE
  185. iac.id = ifa.ins_order_no
  186. AND iac.orderstatus = 3
  187. <if test="params.auditStatus != null and params.auditStatus != ''">
  188. and ifa.auditstatus = #{params.auditStatus}
  189. </if>
  190. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  191. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  192. #{params.quoteEndDateStr}
  193. </if>
  194. <if test="params.orderNo != null and params.orderNo != ''">
  195. AND iac.id= #{params.orderNo}
  196. </if>
  197. <if test="params.licenseNo != null and params.licenseNo != ''">
  198. AND io.licenseno = #{params.licenseNo}
  199. </if>
  200. <if test="params.frameNo != null and params.frameNo != ''">
  201. AND io.frameno = #{params.frameNo}
  202. </if>
  203. <if test="params.insuredName != null and params.insuredName != ''">
  204. AND io.insuredname = #{params.insuredName}
  205. </if>
  206. <if test="params.companyId != null and params.companyId != ''">
  207. AND io.company_id = #{params.companyId}
  208. </if>
  209. <if test="params.engineNo != null and params.engineNo != ''">
  210. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  211. </if>
  212. <if test="params.riskCode != null and params.riskCode != ''">
  213. and iac.product = #{params.riskCode}
  214. </if>
  215. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  216. and ((
  217. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  218. AND #{params.attachEndDateStr}
  219. )
  220. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  221. #{params.attachEndDateStr} )
  222. )
  223. </if>
  224. <if test="params.provinceId != null and params.provinceId != ''">
  225. and io.deptid like "${params.provinceId}%"
  226. </if>
  227. <if test="params.problemOrder != null and params.problemOrder != ''">
  228. and iac.problem_order like "${params.problemOrder}%"
  229. </if>
  230. <if test="params.cityId != null and params.cityId != ''">
  231. and io.deptid like "${params.cityId}%"
  232. </if>
  233. <if test="params.countyId != null and params.countyId != ''">
  234. and io.deptid like "${params.countyId}%"
  235. </if>
  236. <if test="params.houseId != null and params.houseId != ''">
  237. and io.deptid like "${params.houseId}%"
  238. </if>
  239. <if test="params.operatorId != null and params.operatorId != ''">
  240. and io.userid = #{params.operatorId}
  241. </if>
  242. <if test="params.operatorName != null and params.operatorName != ''">
  243. and io.username = #{params.operatorName}
  244. </if>
  245. <if test="params.auditId != null and params.auditId != ''">
  246. and iac.new_operator_id = #{params.auditId}
  247. </if>
  248. <if test="params.agreeId != null and params.agreeId != ''">
  249. and iac.agreement_id = #{params.agreeId}
  250. </if>
  251. <if test="params.managementSource != null and params.managementSource != ''">
  252. and sd.management_source = #{params.managementSource}
  253. </if>
  254. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  255. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  256. #{params.signEndDateStr}
  257. </if>
  258. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  259. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  260. </if>
  261. <if test="params.isExternal != null and params.isExternal != ''">
  262. and io.is_external = #{params.isExternal}
  263. </if>
  264. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  265. and iac.jqpolicyno = #{params.jqPolicyNo}
  266. </if>
  267. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  268. and iac.sypolicyno = #{params.syPolicyNo}
  269. </if>
  270. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  271. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  272. </if>
  273. order by iac.createtime desc
  274. </select>
  275. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  276. SELECT
  277. io.*,
  278. sd.management_source
  279. FROM
  280. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  281. WHERE
  282. orderno IN (
  283. SELECT
  284. orderno
  285. FROM
  286. ins_area_company
  287. WHERE
  288. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  289. AND orderstatus = 3
  290. )
  291. AND
  292. io.orderstatus= 3
  293. <if test="orderNo != null and orderNo != ''">
  294. AND orderno = #{orderNo}
  295. </if>
  296. <if test="licenseNo != null and licenseNo != ''">
  297. AND licenseno = #{licenseNo}
  298. </if>
  299. <if test="frameNo != null and frameNo != ''">
  300. AND frameno = #{frameNo}
  301. </if>
  302. <if test="userId != null and userId != ''">
  303. AND userid = #{userId}
  304. </if>
  305. <if test="insuredname != null and insuredname != ''">
  306. AND insuredname = #{insuredname}
  307. </if>
  308. <if test="startDateStr != null and startDateStr != ''">
  309. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  310. </if>
  311. </select>
  312. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  313. SELECT
  314. sum(a.first_detail_premiums) as "willFirstPremiums"
  315. FROM
  316. ins_fee_order_new a
  317. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  318. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  319. WHERE
  320. iff.auditstatus=0
  321. AND iac.orderstatus =3
  322. <if test="firstUserId != null and firstUserId != ''">
  323. AND a.first_level_user_id = #{firstUserId}
  324. </if>
  325. <if test="secondUserId != null and secondUserId != ''">
  326. AND a.two_level_user_id = #{secondUserId}
  327. </if>
  328. <if test="thirdUserId != null and thirdUserId != ''">
  329. AND a.three_level_user_id = #{thirdUserId}
  330. </if>
  331. <if test="id != null and id != ''">
  332. AND a.id = #{id}
  333. </if>
  334. </select>
  335. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  336. SELECT
  337. sum( fee.p ) as "willFirstPremiums"
  338. FROM
  339. (
  340. SELECT
  341. sum( a.first_detail_premiums ) AS p
  342. FROM
  343. ins_fee_order_new a
  344. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  345. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  346. <where>
  347. iff.auditstatus=0
  348. and iac.orderstatus = '3'
  349. <if test="userId!=null and userId!= ''">
  350. AND a.first_level_user_id = #{userId}
  351. </if>
  352. <if test="id != null and id!=''">
  353. AND a.id =#{id}
  354. </if>
  355. </where>
  356. UNION
  357. SELECT
  358. sum( a.third_detail_premiums ) AS p
  359. FROM
  360. ins_fee_order_new a
  361. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  362. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  363. <where>
  364. iff.auditstatus=0
  365. and iac.orderstatus = '3'
  366. <if test="userId!=null and userId!= ''">
  367. AND a.three_level_user_id = #{userId}
  368. </if>
  369. <if test="id != null and id!=''">
  370. AND a.id =#{id}
  371. </if>
  372. </where>
  373. UNION
  374. SELECT
  375. sum( a.second_detail_premiums ) AS p
  376. FROM
  377. ins_fee_order_new a
  378. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  379. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  380. <where>
  381. iff.auditstatus=0
  382. and iac.orderstatus = '3'
  383. <if test="userId!=null and userId!= ''">
  384. AND a.two_level_user_id = #{userId}
  385. </if>
  386. <if test="id != null and id!=''">
  387. AND a.id =#{id}
  388. </if>
  389. </where>
  390. ) AS fee
  391. </select>
  392. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  393. SELECT
  394. sum(a.third_detail_premiums) as "willThreePremiums"
  395. FROM
  396. ins_fee_order_new a
  397. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  398. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  399. WHERE
  400. iff.auditstatus=0
  401. AND iac.orderstatus =3
  402. <if test="firstUserId != null and firstUserId != ''">
  403. AND a.first_level_user_id = #{firstUserId}
  404. </if>
  405. <if test="secondUserId != null and secondUserId != ''">
  406. AND a.two_level_user_id = #{secondUserId}
  407. </if>
  408. <if test="thirdUserId != null and thirdUserId != ''">
  409. AND a.three_level_user_id = #{thirdUserId}
  410. </if>
  411. <if test="id != null and id != ''">
  412. AND a.id = #{id}
  413. </if>
  414. </select>
  415. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  416. SELECT
  417. io.*,
  418. sd.management_source,
  419. su2.name AS auditUser,
  420. ifa.audittime as auditTime
  421. FROM
  422. ins_orders io
  423. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  424. LEFT JOIN sys_user su ON su.id = io.userid
  425. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  426. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  427. WHERE
  428. io.orderno IN (
  429. SELECT
  430. orderno
  431. FROM
  432. ins_area_company
  433. WHERE
  434. id IN (
  435. SELECT
  436. ifon.ins_order_no
  437. FROM
  438. ins_fee_order_new ifon
  439. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  440. WHERE
  441. ifa.auditstatus = #{params.auditStatus}
  442. )
  443. )
  444. AND orderstatus = 3
  445. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  446. <!-- AND orderno = #{params.orderNo}-->
  447. <!-- </if>-->
  448. <if test="params.licenseNo != null and params.licenseNo != ''">
  449. AND licenseno = #{params.licenseNo}
  450. </if>
  451. <if test="params.frameNo != null and params.frameNo != ''">
  452. AND frameno = #{params.frameNo}
  453. </if>
  454. <if test="params.insuredName != null and params.insuredName != ''">
  455. AND insuredname = #{params.insuredName}
  456. </if>
  457. <if test="params.companyId != null and params.companyId != ''">
  458. AND company_id = #{params.companyId}
  459. </if>
  460. <if test="params.startDateStr != null and params.startDateStr != ''">
  461. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  462. </if>
  463. </select>
  464. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  465. -- 查询订单信息
  466. SELECT
  467. iac.*
  468. FROM
  469. ins_area_company iac
  470. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  471. WHERE
  472. 1=1
  473. <if test="dateStr != null and dateStr != ''">
  474. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  475. </if>
  476. </select>
  477. <select id="selectListById" resultMap="BaseResultMap">
  478. SELECT
  479. iac.*
  480. FROM
  481. ins_area_company iac
  482. WHERE
  483. 1=1
  484. <if test="id != null and id != ''">
  485. AND iac.id =#{id}
  486. </if>
  487. </select>
  488. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  489. SELECT
  490. sum( fee.p ) as "willFirstPremiums"
  491. FROM
  492. (
  493. SELECT
  494. sum( a.first_detail_premiums ) AS p
  495. FROM
  496. ins_fee_order_new a
  497. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  498. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  499. <where>
  500. <choose>
  501. <when test='type == "1"'>
  502. iff.auditstatus=0
  503. </when>
  504. <otherwise>
  505. iff.auditstatus=1
  506. </otherwise>
  507. </choose>
  508. and iac.orderstatus = '3'
  509. <if test="userId!=null and userId!= ''">
  510. AND a.first_level_user_id = #{userId}
  511. </if>
  512. <if test="id != null and id!=''">
  513. AND a.id =#{id}
  514. </if>
  515. </where>
  516. UNION
  517. SELECT
  518. sum( a.third_detail_premiums ) AS p
  519. FROM
  520. ins_fee_order_new a
  521. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  522. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  523. <where>
  524. <choose>
  525. <when test='type == "1"'>
  526. iff.auditstatus=0
  527. </when>
  528. <otherwise>
  529. iff.auditstatus=1
  530. </otherwise>
  531. </choose>
  532. and iac.orderstatus = '3'
  533. <if test="userId!=null and userId!= ''">
  534. AND a.three_level_user_id = #{userId}
  535. </if>
  536. <if test="id != null and id!=''">
  537. AND a.id =#{id}
  538. </if>
  539. </where>
  540. UNION
  541. SELECT
  542. sum( a.second_detail_premiums ) AS p
  543. FROM
  544. ins_fee_order_new a
  545. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  546. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  547. <where>
  548. <choose>
  549. <when test='type == "1"'>
  550. iff.auditstatus=0
  551. </when>
  552. <otherwise>
  553. iff.auditstatus=1
  554. </otherwise>
  555. </choose>
  556. and iac.orderstatus = '3'
  557. <if test="userId!=null and userId!= ''">
  558. AND a.two_level_user_id = #{userId}
  559. </if>
  560. <if test="id != null and id!=''">
  561. AND a.id =#{id}
  562. </if>
  563. </where>
  564. ) AS fee
  565. </select>
  566. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  567. SELECT
  568. iac.id as subOrderId,
  569. iac.signing_time as signingTime,
  570. iac.jqpremium as jqpremium,
  571. iac.sypremium as sypremium,
  572. iac.jypremium as jypremium,
  573. io.licenseno as licenseno,
  574. io.userid as userId
  575. FROM
  576. ins_area_company iac
  577. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  578. WHERE
  579. iac.id=#{subOrderId}
  580. </select>
  581. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  582. SELECT
  583. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  584. sum(jqpremium) jqpremium,
  585. sum(sypremium) sypremium,
  586. sum(sumpremium) sumpremium
  587. FROM
  588. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  589. WHERE
  590. iac.orderstatus = 3 and
  591. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  592. and io.userid=#{userId}
  593. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  594. </select>
  595. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  596. SELECT
  597. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  598. sum(jqpremium) jqpremium,
  599. sum(sypremium) sypremium,
  600. sum(sumpremium) sumpremium
  601. FROM
  602. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  603. WHERE
  604. iac.orderstatus = 3 and
  605. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  606. and io.userid=#{userId}
  607. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  608. </select>
  609. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  610. SELECT
  611. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  612. reportDate,
  613. sum( jqpremium ) jqpremium,
  614. sum( sypremium ) sypremium,
  615. sum( sumpremium ) sumpremium
  616. FROM
  617. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  618. WHERE
  619. iac.orderstatus = 3 and
  620. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  621. and io.userid=#{userId}
  622. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  623. </select>
  624. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  625. SELECT
  626. ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
  627. count( 0 ) as sumCount
  628. FROM
  629. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  630. WHERE
  631. iac.orderstatus = 3
  632. and io.userid=#{userId}
  633. AND YEAR (iac.createtime) = #{year}
  634. </select>
  635. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  636. select
  637. iac.id,
  638. iac.orderno,
  639. iac.agreement_id,
  640. iac.jqpremium,
  641. iac.sypremium,
  642. iac.jypremium,
  643. iac.taxamount,
  644. iac.sumpremium,
  645. io.licenseno,
  646. ifa.audittime,
  647. ifa.audituser as auditname,
  648. ifa.rejectinfo,
  649. "1" as orderExternalStatus
  650. FROM
  651. ins_fee_audit ifa
  652. LEFT JOIN
  653. ins_area_company iac on iac.id = ifa.ins_order_no
  654. LEFT JOIN
  655. ins_orders io on iac.orderno = io.orderno
  656. left join
  657. sys_user su on su.id= ifa.audituser
  658. WHERE
  659. iac.operator_id = #{userId}
  660. AND
  661. ifa.auditstatus = 2
  662. <if test="vo.id != null and vo.id!=''">
  663. and iac.id = #{vo.id}
  664. </if>
  665. <if test="vo.licenseno != null and vo.licenseno!='' ">
  666. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  667. </if>
  668. <if test="vo.auditname != null and vo.auditname!='' ">
  669. and su.name like CONCAT('%', #{vo.auditname}, '%')
  670. </if>
  671. </select>
  672. <select id="queryBusinessDataPage"
  673. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  674. SELECT
  675. <if test="flag != null and flag!='' and flag='1'">
  676. o.userid as userId,
  677. o.username as userName,
  678. </if>
  679. sum( iac.sumpremium ) as signeSumPremiumAmount,
  680. sum( iac.jqpremium ) as jqPremiumAmount,
  681. sum( iac.sypremium ) as syPremiumAmount,
  682. sum( iac.taxamount ) as taxAmount,
  683. sum( ion.no_premium ) as fcFeeAmount
  684. FROM
  685. ins_area_company iac
  686. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  687. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  688. where iac.orderstatus = 3 and ion.id is not null
  689. <if test="userList != null and userList.size()>0 ">
  690. and o.userid IN
  691. <foreach item="item" collection="userList" open="(" separator="," close=")">
  692. #{item}
  693. </foreach>
  694. </if>
  695. <if test="flag != null and flag!='' and flag='1'">
  696. group by o.userid,o.username
  697. </if>
  698. </select>
  699. <select id="queryQuotationSubOrderCountDataPage"
  700. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  701. SELECT
  702. <if test="flag != null and flag!='' and flag='1'">
  703. o.userid as userId,
  704. o.username as userName,
  705. </if>
  706. iac.orderstatus as orderStatus
  707. FROM
  708. ins_area_company iac
  709. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  710. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  711. <if test="userList != null and userList.size()>0 ">
  712. and o.userid IN
  713. <foreach item="item" collection="userList" open="(" separator="," close=")">
  714. #{item}
  715. </foreach>
  716. </if>
  717. <if test="flag != null and flag!='' and flag='1'">
  718. group by o.userid,o.username,iac.orderstatus
  719. </if>
  720. </select>
  721. <select id="queryQuotationOrderCountDataPage"
  722. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  723. SELECT
  724. a.userId as userId,
  725. a.userName as userName,
  726. b.qutationCount AS insOrderQutationCount,
  727. b.qutationInsureCount as insOrderQutationInsureCount,
  728. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  729. a.qutationCount as subOrderQutationCount,
  730. a.underwritingCount as subOrderUnderwritingCount,
  731. a.qutationInsureCount as subOrderQutationInsureCount,
  732. a.passRate as subOrderCloseRate,
  733. a.closeRate as subOrderPassRate,
  734. a.contributionRate as subOrderContributionRate
  735. FROM
  736. (
  737. SELECT
  738. inso.userid AS userId,
  739. inso.username AS userName,
  740. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  741. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  742. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  743. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  744. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  745. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
  746. FROM
  747. ins_area_company iac
  748. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  749. <where>
  750. <if test="userList != null and userList.size()>0 ">
  751. and o.userid IN
  752. <foreach item="item" collection="userList" open="(" separator="," close=")">
  753. #{item}
  754. </foreach>
  755. </if>
  756. </where>
  757. GROUP BY
  758. inso.userid,
  759. inso.username
  760. ) a
  761. LEFT JOIN (
  762. SELECT
  763. inso.userid AS userId,
  764. inso.username AS userName,
  765. count( inso.orderstatus ) AS qutationCount,
  766. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  767. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  768. FROM
  769. ins_orders inso
  770. <where>
  771. <if test="userList != null and userList.size()>0 ">
  772. and o.userid IN
  773. <foreach item="item" collection="userList" open="(" separator="," close=")">
  774. #{item}
  775. </foreach>
  776. </if>
  777. </where>
  778. GROUP BY
  779. inso.userid,
  780. inso.username
  781. ) b ON a.userId = b.userId
  782. </select>
  783. <select id="queryCompanyPremiumDataPage"
  784. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  785. SELECT
  786. agree.insurance_company_id AS companyId,
  787. agree.insurance_company AS companyName,
  788. agree.partner_companies_id AS parterCompanyId,
  789. ins.NAME AS parterCompanyName,
  790. sum( iac.sumpremium ) AS signeSumPremiumAmount
  791. FROM
  792. ins_area_company iac
  793. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  794. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  795. WHERE
  796. iac.orderstatus = 3
  797. and
  798. agree.id is not null
  799. <if test="vo.companyId != null and vo.companyId!='' ">
  800. agree.insurance_company_id = #{vo.companyId}
  801. </if>
  802. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  803. agree.insurance_company_id = #{vo.parterCompanyId}
  804. </if>
  805. GROUP BY
  806. agree.insurance_company_id,
  807. agree.insurance_company,
  808. agree.partner_companies_id,
  809. ins.NAME
  810. </select>
  811. <select id="queryCompanyQutationCountDataPage"
  812. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  813. SELECT
  814. a.* ,
  815. (select ins.namesimple from esm_ins_company
  816. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  817. FROM
  818. (
  819. SELECT
  820. count(agree.partner_companies_id) as "orderSuccessNumber",
  821. agree.insurance_company AS companyName,
  822. agree.partner_companies_id AS parterCompanyId,
  823. iac.company_id as "companId",
  824. count( iac.orderstatus ) AS qutationCount,
  825. count( iac.id ) AS orderSuccessNumberRate,
  826. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  827. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  828. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  829. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  830. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
  831. COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
  832. FROM
  833. ins_area_company iac
  834. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  835. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  836. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  837. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  838. WHERE
  839. agree.id IS NOT NULL
  840. <if test="vo.companyId != null and vo.companyId!='' ">
  841. AND agree.insurance_company_id = #{vo.companyId}
  842. </if>
  843. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  844. AND agree.partner_companies_id = #{vo.parterCompanyId}
  845. </if>
  846. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  847. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  848. </if>
  849. <if test="vo.managementSource != null and vo.managementSource!=''">
  850. AND sd.management_source =#{vo.managementSource}
  851. </if>
  852. GROUP BY
  853. agree.insurance_company,
  854. iac.company_id,
  855. agree.partner_companies_id
  856. ) a
  857. </select>
  858. <select id="getInsAreaCompanyError"
  859. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  860. SELECT
  861. count(iace.id) as "areaCompanyErrNumber"
  862. FROM
  863. ins_area_company_error iace
  864. LEFT JOIN ins_orders io ON iace.orderno = io.orderno
  865. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  866. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  867. WHERE
  868. agree.id IS NOT NULL
  869. <if test="vo.companyId != null and vo.companyId!='' ">
  870. AND agree.insurance_company_id = #{vo.companyId}
  871. </if>
  872. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  873. AND agree.partner_companies_id = #{vo.parterCompanyId}
  874. </if>
  875. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  876. AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  877. </if>
  878. <if test="vo.managementSource != null and vo.managementSource!=''">
  879. AND sd.management_source =#{vo.managementSource}
  880. </if>
  881. </select>
  882. <select id="queryCompanyQutationCountDataPageTotal"
  883. resultType="java.lang.Long">
  884. SELECT
  885. count(0)
  886. FROM
  887. (
  888. SELECT
  889. agree.partner_companies_id
  890. FROM
  891. ins_area_company iac
  892. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  893. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  894. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  895. WHERE
  896. agree.id IS NOT NULL
  897. <if test="vo.companyId != null and vo.companyId!='' ">
  898. AND agree.insurance_company_id = #{vo.companyId}
  899. </if>
  900. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  901. AND agree.partner_companies_id = #{vo.parterCompanyId}
  902. </if>
  903. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  904. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  905. </if>
  906. <if test="vo.managementSource != null and vo.managementSource!=''">
  907. AND sd.management_source =#{vo.managementSource}
  908. </if>
  909. GROUP BY
  910. agree.partner_companies_id
  911. ) a
  912. </select>
  913. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  914. select
  915. iac.id,
  916. iac.orderno,
  917. iac.agreement_id,
  918. iac.jqpremium,
  919. iac.sypremium,
  920. iac.jypremium,
  921. iac.taxamount,
  922. iac.sumpremium,
  923. io.licenseno,
  924. iac.createtime,
  925. "0" as orderExternalStatus
  926. FROM
  927. ins_area_company iac
  928. LEFT JOIN
  929. ins_orders io on iac.orderno = io.orderno
  930. left join ptl_agreement agree on iac.agreement_id =agree.id
  931. WHERE
  932. iac.operator_id = #{userId}
  933. AND
  934. iac.orderstatus = 0
  935. and agree.is_external =1
  936. <if test="vo.id != null and vo.id!='' ">
  937. and iac.id = #{vo.id}
  938. </if>
  939. <if test="vo.licenseno != null and vo.licenseno!='' ">
  940. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  941. </if>
  942. </select>
  943. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  944. select a.*,(select name from sys_user where id =a.userId) as "userName"
  945. from (
  946. SELECT
  947. sd.NAME AS "deptName",
  948. io.userid AS "userId",
  949. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  950. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  951. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  952. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  953. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  954. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  955. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  956. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  957. COUNT( CASE WHEN ifa.auditstatus = '0' THEN 1 END ) AS "auditOrder"
  958. FROM
  959. ins_area_company iac
  960. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  961. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  962. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  963. <where>
  964. sd.management_source = '1'
  965. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  966. and io.deptid like "${taskStatisticsVo.provinceId}%"
  967. </if>
  968. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  969. and io.deptid like "${taskStatisticsVo.cityId}%"
  970. </if>
  971. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  972. and io.deptid like "${taskStatisticsVo.countyId}%"
  973. </if>
  974. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  975. and io.deptid like "${taskStatisticsVo.houseId}%"
  976. </if>
  977. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  978. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  979. </if>
  980. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  981. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  982. </if>
  983. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  984. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  985. </if>
  986. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  987. <choose>
  988. <when test="taskStatisticsVo.days =='1'">
  989. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  990. </when>
  991. <when test="taskStatisticsVo.days =='7'">
  992. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  993. </when>
  994. <when test="taskStatisticsVo.days =='30'">
  995. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  996. </when>
  997. </choose>
  998. </if>
  999. </where>
  1000. GROUP BY
  1001. io.userid,
  1002. sd.NAME
  1003. ) a
  1004. </select>
  1005. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1006. select count(0) from (
  1007. SELECT
  1008. io.userid
  1009. FROM
  1010. ins_area_company iac
  1011. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1012. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1013. <where>
  1014. sd.management_source = '1'
  1015. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1016. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1017. </if>
  1018. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1019. and io.deptid like "${taskStatisticsVo.cityId}%"
  1020. </if>
  1021. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1022. and io.deptid like "${taskStatisticsVo.countyId}%"
  1023. </if>
  1024. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1025. and io.deptid like "${taskStatisticsVo.houseId}%"
  1026. </if>
  1027. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1028. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND
  1029. #{taskStatisticsVo.createtimeEnd}
  1030. </if>
  1031. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1032. <choose>
  1033. <when test="taskStatisticsVo.days =='1'">
  1034. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1035. </when>
  1036. <when test="taskStatisticsVo.days =='7'">
  1037. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1038. </when>
  1039. <when test="taskStatisticsVo.days =='30'">
  1040. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1041. </when>
  1042. </choose>
  1043. </if>
  1044. </where>
  1045. GROUP BY
  1046. io.userid
  1047. ) a
  1048. </select>
  1049. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1050. SELECT
  1051. a.*,
  1052. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1053. FROM
  1054. (
  1055. SELECT
  1056. pa.insurance_company_id,
  1057. pa.partner_companies_id,
  1058. pa.insurance_company AS "insuranceCompanyName",
  1059. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1060. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1061. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1062. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1063. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1064. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1065. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1066. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1067. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  1068. FROM
  1069. ins_area_company iac
  1070. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1071. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1072. <where>
  1073. pa.insurance_company_id IS NOT NULL
  1074. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1075. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1076. </if>
  1077. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1078. and io.deptid like "${taskStatisticsVo.cityId}%"
  1079. </if>
  1080. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1081. and io.deptid like "${taskStatisticsVo.countyId}%"
  1082. </if>
  1083. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1084. and io.deptid like "${taskStatisticsVo.houseId}%"
  1085. </if>
  1086. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1087. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1088. </if>
  1089. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1090. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1091. </if>
  1092. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1093. AND iac.company_id =#{taskStatisticsVo.companyId}
  1094. </if>
  1095. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1096. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1097. </if>
  1098. </where>
  1099. GROUP BY
  1100. pa.insurance_company_id,
  1101. pa.partner_companies_id,
  1102. pa.insurance_company
  1103. ) a
  1104. </select>
  1105. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1106. SELECT
  1107. COUNT(0)
  1108. FROM
  1109. (
  1110. SELECT
  1111. pa.insurance_company_id,
  1112. pa.partner_companies_id
  1113. FROM
  1114. ins_area_company iac
  1115. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1116. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1117. <where>
  1118. pa.insurance_company_id IS NOT NULL
  1119. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1120. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1121. </if>
  1122. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1123. and io.deptid like "${taskStatisticsVo.cityId}%"
  1124. </if>
  1125. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1126. and io.deptid like "${taskStatisticsVo.countyId}%"
  1127. </if>
  1128. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1129. and io.deptid like "${taskStatisticsVo.houseId}%"
  1130. </if>
  1131. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1132. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1133. </if>
  1134. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1135. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1136. </if>
  1137. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1138. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1139. </if>
  1140. </where>
  1141. GROUP BY
  1142. pa.insurance_company_id,
  1143. pa.partner_companies_id
  1144. ) total
  1145. </select>
  1146. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1147. SELECT
  1148. sd.name as "deptName",
  1149. su.name as "userName",
  1150. io.userid as "userId",
  1151. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1152. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1153. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1154. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1155. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "passingRate",
  1156. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
  1157. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
  1158. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
  1159. COUNT( CASE WHEN ifa.auditstatus = '0' THEN 1 END ) as "auditOrder"
  1160. FROM
  1161. ins_area_company iac
  1162. left join ins_orders io on io.orderno = iac.orderno
  1163. left join sys_dept sd on sd.id=io.deptid
  1164. left join sys_user su on su.id=io.userid
  1165. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  1166. <where>
  1167. sd.management_source = '2'
  1168. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1169. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1170. </if>
  1171. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1172. and io.deptid like "${taskStatisticsVo.cityId}%"
  1173. </if>
  1174. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1175. and io.deptid like "${taskStatisticsVo.countyId}%"
  1176. </if>
  1177. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1178. and io.deptid like "${taskStatisticsVo.houseId}%"
  1179. </if>
  1180. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1181. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1182. </if>
  1183. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1184. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1185. </if>
  1186. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1187. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1188. </if>
  1189. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1190. <choose>
  1191. <when test="taskStatisticsVo.days =='1'">
  1192. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1193. </when>
  1194. <when test="taskStatisticsVo.days =='7'">
  1195. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1196. </when>
  1197. <when test="taskStatisticsVo.days =='30'">
  1198. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1199. </when>
  1200. </choose>
  1201. </if>
  1202. </where>
  1203. GROUP BY io.userid , su.name, sd.id , sd.name
  1204. </select>
  1205. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1206. select count(0) from (
  1207. SELECT
  1208. io.userid as "userId"
  1209. FROM
  1210. ins_area_company iac
  1211. left join ins_orders io on io.orderno = iac.orderno
  1212. left join sys_dept sd on sd.id=io.deptid
  1213. <where>
  1214. sd.management_source = '2'
  1215. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1216. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1217. </if>
  1218. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1219. and io.deptid like "${taskStatisticsVo.cityId}%"
  1220. </if>
  1221. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1222. and io.deptid like "${taskStatisticsVo.countyId}%"
  1223. </if>
  1224. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1225. and io.deptid like "${taskStatisticsVo.houseId}%"
  1226. </if>
  1227. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1228. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1229. </if>
  1230. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1231. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1232. </if>
  1233. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1234. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1235. </if>
  1236. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1237. <choose>
  1238. <when test="taskStatisticsVo.days =='1'">
  1239. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1240. </when>
  1241. <when test="taskStatisticsVo.days =='7'">
  1242. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1243. </when>
  1244. <when test="taskStatisticsVo.days =='30'">
  1245. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1246. </when>
  1247. </choose>
  1248. </if>
  1249. </where>
  1250. GROUP BY io.userid
  1251. ) a
  1252. </select>
  1253. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1254. SELECT
  1255. iac.company_id,
  1256. iac.inscompany as "insuranceCompanyName",
  1257. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1258. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1259. COUNT( CASE WHEN pa.audit_type = 1 AND ifa.auditstatus = 1 THEN 1 END ) AS "persionAudit",
  1260. COUNT( CASE WHEN pa.audit_type = 2 AND ifa.auditstatus = 1 THEN 1 END ) AS "automaticAudit"
  1261. FROM
  1262. ins_fee_audit ifa
  1263. LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
  1264. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1265. LEFT JOIN ins_fee_order_new ion ON ion.ins_order_no = iac.id
  1266. <where>
  1267. 1=1
  1268. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1269. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1270. </if>
  1271. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1272. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1273. </if>
  1274. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1275. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1276. </if>
  1277. <choose>
  1278. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1279. and iac.product = #{taskStatisticsVo.riskCode}
  1280. </when>
  1281. </choose>
  1282. </where>
  1283. GROUP BY
  1284. iac.company_id,
  1285. iac.inscompany
  1286. </select>
  1287. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1288. SELECT
  1289. count( a.numberUserId ) as "orderManpower",
  1290. sum( a.orderAmount ) as "totalPremium",
  1291. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1292. FROM
  1293. (
  1294. SELECT
  1295. count( io.userid ) AS "numberUserId",
  1296. SUM(IFNULL(iac.jqpremium, 0)) +
  1297. SUM(IFNULL(iac.sypremium, 0)) +
  1298. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1299. FROM
  1300. `ins_area_company` iac
  1301. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1302. <where>
  1303. iac.orderstatus = '3'
  1304. <if test="ids != null and ids.size()>0 ">
  1305. AND io.userid IN
  1306. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1307. #{item}
  1308. </foreach>
  1309. </if>
  1310. </where>
  1311. GROUP BY
  1312. io.userid
  1313. ) a
  1314. </select>
  1315. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1316. SELECT
  1317. count( a.numberUserId ) as "orderManpower",
  1318. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1319. ROUND(sum( a.orderAmount )/ count( a.numberUserId ),2) AS "averagePremium"
  1320. FROM
  1321. (
  1322. SELECT
  1323. count( io.userid ) AS "numberUserId",
  1324. SUM(IFNULL(iac.jqpremium, 0)
  1325. +IFNULL(iac.sypremium, 0)
  1326. +IFNULL(iac.jypremium, 0)
  1327. ) AS "orderAmount"
  1328. FROM
  1329. `ins_area_company` iac
  1330. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1331. <where>
  1332. iac.orderstatus = '3'
  1333. <if test="vo.ids != null and vo.ids.size()>0 ">
  1334. AND io.userid IN
  1335. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1336. #{item}
  1337. </foreach>
  1338. </if>
  1339. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1340. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1341. </if>
  1342. </where>
  1343. GROUP BY
  1344. io.userid
  1345. ) a
  1346. order by sum( a.orderAmount ) desc
  1347. </select>
  1348. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1349. SELECT
  1350. a.userId as "userId",
  1351. a.orderNumber as "orderNumber",
  1352. a.underwritingCount as "underwritingCount",
  1353. a.qutationInsureCount as "qutationInsureCount",
  1354. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  1355. a.isFactorVerify as "isFactorVerify",
  1356. a.isNotFactorVerify as "isNotFactorVerify"
  1357. FROM
  1358. (
  1359. SELECT
  1360. io.userid as "userId",
  1361. count( iac.orderno ) AS "orderNumber",
  1362. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  1363. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  1364. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  1365. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1366. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1367. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  1368. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  1369. FROM
  1370. `ins_area_company` iac
  1371. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1372. left join sys_user su on su.id=io.userid
  1373. <where>
  1374. <if test="vo.ids != null and vo.ids.size()>0 ">
  1375. AND io.userid IN
  1376. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1377. #{item}
  1378. </foreach>
  1379. </if>
  1380. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1381. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1382. </if>
  1383. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1384. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1385. </if>
  1386. </where>
  1387. GROUP BY
  1388. io.userid
  1389. ) a
  1390. left join sys_user su on su.id=a.userId
  1391. </select>
  1392. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1393. SELECT
  1394. count(iac.id) as "orderNumber",
  1395. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1396. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1397. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1398. FROM
  1399. ins_area_company iac
  1400. left join ins_orders io on io.orderno = iac.orderno
  1401. left join sys_dept sd on sd.id=io.deptid
  1402. left join sys_user su on su.id=io.userid
  1403. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  1404. <where>
  1405. sd.management_source = '2'
  1406. <if test="userId !=null and userId !=''">
  1407. and io.userId =#{userId}
  1408. </if>
  1409. </where>
  1410. </select>
  1411. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1412. SELECT
  1413. agree.insurance_company_id AS companyId,
  1414. agree.insurance_company AS companyName,
  1415. agree.partner_companies_id AS parterCompanyId,
  1416. ins.namesimple AS parterCompanyName,
  1417. count(iac.orderstatus) AS orderNumber,
  1418. '-' as bigQutationCount,
  1419. '-' as bigUnderwritingCount,
  1420. '-' as bigCloseRate,
  1421. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1422. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1423. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  1424. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  1425. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  1426. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  1427. contributionRate
  1428. FROM
  1429. ins_area_company iac
  1430. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1431. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1432. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1433. WHERE
  1434. agree.id IS NOT NULL
  1435. <if test="vo.companyId != null and vo.companyId!='' ">
  1436. agree.insurance_company_id = #{vo.companyId}
  1437. </if>
  1438. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1439. agree.partner_companies_id = #{vo.parterCompanyId}
  1440. </if>
  1441. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1442. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1443. </if>
  1444. <if test="vo.provinceId != null and vo.provinceId != ''">
  1445. and io.deptid like "${vo.provinceId}%"
  1446. </if>
  1447. <if test="vo.cityId != null and vo.cityId != ''">
  1448. and io.deptid like "${vo.cityId}%"
  1449. </if>
  1450. <if test="vo.countyId != null and vo.countyId != ''">
  1451. and io.deptid like "${vo.countyId}%"
  1452. </if>
  1453. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  1454. and io.deptid like "${vo.houseId}%"
  1455. </if>
  1456. GROUP BY
  1457. agree.insurance_company_id,
  1458. agree.insurance_company,
  1459. agree.partner_companies_id,
  1460. ins.NAME
  1461. </select>
  1462. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1463. select
  1464. a.companyId as "companyId",
  1465. a.insuranceCompanyName as "insuranceCompanyName",
  1466. a.parterCompanyId as "parterCompanyId",
  1467. a.partnerCompaniesName as "partnerCompaniesName",
  1468. a.totalPremium as "totalPremium",
  1469. a.qutationInsureCount as "qutationInsureCount",
  1470. a.averagePremium as "averagePremium",
  1471. a.userNumber as "userNumber",
  1472. a.perCapitaAmount as "perCapitaAmount",
  1473. b.logo as "logo"
  1474. from (
  1475. SELECT
  1476. agree.insurance_company_id AS "companyId",
  1477. agree.insurance_company AS "insuranceCompanyName",
  1478. agree.partner_companies_id AS "parterCompanyId",
  1479. ins.namesimple AS "partnerCompaniesName",
  1480. sum(iac.sumpremium) as "totalPremium",
  1481. COUNT(0 ) AS "qutationInsureCount",
  1482. sum(iac.sumpremium) / COUNT(0 ) AS "averagePremium",
  1483. COUNT(DISTINCT io.userId) AS "userNumber",
  1484. sum(iac.sumpremium) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1485. FROM
  1486. ins_area_company iac
  1487. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1488. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1489. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1490. WHERE
  1491. agree.id IS NOT NULL
  1492. and iac.orderstatus = '3'
  1493. <if test="vo.companyId != null and vo.companyId!='' ">
  1494. and agree.insurance_company_id = #{vo.companyId}
  1495. </if>
  1496. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1497. and agree.partner_companies_id = #{vo.parterCompanyId}
  1498. </if>
  1499. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1500. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1501. </if>
  1502. <if test="vo.days !=null and vo.days !='' ">
  1503. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  1504. </if>
  1505. <if test="vo.provinceId != null and vo.provinceId != ''">
  1506. and io.deptid like "${vo.provinceId}%"
  1507. </if>
  1508. <if test="vo.cityId != null and vo.cityId != ''">
  1509. and io.deptid like "${vo.cityId}%"
  1510. </if>
  1511. <if test="vo.countyId != null and vo.countyId != ''">
  1512. and io.deptid like "${vo.countyId}%"
  1513. </if>
  1514. <if test="vo.houseId != null and vo.houseId != ''">
  1515. and io.deptid like "${vo.houseId}%"
  1516. </if>
  1517. GROUP BY
  1518. agree.insurance_company_id,
  1519. agree.insurance_company,
  1520. agree.partner_companies_id
  1521. <choose>
  1522. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  1523. order by
  1524. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1525. </when>
  1526. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  1527. order by
  1528. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  1529. </when>
  1530. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  1531. order by
  1532. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1533. </when>
  1534. </choose>
  1535. ) a
  1536. left join esm_ins_company b on b.id =a.companyId
  1537. </select>
  1538. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1539. SELECT
  1540. agree.insurance_company_id AS "companyId",
  1541. agree.insurance_company AS "insuranceCompanyName",
  1542. agree.partner_companies_id AS "parterCompanyId",
  1543. ins.namesimple AS "partnerCompaniesName",
  1544. sum(sumpremium) as "totalPremium",
  1545. COUNT(0) AS "qutationInsureCount",
  1546. sum(sumpremium) / COUNT(0) AS "averagePremium",
  1547. COUNT(DISTINCT io.userId) AS "userNumber",
  1548. sum(sumpremium) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1549. FROM
  1550. ins_area_company iac
  1551. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1552. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1553. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1554. WHERE
  1555. agree.id IS NOT NULL
  1556. <if test="vo.companyId != null and vo.companyId!='' ">
  1557. and agree.insurance_company_id = #{vo.companyId}
  1558. </if>
  1559. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1560. and agree.partner_companies_id = #{vo.parterCompanyId}
  1561. </if>
  1562. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1563. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeStart}
  1564. </if>
  1565. <if test="vo.provinceId != null and vo.provinceId != ''">
  1566. and io.deptid like "${vo.provinceId}%"
  1567. </if>
  1568. <if test="vo.cityId != null and vo.cityId != ''">
  1569. and io.deptid like "${vo.cityId}%"
  1570. </if>
  1571. <if test="vo.countyId != null and vo.countyId != ''">
  1572. and io.deptid like "${vo.countyId}%"
  1573. </if>
  1574. <if test="vo.houseId != null and vo.houseId != ''">
  1575. and io.deptid like "${vo.houseId}%"
  1576. </if>
  1577. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  1578. and iac.orderstatus =#{vo.quotationStatus}
  1579. </if>
  1580. GROUP BY
  1581. agree.insurance_company_id,
  1582. agree.insurance_company,
  1583. agree.partner_companies_id,
  1584. ins.namesimple
  1585. </select>
  1586. <select id="getOrderPremiumByUserIds" resultType="Double">
  1587. SELECT
  1588. IFNULL(
  1589. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  1590. 0
  1591. ) AS "totalPremium"
  1592. FROM
  1593. `ins_area_company` iac
  1594. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1595. <where>
  1596. iac.orderstatus = '3'
  1597. <if test="ids != null and ids.size()>0 ">
  1598. AND io.userid IN
  1599. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1600. #{item}
  1601. </foreach>
  1602. </if>
  1603. </where>
  1604. </select>
  1605. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1606. SELECT
  1607. io.licenseno AS "licenseno",
  1608. io.frameno AS "frameno",
  1609. pa.partner_companies_id as 'partnerCompaniesId',
  1610. count(io.orderno) as "orderNumber",
  1611. eic.namesimple as "namesimple",
  1612. IFNULL(count(CASE WHEN iac.orderstatus = '3' THEN 1 ELSE 0 END),0) / (IFNULL(count(CASE WHEN iac.orderstatus = '2' THEN 1 ELSE 0 END),0) + IFNULL(count(CASE WHEN iac.orderstatus = '3' THEN 1 ELSE 0 END),0)) AS "closeRate"
  1613. FROM
  1614. ins_area_company iac
  1615. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  1616. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1617. LEFT JOIN esm_ins_company eic ON eic.id = pa.insurance_company_id
  1618. LEFT JOIN sys_user su on io.userid=su.id
  1619. <where>
  1620. 1=1
  1621. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1622. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1623. </if>
  1624. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1625. AND io.licenseno =#{vo.licenseno}
  1626. </if>
  1627. <if test="vo.userId != null and vo.userId!='' ">
  1628. AND io.userId =#{vo.userId}
  1629. </if>
  1630. <if test="vo.userName != null and vo.userName!='' ">
  1631. AND su.name =#{vo.userName}
  1632. </if>
  1633. <if test="vo.mobile != null and vo.mobile!='' ">
  1634. AND su.mobile =#{vo.mobile}
  1635. </if>
  1636. <if test="vo.frameno != null and vo.frameno!='' ">
  1637. AND su.frameno =#{vo.frameno}
  1638. </if>
  1639. <if test="vo.deptId != null and vo.deptId!='' ">
  1640. and io.deptid like concat('%', #{vo.deptId}, '%')
  1641. </if>
  1642. </where>
  1643. GROUP BY
  1644. io.licenseno,
  1645. io.frameno,
  1646. pa.partner_companies_id,
  1647. eic.namesimple
  1648. </select>
  1649. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1650. select count(a.frameno) as "frameno" from (
  1651. SELECT
  1652. io.frameno AS "frameno"
  1653. FROM
  1654. ins_orders io
  1655. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1656. LEFT JOIN sys_user su ON io.userid = su.id
  1657. <where>
  1658. 1=1
  1659. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1660. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1661. </if>
  1662. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1663. AND io.licenseno =#{vo.licenseno}
  1664. </if>
  1665. <if test="vo.userId != null and vo.userId!='' ">
  1666. AND io.userId =#{vo.userId}
  1667. </if>
  1668. <if test="vo.userName != null and vo.userName!='' ">
  1669. AND su.name =#{vo.userName}
  1670. </if>
  1671. <if test="vo.mobile != null and vo.mobile!='' ">
  1672. AND su.mobile =#{vo.mobile}
  1673. </if>
  1674. <if test="vo.frameno != null and vo.frameno!='' ">
  1675. AND su.frameno =#{vo.frameno}
  1676. </if>
  1677. <if test="vo.deptId != null and vo.deptId!='' ">
  1678. and io.deptid like concat('%', #{vo.deptId}, '%')
  1679. </if>
  1680. </where>
  1681. GROUP BY
  1682. io.frameno
  1683. ) a
  1684. </select>
  1685. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1686. SELECT
  1687. count( io.orderno ) AS "orderNumber",
  1688. 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"
  1689. FROM
  1690. ins_orders io
  1691. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1692. LEFT JOIN sys_user su ON io.userid = su.id
  1693. <where>
  1694. 1=1
  1695. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1696. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1697. </if>
  1698. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1699. AND io.licenseno =#{vo.licenseno}
  1700. </if>
  1701. <if test="vo.userId != null and vo.userId!='' ">
  1702. AND io.userId =#{vo.userId}
  1703. </if>
  1704. <if test="vo.userName != null and vo.userName!='' ">
  1705. AND su.name =#{vo.userName}
  1706. </if>
  1707. <if test="vo.mobile != null and vo.mobile!='' ">
  1708. AND su.mobile =#{vo.mobile}
  1709. </if>
  1710. <if test="vo.frameno != null and vo.frameno!='' ">
  1711. AND su.frameno =#{vo.frameno}
  1712. </if>
  1713. <if test="vo.deptId != null and vo.deptId!='' ">
  1714. and io.deptid like concat('%', #{vo.deptId}, '%')
  1715. </if>
  1716. </where>
  1717. </select>
  1718. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1719. SELECT
  1720. count(iac.id) as "orderNumber",
  1721. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1722. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1723. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1724. FROM
  1725. ins_area_company iac
  1726. left join ins_orders io on io.orderno = iac.orderno
  1727. <where>
  1728. <if test="ids != null and ids.size()>0 ">
  1729. AND io.userid IN
  1730. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1731. #{item}
  1732. </foreach>
  1733. </if>
  1734. <if test="month != null and month!='' ">
  1735. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  1736. </if>
  1737. </where>
  1738. </select>
  1739. </mapper>