InsOrdersMapper.xml 100 KB

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