InsOrdersMapper.xml 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489
  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.InsOrdersMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsOrders">
  7. <id property="orderno" column="orderno" jdbcType="VARCHAR"/>
  8. <result property="quoteno" column="quoteno" jdbcType="VARCHAR"/>
  9. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  10. <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
  11. <result property="insCompany" column="ins_company" jdbcType="VARCHAR"/>
  12. <result property="carinfo" column="carinfo" javaType="com.alibaba.fastjson.JSONObject"
  13. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  14. <result property="userid" column="userid" jdbcType="VARCHAR"/>
  15. <result property="username" column="username" jdbcType="VARCHAR"/>
  16. <result property="deptid" column="deptid" jdbcType="VARCHAR"/>
  17. <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
  18. <result property="ownerinfo" column="ownerinfo" javaType="com.alibaba.fastjson.JSONObject"
  19. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  20. <result property="applyinfo" column="applyinfo" javaType="com.alibaba.fastjson.JSONObject"
  21. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  22. <result property="insureinfo" column="insureinfo" javaType="com.alibaba.fastjson.JSONObject"
  23. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"
  24. jdbcType="VARCHAR"/>
  25. <result property="agreeid" column="agreeid" jdbcType="VARCHAR"/>
  26. <result property="productid" column="productid" jdbcType="VARCHAR"/>
  27. <result property="product" column="product" jdbcType="VARCHAR"/>
  28. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  29. <result property="frameno" column="frameno" jdbcType="VARCHAR"/>
  30. <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
  31. <result property="insuredname" column="insuredname" jdbcType="VARCHAR"/>
  32. <result property="jqstartdate" column="jqstartdate" jdbcType="VARCHAR"/>
  33. <result property="jqenddate" column="jqenddate" jdbcType="VARCHAR"/>
  34. <result property="systartdate" column="systartdate" jdbcType="VARCHAR"/>
  35. <result property="syenddate" column="syenddate" jdbcType="VARCHAR"/>
  36. <result property="jqpremium" column="jqpremium" jdbcType="VARCHAR"/>
  37. <result property="sypremium" column="sypremium" jdbcType="VARCHAR"/>
  38. <result property="jypremium" column="jypremium" jdbcType="VARCHAR"/>
  39. <result property="taxamount" column="taxamount" jdbcType="VARCHAR"/>
  40. <result property="risk" column="risk" javaType="com.alibaba.fastjson.JSONArray"
  41. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  42. <result property="king" column="king" javaType="com.alibaba.fastjson.JSONArray"
  43. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  44. <result property="vehicleAndVesselTax" column="vehicle_and_vessel_tax"
  45. javaType="com.alibaba.fastjson.JSONObject"
  46. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  47. <result property="subOrderId" column="subOrderId" jdbcType="VARCHAR"/>
  48. <result property="agreementCode" column="agreementCode" jdbcType="VARCHAR"/>
  49. <result property="agreementName" column="agreementName" jdbcType="VARCHAR"/>
  50. <result property="partnerCompaniesName" column="partnerCompaniesName" jdbcType="VARCHAR"/>
  51. <result property="managementSource" column="managementSource" jdbcType="VARCHAR"/>
  52. <result property="leaderName" column="leader_name" jdbcType="VARCHAR"/>
  53. <result property="leaderId" column="leader_id" jdbcType="VARCHAR"/>
  54. <result property="underwritingStatus" column="underwritingStatus" jdbcType="INTEGER"/>
  55. <result property="entryStatus" column="entryStatus" jdbcType="VARCHAR"/>
  56. <result property="underwritingTime" column="underwritingTime" jdbcType="TIMESTAMP"/>
  57. <result property="payDate" column="payDate" jdbcType="TIMESTAMP"/>
  58. <result property="updateStatus" column="updateStatus" jdbcType="VARCHAR"/>
  59. <result property="updateStatusTime" column="updateStatusTime" jdbcType="TIMESTAMP"/>
  60. <result property="signingTime" column="signingTime" jdbcType="TIMESTAMP"/>
  61. </resultMap>
  62. <resultMap id="OrderResultMap" type="com.ydtech.modules.order.entity.vo.OrderVo">
  63. <id property="orderno" column="orderno" jdbcType="VARCHAR"/>
  64. <result property="quoteno" column="quoteno" jdbcType="VARCHAR"/>
  65. <result property="apiType" column="api_type" jdbcType="VARCHAR"/>
  66. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  67. <result property="carinfo" column="carinfo" javaType="com.alibaba.fastjson.JSONObject"
  68. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  69. <result property="userid" column="userid" jdbcType="VARCHAR"/>
  70. <result property="username" column="username" jdbcType="VARCHAR"/>
  71. <result property="deptid" column="deptid" jdbcType="VARCHAR"/>
  72. <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
  73. <result property="ownerinfo" column="ownerinfo" javaType="com.alibaba.fastjson.JSONObject"
  74. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  75. <result property="applyinfo" column="applyinfo" javaType="com.alibaba.fastjson.JSONObject"
  76. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  77. <result property="insureinfo" column="insureinfo" javaType="com.alibaba.fastjson.JSONObject"
  78. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"
  79. jdbcType="VARCHAR"/>
  80. <result property="agreementId" column="agreement_id" jdbcType="VARCHAR"/>
  81. <result property="entryStatus" column="entry_status" jdbcType="VARCHAR"/>
  82. <result property="productid" column="productid" jdbcType="VARCHAR"/>
  83. <result property="product" column="product" jdbcType="VARCHAR"/>
  84. <result property="frameno" column="frameno" jdbcType="VARCHAR"/>
  85. <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
  86. <result property="insuredname" column="insuredname" jdbcType="VARCHAR"/>
  87. <result property="jqstartdate" column="jqstartdate" jdbcType="VARCHAR"/>
  88. <result property="jqenddate" column="jqenddate" jdbcType="VARCHAR"/>
  89. <result property="systartdate" column="systartdate" jdbcType="VARCHAR"/>
  90. <result property="syenddate" column="syenddate" jdbcType="VARCHAR"/>
  91. <result property="id" column="id" jdbcType="BIGINT"/>
  92. <result property="companyId" column="company_id" jdbcType="BIGINT"/>
  93. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  94. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  95. <result property="vehicleAndVesselTax" column="vehicle_and_vessel_tax"
  96. javaType="com.alibaba.fastjson.JSONObject"
  97. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  98. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  99. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  100. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  101. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  102. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  103. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  104. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  105. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  106. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  107. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  108. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  109. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  110. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  111. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  112. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  113. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  114. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  115. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  116. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  117. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  118. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  119. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  120. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  121. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  122. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  123. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  124. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  125. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  126. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  127. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  128. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  129. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  130. <result property="ubiPredictedInfoScore" column="ubi_predicted_info_score" jdbcType="VARCHAR"/>
  131. <result property="mergeCostRate" column="merge_cost_rate" jdbcType="VARCHAR"/>
  132. <result property="signingTime" column="signingTime" jdbcType="TIMESTAMP"/>
  133. <result property="payDate" column="payDate" jdbcType="TIMESTAMP"/>
  134. <result property="partnerCompaniesName" column="partnerCompaniesName" jdbcType="VARCHAR"/>
  135. <result property="equityType" column="equityType" jdbcType="INTEGER"/>
  136. <result property="mergeCostRate" column="mergeCostRate" jdbcType="DOUBLE"/>
  137. <result property="seriesTypeActualName" column="seriesTypeActualName" jdbcType="VARCHAR"/>
  138. </resultMap>
  139. <resultMap id="OrderExcelResultMap" type="com.ydtech.modules.ins.model.InsOrdersExcel">
  140. <id property="orderNo" column="orderno" jdbcType="VARCHAR"/>
  141. <result property="licenseNo" column="licenseno" jdbcType="VARCHAR"/>
  142. <result property="fraMeno" column="frameno" jdbcType="VARCHAR"/>
  143. <result property="carInfo" column="carinfo" javaType="com.alibaba.fastjson.JSONObject" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  144. <result property="score" column="score" jdbcType="VARCHAR"/>
  145. <result property="ownerInfo" column="ownerinfo" javaType="com.alibaba.fastjson.JSONObject" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  146. <result property="jqpRemIum" column="jqpremium" jdbcType="VARCHAR"/>
  147. <result property="apiType" column="api_type" jdbcType="VARCHAR"/>
  148. <result property="jqPolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  149. <result property="sypRemIum" column="sypremium" jdbcType="VARCHAR"/>
  150. <result property="syPolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  151. <result property="jypRemIum" column="jypremium" jdbcType="VARCHAR"/>
  152. <result property="taxaMount" column="taxamount" jdbcType="VARCHAR"/>
  153. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  154. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  155. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  156. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  157. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  158. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  159. <result property="lossRation" column="loss_ration" jdbcType="VARCHAR"/>
  160. <result property="jqLossRation" column="jq_loss_ration" jdbcType="VARCHAR"/>
  161. <result property="syLossRation" column="sy_loss_ration" jdbcType="VARCHAR"/>
  162. <result property="insCompany" column="inscompany" jdbcType="VARCHAR"/>
  163. <result property="agreementId" column="agreement_id" jdbcType="VARCHAR"/>
  164. <result property="userId" column="userid" jdbcType="VARCHAR"/>
  165. <result property="userName" column="username" jdbcType="VARCHAR"/>
  166. <result property="applyInfo" column="applyinfo" javaType="com.alibaba.fastjson.JSONObject"
  167. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  168. <result property="insureInfo" column="insureinfo" javaType="com.alibaba.fastjson.JSONObject"
  169. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  170. <result property="kindInfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  171. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  172. <result property="payDate" column="pay_date" jdbcType="VARCHAR"/>
  173. <result property="signingTime" column="signing_time" jdbcType="VARCHAR"/>
  174. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  175. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  176. <result property="product" column="product" jdbcType="VARCHAR"/>
  177. <result property="jqBusinessType" column="jq_business_type" jdbcType="VARCHAR"/>
  178. <result property="syBusinessType" column="sy_business_type" jdbcType="VARCHAR"/>
  179. </resultMap>
  180. <sql id="Base_Column_List">
  181. orderno,quoteno,orderstatus,
  182. carinfo,userid,username,
  183. deptid,deptname,ownerinfo,
  184. applyinfo,insureinfo,agreeid,
  185. productid,product,createtime,
  186. frameno,licenseno,insuredname,
  187. jqstartdate,jqenddate,systartdate,
  188. syenddate
  189. </sql>
  190. <select id="getOrderAndAreaCompany" parameterType="java.lang.String" resultMap="OrderResultMap">
  191. select o.orderno,
  192. o.quoteno,
  193. o.carinfo,
  194. o.userid,
  195. o.username,
  196. o.deptid,
  197. o.deptname,
  198. o.ownerinfo,
  199. o.applyinfo,
  200. o.insureinfo,
  201. o.agreeid,
  202. iac.productid,
  203. iac.product,
  204. o.frameno,
  205. o.licenseno,
  206. o.insuredname,
  207. o.vehicle_and_vessel_tax,
  208. o.is_external,
  209. iac.jq_start_date as jqstartdate,
  210. iac.jq_end_date as jqenddate,
  211. iac.sy_start_date as systartdate,
  212. iac.sy_end_date as syenddate,
  213. iac.id,
  214. iac.api_type,
  215. iac.company_id,
  216. iac.reptxt,
  217. iac.orderstatus,
  218. iac.inscompany,
  219. iac.jqapplyno,
  220. iac.jqpolicyno,
  221. iac.syapplyno,
  222. iac.sypolicyno,
  223. iac.riskinfo,
  224. iac.kindinfo,
  225. iac.jqpremium,
  226. iac.sypremium,
  227. iac.jypremium,
  228. iac.taxamount,
  229. iac.sumpremium,
  230. iac.jqdiscountrate,
  231. iac.sydiscountrate,
  232. iac.feerate,
  233. iac.disrate,
  234. iac.auditid,
  235. iac.auditname,
  236. iac.audittime,
  237. iac.auditopinion,
  238. iac.jqappoint,
  239. iac.syappoint,
  240. iac.createtime,
  241. iac.payment_link,
  242. iac.accident_info,
  243. iac.tax_arrears,
  244. iac.cross_insurance,
  245. iac.ubi_predicted_info_score,
  246. iac.merge_cost_rate,
  247. iac.series_type_actual_name,
  248. iac.xyh_grade,
  249. iac.signing_time as signingTime,
  250. iac.pay_date as payDate,
  251. iac.agreement_id,
  252. o.entry_status,
  253. eic.namesimple as partnerCompaniesName,
  254. iac.merge_cost_rate,
  255. iac.extend_info as extendInfo1,
  256. iace.type as equityType
  257. from ins_orders as o
  258. join ins_area_company iac on o.orderno = iac.orderno
  259. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  260. LEFT JOIN esm_ins_company eic on eic.id = pa.partner_companies_id
  261. left join ins_area_company_equity iace on iace.sub_order_no = iac.id
  262. where iac.id = #{companyId}
  263. </select>
  264. <select id="getByUseridAndLicenseNo" resultType="com.ydtech.modules.order.entity.InsOrders"
  265. parameterType="com.ydtech.modules.order.entity.vo.VerifyOrdersVo">
  266. select orderno,
  267. quoteno,
  268. orderstatus,
  269. carinfo,
  270. userid,
  271. username,
  272. deptid,
  273. deptname,
  274. ownerinfo,
  275. applyinfo,
  276. insureinfo,
  277. agreeid,
  278. productid,
  279. product,
  280. createtime,
  281. frameno,
  282. licenseno,
  283. insuredname,
  284. jqstartdate,
  285. jqenddate,
  286. systartdate,
  287. syenddate,
  288. risk,
  289. king,
  290. vehicle_and_vessel_tax
  291. from ins_orders
  292. where userid = #{userId, jdbcType=VARCHAR}
  293. and licenseno = #{licenseNo, jdbcType=VARCHAR}
  294. and createtime > DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
  295. </select>
  296. <select id="queryPageOrderCount" resultType="Long">
  297. select
  298. count(1)
  299. from (
  300. select
  301. io.orderno
  302. from
  303. ins_orders io
  304. <!--如果存在 公司查询则进行连表 -->
  305. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  306. left JOIN
  307. ins_area_company iac on iac.orderno = io.orderno
  308. </if>
  309. <where>
  310. and (io.del_flag IS NULL
  311. or io.del_flag = 1)
  312. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  313. and io.orderno = #{orderQueryVo.orderNo}
  314. </if>
  315. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  316. and io.deptid like "${orderQueryVo.deptId}%"
  317. </if>
  318. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  319. and io.orderstatus = #{orderQueryVo.orderStatus}
  320. </if>
  321. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  322. and io.frameno = #{orderQueryVo.frameNo}
  323. </if>
  324. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  325. and io.licenseno = #{orderQueryVo.licenseNo}
  326. </if>
  327. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  328. and io.insuredname = #{orderQueryVo.insuredName}
  329. </if>
  330. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  331. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  332. </if>
  333. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  334. and iac.company_id = #{orderQueryVo.companyId}
  335. </if>
  336. <!--
  337. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
  338. and io.operatorid = #{orderQueryVo.userId}
  339. </if>
  340. -->
  341. <choose>
  342. <when test="isCdy">
  343. <if test="deptId != null and deptId != '' ">
  344. and io.deptid like "${deptId}%"
  345. </if>
  346. </when>
  347. <when test="isDxFlag">
  348. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' ">
  349. and io.userid in ( select id from sys_user where manager_id = #{orderQueryVo.userId} or id =
  350. #{orderQueryVo.userId} )
  351. </if>
  352. </when>
  353. <otherwise>
  354. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
  355. and io.userid = #{orderQueryVo.userId}
  356. </if>
  357. </otherwise>
  358. </choose>
  359. </where>
  360. group by io.orderno
  361. ) as s
  362. </select>
  363. <select id="queryPageDeleteOrderCount" resultType="Long">
  364. select
  365. count(1)
  366. from (
  367. select
  368. (0)
  369. from
  370. ins_area_company iac
  371. left JOIN
  372. ins_orders io on iac.orderno = io.orderno
  373. LEFT JOIN
  374. sys_dept dept ON dept.id = io.deptid
  375. LEFT JOIN
  376. sys_user u on io.userid = u.id
  377. left join
  378. ptl_agreement agree on iac.agreement_id= agree.id
  379. left join
  380. esm_ins_company company on agree.partner_companies_id= company.id
  381. <where>
  382. <if test="agentUserIds != null and agentUserIds.size>0" >
  383. AND (
  384. (io.userid in
  385. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  386. #{item}
  387. </foreach>
  388. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  389. <if test="deptIds != null and deptIds.size>0" >
  390. AND (
  391. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  392. io.deptid like CONCAT('', #{item}, '%')
  393. </foreach>
  394. )
  395. </if>
  396. )
  397. <if test="flag" >
  398. OR iac.operator_id = #{orderQueryVo.userId}
  399. </if>
  400. )
  401. </if>
  402. <if test="agreeIds != null and agreeIds.size>0">
  403. AND (
  404. (iac.company_id in
  405. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  406. #{item}
  407. </foreach>
  408. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  409. <if test="flag" >
  410. OR iac.operator_id = #{orderQueryVo.userId}
  411. </if>
  412. )
  413. </if>
  414. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  415. and iac.id = #{orderQueryVo.orderNo}
  416. </if>
  417. <if test="orderQueryVo.managementSource != null and orderQueryVo.managementSource.size > 0">
  418. and dept.management_source in
  419. <foreach item="source" collection="orderQueryVo.managementSource" open="(" separator="," close=")">
  420. #{source}
  421. </foreach>
  422. </if>
  423. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  424. and io.frameno = #{orderQueryVo.frameNo}
  425. </if>
  426. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  427. and io.licenseno = #{orderQueryVo.licenseNo}
  428. </if>
  429. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  430. and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
  431. </if>
  432. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  433. and iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND iac.createtime <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
  434. </if>
  435. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  436. and iac.company_id = #{orderQueryVo.companyId}
  437. </if>
  438. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  439. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  440. </if>
  441. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  442. and io.deptid like "${orderQueryVo.provinceId}%"
  443. </if>
  444. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  445. and io.deptid like "${orderQueryVo.cityId}%"
  446. </if>
  447. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  448. and io.deptid like "${orderQueryVo.countyId}%"
  449. </if>
  450. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  451. and io.deptid like "${orderQueryVo.houseId}%"
  452. </if>
  453. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  454. and iac.agreement_id = #{orderQueryVo.agreeId}
  455. </if>
  456. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  457. and io.orderno = #{orderQueryVo.taskNo}
  458. </if>
  459. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  460. and iac.product = #{orderQueryVo.riskCode}
  461. </if>
  462. <if test="orderQueryVo.leaderId != null and orderQueryVo.leaderId != ''">
  463. and u.leader_id = #{orderQueryVo.leaderId}
  464. </if>
  465. <if test="orderQueryVo.leaderName != null and orderQueryVo.leaderName != ''">
  466. and u.leader_name = #{orderQueryVo.leaderName}
  467. </if>
  468. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  469. and ((
  470. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  471. AND #{orderQueryVo.attachEndDateStr}
  472. )
  473. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  474. )
  475. </if>
  476. <choose>
  477. <when test="type==1">
  478. and dept.management_source=1
  479. </when>
  480. <when test="type==2">
  481. and dept.management_source=2
  482. </when>
  483. </choose>
  484. <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
  485. and iac.signing_time >= #{orderQueryVo.signStartDateStr} AND iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
  486. </if>
  487. <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
  488. and io.entry_status = #{orderQueryVo.entryStatus }
  489. </if>
  490. <if test="orderQueryVo.payStartDateStr != null and orderQueryVo.payEndDateStr != null">
  491. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{orderQueryVo.payStartDateStr} AND #{orderQueryVo.payEndDateStr}
  492. </if>
  493. <if test="orderQueryVo.auditStartDateStr != null and orderQueryVo.auditEndDateStr != null">
  494. and DATE_FORMAT(iac.underwriting_time, '%Y-%m-%d') between #{orderQueryVo.auditStartDateStr} AND #{orderQueryVo.auditEndDateStr}
  495. </if>
  496. <if test="orderQueryVo.updateStartDateStr != null and orderQueryVo.updateEndDateStr != null">
  497. and DATE_FORMAT( iac.update_status_time, '%Y-%m-%d') between #{orderQueryVo.updateStartDateStr} AND #{orderQueryVo.updateEndDateStr}
  498. </if>
  499. <if test="orderQueryVo.updateStatus != null and orderQueryVo.updateStatus != null">
  500. and iac.update_status = #{orderQueryVo.updateStatus}
  501. </if>
  502. <if test="orderQueryVo.partnerCompaniesId != null and orderQueryVo.partnerCompaniesId != null">
  503. and agree.partner_companies_id = #{orderQueryVo.partnerCompaniesId}
  504. </if>
  505. and (io.del_flag = 0)
  506. </where>
  507. group by io.orderno,
  508. iac.orderstatus,
  509. iac.productid,
  510. iac.product,
  511. iac.jq_start_date,
  512. iac.jq_end_date,
  513. iac.sy_start_date,
  514. iac.sy_end_date,
  515. iac.jqpremium,
  516. iac.sypremium,
  517. iac.jypremium,
  518. iac.taxamount,
  519. iac.id
  520. ) as s
  521. </select>
  522. <select id="queryPageOrder" resultMap="BaseResultMap">
  523. select
  524. io.*
  525. from
  526. ins_orders io
  527. <!--如果存在 公司查询则进行连表 -->
  528. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  529. left JOIN
  530. ins_area_company iac on iac.orderno = io.orderno
  531. </if>
  532. <where>
  533. and (io.del_flag IS NULL
  534. or io.del_flag = 1)
  535. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  536. and io.orderno = #{orderQueryVo.orderNo}
  537. </if>
  538. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  539. and io.deptid like "${orderQueryVo.deptId}%"
  540. </if>
  541. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  542. and io.orderstatus = #{orderQueryVo.orderStatus}
  543. </if>
  544. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  545. and io.frameno = #{orderQueryVo.frameNo}
  546. </if>
  547. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  548. and io.licenseno = #{orderQueryVo.licenseNo}
  549. </if>
  550. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  551. and io.insuredname = #{orderQueryVo.insuredName}
  552. </if>
  553. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  554. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  555. </if>
  556. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  557. and iac.company_id = #{orderQueryVo.companyId}
  558. </if>
  559. <if test="orderQueryVo.product != null and orderQueryVo.product != ''">
  560. and io.product = #{orderQueryVo.product}
  561. </if>
  562. <if test="orderQueryVo.productid != null and orderQueryVo.productid != ''">
  563. and io.productid = #{orderQueryVo.productid}
  564. </if>
  565. <!--
  566. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
  567. and io.operatorid = #{orderQueryVo.userId}
  568. </if>
  569. -->
  570. <choose>
  571. <when test="isCdy">
  572. <if test="deptId != null and deptId != '' ">
  573. and io.deptid like "${deptId}%"
  574. </if>
  575. </when>
  576. <when test="isDxFlag">
  577. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' ">
  578. and io.userid in ( select id from sys_user where manager_id = #{orderQueryVo.userId} or id =
  579. #{orderQueryVo.userId} )
  580. </if>
  581. </when>
  582. <otherwise>
  583. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
  584. and io.userid = #{orderQueryVo.userId}
  585. </if>
  586. </otherwise>
  587. </choose>
  588. </where>
  589. group by
  590. orderno, io.createtime
  591. order by io.createtime desc
  592. </select>
  593. <select id="queryPageDeleteOrder" resultMap="BaseResultMap">
  594. select
  595. io.orderno as orderno,
  596. io.quoteno as quoteno,
  597. iac.orderstatus as orderstatus,
  598. io.carinfo as carinfo,
  599. io.userid as userid,
  600. io.username as username,
  601. io.deptid as deptid,
  602. io.deptname as deptname,
  603. io.ownerinfo as ownerinfo,
  604. io.applyinfo as applyinfo,
  605. io.insureinfo as insureinfo,
  606. io.agreeid as agreeid,
  607. iac.productid as productid,
  608. iac.product as product,
  609. MAX(iac.createtime) as createtime,
  610. io.frameno as frameno,
  611. io.licenseno as licenseno,
  612. REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') as insuredname,
  613. iac.jq_start_date as jqstartdate,
  614. iac.jq_end_date as jqenddate,
  615. iac.sy_start_date as systartdate,
  616. iac.sy_end_date as syenddate,
  617. iac.jqpremium as jqpremium,
  618. iac.sypremium as sypremium,
  619. iac.jypremium as jypremium,
  620. iac.taxamount as taxamount,
  621. io.risk as risk,
  622. io.king as king,
  623. io.vehicle_and_vessel_tax as vehicleAndVesselTax,
  624. iac.id as subOrderId,
  625. iac.underwriting_status as underwritingStatus,
  626. iac.company_id as company_id,
  627. iac.inscompany as ins_company,
  628. agree.agreement_code as agreementCode,
  629. agree.agreement_name as agreementName,
  630. company.namesimple as partnerCompaniesName,
  631. dept.province,
  632. dept.city,
  633. dept.area,
  634. d1.area_cname as province_name,
  635. d2.area_cname as city_name,
  636. d3.area_cname as area_name,
  637. concat(d1.area_cname,d2.area_cname,d3.area_cname) as area_info,
  638. iac.api_type,
  639. io.is_external,
  640. u.leader_name,
  641. u.leader_id,
  642. CASE dept.management_source
  643. WHEN '1' THEN '渠道'
  644. WHEN '2' THEN '个代'
  645. WHEN '3' THEN '电销'
  646. ELSE '' END
  647. AS managementSource,
  648. io.entry_status as entryStatus,
  649. iac.underwriting_time as underwritingTime,
  650. iac.pay_date as payDate,
  651. iac.update_status AS updateStatus,
  652. iac.update_status_time AS updateStatusTime,
  653. iac.signing_time as signingTime,
  654. oou.NAME as operatorName
  655. from
  656. ins_area_company iac
  657. left JOIN
  658. ins_orders io on iac.orderno = io.orderno
  659. left join
  660. ptl_agreement agree on iac.agreement_id= agree.id
  661. left join
  662. esm_ins_company company on agree.partner_companies_id= company.id
  663. LEFT JOIN
  664. sys_dept dept ON dept.id = io.deptid
  665. LEFT JOIN sys_dept pdept on dept.parent_id = pdept.id
  666. LEFT JOIN sys_area d1 ON d1.area_code = pdept.province
  667. LEFT JOIN sys_area d2 ON d2.area_code = pdept.city
  668. LEFT JOIN sys_area d3 ON d3.area_code = pdept.area
  669. LEFT JOIN
  670. sys_user u on io.userid = u.id
  671. LEFT JOIN sys_user oou ON io.operatorid = oou.id
  672. <where>
  673. <if test="agentUserIds != null and agentUserIds.size>0" >
  674. AND (
  675. (io.userid in
  676. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  677. #{item}
  678. </foreach>
  679. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  680. <if test="deptIds != null and deptIds.size>0" >
  681. AND (
  682. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  683. io.deptid like CONCAT('', #{item}, '%')
  684. </foreach>
  685. )
  686. </if>
  687. )
  688. <if test="flag" >
  689. OR iac.operator_id = #{orderQueryVo.userId}
  690. </if>
  691. )
  692. </if>
  693. <if test="agreeIds != null and agreeIds.size>0">
  694. AND (
  695. (iac.company_id in
  696. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  697. #{item}
  698. </foreach>
  699. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  700. <if test="flag" >
  701. OR iac.operator_id = #{orderQueryVo.userId}
  702. </if>
  703. )
  704. </if>
  705. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  706. and iac.id = #{orderQueryVo.orderNo}
  707. </if>
  708. <if test="orderQueryVo.managementSource != null and orderQueryVo.managementSource.size > 0">
  709. and dept.management_source in
  710. <foreach item="source" collection="orderQueryVo.managementSource" open="(" separator="," close=")">
  711. #{source}
  712. </foreach>
  713. </if>
  714. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  715. and io.frameno = #{orderQueryVo.frameNo}
  716. </if>
  717. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  718. and io.licenseno = #{orderQueryVo.licenseNo}
  719. </if>
  720. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  721. and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
  722. </if>
  723. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  724. and iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND iac.createtime <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
  725. </if>
  726. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  727. and iac.company_id = #{orderQueryVo.companyId}
  728. </if>
  729. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  730. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  731. </if>
  732. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  733. and io.deptid like "${orderQueryVo.provinceId}%"
  734. </if>
  735. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  736. and io.deptid like "${orderQueryVo.cityId}%"
  737. </if>
  738. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  739. and io.deptid like "${orderQueryVo.countyId}%"
  740. </if>
  741. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  742. and io.deptid like "${orderQueryVo.houseId}%"
  743. </if>
  744. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  745. and iac.agreement_id = #{orderQueryVo.agreeId}
  746. </if>
  747. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  748. and io.orderno = #{orderQueryVo.taskNo}
  749. </if>
  750. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  751. and iac.product = #{orderQueryVo.riskCode}
  752. </if>
  753. <if test="orderQueryVo.leaderId != null and orderQueryVo.leaderId != ''">
  754. and u.leader_id = #{orderQueryVo.leaderId}
  755. </if>
  756. <if test="orderQueryVo.leaderName != null and orderQueryVo.leaderName != ''">
  757. and u.leader_name = #{orderQueryVo.leaderName}
  758. </if>
  759. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  760. and ((
  761. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  762. AND #{orderQueryVo.attachEndDateStr}
  763. )
  764. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  765. )
  766. </if>
  767. <choose>
  768. <when test="type==1">
  769. and dept.management_source=1
  770. </when>
  771. <when test="type==2">
  772. and dept.management_source=2
  773. </when>
  774. </choose>
  775. <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
  776. and iac.signing_time >= #{orderQueryVo.signStartDateStr} AND iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
  777. </if>
  778. <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
  779. and io.entry_status = #{orderQueryVo.entryStatus }
  780. </if>
  781. <if test="orderQueryVo.payStartDateStr != null and orderQueryVo.payEndDateStr != null">
  782. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{orderQueryVo.payStartDateStr} AND #{orderQueryVo.payEndDateStr}
  783. </if>
  784. <if test="orderQueryVo.auditStartDateStr != null and orderQueryVo.auditEndDateStr != null">
  785. and DATE_FORMAT(iac.underwriting_time, '%Y-%m-%d') between #{orderQueryVo.auditStartDateStr} AND #{orderQueryVo.auditEndDateStr}
  786. </if>
  787. <if test="orderQueryVo.updateStartDateStr != null and orderQueryVo.updateEndDateStr != null">
  788. and DATE_FORMAT( iac.update_status_time, '%Y-%m-%d') between #{orderQueryVo.updateStartDateStr} AND #{orderQueryVo.updateEndDateStr}
  789. </if>
  790. <if test="orderQueryVo.updateStatus != null and orderQueryVo.updateStatus != null">
  791. and iac.update_status = #{orderQueryVo.updateStatus}
  792. </if>
  793. <if test="orderQueryVo.partnerCompaniesId != null and orderQueryVo.partnerCompaniesId != null">
  794. and agree.partner_companies_id = #{orderQueryVo.partnerCompaniesId}
  795. </if>
  796. and (io.del_flag = 0)
  797. </where>
  798. group by io.orderno,
  799. iac.orderstatus,
  800. iac.productid,
  801. iac.product,
  802. iac.jq_start_date,
  803. iac.jq_end_date,
  804. iac.sy_start_date,
  805. iac.sy_end_date,
  806. iac.jqpremium,
  807. iac.sypremium,
  808. iac.jypremium,
  809. iac.taxamount,
  810. iac.id,
  811. d1.area_cname,
  812. d2.area_cname,
  813. d3.area_cname
  814. order by io.createtime desc
  815. </select>
  816. <select id="queryOrderList" parameterType="com.ydtech.modules.ins.model.InsOrdersExcelVo" resultMap="OrderExcelResultMap">
  817. select
  818. a.orderno,
  819. a.licenseno,
  820. a.frameno,
  821. a.carinfo,
  822. b.api_type,
  823. b.score,
  824. a.ownerinfo,
  825. b.jqpremium,
  826. b.jqpolicyno,
  827. b.sypremium,
  828. b.sypolicyno,
  829. b.jypremium,
  830. b.taxamount,
  831. b.jq_start_date,
  832. b.jq_end_date,
  833. b.sy_start_date,
  834. b.sy_end_date,
  835. b.score,
  836. b.jq_score,
  837. b.sy_score,
  838. b.loss_ration,
  839. b.jq_loss_ration,
  840. b.sy_loss_ration,
  841. b.score,
  842. b.inscompany,
  843. b.agreement_id,
  844. a.userid,
  845. a.username,
  846. a.applyinfo,
  847. a.insureinfo,
  848. b.kindinfo,
  849. b.pay_date,
  850. b.signing_time,
  851. b.cross_insurance,
  852. b.product,
  853. b.jq_renewal,
  854. CASE WHEN b.jq_renewal = '0'THEN '转保' WHEN b.jq_renewal = '1'THEN '续保' END AS jq_business_type,
  855. CASE WHEN b.sy_renewal = '0'THEN '转保' WHEN b.jq_renewal = '1'THEN '续保' END AS sy_business_type
  856. FROM ins_orders a LEFT JOIN ins_area_company b on a.orderno = b.orderno
  857. WHERE
  858. 1 = 1
  859. <if test="orderstatus != null and orderstatus != '' ">
  860. and b.orderstatus = #{orderstatus}
  861. </if>
  862. <if test="startDate != null ">
  863. and b.signing_time &gt;= #{startDate}
  864. </if>
  865. <if test="endDate != null ">
  866. and b.signing_time &lt;= #{endDate}
  867. </if>
  868. </select>
  869. <resultMap id="PolicyInsuranceReportMap" type="com.ydtech.modules.order.entity.vo.PolicyInsuranceReportResVo">
  870. <result property="insCompany" column="insCompany" jdbcType="VARCHAR"/>
  871. <result property="agreementName" column="agreementName" jdbcType="VARCHAR"/>
  872. <result property="policyNo" column="policyNo" jdbcType="VARCHAR"/>
  873. <result property="quoteDate" column="quoteDate" jdbcType="VARCHAR"/>
  874. <result property="policyStartDate" column="policyStartDate" jdbcType="VARCHAR"/>
  875. <result property="riskName" column="riskName" jdbcType="VARCHAR"/>
  876. <result property="sumPremium" column="sumPremium" jdbcType="DECIMAL"/>
  877. <result property="taxPremium" column="taxPremium" jdbcType="DECIMAL"/>
  878. <result property="taxLaterPremium" column="taxLaterPremium" jdbcType="DECIMAL"/>
  879. <result property="insuranceSubAmount" column="insuranceSubAmount" jdbcType="VARCHAR"/>
  880. <result property="licenseNo" column="licenseNo" jdbcType="VARCHAR"/>
  881. <result property="vehicleUse" column="vehicleUse" jdbcType="VARCHAR"/>
  882. <result property="powerType" column="powerType" jdbcType="VARCHAR"/>
  883. <result property="ciModelClass" column="ciModelClass" jdbcType="VARCHAR"/>
  884. <result property="limitLoad" column="limitLoad" jdbcType="VARCHAR"/>
  885. <result property="appliName" column="appliName" jdbcType="VARCHAR"/>
  886. <result property="insureName" column="insureName" jdbcType="VARCHAR"/>
  887. <result property="deptName" column="deptName" jdbcType="VARCHAR"/>
  888. <result property="userName" column="username" jdbcType="VARCHAR"/>
  889. </resultMap>
  890. <select id="getPolicyInsuranceReport" resultMap="PolicyInsuranceReportMap">
  891. /*交强数据*/
  892. SELECT a.`inscompany` AS insCompany,
  893. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  894. a.`jqpolicyno` AS policyNo,
  895. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  896. a.pay_date AS quoteDate,
  897. </if>
  898. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  899. a.inside_pay_time AS quoteDate,
  900. </if>
  901. a.`jq_start_date` AS policyStartDate,
  902. '交强险' AS riskName,
  903. a.`jqpremium` AS sumPremium,
  904. a.`taxamount` AS taxPremium,
  905. getCarShipLateFee(a.`id`) AS taxLaterPremium,
  906. '交强险 : 200000.00,' AS insuranceSubAmount,
  907. b.`licenseno` AS licenseNo,
  908. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  909. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  910. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  911. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  912. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  913. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  914. b.`deptname` AS deptName,
  915. b.`username` AS userName
  916. FROM ins_area_company a,ins_orders b WHERE a.`jqpolicyno` IS NOT NULL AND a.`jqpolicyno`!='' AND a.`agreement_id` IS NOT NULL
  917. AND a.`orderno`=b.`orderno`
  918. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  919. and b.deptid = #{policyReqVo.deptId}
  920. </if>
  921. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  922. and b.userid = #{policyReqVo.userId}
  923. </if>
  924. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  925. and b.username = #{policyReqVo.userName}
  926. </if>
  927. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  928. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  929. </if>
  930. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  931. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  932. </if>
  933. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  934. and b.productid = #{policyReqVo.productId}
  935. </if>
  936. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  937. and a.company_id = #{policyReqVo.insCompany}
  938. </if>
  939. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  940. and a.operatorid = #{policyReqVo.operatorId}
  941. </if>
  942. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  943. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  944. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  945. </if>
  946. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  947. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  948. </if>
  949. </if>
  950. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  951. and a.jq_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  952. </if>
  953. UNION ALL
  954. /*##商业数据*/
  955. SELECT a.`inscompany` AS insCompany,
  956. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  957. a.`sypolicyno` AS policyNo,
  958. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  959. a.pay_date AS quoteDate,
  960. </if>
  961. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  962. a.inside_pay_time AS quoteDate,
  963. </if>
  964. a.`sy_start_date` AS policyStartDate,
  965. '商业险' AS riskName,
  966. a.`sypremium` AS sumPremium,
  967. '' AS taxPremium,
  968. '' AS taxLaterPremium,
  969. getSyAmount(a.`orderno`) AS insuranceSubAmount,
  970. b.`licenseno` AS licenseNo,
  971. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  972. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  973. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  974. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  975. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  976. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  977. b.`deptname` AS deptName,
  978. b.`username` AS userName
  979. FROM ins_area_company a,ins_orders b WHERE a.`sypolicyno` IS NOT NULL AND a.`syapplyno`!='' AND a.`agreement_id` IS NOT NULL
  980. AND a.`orderno`=b.`orderno`
  981. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  982. and b.deptid = #{policyReqVo.deptId}
  983. </if>
  984. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  985. and b.userid = #{policyReqVo.userId}
  986. </if>
  987. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  988. and b.username = #{policyReqVo.userName}
  989. </if>
  990. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  991. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  992. </if>
  993. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  994. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  995. </if>
  996. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  997. and b.productid = #{policyReqVo.productId}
  998. </if>
  999. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  1000. and a.company_id = #{policyReqVo.insCompany}
  1001. </if>
  1002. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  1003. and a.operatorid = #{policyReqVo.operatorId}
  1004. </if>
  1005. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  1006. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  1007. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1008. </if>
  1009. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  1010. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1011. </if>
  1012. </if>
  1013. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  1014. and a.sy_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  1015. </if>
  1016. </select>
  1017. <select id="getPolicyInsuranceReportCount" resultType="Long">
  1018. select
  1019. count(1)
  1020. from (
  1021. /*交强数据*/
  1022. SELECT a.`inscompany` AS insCompany,
  1023. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  1024. a.`jqpolicyno` AS policyNo,
  1025. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  1026. a.pay_date AS quoteDate,
  1027. </if>
  1028. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  1029. a.inside_pay_time AS quoteDate,
  1030. </if>
  1031. a.`jq_start_date` AS policyStartDate,
  1032. '交强险' AS riskName,
  1033. a.`jqpremium` AS sumPremium,
  1034. a.`taxamount` AS taxPremium,
  1035. getCarShipLateFee(a.`id`) AS taxLaterPremium,
  1036. '交强险 : 200000.00,' AS insuranceSubAmount,
  1037. b.`licenseno` AS licenseNo,
  1038. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  1039. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  1040. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  1041. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  1042. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  1043. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  1044. b.`deptname` AS deptName,
  1045. b.`username` AS userName
  1046. FROM ins_area_company a,ins_orders b WHERE a.`jqpolicyno` IS NOT NULL AND a.`jqpolicyno`!='' AND a.`agreement_id` IS NOT NULL
  1047. AND a.`orderno`=b.`orderno`
  1048. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  1049. and b.deptid = #{policyReqVo.deptId}
  1050. </if>
  1051. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  1052. and b.userid = #{policyReqVo.userId}
  1053. </if>
  1054. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  1055. and b.username = #{policyReqVo.userName}
  1056. </if>
  1057. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  1058. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  1059. </if>
  1060. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  1061. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  1062. </if>
  1063. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  1064. and b.productid = #{policyReqVo.productId}
  1065. </if>
  1066. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  1067. and a.company_id = #{policyReqVo.insCompany}
  1068. </if>
  1069. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  1070. and a.operatorid = #{policyReqVo.operatorId}
  1071. </if>
  1072. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  1073. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  1074. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1075. </if>
  1076. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  1077. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1078. </if>
  1079. </if>
  1080. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  1081. and a.jq_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  1082. </if>
  1083. UNION ALL
  1084. /*##商业数据*/
  1085. SELECT a.`inscompany` AS insCompany,
  1086. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  1087. a.`sypolicyno` AS policyNo,
  1088. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  1089. a.pay_date AS quoteDate,
  1090. </if>
  1091. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  1092. a.inside_pay_time AS quoteDate,
  1093. </if>
  1094. a.`sy_start_date` AS policyStartDate,
  1095. '商业险' AS riskName,
  1096. a.`sypremium` AS sumPremium,
  1097. '' AS taxPremium,
  1098. '' AS taxLaterPremium,
  1099. getSyAmount(a.`orderno`) AS insuranceSubAmount,
  1100. b.`licenseno` AS licenseNo,
  1101. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  1102. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  1103. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  1104. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  1105. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  1106. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  1107. b.`deptname` AS deptName,
  1108. b.`username` AS userName
  1109. FROM ins_area_company a,ins_orders b WHERE a.`sypolicyno` IS NOT NULL AND a.`syapplyno`!='' AND a.`agreement_id` IS NOT NULL
  1110. AND a.`orderno`=b.`orderno`
  1111. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  1112. and b.deptid = #{policyReqVo.deptId}
  1113. </if>
  1114. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  1115. and b.userid = #{policyReqVo.userId}
  1116. </if>
  1117. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  1118. and b.username = #{policyReqVo.userName}
  1119. </if>
  1120. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  1121. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  1122. </if>
  1123. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  1124. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  1125. </if>
  1126. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  1127. and b.productid = #{policyReqVo.productId}
  1128. </if>
  1129. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  1130. and a.company_id = #{policyReqVo.insCompany}
  1131. </if>
  1132. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  1133. and a.operatorid = #{policyReqVo.operatorId}
  1134. </if>
  1135. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  1136. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  1137. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1138. </if>
  1139. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  1140. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  1141. </if>
  1142. </if>
  1143. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  1144. and a.sy_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  1145. </if>
  1146. ) as s
  1147. </select>
  1148. <update id="updateStatus">
  1149. update ins_orders set orderstatus = #{status} where orderno = #{orderno}
  1150. </update>
  1151. <select id="queryPageHospitalityOrder" resultMap="BaseResultMap">
  1152. select
  1153. io.*,
  1154. iac.orderno
  1155. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1156. ,eic.namesimple as partnerCompaniesName
  1157. </if>
  1158. from
  1159. ins_orders io
  1160. left JOIN
  1161. ins_area_company iac on iac.orderno = io.orderno
  1162. LEFT JOIN
  1163. ptl_agreement pa on pa.id = iac.agreement_id
  1164. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1165. LEFT JOIN
  1166. esm_ins_company eic on eic.id = pa.partner_companies_id
  1167. </if>
  1168. <where>
  1169. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1170. and io.orderno = #{orderQueryVo.orderNo}
  1171. </if>
  1172. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' ">
  1173. and io.deptid like "${orderQueryVo.deptId}%"
  1174. </if>
  1175. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1176. and io.orderstatus = #{orderQueryVo.orderStatus}
  1177. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1178. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1179. </if>
  1180. </if>
  1181. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1182. and io.frameno = #{orderQueryVo.frameNo}
  1183. </if>
  1184. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1185. and io.licenseno = #{orderQueryVo.licenseNo}
  1186. </if>
  1187. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1188. and io.insuredname = #{orderQueryVo.insuredName}
  1189. </if>
  1190. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1191. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1192. </if>
  1193. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1194. and iac.company_id = #{orderQueryVo.companyId}
  1195. </if>
  1196. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1197. and io.userid = #{orderQueryVo.userId}
  1198. </if>
  1199. and (io.del_flag IS NULL
  1200. or io.del_flag = 1)
  1201. </where>
  1202. group by io.orderno
  1203. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1204. ,eic.namesimple
  1205. </if>
  1206. order by io.createtime desc
  1207. </select>
  1208. <select id="queryPageHospitalityOrderCount" resultType="Long">
  1209. select
  1210. count(1)
  1211. from (
  1212. select
  1213. io.orderno
  1214. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1215. ,eic.namesimple as partnerCompaniesName
  1216. </if>
  1217. from
  1218. ins_orders io
  1219. left JOIN
  1220. ins_area_company iac on iac.orderno = io.orderno
  1221. LEFT JOIN
  1222. ptl_agreement pa on pa.id = iac.agreement_id
  1223. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1224. LEFT JOIN
  1225. esm_ins_company eic on eic.id = pa.partner_companies_id
  1226. </if>
  1227. <where>
  1228. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1229. and io.orderno = #{orderQueryVo.orderNo}
  1230. </if>
  1231. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' ">
  1232. and io.deptid like "${orderQueryVo.deptId}%"
  1233. </if>
  1234. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1235. and io.orderstatus = #{orderQueryVo.orderStatus}
  1236. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1237. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1238. </if>
  1239. </if>
  1240. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1241. and io.frameno = #{orderQueryVo.frameNo}
  1242. </if>
  1243. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1244. and io.licenseno = #{orderQueryVo.licenseNo}
  1245. </if>
  1246. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1247. and io.insuredname = #{orderQueryVo.insuredName}
  1248. </if>
  1249. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1250. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1251. </if>
  1252. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1253. and iac.company_id = #{orderQueryVo.companyId}
  1254. </if>
  1255. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1256. and io.userid = #{orderQueryVo.userId}
  1257. </if>
  1258. </where>
  1259. group by io.orderno
  1260. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  1261. ,eic.namesimple
  1262. </if>
  1263. order by io.createtime desc
  1264. ) as s
  1265. </select>
  1266. <select id="queryPageOrderByLinkType" resultMap="BaseResultMap">
  1267. select
  1268. io.orderno as orderno,
  1269. io.quoteno as quoteno,
  1270. iac.orderstatus as orderstatus,
  1271. io.carinfo as carinfo,
  1272. io.userid as userid,
  1273. io.username as username,
  1274. io.deptid as deptid,
  1275. io.deptname as deptname,
  1276. io.ownerinfo as ownerinfo,
  1277. io.applyinfo as applyinfo,
  1278. io.insureinfo as insureinfo,
  1279. io.agreeid as agreeid,
  1280. iac.productid as productid,
  1281. iac.product as product,
  1282. iac.createtime as createtime,
  1283. io.frameno as frameno,
  1284. io.licenseno as licenseno,
  1285. REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') as insuredname,
  1286. iac.jq_start_date as jqstartdate,
  1287. iac.jq_end_date as jqenddate,
  1288. iac.sy_start_date as systartdate,
  1289. iac.sy_end_date as syenddate,
  1290. iac.jqpremium as jqpremium,
  1291. iac.sypremium as sypremium,
  1292. iac.jypremium as jypremium,
  1293. iac.taxamount as taxamount,
  1294. io.risk as risk,
  1295. io.king as king,
  1296. io.vehicle_and_vessel_tax as vehicleAndVesselTax,
  1297. iac.id as subOrderId,
  1298. iac.underwriting_status as underwritingStatus,
  1299. iac.company_id as company_id,
  1300. iac.inscompany as ins_company,
  1301. agree.agreement_code as agreementCode,
  1302. agree.agreement_name as agreementName,
  1303. company.namesimple as partnerCompaniesName,
  1304. dept.province,
  1305. dept.city,
  1306. dept.area,
  1307. d1.area_cname as province_name,
  1308. d2.area_cname as city_name,
  1309. d3.area_cname as area_name,
  1310. concat(d1.area_cname,d2.area_cname,d3.area_cname) as area_info,
  1311. iac.api_type,
  1312. io.is_external,
  1313. u.leader_name,
  1314. u.leader_id,
  1315. CASE dept.management_source
  1316. WHEN '1' THEN '渠道'
  1317. WHEN '2' THEN '个代'
  1318. WHEN '3' THEN '电销'
  1319. ELSE '' END
  1320. AS managementSource,
  1321. io.entry_status as entryStatus,
  1322. iac.underwriting_time as underwritingTime,
  1323. iac.pay_date as payDate,
  1324. iac.update_status AS updateStatus,
  1325. iac.update_status_time AS updateStatusTime,
  1326. iac.signing_time as signingTime,
  1327. oou.NAME as operatorName
  1328. from
  1329. ins_area_company iac
  1330. left JOIN
  1331. ins_orders io on iac.orderno = io.orderno
  1332. left join
  1333. ptl_agreement agree on iac.agreement_id= agree.id
  1334. left join
  1335. esm_ins_company company on agree.partner_companies_id= company.id
  1336. LEFT JOIN
  1337. sys_dept dept ON dept.id = io.deptid
  1338. LEFT JOIN sys_dept pdept on dept.parent_id = pdept.id
  1339. LEFT JOIN sys_area d1 ON d1.area_code = pdept.province
  1340. LEFT JOIN sys_area d2 ON d2.area_code = pdept.city
  1341. LEFT JOIN sys_area d3 ON d3.area_code = pdept.area
  1342. LEFT JOIN
  1343. sys_user u on io.userid = u.id
  1344. LEFT JOIN sys_user oou ON io.operatorid = oou.id
  1345. <where>
  1346. <if test="agentUserIds != null and agentUserIds.size>0" >
  1347. AND (
  1348. (io.userid in
  1349. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  1350. #{item}
  1351. </foreach>
  1352. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  1353. <if test="deptIds != null and deptIds.size>0" >
  1354. AND (
  1355. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  1356. io.deptid like CONCAT('', #{item}, '%')
  1357. </foreach>
  1358. )
  1359. </if>
  1360. )
  1361. <if test="flag" >
  1362. OR iac.operator_id = #{orderQueryVo.userId}
  1363. </if>
  1364. )
  1365. </if>
  1366. <if test="agreeIds != null and agreeIds.size>0">
  1367. AND (
  1368. (iac.company_id in
  1369. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  1370. #{item}
  1371. </foreach>
  1372. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  1373. <if test="flag" >
  1374. OR iac.operator_id = #{orderQueryVo.userId}
  1375. </if>
  1376. )
  1377. </if>
  1378. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1379. and iac.id = #{orderQueryVo.orderNo}
  1380. </if>
  1381. <if test="orderQueryVo.managementSource != null and orderQueryVo.managementSource.size > 0">
  1382. and dept.management_source in
  1383. <foreach item="source" collection="orderQueryVo.managementSource" open="(" separator="," close=")">
  1384. #{source}
  1385. </foreach>
  1386. </if>
  1387. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1388. and io.deptid like "${orderQueryVo.deptId}%"
  1389. </if>
  1390. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1391. and iac.orderstatus= #{orderQueryVo.orderStatus}
  1392. </if>
  1393. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1394. and io.frameno = #{orderQueryVo.frameNo}
  1395. </if>
  1396. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1397. and io.licenseno = #{orderQueryVo.licenseNo}
  1398. </if>
  1399. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1400. and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
  1401. </if>
  1402. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  1403. and iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND iac.createtime <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
  1404. </if>
  1405. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1406. and iac.company_id = #{orderQueryVo.companyId}
  1407. </if>
  1408. <if test="orderQueryVo.operatorId != null and orderQueryVo.operatorId != ''">
  1409. and io.userid = #{orderQueryVo.operatorId}
  1410. </if>
  1411. <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
  1412. and io.username = #{orderQueryVo.operatorName}
  1413. </if>
  1414. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1415. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1416. </if>
  1417. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  1418. and io.deptid like "${orderQueryVo.provinceId}%"
  1419. </if>
  1420. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  1421. and io.deptid like "${orderQueryVo.cityId}%"
  1422. </if>
  1423. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  1424. and io.deptid like "${orderQueryVo.countyId}%"
  1425. </if>
  1426. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  1427. and io.deptid like "${orderQueryVo.houseId}%"
  1428. </if>
  1429. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  1430. and iac.agreement_id = #{orderQueryVo.agreeId}
  1431. </if>
  1432. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  1433. and io.orderno = #{orderQueryVo.taskNo}
  1434. </if>
  1435. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1436. and iac.product = #{orderQueryVo.riskCode}
  1437. </if>
  1438. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1439. and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
  1440. </if>
  1441. <if test="orderQueryVo.leaderId != null and orderQueryVo.leaderId != ''">
  1442. and u.leader_id = #{orderQueryVo.leaderId}
  1443. </if>
  1444. <if test="orderQueryVo.leaderName != null and orderQueryVo.leaderName != ''">
  1445. and u.leader_name = #{orderQueryVo.leaderName}
  1446. </if>
  1447. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  1448. and ((
  1449. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  1450. AND #{orderQueryVo.attachEndDateStr}
  1451. )
  1452. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  1453. )
  1454. </if>
  1455. <choose>
  1456. <when test="type==1">
  1457. and dept.management_source=1
  1458. </when>
  1459. <when test="type==2">
  1460. and dept.management_source=2
  1461. </when>
  1462. </choose>
  1463. <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
  1464. and iac.signing_time >= #{orderQueryVo.signStartDateStr} AND iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
  1465. </if>
  1466. <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
  1467. and io.entry_status = #{orderQueryVo.entryStatus }
  1468. </if>
  1469. <if test="orderQueryVo.payStartDateStr != null and orderQueryVo.payEndDateStr != null">
  1470. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{orderQueryVo.payStartDateStr} AND #{orderQueryVo.payEndDateStr}
  1471. </if>
  1472. <if test="orderQueryVo.auditStartDateStr != null and orderQueryVo.auditEndDateStr != null">
  1473. and DATE_FORMAT(iac.underwriting_time, '%Y-%m-%d') between #{orderQueryVo.auditStartDateStr} AND #{orderQueryVo.auditEndDateStr}
  1474. </if>
  1475. <if test="orderQueryVo.updateStartDateStr != null and orderQueryVo.updateEndDateStr != null">
  1476. and DATE_FORMAT( iac.update_status_time, '%Y-%m-%d') between #{orderQueryVo.updateStartDateStr} AND #{orderQueryVo.updateEndDateStr}
  1477. </if>
  1478. <if test="orderQueryVo.updateStatus != null and orderQueryVo.updateStatus != null">
  1479. and iac.update_status = #{orderQueryVo.updateStatus}
  1480. </if>
  1481. <if test="orderQueryVo.partnerCompaniesId != null and orderQueryVo.partnerCompaniesId != null">
  1482. and agree.partner_companies_id = #{orderQueryVo.partnerCompaniesId}
  1483. </if>
  1484. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1485. </where>
  1486. order by io.createtime desc
  1487. </select>
  1488. <select id="queryPageOrderByLinkTypeCount" resultType="Long">
  1489. select
  1490. count(1)
  1491. from (
  1492. select
  1493. (0)
  1494. from
  1495. ins_area_company iac
  1496. left JOIN
  1497. ins_orders io on iac.orderno = io.orderno
  1498. LEFT JOIN
  1499. sys_dept dept ON dept.id = io.deptid
  1500. LEFT JOIN
  1501. sys_user u on io.userid = u.id
  1502. left join
  1503. ptl_agreement agree on iac.agreement_id= agree.id
  1504. left join
  1505. esm_ins_company company on agree.partner_companies_id= company.id
  1506. <where>
  1507. <if test="agentUserIds != null and agentUserIds.size>0" >
  1508. AND (
  1509. (io.userid in
  1510. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  1511. #{item}
  1512. </foreach>
  1513. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  1514. <if test="deptIds != null and deptIds.size>0" >
  1515. AND (
  1516. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  1517. io.deptid like CONCAT('', #{item}, '%')
  1518. </foreach>
  1519. )
  1520. </if>
  1521. )
  1522. <if test="flag" >
  1523. OR iac.operator_id = #{orderQueryVo.userId}
  1524. </if>
  1525. )
  1526. </if>
  1527. <if test="agreeIds != null and agreeIds.size>0">
  1528. AND (
  1529. (iac.company_id in
  1530. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  1531. #{item}
  1532. </foreach>
  1533. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  1534. <if test="flag" >
  1535. OR iac.operator_id = #{orderQueryVo.userId}
  1536. </if>
  1537. )
  1538. </if>
  1539. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1540. and iac.id = #{orderQueryVo.orderNo}
  1541. </if>
  1542. <if test="orderQueryVo.managementSource != null and orderQueryVo.managementSource.size > 0">
  1543. and dept.management_source in
  1544. <foreach item="source" collection="orderQueryVo.managementSource" open="(" separator="," close=")">
  1545. #{source}
  1546. </foreach>
  1547. </if>
  1548. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1549. and io.deptid like "${orderQueryVo.deptId}%"
  1550. </if>
  1551. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1552. and iac.orderstatus= #{orderQueryVo.orderStatus}
  1553. </if>
  1554. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1555. and io.frameno = #{orderQueryVo.frameNo}
  1556. </if>
  1557. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1558. and io.licenseno = #{orderQueryVo.licenseNo}
  1559. </if>
  1560. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1561. and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
  1562. </if>
  1563. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  1564. and iac.createtime >= #{orderQueryVo.quoteStartDateStr} AND iac.createtime <![CDATA[ <= ]]> #{orderQueryVo.quoteEndDateStr}
  1565. </if>
  1566. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1567. and iac.company_id = #{orderQueryVo.companyId}
  1568. </if>
  1569. <if test="orderQueryVo.operatorId != null and orderQueryVo.operatorId != ''">
  1570. and io.userid = #{orderQueryVo.operatorId}
  1571. </if>
  1572. <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
  1573. and io.username = #{orderQueryVo.operatorName}
  1574. </if>
  1575. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1576. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1577. </if>
  1578. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  1579. and io.deptid like "${orderQueryVo.provinceId}%"
  1580. </if>
  1581. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  1582. and io.deptid like "${orderQueryVo.cityId}%"
  1583. </if>
  1584. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  1585. and io.deptid like "${orderQueryVo.countyId}%"
  1586. </if>
  1587. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  1588. and io.deptid like "${orderQueryVo.houseId}%"
  1589. </if>
  1590. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  1591. and iac.agreement_id = #{orderQueryVo.agreeId}
  1592. </if>
  1593. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  1594. and io.orderno = #{orderQueryVo.taskNo}
  1595. </if>
  1596. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1597. and iac.product = #{orderQueryVo.riskCode}
  1598. </if>
  1599. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1600. and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
  1601. </if>
  1602. <if test="orderQueryVo.leaderId != null and orderQueryVo.leaderId != ''">
  1603. and u.leader_id = #{orderQueryVo.leaderId}
  1604. </if>
  1605. <if test="orderQueryVo.leaderName != null and orderQueryVo.leaderName != ''">
  1606. and u.leader_name = #{orderQueryVo.leaderName}
  1607. </if>
  1608. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  1609. and ((
  1610. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  1611. AND #{orderQueryVo.attachEndDateStr}
  1612. )
  1613. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  1614. )
  1615. </if>
  1616. <choose>
  1617. <when test="type==1">
  1618. and dept.management_source=1
  1619. </when>
  1620. <when test="type==2">
  1621. and dept.management_source=2
  1622. </when>
  1623. </choose>
  1624. <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
  1625. and iac.signing_time >= #{orderQueryVo.signStartDateStr} AND iac.signing_time <![CDATA[ <= ]]> #{orderQueryVo.signEndDateStr}
  1626. </if>
  1627. <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
  1628. and io.entry_status = #{orderQueryVo.entryStatus }
  1629. </if>
  1630. <if test="orderQueryVo.payStartDateStr != null and orderQueryVo.payEndDateStr != null">
  1631. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{orderQueryVo.payStartDateStr} AND #{orderQueryVo.payEndDateStr}
  1632. </if>
  1633. <if test="orderQueryVo.auditStartDateStr != null and orderQueryVo.auditEndDateStr != null">
  1634. and DATE_FORMAT(iac.underwriting_time, '%Y-%m-%d') between #{orderQueryVo.auditStartDateStr} AND #{orderQueryVo.auditEndDateStr}
  1635. </if>
  1636. <if test="orderQueryVo.updateStartDateStr != null and orderQueryVo.updateEndDateStr != null">
  1637. and DATE_FORMAT( iac.update_status_time, '%Y-%m-%d') between #{orderQueryVo.updateStartDateStr} AND #{orderQueryVo.updateEndDateStr}
  1638. </if>
  1639. <if test="orderQueryVo.updateStatus != null and orderQueryVo.updateStatus != null">
  1640. and iac.update_status = #{orderQueryVo.updateStatus}
  1641. </if>
  1642. <if test="orderQueryVo.partnerCompaniesId != null and orderQueryVo.partnerCompaniesId != null">
  1643. and agree.partner_companies_id = #{orderQueryVo.partnerCompaniesId}
  1644. </if>
  1645. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1646. </where>
  1647. ) as s
  1648. </select>
  1649. <select id="queryPageSubOrders" resultMap="BaseResultMap">
  1650. select
  1651. io.*,
  1652. iac.id as subOrderId
  1653. from
  1654. ins_area_company iac
  1655. left JOIN
  1656. ins_orders io on iac.orderno = io.orderno
  1657. <where>
  1658. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1659. and io.userid = #{orderQueryVo.userid}
  1660. </if>
  1661. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1662. and io.orderno = #{orderQueryVo.orderNo}
  1663. </if>
  1664. <if test="orderQueryVo.quoteNo != null and orderQueryVo.quoteNo != ''">
  1665. and io.quoteno = #{orderQueryVo.quoteNo}
  1666. </if>
  1667. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1668. and io.deptid like "${orderQueryVo.deptId}%"
  1669. </if>
  1670. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1671. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1672. </if>
  1673. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1674. and io.frameno = #{orderQueryVo.frameNo}
  1675. </if>
  1676. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1677. and io.licenseno = #{orderQueryVo.licenseNo}
  1678. </if>
  1679. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1680. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1681. </if>
  1682. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1683. and io.insuredname = #{orderQueryVo.insuredName}
  1684. </if>
  1685. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1686. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1687. </if>
  1688. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1689. and iac.company_id = #{orderQueryVo.companyId}
  1690. </if>
  1691. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1692. and iac.product = #{orderQueryVo.riskCode}
  1693. </if>
  1694. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1695. and IFNULL( io.agreeid, '' ) = #{orderQueryVo.auditId}
  1696. </if>
  1697. <if test="orderQueryVo.policyStartDate != null and orderQueryVo.policyEndDate != ''">
  1698. and ((
  1699. io.jqstartdate BETWEEN #{orderQueryVo.policyStartDate}
  1700. AND #{orderQueryVo.policyEndDate}
  1701. )
  1702. OR ( io.systartdate BETWEEN #{orderQueryVo.policyStartDate} AND #{orderQueryVo.policyEndDate} )
  1703. )
  1704. </if>
  1705. </where>
  1706. group by iac.id
  1707. order by io.createtime desc
  1708. </select>
  1709. <select id="queryPageSubOrdersCount" resultType="Long">
  1710. select
  1711. count(1)
  1712. from (
  1713. select
  1714. io.*
  1715. from
  1716. ins_area_company iac
  1717. left JOIN
  1718. ins_orders io on iac.orderno = io.orderno
  1719. <where>
  1720. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1721. and io.userid = #{orderQueryVo.userid}
  1722. </if>
  1723. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1724. and io.orderno = #{orderQueryVo.orderNo}
  1725. </if>
  1726. <if test="orderQueryVo.quoteNo != null and orderQueryVo.quoteNo != ''">
  1727. and io.quoteno = #{orderQueryVo.quoteNo}
  1728. </if>
  1729. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1730. and io.deptid like "${orderQueryVo.deptId}%"
  1731. </if>
  1732. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1733. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1734. </if>
  1735. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1736. and io.frameno = #{orderQueryVo.frameNo}
  1737. </if>
  1738. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1739. and io.licenseno = #{orderQueryVo.licenseNo}
  1740. </if>
  1741. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1742. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1743. </if>
  1744. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1745. and io.insuredname = #{orderQueryVo.insuredName}
  1746. </if>
  1747. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1748. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1749. </if>
  1750. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1751. and iac.company_id = #{orderQueryVo.companyId}
  1752. </if>
  1753. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1754. and iac.product = #{orderQueryVo.riskCode}
  1755. </if>
  1756. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1757. and IFNULL( io.agreeid, '' ) = #{orderQueryVo.auditId}
  1758. </if>
  1759. <if test="orderQueryVo.policyStartDate != null and orderQueryVo.policyEndDate != ''">
  1760. and ((
  1761. io.jqstartdate BETWEEN #{orderQueryVo.policyStartDate}
  1762. AND #{orderQueryVo.policyEndDate}
  1763. )
  1764. OR ( io.systartdate BETWEEN #{orderQueryVo.policyStartDate} AND #{orderQueryVo.policyEndDate} )
  1765. )
  1766. </if>
  1767. </where>
  1768. group by iac.id
  1769. ) as s
  1770. </select>
  1771. <select id="selectEntityByinsOrderNo" resultMap="OrderResultMap">
  1772. select o.orderno,
  1773. o.quoteno,
  1774. o.frameno,
  1775. o.licenseno,
  1776. iac.jq_start_date as jqstartdate,
  1777. iac.jq_end_date as jqenddate,
  1778. iac.sy_start_date as systartdate,
  1779. iac.sy_end_date as syenddate,
  1780. iac.id,
  1781. iac.company_id,
  1782. iac.reptxt,
  1783. iac.orderstatus,
  1784. iac.inscompany,
  1785. iac.jqapplyno,
  1786. iac.jqpolicyno,
  1787. iac.syapplyno,
  1788. iac.sypolicyno,
  1789. iac.riskinfo,
  1790. iac.kindinfo,
  1791. iac.jqpremium,
  1792. iac.sypremium,
  1793. iac.jypremium,
  1794. iac.taxamount,
  1795. iac.sumpremium,
  1796. iac.jqdiscountrate,
  1797. iac.sydiscountrate,
  1798. iac.feerate,
  1799. iac.disrate,
  1800. iac.auditid,
  1801. iac.auditname,
  1802. iac.audittime,
  1803. iac.auditopinion,
  1804. iac.jqappoint,
  1805. iac.syappoint,
  1806. iac.createtime,
  1807. iac.payment_link,
  1808. iac.accident_info,
  1809. iac.tax_arrears,
  1810. iac.cross_insurance,
  1811. iac.ubi_predicted_info_score
  1812. from ins_area_company iac
  1813. join ins_orders as o on o.orderno = iac.orderno
  1814. where
  1815. iac.id = #{insOrderNo}
  1816. <if test="timeFiltering != null and timeFiltering != ''">
  1817. and DATE_FORMAT(iac.signing_time, '%Y-%m') = #{timeFiltering}
  1818. </if>
  1819. </select>
  1820. <select id="getExpirationInsureCount" resultType="Integer">
  1821. SELECT
  1822. count( b.orderno ) AS count
  1823. FROM
  1824. ins_orders a
  1825. left join
  1826. ins_area_company b
  1827. on a.orderno = b.orderno
  1828. WHERE
  1829. <if test="isJq == 1">
  1830. jqenddate BETWEEN #{startDate} AND #{endDate}
  1831. </if>
  1832. <if test="isJq == 2">
  1833. syenddate BETWEEN #{startDate} AND #{endDate}
  1834. </if>
  1835. AND a.orderstatus = 3
  1836. AND b.orderstatus = 3
  1837. <if test="param != null and param != ''">
  1838. AND (a.licenseno = #{param} or a.ins_company = #{param})
  1839. </if>
  1840. <if test="userId != null and userId != ''">
  1841. AND a.userid = #{userId}
  1842. </if>
  1843. </select>
  1844. <select id="getExpirationInsure" resultType="com.ydtech.modules.order.entity.vo.OrderExpirationVo">
  1845. SELECT
  1846. a.ins_company,
  1847. b.id as orderno,
  1848. b.jq_end_date,
  1849. b.sy_end_date,
  1850. b.productid,
  1851. b.product,
  1852. a.licenseno,
  1853. case when b.jq_end_date is not null then DATEDIFF( b.jq_end_date,NOW() ) else null end AS jqDiff,
  1854. case when b.sy_end_date is not null then DATEDIFF( b.sy_end_date,NOW() ) else null end AS syDiff
  1855. FROM ins_orders a,ins_area_company b
  1856. WHERE a.orderno = b.orderno
  1857. AND (b.jq_end_date BETWEEN #{order.jqStartDate} AND #{order.jqEndDate} or b.sy_end_date BETWEEN #{order.syStartDate} AND #{order.syEndDate})
  1858. AND b.orderstatus = 3
  1859. <if test="order.param != null and order.param != ''">
  1860. AND (a.licenseno = #{order.param} or a.ins_company = #{order.param})
  1861. </if>
  1862. <if test="order.userid != null and order.userid != ''">
  1863. AND a.userid = #{order.userid}
  1864. </if>
  1865. ORDER BY least(IFNULL(jqDiff, 9999999) , IFNULL(syDiff, 9999999)) asc
  1866. </select>
  1867. <select id="getCarBusinessDetailList" resultType="com.ydtech.modules.order.entity.vo.CarBusinessDetailVo">
  1868. SELECT
  1869. io.username,
  1870. iac.signing_time as sign_date,
  1871. io.licenseno,
  1872. JSON_UNQUOTE(json_extract(io.applyinfo, '$.name')) as applyname,
  1873. io.product,
  1874. io.ins_company as inscompany,
  1875. iac.jqpremium,
  1876. iac.sypremium,
  1877. iac.jypremium,
  1878. iac.taxamount,
  1879. ifo.jq_costs_export_proportion+ifo.jq_export_other_costs_proportion as jq_export_proportion,
  1880. ifo.sy_costs_export_proportion+ifo.sy_export_other_costs_proportion as sy_export_proportion,
  1881. ifo.no_costs_export_proportion+ifo.no_export_other_costs_proportion as no_export_proportion,
  1882. ifo.jq_export_supervise_costs_premiums + ifo.sy_export_supervise_costs_premiums + ifo.no_export_supervise_costs_premiums + ifo.jq_export_other_costs_premiums + ifo.sy_export_other_costs_premiums + ifo.no_export_other_costs_premiums as settlement,
  1883. CASE ifa.auditstatus
  1884. WHEN 1 THEN
  1885. '已审核'
  1886. ELSE
  1887. '未审核'
  1888. END as audittype,
  1889. ifa.audittime as audit_date
  1890. FROM
  1891. ins_orders io
  1892. LEFT JOIN ins_area_company iac ON io.orderno = iac.orderno
  1893. LEFT JOIN ins_fee_order_new ifo ON iac.id = ifo.ins_order_no
  1894. left join ins_fee_audit ifa on ifo.ins_order_no = ifa.ins_order_no
  1895. WHERE
  1896. io.userid = #{userId}
  1897. AND io.orderstatus = 3
  1898. AND iac.orderstatus = 3
  1899. AND iac.signing_time BETWEEN #{param.signStartDate} and #{param.signEndDate}
  1900. </select>
  1901. <select id="getRevenueExpenditureDetailList" resultType="com.ydtech.modules.order.entity.vo.RevenueExpenditureDetailVo">
  1902. SELECT
  1903. sua.create_time,
  1904. io.licenseno,
  1905. sua.amount,
  1906. sua.business_eegments_type,
  1907. sua.documentary,
  1908. sua.property
  1909. FROM
  1910. sys_user_account_history sua
  1911. left join ins_area_company iac on sua.suborder = iac.id
  1912. left join ins_orders io on iac.orderno = io.orderno
  1913. WHERE
  1914. (sua.property != 1 and sua.property != 2)
  1915. AND
  1916. user_id = #{userId}
  1917. AND
  1918. sua.create_time BETWEEN #{param.signStartDate} and #{param.signEndDate}
  1919. </select>
  1920. <select id="getAuditExportList" resultType="com.ydtech.modules.order.entity.vo.AuditExportVo">
  1921. SELECT
  1922. iac.company_id,
  1923. iac.api_type,
  1924. iac.cross_insurance,
  1925. io.username,
  1926. iac.signing_time,
  1927. io.licenseno,
  1928. JSON_UNQUOTE(json_extract(io.applyinfo, '$.name')) as applyname,
  1929. io.ins_company,
  1930. io.product,
  1931. eic.namesimple,
  1932. iac.jqapplyno,
  1933. iac.syapplyno,
  1934. iac.cross_insurance,
  1935. iac.jqpremium,
  1936. iac.sypremium,
  1937. iac.jypremium,
  1938. iac.taxamount,
  1939. ifo.jq_costs_export_proportion + ifo.jq_export_other_costs_proportion AS jq_export_proportion,
  1940. ifo.sy_costs_export_proportion+ifo.sy_export_other_costs_proportion as sy_export_proportion,
  1941. ifo.no_costs_export_proportion+ifo.no_export_other_costs_proportion as no_export_proportion,
  1942. ifo.jq_export_supervise_costs_premiums + ifo.sy_export_supervise_costs_premiums + ifo.no_export_supervise_costs_premiums + ifo.jq_export_other_costs_premiums + ifo.sy_export_other_costs_premiums + ifo.no_export_other_costs_premiums as settlement,
  1943. ifo.jq_supervise_costs_proportion + ifo.jq_other_costs_proportion as jq_entrance_proportion,
  1944. ifo.sy_supervise_costs_proportion + ifo.sy_other_costs_proportion as sy_entrance_proportion,
  1945. ifo.no_supervise_costs_proportion + ifo.no_other_costs_proportion as no_entrance_proportion,
  1946. ifo.jq_supervise_costs_premiums + ifo.jq_other_costs_premiums + ifo.sy_supervise_costs_premiums + ifo.sy_other_costs_premiums + ifo.no_supervise_costs_premiums + ifo.no_other_costs_premiums as receivable,
  1947. ifo.jq_dept_premiums_level_1 + ifo.sy_dept_premiums_level_1 + ifo.no_dept_premiums_level_1 as dept_premiums_level_1,
  1948. ifo.jq_dept_premiums_level_2 + ifo.sy_dept_premiums_level_2 + ifo.no_dept_premiums_level_2 as dept_premiums_level_2,
  1949. ifo.jq_dept_premiums_level_3 + ifo.sy_dept_premiums_level_3 + ifo.no_dept_premiums_level_3 as dept_premiums_level_3,
  1950. ifo.jq_dept_premiums_level_4 + ifo.sy_dept_premiums_level_4 + ifo.no_dept_premiums_level_4 as dept_premiums_level_4,
  1951. ifo.jq_dept_premiums_level_5 + ifo.sy_dept_premiums_level_5 + ifo.no_dept_premiums_level_5 as dept_premiums_level_5,
  1952. ifo.first_level_user_id,
  1953. ifo.two_level_user_id,
  1954. ifo.three_level_user_id,
  1955. ifo.first_detail_premiums,
  1956. ifo.second_detail_premiums,
  1957. ifo.third_detail_premiums,
  1958. ifo.jq_profit_margin_premiums,
  1959. ifo.sy_profit_margin_premiums,
  1960. ifo.no_profit_margin_premiums,
  1961. io.is_external,
  1962. pa.agreement_code,
  1963. pa.job_description,
  1964. pa.docking_person,
  1965. pa.docking_phone
  1966. FROM
  1967. ins_fee_order_new ifo
  1968. LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
  1969. left join ins_area_company iac on ifa.ins_order_no = iac.id
  1970. left join ins_orders io on iac.orderno = io.orderno
  1971. left join ptl_agreement pa on iac.agreement_id = pa.id
  1972. left join esm_ins_company eic on pa.partner_companies_id = eic.id
  1973. WHERE
  1974. iac.signing_time between #{param.signStartDate} and #{param.signEndDate}
  1975. <if test="param.audit != null and param.audit != ''">
  1976. AND
  1977. ifa.auditstatus = #{param.audit}
  1978. AND
  1979. iac.orderstatus = 3
  1980. GROUP BY
  1981. io.orderno,
  1982. iac.api_type,
  1983. iac.cross_insurance,
  1984. iac.signing_time,
  1985. eic.namesimple,
  1986. iac.jqapplyno,
  1987. iac.syapplyno,
  1988. iac.jqpremium,
  1989. iac.company_id,
  1990. iac.sypremium,
  1991. iac.jypremium,
  1992. iac.taxamount,
  1993. ifo.jq_costs_export_proportion,
  1994. ifo.jq_export_other_costs_proportion,
  1995. ifo.sy_costs_export_proportion,
  1996. ifo.sy_export_other_costs_proportion,
  1997. ifo.no_costs_export_proportion,
  1998. ifo.no_export_other_costs_proportion,
  1999. ifo.jq_export_supervise_costs_premiums,
  2000. ifo.sy_export_supervise_costs_premiums,
  2001. ifo.no_export_supervise_costs_premiums,
  2002. ifo.jq_export_other_costs_premiums,
  2003. ifo.sy_export_other_costs_premiums,
  2004. ifo.no_export_other_costs_premiums,
  2005. ifo.jq_supervise_costs_proportion,
  2006. ifo.jq_other_costs_proportion,
  2007. ifo.sy_supervise_costs_proportion,
  2008. ifo.sy_other_costs_proportion,
  2009. ifo.no_supervise_costs_proportion,
  2010. ifo.no_other_costs_proportion,
  2011. ifo.jq_supervise_costs_premiums,
  2012. ifo.jq_other_costs_premiums,
  2013. ifo.sy_supervise_costs_premiums,
  2014. ifo.sy_other_costs_premiums,
  2015. ifo.no_supervise_costs_premiums,
  2016. ifo.no_other_costs_premiums,
  2017. ifo.jq_dept_premiums_level_1,
  2018. ifo.jq_dept_premiums_level_2,
  2019. ifo.jq_dept_premiums_level_3,
  2020. ifo.jq_dept_premiums_level_4,
  2021. ifo.jq_dept_premiums_level_5,
  2022. ifo.sy_dept_premiums_level_1,
  2023. ifo.sy_dept_premiums_level_2,
  2024. ifo.sy_dept_premiums_level_3,
  2025. ifo.sy_dept_premiums_level_4,
  2026. ifo.sy_dept_premiums_level_5,
  2027. ifo.no_dept_premiums_level_1,
  2028. ifo.no_dept_premiums_level_2,
  2029. ifo.no_dept_premiums_level_3,
  2030. ifo.no_dept_premiums_level_4,
  2031. ifo.no_dept_premiums_level_5,
  2032. ifo.first_level_user_id,
  2033. ifo.two_level_user_id,
  2034. ifo.three_level_user_id,
  2035. ifo.first_detail_premiums,
  2036. ifo.second_detail_premiums,
  2037. ifo.third_detail_premiums,
  2038. ifo.jq_profit_margin_premiums,
  2039. ifo.sy_profit_margin_premiums,
  2040. ifo.no_profit_margin_premiums,
  2041. pa.agreement_code,
  2042. pa.job_description,
  2043. pa.docking_person,
  2044. pa.docking_phone
  2045. </if>
  2046. </select>
  2047. <select id="getExternalOrder" resultType="com.ydtech.modules.order.entity.InsOrders">
  2048. SELECT
  2049. *
  2050. FROM
  2051. ins_orders io
  2052. LEFT JOIN ins_area_company iac ON io.orderno = iac.orderno
  2053. WHERE
  2054. io.del_flag IS NULL
  2055. <if test="param.jqpolicyno != null and param.jqpolicyno != ''">
  2056. AND iac.jqpolicyno = #{param.jqpolicyno}
  2057. </if>
  2058. <if test="param.sypolicyno != null and param.sypolicyno != ''">
  2059. AND iac.sypolicyno = #{param.sypolicyno}
  2060. </if>
  2061. </select>
  2062. <resultMap id="hxOrderCountMap" type="com.ydtech.modules.order.entity.vo.QueryHxOrdersCountVo">
  2063. <result property="operatorId" column="operatorid" jdbcType="VARCHAR"/>
  2064. <result property="name" column="name" jdbcType="VARCHAR"/>
  2065. <result property="orderStatus0" column="orderstatus0" jdbcType="VARCHAR"/>
  2066. <result property="orderStatus1" column="orderstatus1" jdbcType="VARCHAR"/>
  2067. <result property="orderStatus2" column="orderstatus2" jdbcType="VARCHAR"/>
  2068. <result property="orderStatus3" column="orderstatus3" jdbcType="VARCHAR"/>
  2069. <result property="orderStatus4" column="orderstatus4" jdbcType="VARCHAR"/>
  2070. <result property="createTime" column="createtime" jdbcType="TIMESTAMP"/>
  2071. <result property="createTimeStart" column="createTimeStart" jdbcType="VARCHAR"/>
  2072. <result property="createTimeEnd" column="createTimeEnd" jdbcType="VARCHAR"/>
  2073. <result property="count" column="count1" jdbcType="VARCHAR"/>
  2074. </resultMap>
  2075. <resultMap id="TelemarketingAuditOrderMap" type="com.ydtech.modules.order.entity.dto.TelemarketingAuditOrderDTO">
  2076. <result property="id" column="id" jdbcType="VARCHAR"/>
  2077. <result property="orderNo" column="orderno" jdbcType="VARCHAR"/>
  2078. <result property="userid" column="userid" jdbcType="VARCHAR"/>
  2079. <result property="username" column="username" jdbcType="VARCHAR"/>
  2080. <result property="product" column="product" jdbcType="VARCHAR"/>
  2081. <result property="licenseNo" column="licenseno" jdbcType="VARCHAR"/>
  2082. <result property="orderStatus" column="orderstatus" jdbcType="VARCHAR"/>
  2083. <result property="insuredName" column="insuredname" jdbcType="VARCHAR"/>
  2084. <result property="createTime" column="createtime" jdbcType="VARCHAR"/>
  2085. <result property="auditStatus" column="auditstatus" jdbcType="VARCHAR"/>
  2086. <result property="insCompany" column="insCompany" jdbcType="VARCHAR"/>
  2087. </resultMap>
  2088. <select id="queryHxOrdersCount" resultMap="hxOrderCountMap">
  2089. select
  2090. operatorid,
  2091. su.name,
  2092. count(*) as count1,
  2093. SUM(CASE WHEN orderstatus = '1' THEN 1 ELSE 0 END) AS orderstatus1,
  2094. SUM(CASE WHEN orderstatus = '2' THEN 1 ELSE 0 END) AS orderstatus2,
  2095. SUM(CASE WHEN orderstatus = '3' THEN 1 ELSE 0 END) AS orderstatus3,
  2096. SUM(CASE WHEN orderstatus = '4' THEN 1 ELSE 0 END) AS orderstatus4,
  2097. SUM(CASE WHEN orderstatus = '0' THEN 1 ELSE 0 END) AS orderstatus0
  2098. from
  2099. ins_orders
  2100. LEFT JOIN
  2101. sys_user su ON operatorid = su.id
  2102. WHERE operatorid IS NOT NULL
  2103. AND operatorid NOT LIKE '%M%'
  2104. <if test="queryHxOrdersCountVo.ids != null and !queryHxOrdersCountVo.ids.isEmpty()">
  2105. and operatorid IN
  2106. <foreach item="item" index="index" collection="queryHxOrdersCountVo.ids" open="(" separator="," close=")">
  2107. #{item}
  2108. </foreach>
  2109. </if>
  2110. <if test="queryHxOrdersCountVo.operatorId !=null and queryHxOrdersCountVo.operatorId !=''">
  2111. and operatorid =#{queryHxOrdersCountVo.operatorId}
  2112. </if>
  2113. <if test="queryHxOrdersCountVo.name !=null and queryHxOrdersCountVo.name !=''">
  2114. and su.name =#{queryHxOrdersCountVo.name}
  2115. </if>
  2116. <if test="queryHxOrdersCountVo.createTimeStart != null and queryHxOrdersCountVo.createTimeStart != ''">
  2117. and createtime &gt;= #{queryHxOrdersCountVo.createTimeStart}
  2118. </if>
  2119. <if test="queryHxOrdersCountVo.createTimeEnd != null and queryHxOrdersCountVo.createTimeEnd != ''">
  2120. and createtime &lt;= #{queryHxOrdersCountVo.createTimeEnd}
  2121. </if>
  2122. group by
  2123. operatorid,su.name
  2124. order by
  2125. count1 desc
  2126. </select>
  2127. <select id="getTelemarketingAudit" resultMap="TelemarketingAuditOrderMap">
  2128. SELECT
  2129. iac.id as id,
  2130. iac.orderno as orderno,
  2131. io.userid as userid,
  2132. io.username as username,
  2133. iac.product as product,
  2134. io.licenseno as licenseno,
  2135. io.ins_company as insCompany,
  2136. io.orderstatus as orderstatus,
  2137. io.insuredname as insuredname,
  2138. iac.createtime as createtime,
  2139. ifa.auditstatus as auditstatus
  2140. FROM
  2141. ins_area_company iac
  2142. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  2143. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2144. WHERE
  2145. iac.orderstatus = '3'
  2146. AND ifa.auditstatus IN ('4', '5')
  2147. AND io.userid = #{userId}
  2148. <if test="telemarketingAuditOrderQueryVo.orderNo != null and telemarketingAuditOrderQueryVo.orderNo != '' ">
  2149. AND iac.orderno = #{telemarketingAuditOrderQueryVo.orderNo}
  2150. </if>
  2151. <if test="telemarketingAuditOrderQueryVo.auditStatus != null and telemarketingAuditOrderQueryVo.auditStatus != '' ">
  2152. AND ifa.auditstatus = #{telemarketingAuditOrderQueryVo.auditStatus}
  2153. </if>
  2154. <if test="telemarketingAuditOrderQueryVo.companyId != null and telemarketingAuditOrderQueryVo.companyId != '' ">
  2155. AND iac.company_id = #{telemarketingAuditOrderQueryVo.companyId}
  2156. </if>
  2157. <if test="telemarketingAuditOrderQueryVo.licenseNo != null and telemarketingAuditOrderQueryVo.licenseNo != '' ">
  2158. AND io.licenseno = #{telemarketingAuditOrderQueryVo.licenseNo}
  2159. </if>
  2160. <if test="telemarketingAuditOrderQueryVo.frameNo != null and telemarketingAuditOrderQueryVo.frameNo != '' ">
  2161. AND io.frameno = #{telemarketingAuditOrderQueryVo.frameNo}
  2162. </if>
  2163. <if test="telemarketingAuditOrderQueryVo.productId != null and telemarketingAuditOrderQueryVo.productId != '' ">
  2164. AND io.product = #{telemarketingAuditOrderQueryVo.productId}
  2165. </if>
  2166. <if test="telemarketingAuditOrderQueryVo.startDate != null and telemarketingAuditOrderQueryVo.startDate != '' and telemarketingAuditOrderQueryVo.endDate != null and telemarketingAuditOrderQueryVo.endDate != ''">
  2167. AND iac.createtime BETWEEN #{telemarketingAuditOrderQueryVo.startDate} AND
  2168. #{telemarketingAuditOrderQueryVo.endDate}
  2169. </if>
  2170. </select>
  2171. <select id="queryLicense" resultType="java.lang.String">
  2172. SELECT DISTINCT licenseno
  2173. from ins_orders
  2174. WHERE userid = #{userId}
  2175. <if test="queryLicenseInOrderVo.startDate != null and queryLicenseInOrderVo.startDate != '' and queryLicenseInOrderVo.endDate != null and queryLicenseInOrderVo.endDate != ''">
  2176. AND createtime BETWEEN #{queryLicenseInOrderVo.startDate} AND
  2177. #{queryLicenseInOrderVo.endDate}
  2178. </if>
  2179. </select>
  2180. <select id="queryInsured" resultType="java.lang.String">
  2181. SELECT DISTINCT insuredname
  2182. from ins_orders
  2183. WHERE userid = #{userId}
  2184. <if test="queryInsuredInOrderVo.startDate != null and queryInsuredInOrderVo.startDate != '' and queryInsuredInOrderVo.endDate != null and queryInsuredInOrderVo.endDate != ''">
  2185. AND createtime BETWEEN #{queryInsuredInOrderVo.startDate} AND
  2186. #{queryInsuredInOrderVo.endDate}
  2187. </if>
  2188. </select>
  2189. <select id="queryOrderByLinkType" resultType="com.ydtech.modules.order.entity.InsOrders">
  2190. select
  2191. io.orderno as orderno,
  2192. io.quoteno as quoteno,
  2193. iac.orderstatus as orderstatus,
  2194. io.userid as userid,
  2195. io.username as username,
  2196. io.deptid as deptid,
  2197. io.deptname as deptname,
  2198. io.agreeid as agreeid,
  2199. iac.productid as productid,
  2200. iac.product as product,
  2201. iac.createtime as createtime,
  2202. io.frameno as frameno,
  2203. io.licenseno as licenseno,
  2204. iac.jq_start_date as jqstartdate,
  2205. iac.jq_end_date as jqenddate,
  2206. iac.sy_start_date as systartdate,
  2207. iac.sy_end_date as syenddate,
  2208. iac.jqpremium as jqpremium,
  2209. iac.sypremium as sypremium,
  2210. iac.jypremium as jypremium,
  2211. iac.taxamount as taxamount,
  2212. iac.id as subOrderId,
  2213. iac.underwriting_status as underwritingStatus,
  2214. iac.company_id as company_id,
  2215. iac.inscompany as ins_company,
  2216. agree.agreement_code as agreementCode,
  2217. agree.agreement_name as agreementName,
  2218. company.namesimple as partnerCompaniesName,
  2219. dept.province,
  2220. dept.city,
  2221. dept.area,
  2222. d1.area_cname as province_name,
  2223. d2.area_cname as city_name,
  2224. d3.area_cname as area_name,
  2225. concat(d1.area_cname,d2.area_cname,d3.area_cname) as area_info,
  2226. iac.api_type,
  2227. io.is_external,
  2228. u.leader_name,
  2229. u.leader_id,
  2230. CASE dept.management_source
  2231. WHEN '1' THEN '渠道'
  2232. WHEN '2' THEN '个代'
  2233. WHEN '3' THEN '电销'
  2234. ELSE '' END
  2235. AS managementSource,
  2236. io.entry_status as entryStatus,
  2237. iac.underwriting_time as underwritingTime,
  2238. iac.pay_date as payDate,
  2239. iac.update_status AS updateStatus,
  2240. iac.update_status_time AS updateStatusTime,
  2241. iac.signing_time as signingTime,
  2242. oou.name as operatorName
  2243. from
  2244. ins_area_company iac
  2245. left JOIN
  2246. ins_orders io on iac.orderno = io.orderno
  2247. left join
  2248. ptl_agreement agree on iac.agreement_id= agree.id
  2249. left join
  2250. esm_ins_company company on agree.partner_companies_id= company.id
  2251. LEFT JOIN
  2252. sys_dept dept ON dept.id = io.deptid
  2253. LEFT JOIN sys_dept pdept on dept.parent_id = pdept.id
  2254. LEFT JOIN sys_area d1 ON d1.area_code = pdept.province
  2255. LEFT JOIN sys_area d2 ON d2.area_code = pdept.city
  2256. LEFT JOIN sys_area d3 ON d3.area_code = pdept.area
  2257. LEFT JOIN
  2258. sys_user u on io.userid = u.id
  2259. LEFT JOIN
  2260. sys_user oou on io.operatorid = oou.id
  2261. <where>
  2262. <if test="agentUserIds != null and agentUserIds.size>0">
  2263. AND (
  2264. (io.userid in
  2265. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  2266. #{item}
  2267. </foreach>
  2268. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  2269. )
  2270. <if test="flag">
  2271. OR iac.operator_id = #{orderQueryVo.userId}
  2272. </if>
  2273. )
  2274. </if>
  2275. <if test="agreeIds != null and agreeIds.size>0">
  2276. AND (
  2277. (iac.company_id in
  2278. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  2279. #{item}
  2280. </foreach>
  2281. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  2282. <if test="flag">
  2283. OR iac.operator_id = #{orderQueryVo.userId}
  2284. </if>
  2285. )
  2286. </if>
  2287. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  2288. and iac.id = #{orderQueryVo.orderNo}
  2289. </if>
  2290. <if test="orderQueryVo.managementSource != null and orderQueryVo.managementSource != ''">
  2291. and dept.management_source = #{orderQueryVo.managementSource}
  2292. </if>
  2293. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  2294. and io.deptid like "${orderQueryVo.deptId}%"
  2295. </if>
  2296. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  2297. and iac.orderstatus= #{orderQueryVo.orderStatus}
  2298. </if>
  2299. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  2300. and io.frameno = #{orderQueryVo.frameNo}
  2301. </if>
  2302. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  2303. and io.licenseno = #{orderQueryVo.licenseNo}
  2304. </if>
  2305. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  2306. and REPLACE(JSON_EXTRACT(io.applyinfo, '$.name'),'"','') = #{orderQueryVo.insuredName}
  2307. </if>
  2308. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  2309. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND
  2310. #{orderQueryVo.quoteEndDateStr}
  2311. </if>
  2312. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  2313. and iac.company_id = #{orderQueryVo.companyId}
  2314. </if>
  2315. <if test="orderQueryVo.operatorId != null and orderQueryVo.operatorId != ''">
  2316. and io.userid = #{orderQueryVo.operatorId}
  2317. </if>
  2318. <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
  2319. and io.username = #{orderQueryVo.operatorName}
  2320. </if>
  2321. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  2322. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  2323. </if>
  2324. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  2325. and io.deptid like "${orderQueryVo.provinceId}%"
  2326. </if>
  2327. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  2328. and io.deptid like "${orderQueryVo.cityId}%"
  2329. </if>
  2330. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  2331. and io.deptid like "${orderQueryVo.countyId}%"
  2332. </if>
  2333. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  2334. and io.deptid like "${orderQueryVo.houseId}%"
  2335. </if>
  2336. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  2337. and iac.agreement_id = #{orderQueryVo.agreeId}
  2338. </if>
  2339. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  2340. and io.orderno = #{orderQueryVo.taskNo}
  2341. </if>
  2342. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  2343. and iac.product = #{orderQueryVo.riskCode}
  2344. </if>
  2345. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  2346. and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
  2347. </if>
  2348. <if test="orderQueryVo.leaderId != null and orderQueryVo.leaderId != ''">
  2349. and u.leader_id = #{orderQueryVo.leaderId}
  2350. </if>
  2351. <if test="orderQueryVo.leaderName != null and orderQueryVo.leaderName != ''">
  2352. and u.leader_name = #{orderQueryVo.leaderName}
  2353. </if>
  2354. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  2355. and ((
  2356. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  2357. AND #{orderQueryVo.attachEndDateStr}
  2358. )
  2359. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND
  2360. #{orderQueryVo.attachEndDateStr} )
  2361. )
  2362. </if>
  2363. <choose>
  2364. <when test="type==1">
  2365. and dept.management_source=1
  2366. </when>
  2367. <when test="type==2">
  2368. and dept.management_source=2
  2369. </when>
  2370. </choose>
  2371. <if test="orderQueryVo.signStartDateStr != null and orderQueryVo.signEndDateStr != null">
  2372. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{orderQueryVo.signStartDateStr} AND
  2373. #{orderQueryVo.signEndDateStr}
  2374. </if>
  2375. <if test="orderQueryVo.entryStatus != null and orderQueryVo.entryStatus != ''">
  2376. and io.entry_status = #{orderQueryVo.entryStatus }
  2377. </if>
  2378. <if test="orderQueryVo.payStartDateStr != null and orderQueryVo.payEndDateStr != null">
  2379. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{orderQueryVo.payStartDateStr} AND
  2380. #{orderQueryVo.payEndDateStr}
  2381. </if>
  2382. <if test="orderQueryVo.auditStartDateStr != null and orderQueryVo.auditEndDateStr != null">
  2383. and DATE_FORMAT(iac.underwriting_time, '%Y-%m-%d') between #{orderQueryVo.auditStartDateStr} AND
  2384. #{orderQueryVo.auditEndDateStr}
  2385. </if>
  2386. <if test="orderQueryVo.updateStartDateStr != null and orderQueryVo.updateEndDateStr != null">
  2387. and DATE_FORMAT( iac.update_status_time, '%Y-%m-%d') between #{orderQueryVo.updateStartDateStr} AND
  2388. #{orderQueryVo.updateEndDateStr}
  2389. </if>
  2390. <if test="orderQueryVo.updateStatus != null and orderQueryVo.updateStatus != null">
  2391. and iac.update_status = #{orderQueryVo.updateStatus}
  2392. </if>
  2393. <if test="orderQueryVo.partnerCompaniesId != null and orderQueryVo.partnerCompaniesId != null">
  2394. and agree.partner_companies_id = #{orderQueryVo.partnerCompaniesId}
  2395. </if>
  2396. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2397. </where>
  2398. order by io.createtime desc
  2399. </select>
  2400. <update id="updateDelFlag">
  2401. update ins_orders set del_flag = NULL where orderno = #{orderNo}
  2402. </update>
  2403. </mapper>