InsOrdersMapper.xml 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586
  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. </resultMap>
  53. <resultMap id="OrderResultMap" type="com.ydtech.modules.order.entity.vo.OrderVo">
  54. <id property="orderno" column="orderno" jdbcType="VARCHAR"/>
  55. <result property="quoteno" column="quoteno" jdbcType="VARCHAR"/>
  56. <result property="apiType" column="api_type" jdbcType="VARCHAR"/>
  57. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  58. <result property="carinfo" column="carinfo" javaType="com.alibaba.fastjson.JSONObject"
  59. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  60. <result property="userid" column="userid" jdbcType="VARCHAR"/>
  61. <result property="username" column="username" jdbcType="VARCHAR"/>
  62. <result property="deptid" column="deptid" jdbcType="VARCHAR"/>
  63. <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
  64. <result property="ownerinfo" column="ownerinfo" javaType="com.alibaba.fastjson.JSONObject"
  65. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  66. <result property="applyinfo" column="applyinfo" javaType="com.alibaba.fastjson.JSONObject"
  67. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  68. <result property="insureinfo" column="insureinfo" javaType="com.alibaba.fastjson.JSONObject"
  69. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"
  70. jdbcType="VARCHAR"/>
  71. <result property="agreeid" column="agreeid" jdbcType="VARCHAR"/>
  72. <result property="productid" column="productid" jdbcType="VARCHAR"/>
  73. <result property="product" column="product" jdbcType="VARCHAR"/>
  74. <result property="frameno" column="frameno" jdbcType="VARCHAR"/>
  75. <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
  76. <result property="insuredname" column="insuredname" jdbcType="VARCHAR"/>
  77. <result property="jqstartdate" column="jqstartdate" jdbcType="VARCHAR"/>
  78. <result property="jqenddate" column="jqenddate" jdbcType="VARCHAR"/>
  79. <result property="systartdate" column="systartdate" jdbcType="VARCHAR"/>
  80. <result property="syenddate" column="syenddate" jdbcType="VARCHAR"/>
  81. <result property="id" column="id" jdbcType="BIGINT"/>
  82. <result property="companyId" column="company_id" jdbcType="BIGINT"/>
  83. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  84. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  85. <result property="vehicleAndVesselTax" column="vehicle_and_vessel_tax"
  86. javaType="com.alibaba.fastjson.JSONObject"
  87. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  88. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  89. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  90. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  91. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  92. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  93. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  94. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  95. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  96. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  97. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  98. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  99. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  100. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  101. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  102. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  103. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  104. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  105. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  106. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  107. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  108. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  109. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  110. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  111. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  112. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  113. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  114. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  115. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  116. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  117. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  118. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  119. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  120. <result property="ubiPredictedInfoScore" column="ubi_predicted_info_score" jdbcType="VARCHAR"/>
  121. <result property="signingTime" column="signingTime" jdbcType="TIMESTAMP"/>
  122. <result property="payDate" column="payDate" jdbcType="TIMESTAMP"/>
  123. <result property="partnerCompaniesName" column="partnerCompaniesName" jdbcType="VARCHAR"/>
  124. </resultMap>
  125. <resultMap id="OrderExcelResultMap" type="com.ydtech.modules.ins.model.InsOrdersExcel">
  126. <id property="orderNo" column="orderno" jdbcType="VARCHAR"/>
  127. <result property="licenseNo" column="licenseno" jdbcType="VARCHAR"/>
  128. <result property="fraMeno" column="frameno" jdbcType="VARCHAR"/>
  129. <result property="carInfo" column="carinfo" javaType="com.alibaba.fastjson.JSONObject" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  130. <result property="score" column="score" jdbcType="VARCHAR"/>
  131. <result property="ownerInfo" column="ownerinfo" javaType="com.alibaba.fastjson.JSONObject" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  132. <result property="jqpRemIum" column="jqpremium" jdbcType="VARCHAR"/>
  133. <result property="apiType" column="api_type" jdbcType="VARCHAR"/>
  134. <result property="jqPolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  135. <result property="sypRemIum" column="sypremium" jdbcType="VARCHAR"/>
  136. <result property="syPolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  137. <result property="jypRemIum" column="jypremium" jdbcType="VARCHAR"/>
  138. <result property="taxaMount" column="taxamount" jdbcType="VARCHAR"/>
  139. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  140. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  141. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  142. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  143. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  144. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  145. <result property="lossRation" column="loss_ration" jdbcType="VARCHAR"/>
  146. <result property="jqLossRation" column="jq_loss_ration" jdbcType="VARCHAR"/>
  147. <result property="syLossRation" column="sy_loss_ration" jdbcType="VARCHAR"/>
  148. <result property="insCompany" column="inscompany" jdbcType="VARCHAR"/>
  149. <result property="agreementId" column="agreement_id" jdbcType="VARCHAR"/>
  150. <result property="userId" column="userid" jdbcType="VARCHAR"/>
  151. <result property="userName" column="username" jdbcType="VARCHAR"/>
  152. <result property="applyInfo" column="applyinfo" javaType="com.alibaba.fastjson.JSONObject"
  153. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  154. <result property="insureInfo" column="insureinfo" javaType="com.alibaba.fastjson.JSONObject"
  155. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  156. <result property="kindInfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  157. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  158. <result property="payDate" column="pay_date" jdbcType="VARCHAR"/>
  159. <result property="signingTime" column="signing_time" jdbcType="VARCHAR"/>
  160. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  161. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  162. </resultMap>
  163. <sql id="Base_Column_List">
  164. orderno,quoteno,orderstatus,
  165. carinfo,userid,username,
  166. deptid,deptname,ownerinfo,
  167. applyinfo,insureinfo,agreeid,
  168. productid,product,createtime,
  169. frameno,licenseno,insuredname,
  170. jqstartdate,jqenddate,systartdate,
  171. syenddate
  172. </sql>
  173. <select id="getOrderAndAreaCompany" parameterType="java.lang.String" resultMap="OrderResultMap">
  174. select o.orderno,
  175. o.quoteno,
  176. o.carinfo,
  177. o.userid,
  178. o.username,
  179. o.deptid,
  180. o.deptname,
  181. o.ownerinfo,
  182. o.applyinfo,
  183. o.insureinfo,
  184. o.agreeid,
  185. o.productid,
  186. o.product,
  187. o.frameno,
  188. o.licenseno,
  189. o.insuredname,
  190. o.vehicle_and_vessel_tax,
  191. o.is_external,
  192. iac.jq_start_date as jqstartdate,
  193. iac.jq_end_date as jqenddate,
  194. iac.sy_start_date as systartdate,
  195. iac.sy_end_date as syenddate,
  196. iac.id,
  197. iac.api_type,
  198. iac.company_id,
  199. iac.reptxt,
  200. iac.orderstatus,
  201. iac.inscompany,
  202. iac.jqapplyno,
  203. iac.jqpolicyno,
  204. iac.syapplyno,
  205. iac.sypolicyno,
  206. iac.riskinfo,
  207. iac.kindinfo,
  208. iac.jqpremium,
  209. iac.sypremium,
  210. iac.jypremium,
  211. iac.taxamount,
  212. iac.sumpremium,
  213. iac.jqdiscountrate,
  214. iac.sydiscountrate,
  215. iac.feerate,
  216. iac.disrate,
  217. iac.auditid,
  218. iac.auditname,
  219. iac.audittime,
  220. iac.auditopinion,
  221. iac.jqappoint,
  222. iac.syappoint,
  223. iac.createtime,
  224. iac.payment_link,
  225. iac.accident_info,
  226. iac.tax_arrears,
  227. iac.cross_insurance,
  228. iac.ubi_predicted_info_score,
  229. iac.signing_time as signingTime,
  230. iac.pay_date as payDate,
  231. eic.namesimple as partnerCompaniesName
  232. from ins_orders as o
  233. join ins_area_company iac on o.orderno = iac.orderno
  234. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  235. LEFT JOIN esm_ins_company eic on eic.id = pa.partner_companies_id
  236. where iac.id = #{companyId}
  237. </select>
  238. <select id="getByUseridAndLicenseNo" resultType="com.ydtech.modules.order.entity.InsOrders"
  239. parameterType="com.ydtech.modules.order.entity.vo.VerifyOrdersVo">
  240. select orderno,
  241. quoteno,
  242. orderstatus,
  243. carinfo,
  244. userid,
  245. username,
  246. deptid,
  247. deptname,
  248. ownerinfo,
  249. applyinfo,
  250. insureinfo,
  251. agreeid,
  252. productid,
  253. product,
  254. createtime,
  255. frameno,
  256. licenseno,
  257. insuredname,
  258. jqstartdate,
  259. jqenddate,
  260. systartdate,
  261. syenddate,
  262. risk,
  263. king,
  264. vehicle_and_vessel_tax
  265. from ins_orders
  266. where userid = #{userId, jdbcType=VARCHAR}
  267. and licenseno = #{licenseNo, jdbcType=VARCHAR}
  268. and createtime > DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
  269. </select>
  270. <select id="queryPageOrderCount" resultType="Long">
  271. select
  272. count(1)
  273. from (
  274. select
  275. io.orderno
  276. from
  277. ins_orders io
  278. <!--如果存在 公司查询则进行连表 -->
  279. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  280. left JOIN
  281. ins_area_company iac on iac.orderno = io.orderno
  282. </if>
  283. <where>
  284. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  285. and io.orderno = #{orderQueryVo.orderNo}
  286. </if>
  287. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  288. and io.deptid like "${orderQueryVo.deptId}%"
  289. </if>
  290. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  291. and io.orderstatus = #{orderQueryVo.orderStatus}
  292. </if>
  293. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  294. and io.frameno = #{orderQueryVo.frameNo}
  295. </if>
  296. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  297. and io.licenseno = #{orderQueryVo.licenseNo}
  298. </if>
  299. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  300. and io.insuredname = #{orderQueryVo.insuredName}
  301. </if>
  302. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  303. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  304. </if>
  305. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  306. and iac.company_id = #{orderQueryVo.companyId}
  307. </if>
  308. <!--
  309. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
  310. and io.operatorid = #{orderQueryVo.userId}
  311. </if>
  312. -->
  313. <choose>
  314. <when test="isCdy">
  315. <if test="deptId != null and deptId != '' ">
  316. and io.deptid like "${deptId}%"
  317. </if>
  318. </when>
  319. <otherwise>
  320. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
  321. and io.userid = #{orderQueryVo.userId}
  322. </if>
  323. </otherwise>
  324. </choose>
  325. </where>
  326. group by io.orderno
  327. ) as s
  328. </select>
  329. <select id="queryPageOrder" resultMap="BaseResultMap">
  330. select
  331. io.*
  332. from
  333. ins_orders io
  334. <!--如果存在 公司查询则进行连表 -->
  335. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  336. left JOIN
  337. ins_area_company iac on iac.orderno = io.orderno
  338. </if>
  339. <where>
  340. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  341. and io.orderno = #{orderQueryVo.orderNo}
  342. </if>
  343. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  344. and io.deptid like "${orderQueryVo.deptId}%"
  345. </if>
  346. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  347. and io.orderstatus = #{orderQueryVo.orderStatus}
  348. </if>
  349. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  350. and io.frameno = #{orderQueryVo.frameNo}
  351. </if>
  352. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  353. and io.licenseno = #{orderQueryVo.licenseNo}
  354. </if>
  355. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  356. and io.insuredname = #{orderQueryVo.insuredName}
  357. </if>
  358. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  359. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  360. </if>
  361. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  362. and iac.company_id = #{orderQueryVo.companyId}
  363. </if>
  364. <if test="orderQueryVo.product != null and orderQueryVo.product != ''">
  365. and io.product = #{orderQueryVo.product}
  366. </if>
  367. <if test="orderQueryVo.productid != null and orderQueryVo.productid != ''">
  368. and io.productid = #{orderQueryVo.productid}
  369. </if>
  370. <!--
  371. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and isCdy">
  372. and io.operatorid = #{orderQueryVo.userId}
  373. </if>
  374. -->
  375. <choose>
  376. <when test="isCdy">
  377. <if test="deptId != null and deptId != '' ">
  378. and io.deptid like "${deptId}%"
  379. </if>
  380. </when>
  381. <otherwise>
  382. <if test="orderQueryVo.userId != null and orderQueryVo.userId != '' and !isTeamLeader">
  383. and io.userid = #{orderQueryVo.userId}
  384. </if>
  385. </otherwise>
  386. </choose>
  387. </where>
  388. group by
  389. orderno
  390. order by io.createtime desc
  391. </select>
  392. <select id="queryOrderList" parameterType="com.ydtech.modules.ins.model.InsOrdersExcelVo" resultMap="OrderExcelResultMap">
  393. select
  394. a.orderno,
  395. a.licenseno,
  396. a.frameno,
  397. a.carinfo,
  398. b.api_type,
  399. b.score,
  400. a.ownerinfo,
  401. b.jqpremium,
  402. b.jqpolicyno,
  403. b.sypremium,
  404. b.sypolicyno,
  405. b.jypremium,
  406. b.taxamount,
  407. b.jq_start_date,
  408. b.jq_end_date,
  409. b.sy_start_date,
  410. b.sy_end_date,
  411. b.score,
  412. b.jq_score,
  413. b.sy_score,
  414. b.loss_ration,
  415. b.jq_loss_ration,
  416. b.sy_loss_ration,
  417. b.score,
  418. b.inscompany,
  419. b.agreement_id,
  420. a.userid,
  421. a.username,
  422. a.applyinfo,
  423. a.insureinfo,
  424. b.kindinfo,
  425. b.pay_date,
  426. b.signing_time,
  427. b.cross_insurance
  428. FROM ins_orders a LEFT JOIN ins_area_company b on a.orderno = b.orderno
  429. WHERE
  430. 1 = 1
  431. <if test="orderstatus != null and orderstatus != '' ">
  432. and b.orderstatus = #{orderstatus}
  433. </if>
  434. <if test="startDate != null ">
  435. and b.signing_time &gt;= #{startDate}
  436. </if>
  437. <if test="endDate != null ">
  438. and b.signing_time &lt;= #{endDate}
  439. </if>
  440. </select>
  441. <resultMap id="PolicyInsuranceReportMap" type="com.ydtech.modules.order.entity.vo.PolicyInsuranceReportResVo">
  442. <result property="insCompany" column="insCompany" jdbcType="VARCHAR"/>
  443. <result property="agreementName" column="agreementName" jdbcType="VARCHAR"/>
  444. <result property="policyNo" column="policyNo" jdbcType="VARCHAR"/>
  445. <result property="quoteDate" column="quoteDate" jdbcType="VARCHAR"/>
  446. <result property="policyStartDate" column="policyStartDate" jdbcType="VARCHAR"/>
  447. <result property="riskName" column="riskName" jdbcType="VARCHAR"/>
  448. <result property="sumPremium" column="sumPremium" jdbcType="DECIMAL"/>
  449. <result property="taxPremium" column="taxPremium" jdbcType="DECIMAL"/>
  450. <result property="taxLaterPremium" column="taxLaterPremium" jdbcType="DECIMAL"/>
  451. <result property="insuranceSubAmount" column="insuranceSubAmount" jdbcType="VARCHAR"/>
  452. <result property="licenseNo" column="licenseNo" jdbcType="VARCHAR"/>
  453. <result property="vehicleUse" column="vehicleUse" jdbcType="VARCHAR"/>
  454. <result property="powerType" column="powerType" jdbcType="VARCHAR"/>
  455. <result property="ciModelClass" column="ciModelClass" jdbcType="VARCHAR"/>
  456. <result property="limitLoad" column="limitLoad" jdbcType="VARCHAR"/>
  457. <result property="appliName" column="appliName" jdbcType="VARCHAR"/>
  458. <result property="insureName" column="insureName" jdbcType="VARCHAR"/>
  459. <result property="deptName" column="deptName" jdbcType="VARCHAR"/>
  460. <result property="userName" column="username" jdbcType="VARCHAR"/>
  461. </resultMap>
  462. <select id="getPolicyInsuranceReport" resultMap="PolicyInsuranceReportMap">
  463. /*交强数据*/
  464. SELECT a.`inscompany` AS insCompany,
  465. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  466. a.`jqpolicyno` AS policyNo,
  467. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  468. a.pay_date AS quoteDate,
  469. </if>
  470. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  471. a.inside_pay_time AS quoteDate,
  472. </if>
  473. a.`jq_start_date` AS policyStartDate,
  474. '交强险' AS riskName,
  475. a.`jqpremium` AS sumPremium,
  476. a.`taxamount` AS taxPremium,
  477. getCarShipLateFee(a.`id`) AS taxLaterPremium,
  478. '交强险 : 200000.00,' AS insuranceSubAmount,
  479. b.`licenseno` AS licenseNo,
  480. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  481. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  482. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  483. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  484. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  485. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  486. b.`deptname` AS deptName,
  487. b.`username` AS userName
  488. FROM ins_area_company a,ins_orders b WHERE a.`jqpolicyno` IS NOT NULL AND a.`jqpolicyno`!='' AND a.`agreement_id` IS NOT NULL
  489. AND a.`orderno`=b.`orderno`
  490. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  491. and b.deptid = #{policyReqVo.deptId}
  492. </if>
  493. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  494. and b.userid = #{policyReqVo.userId}
  495. </if>
  496. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  497. and b.username = #{policyReqVo.userName}
  498. </if>
  499. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  500. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  501. </if>
  502. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  503. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  504. </if>
  505. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  506. and b.productid = #{policyReqVo.productId}
  507. </if>
  508. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  509. and a.company_id = #{policyReqVo.insCompany}
  510. </if>
  511. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  512. and a.operatorid = #{policyReqVo.operatorId}
  513. </if>
  514. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  515. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  516. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  517. </if>
  518. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  519. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  520. </if>
  521. </if>
  522. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  523. and a.jq_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  524. </if>
  525. UNION ALL
  526. /*##商业数据*/
  527. SELECT a.`inscompany` AS insCompany,
  528. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  529. a.`sypolicyno` AS policyNo,
  530. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  531. a.pay_date AS quoteDate,
  532. </if>
  533. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  534. a.inside_pay_time AS quoteDate,
  535. </if>
  536. a.`sy_start_date` AS policyStartDate,
  537. '商业险' AS riskName,
  538. a.`sypremium` AS sumPremium,
  539. '' AS taxPremium,
  540. '' AS taxLaterPremium,
  541. getSyAmount(a.`orderno`) AS insuranceSubAmount,
  542. b.`licenseno` AS licenseNo,
  543. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  544. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  545. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  546. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  547. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  548. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  549. b.`deptname` AS deptName,
  550. b.`username` AS userName
  551. FROM ins_area_company a,ins_orders b WHERE a.`sypolicyno` IS NOT NULL AND a.`syapplyno`!='' AND a.`agreement_id` IS NOT NULL
  552. AND a.`orderno`=b.`orderno`
  553. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  554. and b.deptid = #{policyReqVo.deptId}
  555. </if>
  556. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  557. and b.userid = #{policyReqVo.userId}
  558. </if>
  559. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  560. and b.username = #{policyReqVo.userName}
  561. </if>
  562. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  563. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  564. </if>
  565. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  566. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  567. </if>
  568. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  569. and b.productid = #{policyReqVo.productId}
  570. </if>
  571. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  572. and a.company_id = #{policyReqVo.insCompany}
  573. </if>
  574. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  575. and a.operatorid = #{policyReqVo.operatorId}
  576. </if>
  577. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  578. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  579. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  580. </if>
  581. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  582. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  583. </if>
  584. </if>
  585. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  586. and a.sy_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  587. </if>
  588. </select>
  589. <select id="getPolicyInsuranceReportCount" resultType="Long">
  590. select
  591. count(1)
  592. from (
  593. /*交强数据*/
  594. SELECT a.`inscompany` AS insCompany,
  595. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  596. a.`jqpolicyno` AS policyNo,
  597. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  598. a.pay_date AS quoteDate,
  599. </if>
  600. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  601. a.inside_pay_time AS quoteDate,
  602. </if>
  603. a.`jq_start_date` AS policyStartDate,
  604. '交强险' AS riskName,
  605. a.`jqpremium` AS sumPremium,
  606. a.`taxamount` AS taxPremium,
  607. getCarShipLateFee(a.`id`) AS taxLaterPremium,
  608. '交强险 : 200000.00,' AS insuranceSubAmount,
  609. b.`licenseno` AS licenseNo,
  610. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  611. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  612. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  613. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  614. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  615. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  616. b.`deptname` AS deptName,
  617. b.`username` AS userName
  618. FROM ins_area_company a,ins_orders b WHERE a.`jqpolicyno` IS NOT NULL AND a.`jqpolicyno`!='' AND a.`agreement_id` IS NOT NULL
  619. AND a.`orderno`=b.`orderno`
  620. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  621. and b.deptid = #{policyReqVo.deptId}
  622. </if>
  623. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  624. and b.userid = #{policyReqVo.userId}
  625. </if>
  626. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  627. and b.username = #{policyReqVo.userName}
  628. </if>
  629. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  630. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  631. </if>
  632. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  633. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  634. </if>
  635. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  636. and b.productid = #{policyReqVo.productId}
  637. </if>
  638. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  639. and a.company_id = #{policyReqVo.insCompany}
  640. </if>
  641. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  642. and a.operatorid = #{policyReqVo.operatorId}
  643. </if>
  644. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  645. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  646. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  647. </if>
  648. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  649. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  650. </if>
  651. </if>
  652. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  653. and a.jq_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  654. </if>
  655. UNION ALL
  656. /*##商业数据*/
  657. SELECT a.`inscompany` AS insCompany,
  658. (SELECT agreement_name FROM ptl_agreement t WHERE t.`id`= a.`agreement_id`) AS agreementName,
  659. a.`sypolicyno` AS policyNo,
  660. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  661. a.pay_date AS quoteDate,
  662. </if>
  663. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  664. a.inside_pay_time AS quoteDate,
  665. </if>
  666. a.`sy_start_date` AS policyStartDate,
  667. '商业险' AS riskName,
  668. a.`sypremium` AS sumPremium,
  669. '' AS taxPremium,
  670. '' AS taxLaterPremium,
  671. getSyAmount(a.`orderno`) AS insuranceSubAmount,
  672. b.`licenseno` AS licenseNo,
  673. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.vehicleUse'),'"',''),'3') AS vehicleUse,
  674. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.powertype'),'"',''),'2') AS powerType,
  675. getCodeName(REPLACE(JSON_EXTRACT(b.carinfo, '$.cimodelclass'),'"',''),'4') AS ciModelClass,
  676. REPLACE(JSON_EXTRACT(b.carinfo, '$.limitLoad'),'"','') AS limitLoad,
  677. REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') AS appliName,
  678. REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') AS insureName,
  679. b.`deptname` AS deptName,
  680. b.`username` AS userName
  681. FROM ins_area_company a,ins_orders b WHERE a.`sypolicyno` IS NOT NULL AND a.`syapplyno`!='' AND a.`agreement_id` IS NOT NULL
  682. AND a.`orderno`=b.`orderno`
  683. <if test="policyReqVo.deptId != null and policyReqVo.deptId != ''">
  684. and b.deptid = #{policyReqVo.deptId}
  685. </if>
  686. <if test="policyReqVo.userId != null and policyReqVo.userId != ''">
  687. and b.userid = #{policyReqVo.userId}
  688. </if>
  689. <if test="policyReqVo.userName != null and policyReqVo.userName != ''">
  690. and b.username = #{policyReqVo.userName}
  691. </if>
  692. <if test="policyReqVo.appliName != null and policyReqVo.appliName != ''">
  693. and REPLACE(JSON_EXTRACT(applyinfo, '$.name'),'"','') = #{policyReqVo.appliName}
  694. </if>
  695. <if test="policyReqVo.insureName != null and policyReqVo.insureName != ''">
  696. and REPLACE(JSON_EXTRACT(insureinfo, '$.name'),'"','') = #{policyReqVo.insureName}
  697. </if>
  698. <if test="policyReqVo.productId != null and policyReqVo.productId != ''">
  699. and b.productid = #{policyReqVo.productId}
  700. </if>
  701. <if test="policyReqVo.insCompany != null and policyReqVo.insCompany != ''">
  702. and a.company_id = #{policyReqVo.insCompany}
  703. </if>
  704. <if test="policyReqVo.operatorId != null and policyReqVo.operatorId != ''">
  705. and a.operatorid = #{policyReqVo.operatorId}
  706. </if>
  707. <if test="policyReqVo.quoteStartDate != null and policyReqVo.quoteEndDate != null">
  708. <if test="policyReqVo.queryFlag=='queryPayDate'.toString()">
  709. and a.pay_date between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  710. </if>
  711. <if test="policyReqVo.queryFlag=='queryPayTime'.toString()">
  712. and a.inside_pay_time between #{policyReqVo.quoteStartDate} AND #{policyReqVo.quoteEndDate}
  713. </if>
  714. </if>
  715. <if test="policyReqVo.policyStartDate != null and policyReqVo.policyEndDate != null">
  716. and a.sy_start_date between #{policyReqVo.policyStartDate} AND #{policyReqVo.policyEndDate}
  717. </if>
  718. ) as s
  719. </select>
  720. <update id="updateStatus">
  721. update ins_orders set orderstatus = #{status} where orderno = #{orderno}
  722. </update>
  723. <select id="queryPageHospitalityOrder" resultMap="BaseResultMap">
  724. select
  725. io.*,
  726. iac.orderno
  727. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  728. ,eic.namesimple as partnerCompaniesName
  729. </if>
  730. from
  731. ins_orders io
  732. left JOIN
  733. ins_area_company iac on iac.orderno = io.orderno
  734. LEFT JOIN
  735. ptl_agreement pa on pa.id = iac.agreement_id
  736. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  737. LEFT JOIN
  738. esm_ins_company eic on eic.id = pa.partner_companies_id
  739. </if>
  740. <where>
  741. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  742. and io.orderno = #{orderQueryVo.orderNo}
  743. </if>
  744. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' ">
  745. and io.deptid like "${orderQueryVo.deptId}%"
  746. </if>
  747. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  748. and io.orderstatus = #{orderQueryVo.orderStatus}
  749. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  750. and iac.orderstatus = #{orderQueryVo.orderStatus}
  751. </if>
  752. </if>
  753. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  754. and io.frameno = #{orderQueryVo.frameNo}
  755. </if>
  756. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  757. and io.licenseno = #{orderQueryVo.licenseNo}
  758. </if>
  759. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  760. and io.insuredname = #{orderQueryVo.insuredName}
  761. </if>
  762. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  763. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  764. </if>
  765. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  766. and iac.company_id = #{orderQueryVo.companyId}
  767. </if>
  768. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  769. and io.userid = #{orderQueryVo.userId}
  770. </if>
  771. </where>
  772. group by io.orderno
  773. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  774. ,eic.namesimple
  775. </if>
  776. order by io.createtime desc
  777. </select>
  778. <select id="queryPageHospitalityOrderCount" resultType="Long">
  779. select
  780. count(1)
  781. from (
  782. select
  783. io.orderno
  784. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  785. ,eic.namesimple as partnerCompaniesName
  786. </if>
  787. from
  788. ins_orders io
  789. left JOIN
  790. ins_area_company iac on iac.orderno = io.orderno
  791. LEFT JOIN
  792. ptl_agreement pa on pa.id = iac.agreement_id
  793. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  794. LEFT JOIN
  795. esm_ins_company eic on eic.id = pa.partner_companies_id
  796. </if>
  797. <where>
  798. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  799. and io.orderno = #{orderQueryVo.orderNo}
  800. </if>
  801. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != '' ">
  802. and io.deptid like "${orderQueryVo.deptId}%"
  803. </if>
  804. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  805. and io.orderstatus = #{orderQueryVo.orderStatus}
  806. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  807. and iac.orderstatus = #{orderQueryVo.orderStatus}
  808. </if>
  809. </if>
  810. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  811. and io.frameno = #{orderQueryVo.frameNo}
  812. </if>
  813. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  814. and io.licenseno = #{orderQueryVo.licenseNo}
  815. </if>
  816. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  817. and io.insuredname = #{orderQueryVo.insuredName}
  818. </if>
  819. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  820. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  821. </if>
  822. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  823. and iac.company_id = #{orderQueryVo.companyId}
  824. </if>
  825. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  826. and io.userid = #{orderQueryVo.userId}
  827. </if>
  828. </where>
  829. group by io.orderno
  830. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus == 3">
  831. ,eic.namesimple
  832. </if>
  833. order by io.createtime desc
  834. ) as s
  835. </select>
  836. <select id="queryPageOrderByLinkType" resultMap="BaseResultMap">
  837. select
  838. io.orderno as orderno,
  839. io.quoteno as quoteno,
  840. iac.orderstatus as orderstatus,
  841. io.carinfo as carinfo,
  842. io.userid as userid,
  843. io.username as username,
  844. io.deptid as deptid,
  845. io.deptname as deptname,
  846. io.ownerinfo as ownerinfo,
  847. io.applyinfo as applyinfo,
  848. io.insureinfo as insureinfo,
  849. io.agreeid as agreeid,
  850. iac.productid as productid,
  851. iac.product as product,
  852. iac.createtime as createtime,
  853. io.frameno as frameno,
  854. io.licenseno as licenseno,
  855. io.insuredname as insuredname,
  856. iac.jq_start_date as jqstartdate,
  857. iac.jq_end_date as jqenddate,
  858. iac.sy_start_date as systartdate,
  859. iac.sy_end_date as syenddate,
  860. iac.jqpremium as jqpremium,
  861. iac.sypremium as sypremium,
  862. iac.jypremium as jypremium,
  863. iac.taxamount as taxamount,
  864. io.risk as risk,
  865. io.king as king,
  866. io.vehicle_and_vessel_tax as vehicleAndVesselTax,
  867. iac.id as subOrderId,
  868. iac.company_id as company_id,
  869. iac.inscompany as ins_company,
  870. agree.agreement_code as agreementCode,
  871. agree.agreement_name as agreementName,
  872. company.namesimple as partnerCompaniesName,
  873. iac.api_type,
  874. io.is_external,
  875. CASE dept.management_source
  876. WHEN '1' THEN '渠道'
  877. WHEN '2' THEN '个代'
  878. WHEN '3' THEN '电销'
  879. ELSE '' END
  880. AS managementSource
  881. from
  882. ins_area_company iac
  883. left JOIN
  884. ins_orders io on iac.orderno = io.orderno
  885. left join
  886. ptl_agreement agree on iac.agreement_id= agree.id
  887. left join
  888. esm_ins_company company on agree.partner_companies_id= company.id
  889. LEFT JOIN
  890. sys_dept dept ON dept.id = io.deptid
  891. <where>
  892. <if test="agentUserIds != null and agentUserIds.size>0" >
  893. AND (
  894. (io.userid in
  895. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  896. #{item}
  897. </foreach>
  898. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  899. <if test="deptIds != null and deptIds.size>0" >
  900. AND (
  901. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  902. io.deptid like CONCAT('', #{item}, '%')
  903. </foreach>
  904. )
  905. </if>
  906. )
  907. <if test="flag" >
  908. OR iac.operator_id = #{orderQueryVo.userId}
  909. </if>
  910. )
  911. </if>
  912. <if test="agreeIds != null and agreeIds.size>0">
  913. AND (
  914. (iac.agreement_id in
  915. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  916. #{item}
  917. </foreach>
  918. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  919. <if test="flag" >
  920. OR iac.operator_id = #{orderQueryVo.userId}
  921. </if>
  922. )
  923. </if>
  924. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  925. and iac.id = #{orderQueryVo.orderNo}
  926. </if>
  927. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  928. and io.deptid like "${orderQueryVo.deptId}%"
  929. </if>
  930. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  931. and iac.orderstatus= #{orderQueryVo.orderStatus}
  932. </if>
  933. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  934. and io.frameno = #{orderQueryVo.frameNo}
  935. </if>
  936. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  937. and io.licenseno = #{orderQueryVo.licenseNo}
  938. </if>
  939. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  940. and io.insuredname = #{orderQueryVo.insuredName}
  941. </if>
  942. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  943. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
  944. </if>
  945. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  946. and iac.company_id = #{orderQueryVo.companyId}
  947. </if>
  948. <if test="orderQueryVo.operatorId != null and orderQueryVo.operatorId != ''">
  949. and io.userid = #{orderQueryVo.operatorId}
  950. </if>
  951. <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
  952. and io.username = #{orderQueryVo.operatorName}
  953. </if>
  954. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  955. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  956. </if>
  957. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  958. and io.deptid like "${orderQueryVo.provinceId}%"
  959. </if>
  960. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  961. and io.deptid like "${orderQueryVo.cityId}%"
  962. </if>
  963. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  964. and io.deptid like "${orderQueryVo.countyId}%"
  965. </if>
  966. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  967. and io.deptid like "${orderQueryVo.houseId}%"
  968. </if>
  969. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  970. and iac.agreement_id = #{orderQueryVo.agreeId}
  971. </if>
  972. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  973. and io.orderno = #{orderQueryVo.taskNo}
  974. </if>
  975. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  976. and iac.product = #{orderQueryVo.riskCode}
  977. </if>
  978. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  979. and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
  980. </if>
  981. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  982. and ((
  983. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  984. AND #{orderQueryVo.attachEndDateStr}
  985. )
  986. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  987. )
  988. </if>
  989. </where>
  990. order by io.createtime desc
  991. </select>
  992. <select id="queryPageOrderByLinkTypeCount" resultType="Long">
  993. select
  994. count(1)
  995. from (
  996. select
  997. (0)
  998. from
  999. ins_area_company iac
  1000. left JOIN
  1001. ins_orders io on iac.orderno = io.orderno
  1002. <where>
  1003. <if test="agentUserIds != null and agentUserIds.size>0" >
  1004. AND (
  1005. (io.userid in
  1006. <foreach collection="agentUserIds" item="item" open="(" separator="," close=")">
  1007. #{item}
  1008. </foreach>
  1009. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} )
  1010. <if test="deptIds != null and deptIds.size>0" >
  1011. AND (
  1012. <foreach collection="deptIds" item="item" open="(" separator="OR" close=")">
  1013. io.deptid like CONCAT('', #{item}, '%')
  1014. </foreach>
  1015. )
  1016. </if>
  1017. )
  1018. <if test="flag" >
  1019. OR iac.operator_id = #{orderQueryVo.userId}
  1020. </if>
  1021. )
  1022. </if>
  1023. <if test="agreeIds != null and agreeIds.size>0">
  1024. AND (
  1025. (iac.agreement_id in
  1026. <foreach collection="agreeIds" item="item" open="(" separator="," close=")">
  1027. #{item}
  1028. </foreach>
  1029. AND ( iac.new_operator_id IS NULL OR iac.new_operator_id = #{orderQueryVo.userId} ) )
  1030. <if test="flag" >
  1031. OR iac.operator_id = #{orderQueryVo.userId}
  1032. </if>
  1033. )
  1034. </if>
  1035. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1036. and iac.id = #{orderQueryVo.orderNo}
  1037. </if>
  1038. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1039. and io.deptid like "${orderQueryVo.deptId}%"
  1040. </if>
  1041. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1042. and iac.orderstatus= #{orderQueryVo.orderStatus}
  1043. </if>
  1044. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1045. and io.frameno = #{orderQueryVo.frameNo}
  1046. </if>
  1047. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1048. and io.licenseno = #{orderQueryVo.licenseNo}
  1049. </if>
  1050. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1051. and io.insuredname = #{orderQueryVo.insuredName}
  1052. </if>
  1053. <if test="orderQueryVo.quoteStartDateStr != null and orderQueryVo.quoteEndDateStr != null">
  1054. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{orderQueryVo.quoteStartDateStr} AND #{orderQueryVo.quoteEndDateStr}
  1055. </if>
  1056. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1057. and iac.company_id = #{orderQueryVo.companyId}
  1058. </if>
  1059. <if test="orderQueryVo.operatorId != null and orderQueryVo.operatorId != ''">
  1060. and io.userid = #{orderQueryVo.operatorId}
  1061. </if>
  1062. <if test="orderQueryVo.operatorName != null and orderQueryVo.operatorName != ''">
  1063. and io.username = #{orderQueryVo.operatorName}
  1064. </if>
  1065. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1066. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1067. </if>
  1068. <if test="orderQueryVo.provinceId != null and orderQueryVo.provinceId != ''">
  1069. and io.deptid like "${orderQueryVo.provinceId}%"
  1070. </if>
  1071. <if test="orderQueryVo.cityId != null and orderQueryVo.cityId != ''">
  1072. and io.deptid like "${orderQueryVo.cityId}%"
  1073. </if>
  1074. <if test="orderQueryVo.countyId != null and orderQueryVo.countyId != ''">
  1075. and io.deptid like "${orderQueryVo.countyId}%"
  1076. </if>
  1077. <if test="orderQueryVo.houseId != null and orderQueryVo.houseId != ''">
  1078. and io.deptid like "${orderQueryVo.houseId}%"
  1079. </if>
  1080. <if test="orderQueryVo.agreeId != null and orderQueryVo.agreeId != ''">
  1081. and iac.agreement_id = #{orderQueryVo.agreeId}
  1082. </if>
  1083. <if test="orderQueryVo.taskNo != null and orderQueryVo.taskNo != ''">
  1084. and io.orderno = #{orderQueryVo.taskNo}
  1085. </if>
  1086. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1087. and iac.product = #{orderQueryVo.riskCode}
  1088. </if>
  1089. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1090. and IFNULL( iac.new_operator_id, '' ) = #{orderQueryVo.auditId}
  1091. </if>
  1092. <if test="orderQueryVo.attachStartDateStr != null and orderQueryVo.attachEndDateStr != ''">
  1093. and ((
  1094. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr}
  1095. AND #{orderQueryVo.attachEndDateStr}
  1096. )
  1097. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{orderQueryVo.attachStartDateStr} AND #{orderQueryVo.attachEndDateStr} )
  1098. )
  1099. </if>
  1100. </where>
  1101. ) as s
  1102. </select>
  1103. <select id="queryPageSubOrders" resultMap="BaseResultMap">
  1104. select
  1105. io.*,
  1106. iac.id as subOrderId
  1107. from
  1108. ins_area_company iac
  1109. left JOIN
  1110. ins_orders io on iac.orderno = io.orderno
  1111. <where>
  1112. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1113. and io.userid = #{orderQueryVo.userid}
  1114. </if>
  1115. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1116. and io.orderno = #{orderQueryVo.orderNo}
  1117. </if>
  1118. <if test="orderQueryVo.quoteNo != null and orderQueryVo.quoteNo != ''">
  1119. and io.quoteno = #{orderQueryVo.quoteNo}
  1120. </if>
  1121. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1122. and io.deptid like "${orderQueryVo.deptId}%"
  1123. </if>
  1124. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1125. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1126. </if>
  1127. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1128. and io.frameno = #{orderQueryVo.frameNo}
  1129. </if>
  1130. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1131. and io.licenseno = #{orderQueryVo.licenseNo}
  1132. </if>
  1133. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1134. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1135. </if>
  1136. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1137. and io.insuredname = #{orderQueryVo.insuredName}
  1138. </if>
  1139. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1140. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1141. </if>
  1142. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1143. and iac.company_id = #{orderQueryVo.companyId}
  1144. </if>
  1145. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1146. and iac.product = #{orderQueryVo.riskCode}
  1147. </if>
  1148. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1149. and IFNULL( io.agreeid, '' ) = #{orderQueryVo.auditId}
  1150. </if>
  1151. <if test="orderQueryVo.policyStartDate != null and orderQueryVo.policyEndDate != ''">
  1152. and ((
  1153. io.jqstartdate BETWEEN #{orderQueryVo.policyStartDate}
  1154. AND #{orderQueryVo.policyEndDate}
  1155. )
  1156. OR ( io.systartdate BETWEEN #{orderQueryVo.policyStartDate} AND #{orderQueryVo.policyEndDate} )
  1157. )
  1158. </if>
  1159. </where>
  1160. group by iac.id
  1161. order by io.createtime desc
  1162. </select>
  1163. <select id="queryPageSubOrdersCount" resultType="Long">
  1164. select
  1165. count(1)
  1166. from (
  1167. select
  1168. io.*
  1169. from
  1170. ins_area_company iac
  1171. left JOIN
  1172. ins_orders io on iac.orderno = io.orderno
  1173. <where>
  1174. <if test="orderQueryVo.userId != null and orderQueryVo.userId != ''">
  1175. and io.userid = #{orderQueryVo.userid}
  1176. </if>
  1177. <if test="orderQueryVo.orderNo != null and orderQueryVo.orderNo != ''">
  1178. and io.orderno = #{orderQueryVo.orderNo}
  1179. </if>
  1180. <if test="orderQueryVo.quoteNo != null and orderQueryVo.quoteNo != ''">
  1181. and io.quoteno = #{orderQueryVo.quoteNo}
  1182. </if>
  1183. <if test="orderQueryVo.deptId != null and orderQueryVo.deptId != ''">
  1184. and io.deptid like "${orderQueryVo.deptId}%"
  1185. </if>
  1186. <if test="orderQueryVo.orderStatus != null and orderQueryVo.orderStatus != ''">
  1187. and iac.orderstatus = #{orderQueryVo.orderStatus}
  1188. </if>
  1189. <if test="orderQueryVo.frameNo != null and orderQueryVo.frameNo != ''">
  1190. and io.frameno = #{orderQueryVo.frameNo}
  1191. </if>
  1192. <if test="orderQueryVo.licenseNo != null and orderQueryVo.licenseNo != ''">
  1193. and io.licenseno = #{orderQueryVo.licenseNo}
  1194. </if>
  1195. <if test="orderQueryVo.engineNo != null and orderQueryVo.engineNo != ''">
  1196. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{orderQueryVo.engineNo}
  1197. </if>
  1198. <if test="orderQueryVo.insuredName != null and orderQueryVo.insuredName != ''">
  1199. and io.insuredname = #{orderQueryVo.insuredName}
  1200. </if>
  1201. <if test="orderQueryVo.startDate != null and orderQueryVo.endDate != null">
  1202. and io.createtime between #{orderQueryVo.startDate} AND #{orderQueryVo.endDate}
  1203. </if>
  1204. <if test="orderQueryVo.companyId != null and orderQueryVo.companyId != ''">
  1205. and iac.company_id = #{orderQueryVo.companyId}
  1206. </if>
  1207. <if test="orderQueryVo.riskCode != null and orderQueryVo.riskCode != ''">
  1208. and iac.product = #{orderQueryVo.riskCode}
  1209. </if>
  1210. <if test="orderQueryVo.auditId != null and orderQueryVo.auditId != ''">
  1211. and IFNULL( io.agreeid, '' ) = #{orderQueryVo.auditId}
  1212. </if>
  1213. <if test="orderQueryVo.policyStartDate != null and orderQueryVo.policyEndDate != ''">
  1214. and ((
  1215. io.jqstartdate BETWEEN #{orderQueryVo.policyStartDate}
  1216. AND #{orderQueryVo.policyEndDate}
  1217. )
  1218. OR ( io.systartdate BETWEEN #{orderQueryVo.policyStartDate} AND #{orderQueryVo.policyEndDate} )
  1219. )
  1220. </if>
  1221. </where>
  1222. group by iac.id
  1223. ) as s
  1224. </select>
  1225. <select id="selectEntityByinsOrderNo" resultMap="OrderResultMap">
  1226. select o.orderno,
  1227. o.quoteno,
  1228. o.frameno,
  1229. o.licenseno,
  1230. iac.jq_start_date as jqstartdate,
  1231. iac.jq_end_date as jqenddate,
  1232. iac.sy_start_date as systartdate,
  1233. iac.sy_end_date as syenddate,
  1234. iac.id,
  1235. iac.company_id,
  1236. iac.reptxt,
  1237. iac.orderstatus,
  1238. iac.inscompany,
  1239. iac.jqapplyno,
  1240. iac.jqpolicyno,
  1241. iac.syapplyno,
  1242. iac.sypolicyno,
  1243. iac.riskinfo,
  1244. iac.kindinfo,
  1245. iac.jqpremium,
  1246. iac.sypremium,
  1247. iac.jypremium,
  1248. iac.taxamount,
  1249. iac.sumpremium,
  1250. iac.jqdiscountrate,
  1251. iac.sydiscountrate,
  1252. iac.feerate,
  1253. iac.disrate,
  1254. iac.auditid,
  1255. iac.auditname,
  1256. iac.audittime,
  1257. iac.auditopinion,
  1258. iac.jqappoint,
  1259. iac.syappoint,
  1260. iac.createtime,
  1261. iac.payment_link,
  1262. iac.accident_info,
  1263. iac.tax_arrears,
  1264. iac.cross_insurance,
  1265. iac.ubi_predicted_info_score
  1266. from ins_area_company iac
  1267. join ins_orders as o on o.orderno = iac.orderno
  1268. where
  1269. iac.id = #{insOrderNo}
  1270. <if test="timeFiltering != null and timeFiltering != ''">
  1271. and DATE_FORMAT(iac.signing_time, '%Y-%m') = #{timeFiltering}
  1272. </if>
  1273. </select>
  1274. <select id="getExpirationInsureCount" resultType="Integer">
  1275. SELECT
  1276. count( b.orderno ) AS count
  1277. FROM
  1278. ins_orders a
  1279. left join
  1280. ins_area_company b
  1281. on a.orderno = b.orderno
  1282. WHERE
  1283. <if test="isJq == 1">
  1284. jqenddate BETWEEN #{startDate} AND #{endDate}
  1285. </if>
  1286. <if test="isJq == 2">
  1287. syenddate BETWEEN #{startDate} AND #{endDate}
  1288. </if>
  1289. AND a.orderstatus = 3
  1290. AND b.orderstatus = 3
  1291. <if test="param != null and param != ''">
  1292. AND (a.licenseno = #{param} or a.ins_company = #{param})
  1293. </if>
  1294. <if test="userId != null and userId != ''">
  1295. AND a.userid = #{userId}
  1296. </if>
  1297. </select>
  1298. <select id="getExpirationInsure" resultType="com.ydtech.modules.order.entity.vo.OrderExpirationVo">
  1299. SELECT
  1300. a.ins_company,
  1301. b.id as orderno,
  1302. b.jq_end_date,
  1303. b.sy_end_date,
  1304. b.productid,
  1305. b.product,
  1306. a.licenseno,
  1307. case when b.jq_end_date is not null then DATEDIFF( b.jq_end_date,NOW() ) else null end AS jqDiff,
  1308. case when b.sy_end_date is not null then DATEDIFF( b.sy_end_date,NOW() ) else null end AS syDiff
  1309. FROM ins_orders a,ins_area_company b
  1310. WHERE a.orderno = b.orderno
  1311. AND (b.jq_end_date BETWEEN #{order.jqStartDate} AND #{order.jqEndDate} or b.sy_end_date BETWEEN #{order.syStartDate} AND #{order.syEndDate})
  1312. AND b.orderstatus = 3
  1313. <if test="order.param != null and order.param != ''">
  1314. AND (a.licenseno = #{order.param} or a.ins_company = #{order.param})
  1315. </if>
  1316. <if test="order.userid != null and order.userid != ''">
  1317. AND a.userid = #{order.userid}
  1318. </if>
  1319. ORDER BY least(IFNULL(jqDiff, 9999999) , IFNULL(syDiff, 9999999)) asc
  1320. </select>
  1321. <select id="getCarBusinessDetailList" resultType="com.ydtech.modules.order.entity.vo.CarBusinessDetailVo">
  1322. SELECT
  1323. io.username,
  1324. iac.signing_time as sign_date,
  1325. io.licenseno,
  1326. JSON_UNQUOTE(json_extract(io.applyinfo, '$.name')) as applyname,
  1327. io.product,
  1328. io.ins_company as inscompany,
  1329. iac.jqpremium,
  1330. iac.sypremium,
  1331. iac.jypremium,
  1332. iac.taxamount,
  1333. ifo.jq_costs_export_proportion+ifo.jq_export_other_costs_proportion as jq_export_proportion,
  1334. ifo.sy_costs_export_proportion+ifo.sy_export_other_costs_proportion as sy_export_proportion,
  1335. ifo.no_costs_export_proportion+ifo.no_export_other_costs_proportion as no_export_proportion,
  1336. 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,
  1337. CASE ifa.auditstatus
  1338. WHEN 1 THEN
  1339. '已审核'
  1340. ELSE
  1341. '未审核'
  1342. END as audittype,
  1343. ifa.audittime as audit_date
  1344. FROM
  1345. ins_orders io
  1346. LEFT JOIN ins_area_company iac ON io.orderno = iac.orderno
  1347. LEFT JOIN ins_fee_order_new ifo ON iac.id = ifo.ins_order_no
  1348. left join ins_fee_audit ifa on ifo.ins_order_no = ifa.ins_order_no
  1349. WHERE
  1350. io.userid = #{userId}
  1351. AND io.orderstatus = 3
  1352. AND iac.orderstatus = 3
  1353. AND iac.signing_time BETWEEN #{param.signStartDate} and #{param.signEndDate}
  1354. </select>
  1355. <select id="getRevenueExpenditureDetailList" resultType="com.ydtech.modules.order.entity.vo.RevenueExpenditureDetailVo">
  1356. SELECT
  1357. sua.create_time,
  1358. io.licenseno,
  1359. sua.amount,
  1360. sua.business_eegments_type,
  1361. sua.documentary,
  1362. sua.property
  1363. FROM
  1364. sys_user_account_history sua
  1365. left join ins_area_company iac on sua.suborder = iac.id
  1366. left join ins_orders io on iac.orderno = io.orderno
  1367. WHERE
  1368. (sua.property != 1 and sua.property != 2)
  1369. AND
  1370. user_id = #{userId}
  1371. AND
  1372. sua.create_time BETWEEN #{param.signStartDate} and #{param.signEndDate}
  1373. </select>
  1374. <select id="getAuditExportList" resultType="com.ydtech.modules.order.entity.vo.AuditExportVo">
  1375. SELECT
  1376. iac.company_id,
  1377. iac.api_type,
  1378. iac.cross_insurance,
  1379. io.username,
  1380. iac.signing_time,
  1381. io.licenseno,
  1382. JSON_UNQUOTE(json_extract(io.applyinfo, '$.name')) as applyname,
  1383. io.ins_company,
  1384. io.product,
  1385. eic.namesimple,
  1386. iac.jqapplyno,
  1387. iac.syapplyno,
  1388. iac.cross_insurance,
  1389. iac.jqpremium,
  1390. iac.sypremium,
  1391. iac.jypremium,
  1392. iac.taxamount,
  1393. ifo.jq_costs_export_proportion + ifo.jq_export_other_costs_proportion AS jq_export_proportion,
  1394. ifo.sy_costs_export_proportion+ifo.sy_export_other_costs_proportion as sy_export_proportion,
  1395. ifo.no_costs_export_proportion+ifo.no_export_other_costs_proportion as no_export_proportion,
  1396. 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,
  1397. ifo.jq_supervise_costs_proportion + ifo.jq_other_costs_proportion as jq_entrance_proportion,
  1398. ifo.sy_supervise_costs_proportion + ifo.sy_other_costs_proportion as sy_entrance_proportion,
  1399. ifo.no_supervise_costs_proportion + ifo.no_other_costs_proportion as no_entrance_proportion,
  1400. 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,
  1401. ifo.jq_dept_premiums_level_1 + ifo.sy_dept_premiums_level_1 + ifo.no_dept_premiums_level_1 as dept_premiums_level_1,
  1402. ifo.jq_dept_premiums_level_2 + ifo.sy_dept_premiums_level_2 + ifo.no_dept_premiums_level_2 as dept_premiums_level_2,
  1403. ifo.jq_dept_premiums_level_3 + ifo.sy_dept_premiums_level_3 + ifo.no_dept_premiums_level_3 as dept_premiums_level_3,
  1404. ifo.jq_dept_premiums_level_4 + ifo.sy_dept_premiums_level_4 + ifo.no_dept_premiums_level_4 as dept_premiums_level_4,
  1405. ifo.jq_dept_premiums_level_5 + ifo.sy_dept_premiums_level_5 + ifo.no_dept_premiums_level_5 as dept_premiums_level_5,
  1406. ifo.first_detail_premiums,
  1407. ifo.second_detail_premiums,
  1408. ifo.third_detail_premiums,
  1409. ifo.jq_profit_margin_premiums,
  1410. ifo.sy_profit_margin_premiums,
  1411. ifo.no_profit_margin_premiums,
  1412. io.is_external
  1413. FROM
  1414. ins_fee_order_new ifo
  1415. LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
  1416. left join ins_area_company iac on ifa.ins_order_no = iac.id
  1417. left join ins_orders io on iac.orderno = io.orderno
  1418. left join ptl_agreement pa on iac.agreement_id = pa.id
  1419. left join esm_ins_company eic on pa.partner_companies_id = eic.id
  1420. WHERE
  1421. iac.signing_time between #{param.signStartDate} and #{param.signEndDate}
  1422. <if test="param.audit != null and param.audit != ''">
  1423. AND
  1424. ifa.auditstatus = #{param.audit}
  1425. AND
  1426. io.orderstatus = 3
  1427. AND
  1428. iac.orderstatus = 3
  1429. GROUP BY
  1430. io.orderno,
  1431. iac.api_type,
  1432. iac.cross_insurance,
  1433. iac.signing_time,
  1434. eic.namesimple,
  1435. iac.jqapplyno,
  1436. iac.syapplyno,
  1437. iac.jqpremium,
  1438. iac.company_id,
  1439. iac.sypremium,
  1440. iac.jypremium,
  1441. iac.taxamount,
  1442. ifo.jq_costs_export_proportion,
  1443. ifo.jq_export_other_costs_proportion,
  1444. ifo.sy_costs_export_proportion,
  1445. ifo.sy_export_other_costs_proportion,
  1446. ifo.no_costs_export_proportion,
  1447. ifo.no_export_other_costs_proportion,
  1448. ifo.jq_export_supervise_costs_premiums,
  1449. ifo.sy_export_supervise_costs_premiums,
  1450. ifo.no_export_supervise_costs_premiums,
  1451. ifo.jq_export_other_costs_premiums,
  1452. ifo.sy_export_other_costs_premiums,
  1453. ifo.no_export_other_costs_premiums,
  1454. ifo.jq_supervise_costs_proportion,
  1455. ifo.jq_other_costs_proportion,
  1456. ifo.sy_supervise_costs_proportion,
  1457. ifo.sy_other_costs_proportion,
  1458. ifo.no_supervise_costs_proportion,
  1459. ifo.no_other_costs_proportion,
  1460. ifo.jq_supervise_costs_premiums,
  1461. ifo.jq_other_costs_premiums,
  1462. ifo.sy_supervise_costs_premiums,
  1463. ifo.sy_other_costs_premiums,
  1464. ifo.no_supervise_costs_premiums,
  1465. ifo.no_other_costs_premiums,
  1466. ifo.jq_dept_premiums_level_1,
  1467. ifo.jq_dept_premiums_level_2,
  1468. ifo.jq_dept_premiums_level_3,
  1469. ifo.jq_dept_premiums_level_4,
  1470. ifo.jq_dept_premiums_level_5,
  1471. ifo.sy_dept_premiums_level_1,
  1472. ifo.sy_dept_premiums_level_2,
  1473. ifo.sy_dept_premiums_level_3,
  1474. ifo.sy_dept_premiums_level_4,
  1475. ifo.sy_dept_premiums_level_5,
  1476. ifo.no_dept_premiums_level_1,
  1477. ifo.no_dept_premiums_level_2,
  1478. ifo.no_dept_premiums_level_3,
  1479. ifo.no_dept_premiums_level_4,
  1480. ifo.no_dept_premiums_level_5,
  1481. ifo.first_detail_premiums,
  1482. ifo.second_detail_premiums,
  1483. ifo.third_detail_premiums,
  1484. ifo.jq_profit_margin_premiums,
  1485. ifo.sy_profit_margin_premiums,
  1486. ifo.no_profit_margin_premiums
  1487. </if>
  1488. </select>
  1489. <resultMap id="hxOrderCountMap" type="com.ydtech.modules.order.entity.vo.QueryHxOrdersCountVo">
  1490. <result property="operatorId" column="operatorid" jdbcType="VARCHAR"/>
  1491. <result property="name" column="name" jdbcType="VARCHAR"/>
  1492. <result property="orderStatus0" column="orderstatus0" jdbcType="VARCHAR"/>
  1493. <result property="orderStatus1" column="orderstatus1" jdbcType="VARCHAR"/>
  1494. <result property="orderStatus2" column="orderstatus2" jdbcType="VARCHAR"/>
  1495. <result property="orderStatus3" column="orderstatus3" jdbcType="VARCHAR"/>
  1496. <result property="orderStatus4" column="orderstatus4" jdbcType="VARCHAR"/>
  1497. <result property="createTime" column="createtime" jdbcType="TIMESTAMP"/>
  1498. <result property="createTimeStart" column="createTimeStart" jdbcType="VARCHAR"/>
  1499. <result property="createTimeEnd" column="createTimeEnd" jdbcType="VARCHAR"/>
  1500. <result property="count" column="count1" jdbcType="VARCHAR"/>
  1501. </resultMap>
  1502. <select id="queryHxOrdersCount" resultMap="hxOrderCountMap">
  1503. select
  1504. operatorid,
  1505. su.name,
  1506. count(*) as count1,
  1507. SUM(CASE WHEN orderstatus = '1' THEN 1 ELSE 0 END) AS orderstatus1,
  1508. SUM(CASE WHEN orderstatus = '2' THEN 1 ELSE 0 END) AS orderstatus2,
  1509. SUM(CASE WHEN orderstatus = '3' THEN 1 ELSE 0 END) AS orderstatus3,
  1510. SUM(CASE WHEN orderstatus = '4' THEN 1 ELSE 0 END) AS orderstatus4,
  1511. SUM(CASE WHEN orderstatus = '0' THEN 1 ELSE 0 END) AS orderstatus0
  1512. from
  1513. ins_orders
  1514. LEFT JOIN
  1515. sys_user su ON operatorid = su.id
  1516. WHERE operatorid IS NOT NULL
  1517. AND operatorid NOT LIKE '%M%'
  1518. <if test="queryHxOrdersCountVo.ids != null and !queryHxOrdersCountVo.ids.isEmpty()">
  1519. and operatorid IN
  1520. <foreach item="item" index="index" collection="queryHxOrdersCountVo.ids" open="(" separator="," close=")">
  1521. #{item}
  1522. </foreach>
  1523. </if>
  1524. <if test="queryHxOrdersCountVo.operatorId !=null and queryHxOrdersCountVo.operatorId !=''">
  1525. and operatorid =#{queryHxOrdersCountVo.operatorId}
  1526. </if>
  1527. <if test="queryHxOrdersCountVo.name !=null and queryHxOrdersCountVo.name !=''">
  1528. and su.name =#{queryHxOrdersCountVo.name}
  1529. </if>
  1530. <if test="queryHxOrdersCountVo.createTimeStart != null and queryHxOrdersCountVo.createTimeStart != ''">
  1531. and createtime &gt;= #{queryHxOrdersCountVo.createTimeStart}
  1532. </if>
  1533. <if test="queryHxOrdersCountVo.createTimeEnd != null and queryHxOrdersCountVo.createTimeEnd != ''">
  1534. and createtime &lt;= #{queryHxOrdersCountVo.createTimeEnd}
  1535. </if>
  1536. group by
  1537. operatorid,su.name
  1538. order by
  1539. count1 desc
  1540. </select>
  1541. </mapper>