InsAreaCompanyMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. iac.createtime,
  144. io.frameno,
  145. io.licenseno,
  146. io.insuredname,
  147. iac.jq_start_date as jqstartdate,
  148. iac.jq_end_date as jqenddate,
  149. iac.sy_start_date as systartdate,
  150. iac.sy_end_date as 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_fee_audit ifa
  168. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  169. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  170. AND iac.orderstatus = 3
  171. LEFT JOIN sys_user su ON su.id = io.userid
  172. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  173. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  174. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  175. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  176. WHERE
  177. iac.id = ifa.ins_order_no
  178. AND iac.orderstatus = 3
  179. <if test="params.auditStatus != null and params.auditStatus != ''">
  180. and ifa.auditstatus = #{params.auditStatus}
  181. </if>
  182. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  183. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  184. #{params.quoteEndDateStr}
  185. </if>
  186. <if test="params.taskNo != null and params.taskNo != ''">
  187. AND io.orderno = #{params.taskNo}
  188. </if>
  189. <if test="params.orderNo != null and params.orderNo != ''">
  190. AND iac.id = #{params.orderNo}
  191. </if>
  192. <if test="params.licenseNo != null and params.licenseNo != ''">
  193. AND io.licenseno = #{params.licenseNo}
  194. </if>
  195. <if test="params.frameNo != null and params.frameNo != ''">
  196. AND io.frameno = #{params.frameNo}
  197. </if>
  198. <if test="params.insuredName != null and params.insuredName != ''">
  199. AND io.insuredname = #{params.insuredName}
  200. </if>
  201. <if test="params.companyId != null and params.companyId != ''">
  202. AND io.company_id = #{params.companyId}
  203. </if>
  204. <if test="params.engineNo != null and params.engineNo != ''">
  205. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  206. </if>
  207. <if test="params.riskCode != null and params.riskCode != ''">
  208. and iac.product = #{params.riskCode}
  209. </if>
  210. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  211. and ((
  212. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  213. AND #{params.attachEndDateStr}
  214. )
  215. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  216. #{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(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  248. #{params.signEndDateStr}
  249. </if>
  250. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  251. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  252. </if>
  253. order by iac.createtime desc
  254. </select>
  255. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  256. SELECT
  257. io.*,
  258. sd.management_source
  259. FROM
  260. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  261. WHERE
  262. orderno IN (
  263. SELECT
  264. orderno
  265. FROM
  266. ins_area_company
  267. WHERE
  268. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  269. AND orderstatus = 3
  270. )
  271. AND
  272. io.orderstatus= 3
  273. <if test="orderNo != null and orderNo != ''">
  274. AND orderno = #{orderNo}
  275. </if>
  276. <if test="licenseNo != null and licenseNo != ''">
  277. AND licenseno = #{licenseNo}
  278. </if>
  279. <if test="frameNo != null and frameNo != ''">
  280. AND frameno = #{frameNo}
  281. </if>
  282. <if test="userId != null and userId != ''">
  283. AND userid = #{userId}
  284. </if>
  285. <if test="insuredname != null and insuredname != ''">
  286. AND insuredname = #{insuredname}
  287. </if>
  288. <if test="startDateStr != null and startDateStr != ''">
  289. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  290. </if>
  291. </select>
  292. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  293. SELECT
  294. sum(a.first_detail_premiums) as "willFirstPremiums"
  295. FROM
  296. ins_fee_order_new a
  297. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  298. WHERE
  299. a.ins_order_no NOT IN (
  300. SELECT
  301. ins_order_no
  302. FROM
  303. ins_fee_audit
  304. )
  305. AND iac.orderstatus =3
  306. <if test="firstUserId != null and firstUserId != ''">
  307. AND a.first_level_user_id = #{firstUserId}
  308. </if>
  309. <if test="secondUserId != null and secondUserId != ''">
  310. AND a.two_level_user_id = #{secondUserId}
  311. </if>
  312. <if test="thirdUserId != null and thirdUserId != ''">
  313. AND a.three_level_user_id = #{thirdUserId}
  314. </if>
  315. <if test="id != null and id != ''">
  316. AND a.id = #{id}
  317. </if>
  318. </select>
  319. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  320. SELECT
  321. sum( fee.p ) as "willFirstPremiums"
  322. FROM
  323. (
  324. SELECT
  325. sum( a.first_detail_premiums ) AS p
  326. FROM
  327. ins_fee_order_new a
  328. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  329. <where>
  330. NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  331. and iac.orderstatus = '3'
  332. <if test="userId!=null and userId!= ''">
  333. AND a.first_level_user_id = #{userId}
  334. </if>
  335. <if test="id != null and id!=''">
  336. AND a.id =#{id}
  337. </if>
  338. </where>
  339. UNION
  340. SELECT
  341. sum( a.third_detail_premiums ) AS p
  342. FROM
  343. ins_fee_order_new a
  344. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  345. <where>
  346. NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  347. and iac.orderstatus = '3'
  348. <if test="userId!=null and userId!= ''">
  349. AND a.three_level_user_id = #{userId}
  350. </if>
  351. <if test="id != null and id!=''">
  352. AND a.id =#{id}
  353. </if>
  354. </where>
  355. UNION
  356. SELECT
  357. sum( a.second_detail_premiums ) AS p
  358. FROM
  359. ins_fee_order_new a
  360. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  361. <where>
  362. NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  363. and iac.orderstatus = '3'
  364. <if test="userId!=null and userId!= ''">
  365. AND a.two_level_user_id = #{userId}
  366. </if>
  367. <if test="id != null and id!=''">
  368. AND a.id =#{id}
  369. </if>
  370. </where>
  371. ) AS fee
  372. </select>
  373. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  374. SELECT
  375. sum(a.third_detail_premiums) as "willThreePremiums"
  376. FROM
  377. ins_fee_order_new a
  378. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  379. WHERE
  380. NOT EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  381. AND iac.orderstatus =3
  382. <if test="firstUserId != null and firstUserId != ''">
  383. AND a.first_level_user_id = #{firstUserId}
  384. </if>
  385. <if test="secondUserId != null and secondUserId != ''">
  386. AND a.two_level_user_id = #{secondUserId}
  387. </if>
  388. <if test="thirdUserId != null and thirdUserId != ''">
  389. AND a.three_level_user_id = #{thirdUserId}
  390. </if>
  391. <if test="id != null and id != ''">
  392. AND a.id = #{id}
  393. </if>
  394. </select>
  395. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  396. SELECT
  397. io.*,
  398. sd.management_source,
  399. su2.name AS auditUser,
  400. ifa.audittime as auditTime
  401. FROM
  402. ins_orders io
  403. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  404. LEFT JOIN sys_user su ON su.id = io.userid
  405. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  406. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  407. WHERE
  408. io.orderno IN (
  409. SELECT
  410. orderno
  411. FROM
  412. ins_area_company
  413. WHERE
  414. id IN (
  415. SELECT
  416. ifon.ins_order_no
  417. FROM
  418. ins_fee_order_new ifon
  419. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  420. WHERE
  421. ifa.auditstatus = #{params.auditStatus}
  422. )
  423. )
  424. AND orderstatus = 3
  425. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  426. <!-- AND orderno = #{params.orderNo}-->
  427. <!-- </if>-->
  428. <if test="params.licenseNo != null and params.licenseNo != ''">
  429. AND licenseno = #{params.licenseNo}
  430. </if>
  431. <if test="params.frameNo != null and params.frameNo != ''">
  432. AND frameno = #{params.frameNo}
  433. </if>
  434. <if test="params.insuredName != null and params.insuredName != ''">
  435. AND insuredname = #{params.insuredName}
  436. </if>
  437. <if test="params.companyId != null and params.companyId != ''">
  438. AND company_id = #{params.companyId}
  439. </if>
  440. <if test="params.startDateStr != null and params.startDateStr != ''">
  441. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  442. </if>
  443. </select>
  444. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  445. -- 查询订单信息
  446. SELECT
  447. iac.*
  448. FROM
  449. ins_area_company iac
  450. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  451. WHERE
  452. 1=1
  453. <if test="dateStr != null and dateStr != ''">
  454. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  455. </if>
  456. </select>
  457. <select id="selectListById" resultMap="BaseResultMap">
  458. SELECT
  459. iac.*
  460. FROM
  461. ins_area_company iac
  462. WHERE
  463. 1=1
  464. <if test="id != null and id != ''">
  465. AND iac.id =#{id}
  466. </if>
  467. </select>
  468. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  469. SELECT
  470. sum( fee.p ) as "willFirstPremiums"
  471. FROM
  472. (
  473. SELECT
  474. sum( a.first_detail_premiums ) AS p
  475. FROM
  476. ins_fee_order_new a
  477. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  478. <where>
  479. <if test='type == "1"'>
  480. NOT
  481. </if>
  482. EXISTS
  483. ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  484. and iac.orderstatus = '3'
  485. <if test="userId!=null and userId!= ''">
  486. AND a.first_level_user_id = #{userId}
  487. </if>
  488. <if test="id != null and id!=''">
  489. AND a.id =#{id}
  490. </if>
  491. </where>
  492. UNION
  493. SELECT
  494. sum( a.third_detail_premiums ) AS p
  495. FROM
  496. ins_fee_order_new a
  497. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  498. <where>
  499. <if test='type == "1"'>
  500. NOT
  501. </if>
  502. EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  503. and iac.orderstatus = '3'
  504. <if test="userId!=null and userId!= ''">
  505. AND a.three_level_user_id = #{userId}
  506. </if>
  507. <if test="id != null and id!=''">
  508. AND a.id =#{id}
  509. </if>
  510. </where>
  511. UNION
  512. SELECT
  513. sum( a.second_detail_premiums ) AS p
  514. FROM
  515. ins_fee_order_new a
  516. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  517. <where>
  518. <if test='type == "1"'>
  519. NOT
  520. </if>
  521. EXISTS ( SELECT ins_order_no FROM ins_fee_audit AS b WHERE b.ins_order_no = a.ins_order_no )
  522. and iac.orderstatus = '3'
  523. <if test="userId!=null and userId!= ''">
  524. AND a.two_level_user_id = #{userId}
  525. </if>
  526. <if test="id != null and id!=''">
  527. AND a.id =#{id}
  528. </if>
  529. </where>
  530. ) AS fee
  531. </select>
  532. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  533. SELECT
  534. iac.id as subOrderId,
  535. iac.signing_time as signingTime,
  536. iac.jqpremium as jqpremium,
  537. iac.sypremium as sypremium,
  538. iac.jypremium as jypremium,
  539. io.licenseno as licenseno,
  540. io.userid as userId
  541. FROM
  542. ins_area_company iac
  543. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  544. WHERE
  545. iac.id=#{subOrderId}
  546. </select>
  547. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  548. SELECT
  549. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  550. sum(jqpremium) jqpremium,
  551. sum(sypremium) sypremium,
  552. sum(sumpremium) sumpremium
  553. FROM
  554. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  555. WHERE
  556. iac.orderstatus = 3 and
  557. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  558. and io.userid=#{userId}
  559. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  560. </select>
  561. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  562. SELECT
  563. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  564. sum(jqpremium) jqpremium,
  565. sum(sypremium) sypremium,
  566. sum(sumpremium) sumpremium
  567. FROM
  568. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  569. WHERE
  570. iac.orderstatus = 3 and
  571. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  572. and io.userid=#{userId}
  573. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  574. </select>
  575. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  576. SELECT
  577. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  578. reportDate,
  579. sum( jqpremium ) jqpremium,
  580. sum( sypremium ) sypremium,
  581. sum( sumpremium ) sumpremium
  582. FROM
  583. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  584. WHERE
  585. iac.orderstatus = 3 and
  586. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  587. and io.userid=#{userId}
  588. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  589. </select>
  590. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  591. SELECT
  592. ifnull(sum( iac.sumpremium ),0) as sumPremium,
  593. count( 0 ) as sumCount
  594. FROM
  595. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  596. WHERE
  597. iac.orderstatus = 3
  598. and io.userid=#{userId}
  599. AND YEAR (iac.createtime) = #{year}
  600. </select>
  601. </mapper>