InsAreaCompanyMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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.InsAreaCompanyMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
  9. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  10. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  11. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  12. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  13. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  14. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  15. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  16. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  17. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  18. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  19. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  20. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  21. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  22. <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
  23. <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
  24. <result property="apiType" column="api_type" jdbcType="TINYINT"/>
  25. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  26. <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
  27. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  28. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  29. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  30. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  31. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  32. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  33. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  34. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  35. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  36. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  37. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  38. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  39. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  40. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  41. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  42. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  43. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  44. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  45. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  46. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  47. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  48. <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
  49. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  50. <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
  51. <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
  52. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  53. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  54. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  55. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  56. <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
  57. <result property="score" column="score" jdbcType="VARCHAR"/>
  58. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  59. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  60. <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
  61. <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
  62. <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
  63. <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
  64. <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
  65. <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
  66. <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
  67. <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
  68. <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
  69. </resultMap>
  70. <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
  71. extends="BaseResultMap">
  72. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  73. </resultMap>
  74. <sql id="Base_Column_List">
  75. id,orderno,inscompany,
  76. reqtxt,reptxt,jqapplyno,
  77. jqpolicyno,syapplyno,sypolicyno,
  78. riskinfo,kindinfo,jqpremium,
  79. sypremium,taxamount,sumpremium,
  80. jqdiscountrate,sydiscountrate,feerate,
  81. disrate,auditid,auditname,
  82. audittime,auditopinion,jqappoint,
  83. syappoint,createtime,payment_link
  84. </sql>
  85. <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
  86. SELECT iac.*, pa.agreement_name
  87. FROM ins_area_company as iac
  88. left join ptl_agreement as pa on pa.id = iac.agreement_id
  89. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  90. FROM ins_area_company
  91. WHERE orderno = #{orderNo}
  92. GROUP BY company_id) t ON t.company_id = iac.company_id
  93. AND t.max_createtime = iac.createtime
  94. WHERE iac.orderno = #{orderNo}
  95. </select>
  96. <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
  97. SELECT iac.*, pa.agreement_name
  98. FROM ins_area_company as iac
  99. left join ptl_agreement as pa on pa.id = iac.agreement_id
  100. WHERE iac.orderstatus = 3
  101. and orderno = #{orderNo};
  102. </select>
  103. <select id="queryLatestStatus" resultType="java.lang.String">
  104. SELECT iac.orderstatus
  105. FROM ins_area_company as iac
  106. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  107. FROM ins_area_company
  108. WHERE orderno = #{orderNo}
  109. GROUP BY company_id) t ON t.company_id = iac.company_id
  110. AND t.max_createtime = iac.createtime
  111. WHERE iac.orderno = #{orderNo}
  112. ORDER BY orderstatus DESC
  113. LIMIT 1
  114. </select>
  115. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  116. SELECT a.id as "id",
  117. a.orderno as "orderno"
  118. FROM ins_area_company a
  119. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  120. WHERE a.orderstatus = '3'
  121. or a.orderstatus = '2'
  122. and b.id is not null
  123. </select>
  124. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  125. SELECT
  126. io.orderno,
  127. io.quoteno,
  128. io.orderstatus,
  129. io.company_id,
  130. io.ins_company,
  131. io.carinfo,
  132. io.userid,
  133. io.username,
  134. io.deptid,
  135. io.deptname,
  136. io.agreeid,
  137. iac.productid,
  138. iac.product,
  139. io.createtime,
  140. io.frameno,
  141. io.licenseno,
  142. io.insuredname,
  143. io.jqstartdate,
  144. io.jqenddate,
  145. io.systartdate,
  146. io.syenddate,
  147. io.vehicle_and_vessel_tax,
  148. io.operatorid,
  149. sd.management_source,
  150. CASE ifa.audituser
  151. WHEN '自动审核' THEN ifa.audituser
  152. ELSE su2.name END
  153. AS auditUser,
  154. ifa.audittime as auditTime,
  155. ifa.auditstatus as auditStatus,
  156. eic.namesimple as partnerCompaniesName,
  157. iac.id as subOrderId,
  158. iac.signing_time as signingTime,
  159. iac.pay_date as payDate,
  160. pa.agreement_code as agreementCode,
  161. pa.agreement_name as agreementName
  162. FROM
  163. ins_orders io
  164. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno and iac.orderstatus = 3
  165. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  166. LEFT JOIN sys_user su ON su.id = io.userid
  167. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  168. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  169. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  170. LEFT JOIN esm_ins_company eic on eic.id = pa.partner_companies_id
  171. WHERE
  172. io.orderno IN ( SELECT orderno FROM ins_area_company WHERE id IN (
  173. SELECT ins_order_no FROM ins_fee_order_new
  174. WHERE ins_order_no
  175. <if test="params.auditStatus != null and params.auditStatus == 0">
  176. NOT
  177. </if>
  178. IN ( SELECT ins_order_no FROM ins_fee_audit) ) AND orderstatus = 3 )
  179. AND io.orderstatus = 3
  180. <if test="params.taskNo != null and params.taskNo != ''">
  181. AND io.orderno = #{params.taskNo}
  182. </if>
  183. <if test="params.orderNo != null and params.orderNo != ''">
  184. AND iac.id = #{params.orderNo}
  185. </if>
  186. <if test="params.licenseNo != null and params.licenseNo != ''">
  187. AND io.licenseno = #{params.licenseNo}
  188. </if>
  189. <if test="params.frameNo != null and params.frameNo != ''">
  190. AND io.frameno = #{params.frameNo}
  191. </if>
  192. <if test="params.insuredName != null and params.insuredName != ''">
  193. AND io.insuredname = #{params.insuredName}
  194. </if>
  195. <if test="params.companyId != null and params.companyId != ''">
  196. AND io.company_id = #{params.companyId}
  197. </if>
  198. <if test="params.engineNo != null and params.engineNo != ''">
  199. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  200. </if>
  201. <if test="params.riskCode != null and params.riskCode != ''">
  202. and iac.product = #{params.riskCode}
  203. </if>
  204. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  205. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND #{params.quoteEndDateStr}
  206. </if>
  207. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  208. and ((
  209. DATE_FORMAT(io.jqstartdate, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  210. AND #{params.attachEndDateStr}
  211. )
  212. OR ( DATE_FORMAT(io.systartdate, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND #{params.attachEndDateStr} )
  213. )
  214. </if>
  215. <if test="params.provinceId != null and params.provinceId != ''">
  216. and io.deptid like "${params.provinceId}%"
  217. </if>
  218. <if test="params.cityId != null and params.cityId != ''">
  219. and io.deptid like "${params.cityId}%"
  220. </if>
  221. <if test="params.countyId != null and params.countyId != ''">
  222. and io.deptid like "${params.countyId}%"
  223. </if>
  224. <if test="params.houseId != null and params.houseId != ''">
  225. and io.deptid like "${params.houseId}%"
  226. </if>
  227. <if test="params.operatorId != null and params.operatorId != ''">
  228. and io.userid = #{params.operatorId}
  229. </if>
  230. <if test="params.operatorName != null and params.operatorName != ''">
  231. and io.username = #{params.operatorName}
  232. </if>
  233. <if test="params.auditId != null and params.auditId != ''">
  234. and iac.new_operator_id = #{params.auditId}
  235. </if>
  236. <if test="params.agreeId != null and params.agreeId != ''">
  237. and iac.agreement_id = #{params.agreeId}
  238. </if>
  239. <if test="params.managementSource != null and params.managementSource != ''">
  240. and sd.management_source = #{params.managementSource}
  241. </if>
  242. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  243. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{params.signStartDateStr} AND #{params.signEndDateStr}
  244. </if>
  245. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  246. and DATE_FORMAT(io.createtime, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  247. </if>
  248. </select>
  249. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  250. SELECT
  251. io.*,
  252. sd.management_source
  253. FROM
  254. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  255. WHERE
  256. orderno IN (
  257. SELECT
  258. orderno
  259. FROM
  260. ins_area_company
  261. WHERE
  262. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  263. AND orderstatus = 3
  264. )
  265. AND
  266. io.orderstatus= 3
  267. <if test="orderNo != null and orderNo != ''">
  268. AND orderno = #{orderNo}
  269. </if>
  270. <if test="licenseNo != null and licenseNo != ''">
  271. AND licenseno = #{licenseNo}
  272. </if>
  273. <if test="frameNo != null and frameNo != ''">
  274. AND frameno = #{frameNo}
  275. </if>
  276. <if test="userId != null and userId != ''">
  277. AND userid = #{userId}
  278. </if>
  279. <if test="insuredname != null and insuredname != ''">
  280. AND insuredname = #{insuredname}
  281. </if>
  282. <if test="startDateStr != null and startDateStr != ''">
  283. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  284. </if>
  285. </select>
  286. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  287. SELECT
  288. sum(a.first_detail_premiums) as "willFirstPremiums"
  289. FROM
  290. ins_fee_order_new a
  291. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  292. WHERE
  293. a.ins_order_no NOT IN (
  294. SELECT
  295. ins_order_no
  296. FROM
  297. ins_fee_audit
  298. )
  299. AND iac.orderstatus =3
  300. <if test="firstUserId != null and firstUserId != ''">
  301. AND a.first_level_user_id = #{firstUserId}
  302. </if>
  303. <if test="secondUserId != null and secondUserId != ''">
  304. AND a.two_level_user_id = #{secondUserId}
  305. </if>
  306. <if test="thirdUserId != null and thirdUserId != ''">
  307. AND a.three_level_user_id = #{thirdUserId}
  308. </if>
  309. <if test="id != null and id != ''">
  310. AND a.id = #{id}
  311. </if>
  312. </select>
  313. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  314. SELECT
  315. sum(a.second_detail_premiums) as "willSecondPremiums"
  316. FROM
  317. ins_fee_order_new a
  318. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  319. WHERE
  320. a.ins_order_no NOT IN (
  321. SELECT
  322. ins_order_no
  323. FROM
  324. ins_fee_audit
  325. )
  326. AND iac.orderstatus =3
  327. <if test="firstUserId != null and firstUserId != ''">
  328. AND a.first_level_user_id = #{firstUserId}
  329. </if>
  330. <if test="secondUserId != null and secondUserId != ''">
  331. AND a.two_level_user_id = #{secondUserId}
  332. </if>
  333. <if test="thirdUserId != null and thirdUserId != ''">
  334. AND a.three_level_user_id = #{thirdUserId}
  335. </if>
  336. <if test="id != null and id != ''">
  337. AND a.id = #{id}
  338. </if>
  339. </select>
  340. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  341. SELECT
  342. sum(a.third_detail_premiums) as "willThreePremiums"
  343. FROM
  344. ins_fee_order_new a
  345. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  346. WHERE
  347. a.ins_order_no NOT IN (
  348. SELECT
  349. ins_order_no
  350. FROM
  351. ins_fee_audit
  352. )
  353. AND iac.orderstatus =3
  354. <if test="firstUserId != null and firstUserId != ''">
  355. AND a.first_level_user_id = #{firstUserId}
  356. </if>
  357. <if test="secondUserId != null and secondUserId != ''">
  358. AND a.two_level_user_id = #{secondUserId}
  359. </if>
  360. <if test="thirdUserId != null and thirdUserId != ''">
  361. AND a.three_level_user_id = #{thirdUserId}
  362. </if>
  363. <if test="id != null and id != ''">
  364. AND a.id = #{id}
  365. </if>
  366. </select>
  367. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  368. SELECT
  369. io.*,
  370. sd.management_source,
  371. su2.name AS auditUser,
  372. ifa.audittime as auditTime
  373. FROM
  374. ins_orders io
  375. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  376. LEFT JOIN sys_user su ON su.id = io.userid
  377. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  378. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  379. WHERE
  380. io.orderno IN (
  381. SELECT
  382. orderno
  383. FROM
  384. ins_area_company
  385. WHERE
  386. id IN (
  387. SELECT
  388. ifon.ins_order_no
  389. FROM
  390. ins_fee_order_new ifon
  391. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  392. WHERE
  393. ifa.auditstatus = #{params.auditStatus}
  394. )
  395. )
  396. AND orderstatus = 3
  397. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  398. <!-- AND orderno = #{params.orderNo}-->
  399. <!-- </if>-->
  400. <if test="params.licenseNo != null and params.licenseNo != ''">
  401. AND licenseno = #{params.licenseNo}
  402. </if>
  403. <if test="params.frameNo != null and params.frameNo != ''">
  404. AND frameno = #{params.frameNo}
  405. </if>
  406. <if test="params.insuredName != null and params.insuredName != ''">
  407. AND insuredname = #{params.insuredName}
  408. </if>
  409. <if test="params.companyId != null and params.companyId != ''">
  410. AND company_id = #{params.companyId}
  411. </if>
  412. <if test="params.startDateStr != null and params.startDateStr != ''">
  413. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  414. </if>
  415. </select>
  416. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  417. -- 查询订单信息
  418. SELECT
  419. iac.*
  420. FROM
  421. ins_area_company iac
  422. JOIN ins_orders AS io ON io.orderno = iac.orderno
  423. WHERE
  424. 1=1
  425. <if test="dateStr != null and dateStr != ''">
  426. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  427. </if>
  428. </select>
  429. <select id="selectListById" resultMap="BaseResultMap">
  430. SELECT
  431. iac.*
  432. FROM
  433. ins_area_company iac
  434. WHERE
  435. 1=1
  436. <if test="id != null and id != ''">
  437. AND iac.id =#{id}
  438. </if>
  439. </select>
  440. </mapper>