InsOrdersMapper.xml 100 KB

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