InsFeeOrderNewMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  198. WHERE
  199. a.user_id = #{userId}
  200. and ins.orderstatus ='3'
  201. and iff.auditstatus=0
  202. </select>
  203. <select id="getSumWillAmount" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  204. select
  205. a.ins_order_no as "id",
  206. a.user_id as "userId",
  207. ins.signing_time as "signingTime",
  208. o.licenseno as "licenseno",
  209. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  210. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  211. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  212. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  213. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  214. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  215. from
  216. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  217. left join ins_orders o ON o.orderno=ins.orderno
  218. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  219. <where>
  220. <if test="userId !=null and userId !=''">
  221. a.user_id = #{userId}
  222. </if>
  223. and ins.orderstatus ='3'
  224. and iff.auditstatus=0
  225. <if test="timeFiltering!= null and timeFiltering !=''">
  226. AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
  227. </if>
  228. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  229. 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 )
  230. </if>
  231. </where>
  232. </select>
  233. <select id="getSumWillAmountGeneralization" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  234. SELECT
  235. fee.id,
  236. fee.userId,
  237. fee.signingTime,
  238. fee.licenseno,
  239. fee.jqExportSuperviseCostsPremiums,
  240. fee.syExportSuperviseCostsPremiums,
  241. fee.noExportSuperviseCostsPremiums,
  242. fee.jqExportOtherCostsPremiums,
  243. fee.syExportOtherCostsPremiums,
  244. fee.noExportOtherCostsPremiums,
  245. fee.willAmount
  246. FROM
  247. (
  248. SELECT
  249. a.ins_order_no as "id",
  250. a.user_id as "userId",
  251. iac.signing_time as "signingTime",
  252. o.licenseno as "licenseno",
  253. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  254. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  255. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  256. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  257. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  258. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  259. a.first_detail_premiums as "willAmount"
  260. FROM
  261. ins_fee_order_new a
  262. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  263. left join ins_orders o ON o.orderno=iac.orderno
  264. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  265. <where>
  266. iff.auditstatus=0
  267. and iac.orderstatus = '3'
  268. <if test="userId!=null and userId!= ''">
  269. AND a.first_level_user_id = #{userId}
  270. </if>
  271. </where>
  272. UNION
  273. SELECT
  274. a.ins_order_no as "id",
  275. a.user_id as "userId",
  276. iac.signing_time as "signingTime",
  277. o.licenseno as "licenseno",
  278. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  279. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  280. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  281. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  282. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  283. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  284. a.third_detail_premiums as "willAmount"
  285. FROM
  286. ins_fee_order_new a
  287. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  288. left join ins_orders o ON o.orderno=iac.orderno
  289. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  290. <where>
  291. iff.auditstatus=0
  292. and iac.orderstatus = '3'
  293. <if test="userId!=null and userId!= ''">
  294. AND a.three_level_user_id = #{userId}
  295. </if>
  296. </where>
  297. UNION
  298. SELECT
  299. a.ins_order_no as "id",
  300. a.user_id as "userId",
  301. iac.signing_time as "signingTime",
  302. o.licenseno as "licenseno",
  303. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  304. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  305. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  306. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  307. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  308. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  309. a.second_detail_premiums as "willAmount"
  310. FROM
  311. ins_fee_order_new a
  312. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  313. left join ins_orders o ON o.orderno=iac.orderno
  314. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  315. <where>
  316. iff.auditstatus=0
  317. and iac.orderstatus = '3'
  318. <if test="userId!=null and userId!= ''">
  319. AND a.two_level_user_id = #{userId}
  320. </if>
  321. </where>
  322. ) AS fee
  323. </select>
  324. <select id="getByUserIdAndOrderStatusAndNoCheckType"
  325. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  326. select
  327. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  328. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  329. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  330. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  331. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  332. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  333. from
  334. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  335. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  336. WHERE
  337. a.user_id = #{userId}
  338. and ins.orderstatus ='3'
  339. <choose>
  340. <when test='type == "1"'>
  341. and iff.auditstatus=0
  342. </when>
  343. <otherwise>
  344. and iff.auditstatus=1
  345. </otherwise>
  346. </choose>
  347. </select>
  348. <select id="getSumWillAmountGeneralizationNew"
  349. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  350. SELECT
  351. fee.id,
  352. fee.userId,
  353. fee.signingTime,
  354. fee.licenseno,
  355. fee.jqExportSuperviseCostsPremiums,
  356. fee.syExportSuperviseCostsPremiums,
  357. fee.noExportSuperviseCostsPremiums,
  358. fee.jqExportOtherCostsPremiums,
  359. fee.syExportOtherCostsPremiums,
  360. fee.noExportOtherCostsPremiums,
  361. fee.willAmount
  362. FROM
  363. (
  364. SELECT
  365. a.ins_order_no as "id",
  366. a.user_id as "userId",
  367. iac.signing_time as "signingTime",
  368. o.licenseno as "licenseno",
  369. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  370. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  371. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  372. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  373. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  374. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  375. a.first_detail_premiums as "willAmount"
  376. FROM
  377. ins_fee_order_new a
  378. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  379. left join ins_orders o ON o.orderno=iac.orderno
  380. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  381. <where>
  382. <choose>
  383. <when test='type == "1"'>
  384. iff.auditstatus=0
  385. </when>
  386. <otherwise>
  387. iff.auditstatus=1
  388. </otherwise>
  389. </choose>
  390. and iac.orderstatus = '3'
  391. <if test="userId!=null and userId!= ''">
  392. AND a.first_level_user_id = #{userId}
  393. </if>
  394. <if test="timeFiltering!= null and timeFiltering !=''">
  395. <choose>
  396. <when test='type == "1"'>
  397. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  398. </when>
  399. <otherwise>
  400. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  401. </otherwise>
  402. </choose>
  403. </if>
  404. </where>
  405. UNION
  406. SELECT
  407. a.ins_order_no as "id",
  408. a.user_id as "userId",
  409. iac.signing_time as "signingTime",
  410. o.licenseno as "licenseno",
  411. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  412. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  413. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  414. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  415. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  416. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  417. a.third_detail_premiums as "willAmount"
  418. FROM
  419. ins_fee_order_new a
  420. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  421. left join ins_orders o ON o.orderno=iac.orderno
  422. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  423. <where>
  424. <choose>
  425. <when test='type == "1"'>
  426. iff.auditstatus=0
  427. </when>
  428. <otherwise>
  429. iff.auditstatus=1
  430. </otherwise>
  431. </choose>
  432. and iac.orderstatus = '3'
  433. <if test="userId!=null and userId!= ''">
  434. AND a.three_level_user_id = #{userId}
  435. </if>
  436. <if test="timeFiltering!= null and timeFiltering !=''">
  437. <choose>
  438. <when test='type == "1"'>
  439. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  440. </when>
  441. <otherwise>
  442. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  443. </otherwise>
  444. </choose>
  445. </if>
  446. </where>
  447. UNION
  448. SELECT
  449. a.ins_order_no as "id",
  450. a.user_id as "userId",
  451. iac.signing_time as "signingTime",
  452. o.licenseno as "licenseno",
  453. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  454. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  455. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  456. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  457. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  458. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  459. a.second_detail_premiums as "willAmount"
  460. FROM
  461. ins_fee_order_new a
  462. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  463. left join ins_orders o ON o.orderno=iac.orderno
  464. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  465. <where>
  466. <choose>
  467. <when test='type == "1"'>
  468. iff.auditstatus=0
  469. </when>
  470. <otherwise>
  471. iff.auditstatus=1
  472. </otherwise>
  473. </choose>
  474. and iac.orderstatus = '3'
  475. <if test="userId!=null and userId!= ''">
  476. AND a.two_level_user_id = #{userId}
  477. </if>
  478. <if test="timeFiltering!= null and timeFiltering !=''">
  479. <choose>
  480. <when test='type == "1"'>
  481. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  482. </when>
  483. <otherwise>
  484. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  485. </otherwise>
  486. </choose>
  487. </if>
  488. </where>
  489. ) AS fee
  490. </select>
  491. <select id="getSumWillAmountNew" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  492. select
  493. a.ins_order_no as "id",
  494. a.user_id as "userId",
  495. ins.signing_time as "signingTime",
  496. o.licenseno as "licenseno",
  497. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  498. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  499. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  500. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  501. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  502. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  503. from
  504. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  505. left join ins_orders o ON o.orderno=ins.orderno
  506. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  507. <where>
  508. <if test="userId !=null and userId !=''">
  509. a.user_id = #{userId}
  510. </if>
  511. and ins.orderstatus ='3'
  512. <choose>
  513. <when test='type == "1"'>
  514. and iff.auditstatus=0
  515. </when>
  516. <otherwise>
  517. and iff.auditstatus=1
  518. </otherwise>
  519. </choose>
  520. <if test="timeFiltering!= null and timeFiltering !=''">
  521. <choose>
  522. <when test='type == "1"'>
  523. AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  524. </when>
  525. <otherwise>
  526. AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  527. </otherwise>
  528. </choose>
  529. </if>
  530. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  531. 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 )
  532. </if>
  533. </where>
  534. </select>
  535. </mapper>