InsOrdersMapper.xml 85 KB

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