InsAreaCompanyMapper.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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,io.is_external
  102. FROM ins_area_company as iac
  103. left join ptl_agreement as pa on pa.id = iac.agreement_id
  104. left join ins_orders io on iac.orderno=io.orderno
  105. WHERE iac.orderstatus = 3
  106. and iac.orderno = #{orderNo};
  107. </select>
  108. <select id="queryLatestStatus" resultType="java.lang.String">
  109. SELECT iac.orderstatus
  110. FROM ins_area_company as iac
  111. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  112. FROM ins_area_company
  113. WHERE orderno = #{orderNo}
  114. GROUP BY company_id) t ON t.company_id = iac.company_id
  115. AND t.max_createtime = iac.createtime
  116. WHERE iac.orderno = #{orderNo}
  117. ORDER BY orderstatus DESC
  118. LIMIT 1
  119. </select>
  120. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  121. SELECT a.id as "id",
  122. a.orderno as "orderno"
  123. FROM ins_area_company a
  124. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  125. WHERE a.orderstatus = '3'
  126. or a.orderstatus = '2'
  127. and b.id is not null
  128. </select>
  129. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  130. SELECT
  131. iac.id as orderno,
  132. io.quoteno,
  133. io.orderstatus,
  134. io.company_id,
  135. io.ins_company,
  136. io.carinfo,
  137. io.userid,
  138. io.username,
  139. io.deptid,
  140. io.deptname,
  141. io.agreeid,
  142. iac.productid,
  143. iac.product,
  144. iac.createtime,
  145. io.frameno,
  146. io.licenseno,
  147. io.insuredname,
  148. io.is_external,
  149. iac.jq_start_date as jqstartdate,
  150. iac.jq_end_date as jqenddate,
  151. iac.sy_start_date as systartdate,
  152. iac.sy_end_date as syenddate,
  153. io.vehicle_and_vessel_tax,
  154. io.operatorid,
  155. iac.operator_name,
  156. sd.management_source,
  157. iac.problem_order,
  158. CASE ifa.audituser
  159. WHEN '自动审核' THEN ifa.audituser
  160. ELSE su2.name END
  161. AS auditUser,
  162. ifa.audittime as auditTime,
  163. ifa.auditstatus as auditStatus,
  164. eic.namesimple as partnerCompaniesName,
  165. iac.id as subOrderId,
  166. iac.signing_time as signingTime,
  167. iac.pay_date as payDate,
  168. pa.agreement_code as agreementCode,
  169. pa.agreement_name as agreementName
  170. FROM
  171. ins_fee_audit ifa
  172. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  173. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  174. AND iac.orderstatus = 3
  175. LEFT JOIN sys_user su ON su.id = io.userid
  176. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  177. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  178. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  179. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  180. WHERE
  181. iac.id = ifa.ins_order_no
  182. AND iac.orderstatus = 3
  183. <if test="params.auditStatus != null and params.auditStatus != ''">
  184. and ifa.auditstatus = #{params.auditStatus}
  185. </if>
  186. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  187. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  188. #{params.quoteEndDateStr}
  189. </if>
  190. <if test="params.orderNo != null and params.orderNo != ''">
  191. AND iac.id= #{params.orderNo}
  192. </if>
  193. <if test="params.licenseNo != null and params.licenseNo != ''">
  194. AND io.licenseno = #{params.licenseNo}
  195. </if>
  196. <if test="params.frameNo != null and params.frameNo != ''">
  197. AND io.frameno = #{params.frameNo}
  198. </if>
  199. <if test="params.insuredName != null and params.insuredName != ''">
  200. AND io.insuredname = #{params.insuredName}
  201. </if>
  202. <if test="params.companyId != null and params.companyId != ''">
  203. AND io.company_id = #{params.companyId}
  204. </if>
  205. <if test="params.engineNo != null and params.engineNo != ''">
  206. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  207. </if>
  208. <if test="params.riskCode != null and params.riskCode != ''">
  209. and iac.product = #{params.riskCode}
  210. </if>
  211. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  212. and ((
  213. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  214. AND #{params.attachEndDateStr}
  215. )
  216. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  217. #{params.attachEndDateStr} )
  218. )
  219. </if>
  220. <if test="params.provinceId != null and params.provinceId != ''">
  221. and io.deptid like "${params.provinceId}%"
  222. </if>
  223. <if test="params.problemOrder != null and params.problemOrder != ''">
  224. and iac.problem_order like "${params.problemOrder}%"
  225. </if>
  226. <if test="params.cityId != null and params.cityId != ''">
  227. and io.deptid like "${params.cityId}%"
  228. </if>
  229. <if test="params.countyId != null and params.countyId != ''">
  230. and io.deptid like "${params.countyId}%"
  231. </if>
  232. <if test="params.houseId != null and params.houseId != ''">
  233. and io.deptid like "${params.houseId}%"
  234. </if>
  235. <if test="params.operatorId != null and params.operatorId != ''">
  236. and io.userid = #{params.operatorId}
  237. </if>
  238. <if test="params.operatorName != null and params.operatorName != ''">
  239. and io.username = #{params.operatorName}
  240. </if>
  241. <if test="params.auditId != null and params.auditId != ''">
  242. and iac.new_operator_id = #{params.auditId}
  243. </if>
  244. <if test="params.agreeId != null and params.agreeId != ''">
  245. and iac.agreement_id = #{params.agreeId}
  246. </if>
  247. <if test="params.managementSource != null and params.managementSource != ''">
  248. and sd.management_source = #{params.managementSource}
  249. </if>
  250. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  251. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  252. #{params.signEndDateStr}
  253. </if>
  254. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  255. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  256. </if>
  257. <if test="params.isExternal != null and params.isExternal != ''">
  258. and iac.is_external = #{params.isExternal}
  259. </if>
  260. order by iac.createtime desc
  261. </select>
  262. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  263. SELECT
  264. io.*,
  265. sd.management_source
  266. FROM
  267. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  268. WHERE
  269. orderno IN (
  270. SELECT
  271. orderno
  272. FROM
  273. ins_area_company
  274. WHERE
  275. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  276. AND orderstatus = 3
  277. )
  278. AND
  279. io.orderstatus= 3
  280. <if test="orderNo != null and orderNo != ''">
  281. AND orderno = #{orderNo}
  282. </if>
  283. <if test="licenseNo != null and licenseNo != ''">
  284. AND licenseno = #{licenseNo}
  285. </if>
  286. <if test="frameNo != null and frameNo != ''">
  287. AND frameno = #{frameNo}
  288. </if>
  289. <if test="userId != null and userId != ''">
  290. AND userid = #{userId}
  291. </if>
  292. <if test="insuredname != null and insuredname != ''">
  293. AND insuredname = #{insuredname}
  294. </if>
  295. <if test="startDateStr != null and startDateStr != ''">
  296. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  297. </if>
  298. </select>
  299. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  300. SELECT
  301. sum(a.first_detail_premiums) as "willFirstPremiums"
  302. FROM
  303. ins_fee_order_new a
  304. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  305. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  306. WHERE
  307. iff.auditstatus=0
  308. AND iac.orderstatus =3
  309. <if test="firstUserId != null and firstUserId != ''">
  310. AND a.first_level_user_id = #{firstUserId}
  311. </if>
  312. <if test="secondUserId != null and secondUserId != ''">
  313. AND a.two_level_user_id = #{secondUserId}
  314. </if>
  315. <if test="thirdUserId != null and thirdUserId != ''">
  316. AND a.three_level_user_id = #{thirdUserId}
  317. </if>
  318. <if test="id != null and id != ''">
  319. AND a.id = #{id}
  320. </if>
  321. </select>
  322. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  323. SELECT
  324. sum( fee.p ) as "willFirstPremiums"
  325. FROM
  326. (
  327. SELECT
  328. sum( a.first_detail_premiums ) AS p
  329. FROM
  330. ins_fee_order_new a
  331. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  332. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  333. <where>
  334. iff.auditstatus=0
  335. and iac.orderstatus = '3'
  336. <if test="userId!=null and userId!= ''">
  337. AND a.first_level_user_id = #{userId}
  338. </if>
  339. <if test="id != null and id!=''">
  340. AND a.id =#{id}
  341. </if>
  342. </where>
  343. UNION
  344. SELECT
  345. sum( a.third_detail_premiums ) AS p
  346. FROM
  347. ins_fee_order_new a
  348. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  349. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  350. <where>
  351. iff.auditstatus=0
  352. and iac.orderstatus = '3'
  353. <if test="userId!=null and userId!= ''">
  354. AND a.three_level_user_id = #{userId}
  355. </if>
  356. <if test="id != null and id!=''">
  357. AND a.id =#{id}
  358. </if>
  359. </where>
  360. UNION
  361. SELECT
  362. sum( a.second_detail_premiums ) AS p
  363. FROM
  364. ins_fee_order_new a
  365. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  366. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  367. <where>
  368. iff.auditstatus=0
  369. and iac.orderstatus = '3'
  370. <if test="userId!=null and userId!= ''">
  371. AND a.two_level_user_id = #{userId}
  372. </if>
  373. <if test="id != null and id!=''">
  374. AND a.id =#{id}
  375. </if>
  376. </where>
  377. ) AS fee
  378. </select>
  379. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  380. SELECT
  381. sum(a.third_detail_premiums) as "willThreePremiums"
  382. FROM
  383. ins_fee_order_new a
  384. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  385. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  386. WHERE
  387. iff.auditstatus=0
  388. AND iac.orderstatus =3
  389. <if test="firstUserId != null and firstUserId != ''">
  390. AND a.first_level_user_id = #{firstUserId}
  391. </if>
  392. <if test="secondUserId != null and secondUserId != ''">
  393. AND a.two_level_user_id = #{secondUserId}
  394. </if>
  395. <if test="thirdUserId != null and thirdUserId != ''">
  396. AND a.three_level_user_id = #{thirdUserId}
  397. </if>
  398. <if test="id != null and id != ''">
  399. AND a.id = #{id}
  400. </if>
  401. </select>
  402. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  403. SELECT
  404. io.*,
  405. sd.management_source,
  406. su2.name AS auditUser,
  407. ifa.audittime as auditTime
  408. FROM
  409. ins_orders io
  410. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  411. LEFT JOIN sys_user su ON su.id = io.userid
  412. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  413. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  414. WHERE
  415. io.orderno IN (
  416. SELECT
  417. orderno
  418. FROM
  419. ins_area_company
  420. WHERE
  421. id IN (
  422. SELECT
  423. ifon.ins_order_no
  424. FROM
  425. ins_fee_order_new ifon
  426. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  427. WHERE
  428. ifa.auditstatus = #{params.auditStatus}
  429. )
  430. )
  431. AND orderstatus = 3
  432. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  433. <!-- AND orderno = #{params.orderNo}-->
  434. <!-- </if>-->
  435. <if test="params.licenseNo != null and params.licenseNo != ''">
  436. AND licenseno = #{params.licenseNo}
  437. </if>
  438. <if test="params.frameNo != null and params.frameNo != ''">
  439. AND frameno = #{params.frameNo}
  440. </if>
  441. <if test="params.insuredName != null and params.insuredName != ''">
  442. AND insuredname = #{params.insuredName}
  443. </if>
  444. <if test="params.companyId != null and params.companyId != ''">
  445. AND company_id = #{params.companyId}
  446. </if>
  447. <if test="params.startDateStr != null and params.startDateStr != ''">
  448. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  449. </if>
  450. </select>
  451. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  452. -- 查询订单信息
  453. SELECT
  454. iac.*
  455. FROM
  456. ins_area_company iac
  457. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  458. WHERE
  459. 1=1
  460. <if test="dateStr != null and dateStr != ''">
  461. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  462. </if>
  463. </select>
  464. <select id="selectListById" resultMap="BaseResultMap">
  465. SELECT
  466. iac.*
  467. FROM
  468. ins_area_company iac
  469. WHERE
  470. 1=1
  471. <if test="id != null and id != ''">
  472. AND iac.id =#{id}
  473. </if>
  474. </select>
  475. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  476. SELECT
  477. sum( fee.p ) as "willFirstPremiums"
  478. FROM
  479. (
  480. SELECT
  481. sum( a.first_detail_premiums ) AS p
  482. FROM
  483. ins_fee_order_new a
  484. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  485. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  486. <where>
  487. <choose>
  488. <when test='type == "1"'>
  489. iff.auditstatus=0
  490. </when>
  491. <otherwise>
  492. iff.auditstatus=1
  493. </otherwise>
  494. </choose>
  495. and iac.orderstatus = '3'
  496. <if test="userId!=null and userId!= ''">
  497. AND a.first_level_user_id = #{userId}
  498. </if>
  499. <if test="id != null and id!=''">
  500. AND a.id =#{id}
  501. </if>
  502. </where>
  503. UNION
  504. SELECT
  505. sum( a.third_detail_premiums ) AS p
  506. FROM
  507. ins_fee_order_new a
  508. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  509. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  510. <where>
  511. <choose>
  512. <when test='type == "1"'>
  513. iff.auditstatus=0
  514. </when>
  515. <otherwise>
  516. iff.auditstatus=1
  517. </otherwise>
  518. </choose>
  519. and iac.orderstatus = '3'
  520. <if test="userId!=null and userId!= ''">
  521. AND a.three_level_user_id = #{userId}
  522. </if>
  523. <if test="id != null and id!=''">
  524. AND a.id =#{id}
  525. </if>
  526. </where>
  527. UNION
  528. SELECT
  529. sum( a.second_detail_premiums ) AS p
  530. FROM
  531. ins_fee_order_new a
  532. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  533. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  534. <where>
  535. <choose>
  536. <when test='type == "1"'>
  537. iff.auditstatus=0
  538. </when>
  539. <otherwise>
  540. iff.auditstatus=1
  541. </otherwise>
  542. </choose>
  543. and iac.orderstatus = '3'
  544. <if test="userId!=null and userId!= ''">
  545. AND a.two_level_user_id = #{userId}
  546. </if>
  547. <if test="id != null and id!=''">
  548. AND a.id =#{id}
  549. </if>
  550. </where>
  551. ) AS fee
  552. </select>
  553. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  554. SELECT
  555. iac.id as subOrderId,
  556. iac.signing_time as signingTime,
  557. iac.jqpremium as jqpremium,
  558. iac.sypremium as sypremium,
  559. iac.jypremium as jypremium,
  560. io.licenseno as licenseno,
  561. io.userid as userId
  562. FROM
  563. ins_area_company iac
  564. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  565. WHERE
  566. iac.id=#{subOrderId}
  567. </select>
  568. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  569. SELECT
  570. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  571. sum(jqpremium) jqpremium,
  572. sum(sypremium) sypremium,
  573. sum(sumpremium) sumpremium
  574. FROM
  575. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  576. WHERE
  577. iac.orderstatus = 3 and
  578. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  579. and io.userid=#{userId}
  580. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  581. </select>
  582. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  583. SELECT
  584. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  585. sum(jqpremium) jqpremium,
  586. sum(sypremium) sypremium,
  587. sum(sumpremium) sumpremium
  588. FROM
  589. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  590. WHERE
  591. iac.orderstatus = 3 and
  592. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  593. and io.userid=#{userId}
  594. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  595. </select>
  596. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  597. SELECT
  598. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  599. reportDate,
  600. sum( jqpremium ) jqpremium,
  601. sum( sypremium ) sypremium,
  602. sum( sumpremium ) sumpremium
  603. FROM
  604. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  605. WHERE
  606. iac.orderstatus = 3 and
  607. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  608. and io.userid=#{userId}
  609. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  610. </select>
  611. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  612. SELECT
  613. ifnull(sum( iac.sumpremium ),0) as sumPremium,
  614. count( 0 ) as sumCount
  615. FROM
  616. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  617. WHERE
  618. iac.orderstatus = 3
  619. and io.userid=#{userId}
  620. AND YEAR (iac.createtime) = #{year}
  621. </select>
  622. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  623. select
  624. *
  625. FROM
  626. ins_fee_audit ifa
  627. LEFT JOIN
  628. ins_area_company iac on iac.id = ifa.ins_order_no
  629. WHERE
  630. iac.operator_id = #{userId}
  631. AND
  632. ifa.auditstatus = 2
  633. </select>
  634. <select id="queryBusinessDataPage"
  635. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  636. SELECT
  637. <if test="flag != null and flag!='' and flag='1'">
  638. o.userid as userId,
  639. o.username as userName,
  640. </if>
  641. sum(iac.sumpremium),
  642. sum(iac.jqpremium),
  643. sum(iac.sypremium),
  644. sum(iac.taxamount),
  645. sum(ion.no_premium)
  646. FROM
  647. ins_area_company iac
  648. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  649. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  650. where iac.orderstatus = 3 and ion.id is not null
  651. and o.userid IN
  652. <foreach item="item" collection="userList" open="(" separator="," close=")">
  653. #{item}
  654. </foreach>
  655. <if test="flag != null and flag!='' and flag='1'">
  656. group by o.userid,o.username
  657. </if>
  658. </select>
  659. <select id="queryQuotationSubOrderCountDataPage"
  660. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  661. SELECT
  662. <if test="flag != null and flag!='' and flag='1'">
  663. o.userid as userId,
  664. o.username as userName,
  665. </if>
  666. iac.orderstatus as orderStatus
  667. FROM
  668. ins_area_company iac
  669. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  670. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  671. and o.userid IN
  672. <foreach item="item" collection="userList" open="(" separator="," close=")">
  673. #{item}
  674. </foreach>
  675. <if test="flag != null and flag!='' and flag='1'">
  676. group by o.userid,o.username,iac.orderstatus
  677. </if>
  678. </select>
  679. <select id="queryQuotationOrderCountDataPage"
  680. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  681. SELECT
  682. <if test="flag != null and flag!='' and flag='1'">
  683. o.userid as userId,
  684. o.username as userName,
  685. </if>
  686. o.orderstatus
  687. FROM
  688. ins_orders o
  689. where (o.orderstatus = 0 or o.orderstatus = 3 )
  690. and o.userid IN
  691. <foreach item="item" collection="userList" open="(" separator="," close=")">
  692. #{item}
  693. </foreach>
  694. <if test="flag != null and flag!='' and flag='1'">
  695. group by o.userid,o.username,o.orderstatus
  696. </if>
  697. </select>
  698. </mapper>