InsAreaCompanyMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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.*,
  127. sd.management_source,
  128. su2.name AS auditUser,
  129. ifa.audittime as auditTime,
  130. ifa.auditstatus as auditStatus,
  131. eic.namesimple as partnerCompaniesName
  132. FROM
  133. ins_orders io
  134. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  135. LEFT JOIN sys_user su ON su.id = io.userid
  136. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  137. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  138. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno and iac.orderstatus = 3
  139. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  140. LEFT JOIN esm_ins_company eic on eic.id = pa.partner_companies_id
  141. WHERE
  142. io.orderno IN ( SELECT orderno FROM ins_area_company WHERE id IN (
  143. SELECT ins_order_no FROM ins_fee_order_new
  144. WHERE ins_order_no
  145. <if test="params.auditStatus != null and params.auditStatus == 0">
  146. NOT
  147. </if>
  148. IN ( SELECT ins_order_no FROM ins_fee_audit) ) AND orderstatus = 3 )
  149. AND io.orderstatus = 3
  150. <if test="params.taskNo != null and params.taskNo != ''">
  151. AND io.orderno = #{params.taskNo}
  152. </if>
  153. <if test="params.orderNo != null and params.orderNo != ''">
  154. AND iac.id = #{params.orderNo}
  155. </if>
  156. <if test="params.licenseNo != null and params.licenseNo != ''">
  157. AND io.licenseno = #{params.licenseNo}
  158. </if>
  159. <if test="params.frameNo != null and params.frameNo != ''">
  160. AND io.frameno = #{params.frameNo}
  161. </if>
  162. <if test="params.insuredName != null and params.insuredName != ''">
  163. AND io.insuredname = #{params.insuredName}
  164. </if>
  165. <if test="params.companyId != null and params.companyId != ''">
  166. AND io.company_id = #{params.companyId}
  167. </if>
  168. <if test="params.engineNo != null and params.engineNo != ''">
  169. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  170. </if>
  171. <if test="params.riskCode != null and params.riskCode != ''">
  172. and io.product = #{params.riskCode}
  173. </if>
  174. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != ''">
  175. AND iac.createtime BETWEEN #{params.quoteStartDateStr} and #{params.quoteEndDateStr}
  176. </if>
  177. <if test="params.attachStartDateStr != null and params.attachStartDateStr != ''">
  178. AND iac.signing_time BETWEEN #{params.attachStartDateStr} and #{params.attachEndDateStr}
  179. </if>
  180. <if test="params.startDateStr != null and params.startDateStr != ''">
  181. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  182. </if>
  183. <if test="params.provinceId != null and params.provinceId != ''">
  184. and io.deptid like "${params.provinceId}%"
  185. </if>
  186. <if test="params.cityId != null and params.cityId != ''">
  187. and io.deptid like "${params.cityId}%"
  188. </if>
  189. <if test="params.countyId != null and params.countyId != ''">
  190. and io.deptid like "${params.countyId}%"
  191. </if>
  192. <if test="params.houseId != null and params.houseId != ''">
  193. and io.deptid like "${params.houseId}%"
  194. </if>
  195. <if test="params.operatorId != null and params.operatorId != ''">
  196. and io.userid = #{params.operatorId}
  197. </if>
  198. <if test="params.operatorName != null and params.operatorName != ''">
  199. and io.username = #{params.operatorName}
  200. </if>
  201. <if test="params.auditId != null and params.auditId != ''">
  202. and iac.new_operator_id = #{params.auditId}
  203. </if>
  204. <if test="params.agreeId != null and params.agreeId != ''">
  205. and iac.agreement_id = #{params.agreeId}
  206. </if>
  207. </select>
  208. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  209. SELECT
  210. io.*,
  211. sd.management_source
  212. FROM
  213. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  214. WHERE
  215. orderno IN (
  216. SELECT
  217. orderno
  218. FROM
  219. ins_area_company
  220. WHERE
  221. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  222. AND orderstatus = 3
  223. )
  224. AND
  225. io.orderstatus= 3
  226. <if test="orderNo != null and orderNo != ''">
  227. AND orderno = #{orderNo}
  228. </if>
  229. <if test="licenseNo != null and licenseNo != ''">
  230. AND licenseno = #{licenseNo}
  231. </if>
  232. <if test="frameNo != null and frameNo != ''">
  233. AND frameno = #{frameNo}
  234. </if>
  235. <if test="userId != null and userId != ''">
  236. AND userid = #{userId}
  237. </if>
  238. <if test="insuredname != null and insuredname != ''">
  239. AND insuredname = #{insuredname}
  240. </if>
  241. <if test="startDateStr != null and startDateStr != ''">
  242. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  243. </if>
  244. </select>
  245. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  246. SELECT
  247. sum(a.first_detail_premiums) as "willFirstPremiums"
  248. FROM
  249. ins_fee_order_new a
  250. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  251. WHERE
  252. a.id NOT IN (
  253. SELECT
  254. ins_order_no
  255. FROM
  256. ins_fee_audit
  257. )
  258. AND iac.orderstatus =3
  259. <if test="firstUserId != null and firstUserId != ''">
  260. AND a.first_level_user_id = #{firstUserId}
  261. </if>
  262. <if test="secondUserId != null and secondUserId != ''">
  263. AND a.two_level_user_id = #{secondUserId}
  264. </if>
  265. <if test="thirdUserId != null and thirdUserId != ''">
  266. AND a.three_level_user_id = #{thirdUserId}
  267. </if>
  268. <if test="id != null and id != ''">
  269. AND a.id = #{id}
  270. </if>
  271. </select>
  272. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  273. SELECT
  274. sum(a.second_detail_premiums) as "willSecondPremiums"
  275. FROM
  276. ins_fee_order_new a
  277. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  278. WHERE
  279. a.id NOT IN (
  280. SELECT
  281. ins_order_no
  282. FROM
  283. ins_fee_audit
  284. )
  285. AND iac.orderstatus =3
  286. <if test="firstUserId != null and firstUserId != ''">
  287. AND a.first_level_user_id = #{firstUserId}
  288. </if>
  289. <if test="secondUserId != null and secondUserId != ''">
  290. AND a.two_level_user_id = #{secondUserId}
  291. </if>
  292. <if test="thirdUserId != null and thirdUserId != ''">
  293. AND a.three_level_user_id = #{thirdUserId}
  294. </if>
  295. <if test="id != null and id != ''">
  296. AND a.id = #{id}
  297. </if>
  298. </select>
  299. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  300. SELECT
  301. sum(a.third_detail_premiums) as "willThreePremiums"
  302. FROM
  303. ins_fee_order_new a
  304. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  305. WHERE
  306. a.id NOT IN (
  307. SELECT
  308. ins_order_no
  309. FROM
  310. ins_fee_audit
  311. )
  312. AND iac.orderstatus =3
  313. <if test="firstUserId != null and firstUserId != ''">
  314. AND a.first_level_user_id = #{firstUserId}
  315. </if>
  316. <if test="secondUserId != null and secondUserId != ''">
  317. AND a.two_level_user_id = #{secondUserId}
  318. </if>
  319. <if test="thirdUserId != null and thirdUserId != ''">
  320. AND a.three_level_user_id = #{thirdUserId}
  321. </if>
  322. <if test="id != null and id != ''">
  323. AND a.id = #{id}
  324. </if>
  325. </select>
  326. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  327. SELECT
  328. io.*,
  329. sd.management_source,
  330. su2.name AS auditUser,
  331. ifa.audittime as auditTime
  332. FROM
  333. ins_orders io
  334. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  335. LEFT JOIN sys_user su ON su.id = io.userid
  336. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  337. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  338. WHERE
  339. io.orderno IN (
  340. SELECT
  341. orderno
  342. FROM
  343. ins_area_company
  344. WHERE
  345. id IN (
  346. SELECT
  347. ifon.ins_order_no
  348. FROM
  349. ins_fee_order_new ifon
  350. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  351. WHERE
  352. ifa.auditstatus = #{params.auditStatus}
  353. )
  354. )
  355. AND orderstatus = 3
  356. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  357. <!-- AND orderno = #{params.orderNo}-->
  358. <!-- </if>-->
  359. <if test="params.licenseNo != null and params.licenseNo != ''">
  360. AND licenseno = #{params.licenseNo}
  361. </if>
  362. <if test="params.frameNo != null and params.frameNo != ''">
  363. AND frameno = #{params.frameNo}
  364. </if>
  365. <if test="params.insuredName != null and params.insuredName != ''">
  366. AND insuredname = #{params.insuredName}
  367. </if>
  368. <if test="params.companyId != null and params.companyId != ''">
  369. AND company_id = #{params.companyId}
  370. </if>
  371. <if test="params.startDateStr != null and params.startDateStr != ''">
  372. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  373. </if>
  374. </select>
  375. </mapper>