InsAreaCompanyMapper.xml 20 KB

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