InsAreaCompanyMapper.xml 18 KB

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