InsOrdersMapper.xml 100 KB

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