InsAreaCompanyMapper.xml 17 KB

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