InsFeeOrderNewMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydtech.modules.protocols.dao.InsFeeOrderNewMapper">
  4. <resultMap id="BaseResultMap" type="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  5. <id column="id" property="id"/>
  6. <result column="ins_order_no" property="insOrderNo"/>
  7. <result column="agreement_id" property="agreementId"/>
  8. <result column="costs_id" property="costsId"/>
  9. <result column="dept_id" property="deptId"/>
  10. <result column="user_id" property="userId"/>
  11. <result column="jq_premium" property="jqPremium"/>
  12. <result column="sy_premium" property="syPremium"/>
  13. <result column="no_premium" property="noPremium"/>
  14. <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
  15. <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
  16. <result column="no_no_tax_premium" property="noNoTaxPremium"/>
  17. <result column="jq_costs_proportion" property="jqCostsProportion"/>
  18. <result column="jq_costs_premiums" property="jqCostsPremiums"/>
  19. <result column="sy_costs_proportion" property="syCostsProportion"/>
  20. <result column="sy_costs_premiums" property="syCostsPremiums"/>
  21. <result column="no_costs_proportion" property="noCostsProportion"/>
  22. <result column="no_costs_premiums" property="noCostsPremiums"/>
  23. <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
  24. <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
  25. <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
  26. <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
  27. <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
  28. <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
  29. <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
  30. <result column="jq_other_costs_premiums" property="jqOtherCostsPremiums"/>
  31. <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
  32. <result column="sy_other_costs_premiums" property="syOtherCostsPremiums"/>
  33. <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
  34. <result column="no_other_costs_premiums" property="noOtherCostsPremiums"/>
  35. <result column="jq_investment_costs_proportion" property="jqInvestmentCostsProportion"/>
  36. <result column="jq_investment_costs_premiums" property="jqInvestmentCostsPremiums"/>
  37. <result column="sy_investment_costs_proportion" property="syInvestmentCostsProportion"/>
  38. <result column="sy_investment_costs_premiums" property="syInvestmentCostsPremiums"/>
  39. <result column="jq_dept_proportion_level_1" property="jqDeptProportionLevel1"/>
  40. <result column="jq_dept_premiums_level_1" property="jqDeptPremiumsLevel1"/>
  41. <result column="sy_dept_proportion_level_1" property="syDeptProportionLevel1"/>
  42. <result column="sy_dept_premiums_level_1" property="syDeptPremiumsLevel1"/>
  43. <result column="no_dept_proportion_level_1" property="noDeptProportionLevel1"/>
  44. <result column="no_dept_premiums_level_1" property="noDeptPremiumsLevel1"/>
  45. <result column="jq_dept_proportion_level_2" property="jqDeptProportionLevel2"/>
  46. <result column="jq_dept_premiums_level_2" property="jqDeptPremiumsLevel2"/>
  47. <result column="sy_dept_proportion_level_2" property="syDeptProportionLevel2"/>
  48. <result column="sy_dept_premiums_level_2" property="syDeptPremiumsLevel2"/>
  49. <result column="no_dept_proportion_level_2" property="noDeptProportionLevel2"/>
  50. <result column="no_dept_premiums_level_2" property="noDeptPremiumsLevel2"/>
  51. <result column="jq_dept_proportion_level_3" property="jqDeptProportionLevel3"/>
  52. <result column="jq_dept_premiums_level_3" property="jqDeptPremiumsLevel3"/>
  53. <result column="sy_dept_proportion_level_3" property="syDeptProportionLevel3"/>
  54. <result column="sy_dept_premiums_level_3" property="syDeptPremiumsLevel3"/>
  55. <result column="no_dept_proportion_level_3" property="noDeptProportionLevel3"/>
  56. <result column="no_dept_premiums_level_3" property="noDeptPremiumsLevel3"/>
  57. <result column="jq_dept_proportion_level_4" property="jqDeptProportionLevel4"/>
  58. <result column="jq_dept_premiums_level_4" property="jqDeptPremiumsLevel4"/>
  59. <result column="sy_dept_proportion_level_4" property="syDeptProportionLevel4"/>
  60. <result column="sy_dept_premiums_level_4" property="syDeptPremiumsLevel4"/>
  61. <result column="no_dept_proportion_level_4" property="noDeptProportionLevel4"/>
  62. <result column="no_dept_premiums_level_4" property="noDeptPremiumsLevel4"/>
  63. <result column="jq_dept_proportion_level_5" property="jqDeptProportionLevel5"/>
  64. <result column="jq_dept_premiums_level_5" property="jqDeptPremiumsLevel5"/>
  65. <result column="sy_dept_proportion_level_5" property="syDeptProportionLevel5"/>
  66. <result column="sy_dept_premiums_level_5" property="syDeptPremiumsLevel5"/>
  67. <result column="no_dept_proportion_level_5" property="noDeptProportionLevel5"/>
  68. <result column="no_dept_premiums_level_5" property="noDeptPremiumsLevel5"/>
  69. <result column="jq_costs_export_proportion" property="jqCostsExportProportion"/>
  70. <result column="sy_costs_export_proportion" property="syCostsExportProportion"/>
  71. <result column="no_costs_export_proportion" property="noCostsExportProportion"/>
  72. <result column="jq_export_investment_proportion" property="jqExportInvestmentProportion"/>
  73. <result column="jq_export_investment_premiums" property="jqExportInvestmentPremiums"/>
  74. <result column="sy_export_investment_proportion" property="syExportInvestmentProportion"/>
  75. <result column="sy_export_investment_premiums" property="syExportInvestmentPremiums"/>
  76. <result column="first_detail_proportion" property="firstDetailProportion"/>
  77. <result column="first_detail_premiums" property="firstDetailPremiums"/>
  78. <result column="second_detail_proportion" property="secondDetailProportion"/>
  79. <result column="second_detail_premiums" property="secondDetailPremiums"/>
  80. <result column="third_detail_proportion" property="thirdDetailProportion"/>
  81. <result column="third_detail_premiums" property="thirdDetailPremiums"/>
  82. <result column="create_time" property="createTime"/>
  83. <result column="first_level_user_id" property="firstLevelUserId"/>
  84. <result column="two_level_user_id" property="twoLevelUserId"/>
  85. <result column="three_level_user_id" property="threeLevelUserId"/>
  86. <result column="distribution_status" property="distributionStatus"/>
  87. <result column="dept_distribution" property="deptDistribution"/>
  88. </resultMap>
  89. <select id="getInsFeeOrderEntity" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  90. select
  91. a.id as "id",
  92. a.ins_order_no as "insOrderNo",
  93. a.agreement_id as "agreementId",
  94. a.costs_id as "costsId",
  95. a.dept_id as "deptId",
  96. a.user_id as "userId",
  97. a.jq_premium as "jqPremium",
  98. a.sy_premium as "syPremium",
  99. a.no_premium as "noPremium",
  100. a.jq_no_tax_premium as "jqNoTaxPremium",
  101. a.sy_no_tax_premium as "syNoTaxPremium",
  102. a.no_no_tax_premium as "noNoTaxPremium",
  103. a.jq_costs_proportion as "jqCostsProportion",
  104. a.jq_costs_premiums as "jqCostsPremiums",
  105. a.sy_costs_proportion as "syCostsProportion",
  106. a.sy_costs_premiums as "syCostsPremiums",
  107. a.no_costs_proportion as "noCostsProportion",
  108. a.no_costs_premiums as "noCostsPremiums",
  109. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  110. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  111. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  112. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  113. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  114. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  115. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  116. a.jq_other_costs_premiums as "jqOtherCostsPremiums",
  117. a.sy_other_costs_proportion as "syOtherCostsProportion",
  118. a.sy_other_costs_premiums as "syOtherCostsPremiums",
  119. a.no_other_costs_proportion as "noOtherCostsProportion",
  120. a.no_other_costs_premiums as "noOtherCostsPremiums",
  121. a.jq_investment_costs_proportion as "jqInvestmentCostsProportion",
  122. a.jq_investment_costs_premiums as "jqInvestmentCostsPremiums",
  123. a.sy_investment_costs_proportion as "syInvestmentCostsProportion",
  124. a.sy_investment_costs_premiums as "syInvestmentCostsPremiums",
  125. a.jq_dept_proportion_level_1 as "jqDeptProportionLevel1",
  126. a.jq_dept_premiums_level_1 as "jqDeptPremiumsLevel1",
  127. a.sy_dept_proportion_level_1 as "syDeptProportionLevel1",
  128. a.sy_dept_premiums_level_1 as "syDeptPremiumsLevel1",
  129. a.no_dept_proportion_level_1 as "noDeptProportionLevel1",
  130. a.no_dept_premiums_level_1 as "noDeptPremiumsLevel1",
  131. a.jq_dept_proportion_level_2 as "jqDeptProportionLevel2",
  132. a.jq_dept_premiums_level_2 as "jqDeptPremiumsLevel2",
  133. a.sy_dept_proportion_level_2 as "syDeptProportionLevel2",
  134. a.sy_dept_premiums_level_2 as "syDeptPremiumsLevel2",
  135. a.no_dept_proportion_level_2 as "noDeptProportionLevel2",
  136. a.no_dept_premiums_level_2 as "noDeptPremiumsLevel2",
  137. a.jq_dept_proportion_level_3 as "jqDeptProportionLevel3",
  138. a.jq_dept_premiums_level_3 as "jqDeptPremiumsLevel3",
  139. a.sy_dept_proportion_level_3 as "syDeptProportionLevel3",
  140. a.sy_dept_premiums_level_3 as "syDeptPremiumsLevel3",
  141. a.no_dept_proportion_level_3 as "noDeptProportionLevel3",
  142. a.no_dept_premiums_level_3 as "noDeptPremiumsLevel3",
  143. a.jq_dept_proportion_level_4 as "jqDeptProportionLevel4",
  144. a.jq_dept_premiums_level_4 as "jqDeptPremiumsLevel4",
  145. a.sy_dept_proportion_level_4 as "syDeptProportionLevel4",
  146. a.sy_dept_premiums_level_4 as "syDeptPremiumsLevel4",
  147. a.no_dept_proportion_level_4 as "noDeptProportionLevel4",
  148. a.no_dept_premiums_level_4 as "noDeptPremiumsLevel4",
  149. a.jq_dept_proportion_level_5 as "jqDeptProportionLevel5",
  150. a.jq_dept_premiums_level_5 as "jqDeptPremiumsLevel5",
  151. a.sy_dept_proportion_level_5 as "syDeptProportionLevel5",
  152. a.sy_dept_premiums_level_5 as "syDeptPremiumsLevel5",
  153. a.no_dept_proportion_level_5 as "noDeptProportionLevel5",
  154. a.no_dept_premiums_level_5 as "noDeptPremiumsLevel5",
  155. a.jq_costs_export_proportion as "jqCostsExportProportion",
  156. a.sy_costs_export_proportion as "syCostsExportProportion",
  157. a.no_costs_export_proportion as "noCostsExportProportion",
  158. a.jq_export_investment_proportion as "jqExportInvestmentProportion",
  159. a.jq_export_investment_premiums as "jqExportInvestmentPremiums",
  160. a.sy_export_investment_proportion as "syExportInvestmentProportion",
  161. a.sy_export_investment_premiums as "syExportInvestmentPremiums",
  162. a.first_detail_proportion as "firstDetailProportion",
  163. a.first_detail_premiums as "firstDetailPremiums",
  164. a.second_detail_proportion as "secondDetailProportion",
  165. a.second_detail_premiums as "secondDetailPremiums",
  166. a.third_detail_proportion as "thirdDetailProportion",
  167. a.third_detail_premiums as "thirdDetailPremiums",
  168. a.create_time as "createTime",
  169. a.first_level_user_id as "firstLevelUserId",
  170. a.two_level_user_id as "twoLevelUserId",
  171. a.three_level_user_id as "threeLevelUserId",
  172. a.distribution_status as "distributionStatus",
  173. a.dept_distribution as "deptDistribution",
  174. iac.signing_time as "signingTime",
  175. io.licenseno as "licenseno"
  176. from ins_fee_order_new a
  177. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  178. LEFT JOIN ins_orders io on io.quoteno =iac.id
  179. <where>
  180. 1=1
  181. <if test="id !=null and id !=''">
  182. AND a.ins_order_no=#{id}
  183. </if>
  184. </where>
  185. </select>
  186. <select id="getByUserId" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  187. select a.* from ins_fee_order_new a
  188. <where>
  189. <if test="userId !=null and userId !=''">
  190. a.user_id =#{userId}
  191. </if>
  192. </where>
  193. </select>
  194. <select id="getByUserIdAndOrderStatusAndNoCheck" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  195. select a.* from
  196. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  197. WHERE
  198. a.user_id = #{userId}
  199. and ins.orderstatus ='3'
  200. and a.ins_order_no not in (select ins_order_no from ins_fee_audit)
  201. </select>
  202. <select id="getSumWillAmount" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  203. select
  204. a.ins_order_no as "id",
  205. a.user_id as "userId",
  206. ins.signing_time as "signingTime",
  207. o.licenseno as "licenseno",
  208. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  209. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  210. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  211. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  212. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  213. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  214. from
  215. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  216. left join ins_orders o ON o.orderno=ins.orderno
  217. <where>
  218. <if test="userId !=null and userId !=''">
  219. a.user_id = #{userId}
  220. </if>
  221. and ins.orderstatus ='3'
  222. and a.ins_order_no not in (select ins_order_no from ins_fee_audit)
  223. <if test="timeFiltering!= null and timeFiltering !=''">
  224. AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
  225. </if>
  226. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  227. and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
  228. </if>
  229. </where>
  230. </select>
  231. <select id="getSumWillAmountGeneralization" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  232. SELECT
  233. fee.id,
  234. fee.userId,
  235. fee.signingTime,
  236. fee.licenseno,
  237. fee.jqExportSuperviseCostsPremiums,
  238. fee.syExportSuperviseCostsPremiums,
  239. fee.noExportSuperviseCostsPremiums,
  240. fee.jqExportOtherCostsPremiums,
  241. fee.syExportOtherCostsPremiums,
  242. fee.noExportOtherCostsPremiums,
  243. fee.willAmount
  244. FROM
  245. (
  246. SELECT
  247. a.ins_order_no as "id",
  248. a.user_id as "userId",
  249. iac.signing_time as "signingTime",
  250. o.licenseno as "licenseno",
  251. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  252. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  253. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  254. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  255. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  256. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  257. a.first_detail_premiums as "willAmount"
  258. FROM
  259. ins_fee_order_new a
  260. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  261. left join ins_orders o ON o.orderno=iac.orderno
  262. <where>
  263. a.ins_order_no NOT IN ( SELECT ins_order_no FROM ins_fee_audit )
  264. and iac.orderstatus = '3'
  265. <if test="userId!=null and userId!= ''">
  266. AND a.first_level_user_id = #{userId}
  267. </if>
  268. </where>
  269. UNION
  270. SELECT
  271. a.ins_order_no as "id",
  272. a.user_id as "userId",
  273. iac.signing_time as "signingTime",
  274. o.licenseno as "licenseno",
  275. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  276. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  277. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  278. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  279. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  280. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  281. a.third_detail_premiums as "willAmount"
  282. FROM
  283. ins_fee_order_new a
  284. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  285. left join ins_orders o ON o.orderno=iac.orderno
  286. <where>
  287. a.ins_order_no NOT IN ( SELECT ins_order_no FROM ins_fee_audit )
  288. and iac.orderstatus = '3'
  289. <if test="userId!=null and userId!= ''">
  290. AND a.three_level_user_id = #{userId}
  291. </if>
  292. </where>
  293. UNION
  294. SELECT
  295. a.ins_order_no as "id",
  296. a.user_id as "userId",
  297. iac.signing_time as "signingTime",
  298. o.licenseno as "licenseno",
  299. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  300. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  301. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  302. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  303. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  304. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  305. a.second_detail_premiums as "willAmount"
  306. FROM
  307. ins_fee_order_new a
  308. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  309. left join ins_orders o ON o.orderno=iac.orderno
  310. <where>
  311. a.ins_order_no NOT IN ( SELECT ins_order_no FROM ins_fee_audit )
  312. and iac.orderstatus = '3'
  313. <if test="userId!=null and userId!= ''">
  314. AND a.two_level_user_id = #{userId}
  315. </if>
  316. </where>
  317. ) AS fee
  318. </select>
  319. <select id="getByUserIdAndOrderStatusAndNoCheckType"
  320. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  321. select a.* from
  322. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  323. WHERE
  324. a.user_id = #{userId}
  325. and ins.orderstatus ='3'
  326. and a.ins_order_no
  327. <if test="type=='1'">
  328. not
  329. </if>
  330. in
  331. (select ins_order_no from ins_fee_audit)
  332. </select>
  333. <select id="getSumWillAmountGeneralizationNew"
  334. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  335. SELECT
  336. fee.id,
  337. fee.userId,
  338. fee.signingTime,
  339. fee.licenseno,
  340. fee.jqExportSuperviseCostsPremiums,
  341. fee.syExportSuperviseCostsPremiums,
  342. fee.noExportSuperviseCostsPremiums,
  343. fee.jqExportOtherCostsPremiums,
  344. fee.syExportOtherCostsPremiums,
  345. fee.noExportOtherCostsPremiums,
  346. fee.willAmount
  347. FROM
  348. (
  349. SELECT
  350. a.ins_order_no as "id",
  351. a.user_id as "userId",
  352. iac.signing_time as "signingTime",
  353. o.licenseno as "licenseno",
  354. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  355. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  356. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  357. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  358. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  359. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  360. a.first_detail_premiums as "willAmount"
  361. FROM
  362. ins_fee_order_new a
  363. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  364. left join ins_orders o ON o.orderno=iac.orderno
  365. <where>
  366. <if test='type == "1"'>
  367. NOT
  368. </if>
  369. EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
  370. and iac.orderstatus = '3'
  371. <if test="userId!=null and userId!= ''">
  372. AND a.first_level_user_id = #{userId}
  373. </if>
  374. <if test="timeFiltering!= null and timeFiltering !=''">
  375. <choose>
  376. <when test='type == "1"'>
  377. AND DATE_FORMAT(iac.signing_time, '%Y-%m' ) = #{timeFiltering}
  378. </when>
  379. <otherwise>
  380. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  381. </otherwise>
  382. </choose>
  383. </if>
  384. </where>
  385. UNION
  386. SELECT
  387. a.ins_order_no as "id",
  388. a.user_id as "userId",
  389. iac.signing_time as "signingTime",
  390. o.licenseno as "licenseno",
  391. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  392. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  393. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  394. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  395. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  396. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  397. a.third_detail_premiums as "willAmount"
  398. FROM
  399. ins_fee_order_new a
  400. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  401. left join ins_orders o ON o.orderno=iac.orderno
  402. <where>
  403. <if test='type == "1"'>
  404. NOT
  405. </if>
  406. EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
  407. and iac.orderstatus = '3'
  408. <if test="userId!=null and userId!= ''">
  409. AND a.three_level_user_id = #{userId}
  410. </if>
  411. <if test="timeFiltering!= null and timeFiltering !=''">
  412. <choose>
  413. <when test='type == "1"'>
  414. AND DATE_FORMAT(iac.signing_time, '%Y-%m' ) = #{timeFiltering}
  415. </when>
  416. <otherwise>
  417. AND DATE_FORMAT(iac.signing_time, '%Y-%m' ) = #{timeFiltering}
  418. </otherwise>
  419. </choose>
  420. </if>
  421. </where>
  422. UNION
  423. SELECT
  424. a.ins_order_no as "id",
  425. a.user_id as "userId",
  426. iac.signing_time as "signingTime",
  427. o.licenseno as "licenseno",
  428. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  429. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  430. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  431. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  432. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  433. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  434. a.second_detail_premiums as "willAmount"
  435. FROM
  436. ins_fee_order_new a
  437. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  438. left join ins_orders o ON o.orderno=iac.orderno
  439. <where>
  440. <if test='type == "1"'>
  441. NOT
  442. </if>
  443. EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
  444. and iac.orderstatus = '3'
  445. <if test="userId!=null and userId!= ''">
  446. AND a.two_level_user_id = #{userId}
  447. </if>
  448. <if test="timeFiltering!= null and timeFiltering !=''">
  449. <choose>
  450. <when test='type == "1"'>
  451. AND DATE_FORMAT(iac.signing_time, '%Y-%m' ) = #{timeFiltering}
  452. </when>
  453. <otherwise>
  454. AND DATE_FORMAT(iac.signing_time, '%Y-%m' ) = #{timeFiltering}
  455. </otherwise>
  456. </choose>
  457. </if>
  458. </where>
  459. ) AS fee
  460. </select>
  461. <select id="getSumWillAmountNew" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  462. select
  463. a.ins_order_no as "id",
  464. a.user_id as "userId",
  465. ins.signing_time as "signingTime",
  466. o.licenseno as "licenseno",
  467. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  468. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  469. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  470. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  471. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  472. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  473. from
  474. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  475. left join ins_orders o ON o.orderno=ins.orderno
  476. <where>
  477. <if test="userId !=null and userId !=''">
  478. a.user_id = #{userId}
  479. </if>
  480. and ins.orderstatus ='3'
  481. and
  482. <if test='type == "1"'>
  483. NOT
  484. </if>
  485. EXISTS (SELECT ins_order_no FROM ins_fee_audit fee where fee.ins_order_no =a.ins_order_no)
  486. <if test="timeFiltering!= null and timeFiltering !=''">
  487. <choose>
  488. <when test='type == "1"'>
  489. AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
  490. </when>
  491. <otherwise>
  492. AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
  493. </otherwise>
  494. </choose>
  495. </if>
  496. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  497. and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
  498. </if>
  499. </where>
  500. </select>
  501. </mapper>