InsAreaCompanyMapper.xml 27 KB

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