InsFeeOrderNewMapper.xml 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  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. <select id="findMyCollectInAdvanceWillAmountByUserId"
  536. resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
  537. SELECT
  538. fee.subOrderNo,
  539. fee.signingTime,
  540. fee.licenseno,
  541. fee.amount,
  542. "1" as businessSegmentsType,
  543. "2" as transactionType,
  544. fee.createTime
  545. FROM
  546. (
  547. SELECT
  548. a.ins_order_no as "subOrderNo",
  549. iac.signing_time as "signingTime",
  550. o.licenseno as "licenseno",
  551. a.first_detail_premiums as "amount",
  552. iac.createtime as "createTime"
  553. FROM
  554. ins_fee_order_new a
  555. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  556. left join ins_orders o ON o.orderno=iac.orderno
  557. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  558. <where>
  559. iac.orderstatus = '3'
  560. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  561. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  562. </if>
  563. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  564. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  565. </if>
  566. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  567. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  568. </if>
  569. </where>
  570. UNION
  571. SELECT
  572. a.ins_order_no as "subOrderNo",
  573. iac.signing_time as "signingTime",
  574. o.licenseno as "licenseno",
  575. a.third_detail_premiums as "amount",
  576. iac.createtime as "createTime"
  577. FROM
  578. ins_fee_order_new a
  579. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  580. left join ins_orders o ON o.orderno=iac.orderno
  581. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  582. <where>
  583. iff.auditstatus=0
  584. and iac.orderstatus = '3'
  585. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  586. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  587. </if>
  588. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  589. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  590. </if>
  591. </where>
  592. UNION
  593. SELECT
  594. a.ins_order_no as "subOrderNo",
  595. iac.signing_time as "signingTime",
  596. o.licenseno as "licenseno",
  597. a.second_detail_premiums as "amount",
  598. iac.createtime as "createTime"
  599. FROM
  600. ins_fee_order_new a
  601. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  602. left join ins_orders o ON o.orderno=iac.orderno
  603. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  604. <where>
  605. iff.auditstatus=0
  606. and iac.orderstatus = '3'
  607. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  608. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  609. </if>
  610. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  611. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  612. </if>
  613. </where>
  614. ) AS fee
  615. </select>
  616. <select id="findMyCollectInAdvanceSumByUserId"
  617. resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
  618. select
  619. a.ins_order_no as "subOrderNo",
  620. ins.signing_time as "signingTime",
  621. o.licenseno as "licenseno",
  622. (ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
  623. +
  624. (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
  625. as "amount",
  626. "1" as businessSegmentsType,
  627. "1" as transactionType,
  628. ins.createtime as "createTime"
  629. from
  630. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  631. left join ins_orders o ON o.orderno=ins.orderno
  632. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  633. <where>
  634. ins.orderstatus ='3'
  635. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  636. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  637. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  638. </if>
  639. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  640. AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  641. </if>
  642. </where>
  643. </select>
  644. <select id="findMyCollectInAdvanceWillAmountByUserIdCount" resultType="java.lang.Long">
  645. SELECT
  646. count(0)
  647. FROM
  648. (
  649. SELECT
  650. a.ins_order_no as "subOrderNo",
  651. iac.signing_time as "signingTime",
  652. o.licenseno as "licenseno",
  653. a.first_detail_premiums as "amount"
  654. FROM
  655. ins_fee_order_new a
  656. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  657. left join ins_orders o ON o.orderno=iac.orderno
  658. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  659. <where>
  660. iac.orderstatus = '3'
  661. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  662. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  663. </if>
  664. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  665. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  666. </if>
  667. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  668. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  669. </if>
  670. </where>
  671. UNION
  672. SELECT
  673. a.ins_order_no as "subOrderNo",
  674. iac.signing_time as "signingTime",
  675. o.licenseno as "licenseno",
  676. a.third_detail_premiums as "amount"
  677. FROM
  678. ins_fee_order_new a
  679. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  680. left join ins_orders o ON o.orderno=iac.orderno
  681. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  682. <where>
  683. iac.orderstatus = '3'
  684. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  685. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  686. </if>
  687. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  688. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  689. </if>
  690. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  691. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  692. </if>
  693. </where>
  694. UNION
  695. SELECT
  696. a.ins_order_no as "subOrderNo",
  697. iac.signing_time as "signingTime",
  698. o.licenseno as "licenseno",
  699. a.second_detail_premiums as "amount"
  700. FROM
  701. ins_fee_order_new a
  702. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  703. left join ins_orders o ON o.orderno=iac.orderno
  704. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  705. <where>
  706. iac.orderstatus = '3'
  707. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  708. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  709. </if>
  710. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  711. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  712. </if>
  713. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  714. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  715. </if>
  716. </where>
  717. ) AS fee
  718. </select>
  719. <select id="findMyCollectInAdvanceSumByUserIdCount" resultType="java.lang.Long">
  720. select
  721. count(0)
  722. from
  723. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  724. left join ins_orders o ON o.orderno=ins.orderno
  725. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  726. <where>
  727. iac.orderstatus = '3'
  728. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  729. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  730. </if>
  731. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  732. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  733. AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  734. </if>
  735. </where>
  736. </select>
  737. <select id="findSumWillAmount" resultType="java.math.BigDecimal">
  738. SELECT
  739. sum(fee.amount)
  740. FROM
  741. (
  742. SELECT
  743. a.first_detail_premiums as "amount"
  744. FROM
  745. ins_fee_order_new a
  746. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  747. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  748. <where>
  749. iac.orderstatus = '3'
  750. AND iff.auditstatus =0
  751. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  752. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  753. </if>
  754. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  755. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  756. </if>
  757. </where>
  758. UNION
  759. SELECT
  760. a.third_detail_premiums as "amount"
  761. FROM
  762. ins_fee_order_new a
  763. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  764. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  765. <where>
  766. iac.orderstatus = '3'
  767. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  768. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  769. </if>
  770. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  771. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  772. </if>
  773. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  774. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  775. </if>
  776. </where>
  777. UNION
  778. SELECT
  779. a.second_detail_premiums as "amount"
  780. FROM
  781. ins_fee_order_new a
  782. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  783. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  784. <where>
  785. iac.orderstatus = '3'
  786. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  787. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  788. </if>
  789. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  790. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  791. </if>
  792. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  793. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  794. </if>
  795. </where>
  796. ) AS fee
  797. </select>
  798. <select id="findSumAmount" resultType="java.math.BigDecimal">
  799. select
  800. ifnull(sum((ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
  801. +
  802. (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
  803. ),0)
  804. as "amount"
  805. from
  806. ins_fee_order_new a left join ins_area_company iac on a.ins_order_no=iac.id
  807. left join ins_orders o ON o.orderno=iac.orderno
  808. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  809. <where>
  810. iac.orderstatus = '3'
  811. AND iff.auditstatus = 0
  812. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  813. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  814. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  815. </if>
  816. </where>
  817. </select>
  818. <select id="findMyInsuranceByUserId"
  819. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
  820. <include refid="common_List_sql"/>
  821. </select>
  822. <select id="exportMyInsuranceByUserId"
  823. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
  824. <include refid="common_List_sql"/>
  825. </select>
  826. <sql id="common_List_sql">
  827. SELECT
  828. a.ins_order_no AS "subOrderNo",
  829. DATE_FORMAT(iac.signing_time, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  830. DATE_FORMAT(iac.signing_time, '%Y-%m-%d') AS "signingTimeDay",
  831. DATE_FORMAT(iff.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  832. DATE_FORMAT(iff.audittime, '%Y-%m-%d') AS "auditTimeDay",
  833. CASE iff.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  834. o.licenseno AS "licenseno",
  835. (
  836. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 )) + (
  837. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )) AS "amount",
  838. a.user_id AS userId,
  839. iac.jqapplyno AS jqapplyno,
  840. iac.syapplyno AS syapplyno,
  841. iac.inscompany AS companyName,
  842. JSON_UNQUOTE(json_extract(o.applyinfo, '$.name')) as insuredName,
  843. ins.NAME AS partnerCompaniesName,
  844. o.username as userName,
  845. o.orderno as orderno,
  846. o.frameno as frameNo,
  847. JSON_EXTRACT( o.carinfo, '$.engineNo' ) as engineNo,
  848. iac.product as productId,
  849. iac.jqpremium,
  850. iac.sypremium,
  851. iac.jypremium,
  852. iac.taxamount,
  853. a.jq_costs_export_proportion+a.jq_export_other_costs_proportion as jq_export_proportion,
  854. a.sy_costs_export_proportion+a.sy_export_other_costs_proportion as sy_export_proportion,
  855. a.no_costs_export_proportion+a.no_export_other_costs_proportion as no_export_proportion
  856. FROM
  857. ins_fee_audit iff
  858. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  859. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  860. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  861. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  862. LEFT JOIN esm_ins_company ins ON ins.id = agree.partner_companies_id
  863. WHERE
  864. iac.orderstatus = '3'
  865. and iff.auditstatus !=2
  866. <choose>
  867. <when test="userList != null and userList.size>0">
  868. AND ( a.user_id = #{vo.userId} or a.user_id in
  869. <foreach collection="userList" item="item" open="(" separator="," close=")">
  870. #{item}
  871. </foreach>
  872. )
  873. </when>
  874. <otherwise>
  875. AND a.user_id = #{vo.userId}
  876. </otherwise>
  877. </choose>
  878. <if test="vo.orderNo!=null and vo.orderNo!= ''">
  879. AND o.orderno = #{vo.orderNo}
  880. </if>
  881. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  882. AND iac.id = #{vo.subOrderNo}
  883. </if>
  884. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  885. AND a.user_id = #{vo.userDLId}
  886. </if>
  887. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  888. AND o.username= #{vo.userDLName}
  889. </if>
  890. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  891. AND o.licenseno = #{vo.licenseNo}
  892. </if>
  893. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  894. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  895. </if>
  896. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  897. AND iff.auditstatus = #{vo.auditstatus}
  898. </if>
  899. <if test="vo.salesmanId!=null and vo.salesmanId!= ''">
  900. AND o.user_id = #{vo.salesmanId}
  901. </if>
  902. <if test="vo.salesmanName!=null and vo.salesmanName!= ''">
  903. AND o.username = #{vo.salesmanName}
  904. </if>
  905. <if test="vo.jqapplyno!=null and vo.jqapplyno!= ''">
  906. AND iac.jqapplyno like concat('%', #{vo.jqapplyno},'%')
  907. </if>
  908. <if test="vo.syapplyno!=null and vo.syapplyno!= ''">
  909. AND iac.syapplyno like concat('%', #{vo.syapplyno},'%')
  910. </if>
  911. <if test="vo.frameNo!=null and vo.frameNo!= ''">
  912. AND o.frameno = #{vo.frameNo}
  913. </if>
  914. <if test="vo.engineNo!=null and vo.engineNo!= ''">
  915. and JSON_EXTRACT( o.carinfo, '$.engineNo' ) = #{vo.engineNo}
  916. </if>
  917. <if test="vo.productId!=null and vo.productId!= ''">
  918. AND iac.productid = #{vo.productId}
  919. </if>
  920. <if test="vo.insuredName!=null and vo.insuredName!= ''">
  921. AND o.insuredname = #{vo.insuredName}
  922. </if>
  923. <if test="vo.companyId!=null and vo.companyId!= ''">
  924. AND iac.company_id = #{vo.companyId}
  925. </if>
  926. </sql>
  927. <select id="findMyInsuranceTGByUserId"
  928. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  929. <include refid="common_List_sql_tg"/>
  930. </select>
  931. <select id="exportMyInsuranceTGByUserId"
  932. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  933. <include refid="common_List_sql_tg"/>
  934. </select>
  935. <sql id="common_List_sql_tg">
  936. SELECT
  937. fee.subOrderNo,
  938. DATE_FORMAT(fee.signingTime, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  939. DATE_FORMAT(fee.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  940. CASE fee.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  941. fee.licenseno,
  942. fee.amount,
  943. fee.userId,
  944. fee.userName,
  945. fee.jqpremium,
  946. fee.sypremium,
  947. fee.jypremium,
  948. fee.sumpremium,
  949. fee.userLevel
  950. FROM
  951. (
  952. SELECT
  953. a.ins_order_no AS "subOrderNo",
  954. iac.signing_time AS "signingTime",
  955. o.licenseno AS "licenseno",
  956. iff.audittime AS "auditTime",
  957. iff.auditstatus AS auditstatus,
  958. o.username AS userName,
  959. o.userid AS userId,
  960. iac.jqpremium AS jqpremium,
  961. iac.sypremium AS sypremium,
  962. iac.jypremium AS jypremium,
  963. iac.sumpremium AS sumpremium,
  964. a.first_detail_premiums AS "amount",
  965. "一级代理" AS userLevel
  966. FROM
  967. ins_fee_audit iff
  968. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  969. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  970. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  971. WHERE
  972. iac.orderstatus = '3'
  973. AND a.first_level_user_id = #{vo.userId}
  974. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  975. AND iac.id = #{vo.subOrderNo}
  976. </if>
  977. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  978. AND o.userid = #{vo.userDLId}
  979. </if>
  980. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  981. AND o.username= #{vo.userDLName}
  982. </if>
  983. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  984. AND o.licenseno = #{vo.licenseNo}
  985. </if>
  986. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  987. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  988. </if>
  989. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  990. AND iff.auditstatus = #{vo.auditstatus}
  991. </if>
  992. UNION
  993. SELECT
  994. a.ins_order_no AS "subOrderNo",
  995. iac.signing_time AS "signingTime",
  996. o.licenseno AS "licenseno",
  997. iff.audittime AS "auditTime",
  998. iff.auditstatus AS auditstatus,
  999. o.username AS userName,
  1000. o.userid AS userId,
  1001. iac.jqpremium AS jqpremium,
  1002. iac.sypremium AS sypremium,
  1003. iac.jypremium AS jypremium,
  1004. iac.sumpremium AS sumpremium,
  1005. a.third_detail_premiums AS "amount",
  1006. "三级级代理" AS userLevel
  1007. FROM
  1008. ins_fee_audit iff
  1009. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1010. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1011. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1012. WHERE
  1013. iac.orderstatus = '3'
  1014. AND iff.auditstatus = 0
  1015. AND a.three_level_user_id = #{vo.userId}
  1016. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1017. AND iac.id = #{vo.subOrderNo}
  1018. </if>
  1019. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1020. AND o.userid = #{vo.userDLId}
  1021. </if>
  1022. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1023. AND o.username= #{vo.userDLName}
  1024. </if>
  1025. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1026. AND o.licenseno = #{vo.licenseNo}
  1027. </if>
  1028. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1029. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1030. </if>
  1031. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1032. AND iff.auditstatus = #{vo.auditstatus}
  1033. </if>
  1034. UNION
  1035. SELECT
  1036. a.ins_order_no AS "subOrderNo",
  1037. iac.signing_time AS "signingTime",
  1038. o.licenseno AS "licenseno",
  1039. iff.audittime AS "auditTime",
  1040. iff.auditstatus AS auditstatus,
  1041. o.username AS userName,
  1042. o.userid AS userId,
  1043. iac.jqpremium AS jqpremium,
  1044. iac.sypremium AS sypremium,
  1045. iac.jypremium AS jypremium,
  1046. iac.sumpremium AS sumpremium,
  1047. a.second_detail_premiums AS "amount",
  1048. "二级代理" AS userLevel
  1049. FROM
  1050. ins_fee_audit iff
  1051. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1052. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1053. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1054. WHERE
  1055. iac.orderstatus = '3'
  1056. AND a.two_level_user_id = #{vo.userId}
  1057. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1058. AND iac.id = #{vo.subOrderNo}
  1059. </if>
  1060. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1061. AND o.userid = #{vo.userDLId}
  1062. </if>
  1063. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1064. AND o.username= #{vo.userDLName}
  1065. </if>
  1066. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1067. AND o.licenseno = #{vo.licenseNo}
  1068. </if>
  1069. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1070. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1071. </if>
  1072. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1073. AND iff.auditstatus = #{vo.auditstatus}
  1074. </if>
  1075. ) AS fee
  1076. ORDER BY
  1077. fee.signingTime DESC
  1078. </sql>
  1079. <select id="findMyAmountYSOrSSCXAmount" resultType="java.math.BigDecimal">
  1080. SELECT
  1081. ifnull(sum(
  1082. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) +
  1083. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )
  1084. ),0)
  1085. FROM
  1086. ins_fee_audit iff
  1087. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1088. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1089. left join ins_orders io on iac.orderno =io.orderno
  1090. WHERE
  1091. iac.orderstatus = '3'
  1092. and iff.auditstatus=#{vo.auditstatus}
  1093. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1094. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1095. </if>
  1096. <choose>
  1097. <when test="vo.deptId!=null and vo.deptId!= '' ">
  1098. and io.deptid like "${vo.deptId}%"
  1099. </when>
  1100. <otherwise>
  1101. AND a.user_id = #{vo.userId}
  1102. </otherwise>
  1103. </choose>
  1104. </select>
  1105. <select id="findMyAmountYSOrSSTGAmount" resultType="java.math.BigDecimal">
  1106. SELECT
  1107. ifnull(sum(fee.amount),0)
  1108. FROM
  1109. (
  1110. SELECT
  1111. a.first_detail_premiums AS "amount"
  1112. FROM
  1113. ins_fee_audit iff
  1114. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1115. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1116. WHERE
  1117. iac.orderstatus = '3'
  1118. AND a.first_level_user_id = #{vo.userId}
  1119. and iff.auditstatus = #{vo.auditstatus}
  1120. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1121. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1122. </if>
  1123. UNION
  1124. SELECT
  1125. a.third_detail_premiums AS "amount"
  1126. FROM
  1127. ins_fee_audit iff
  1128. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1129. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1130. WHERE
  1131. iac.orderstatus = '3'
  1132. AND a.three_level_user_id = #{vo.userId}
  1133. and iff.auditstatus = #{vo.auditstatus}
  1134. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1135. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1136. </if>
  1137. UNION
  1138. SELECT
  1139. a.second_detail_premiums AS "amount"
  1140. FROM
  1141. ins_fee_audit iff
  1142. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1143. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1144. WHERE
  1145. iac.orderstatus = '3'
  1146. AND a.two_level_user_id = #{vo.userId}
  1147. and iff.auditstatus = #{vo.auditstatus}
  1148. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1149. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1150. </if>
  1151. ) AS fee
  1152. </select>
  1153. <select id="findMyAmountYTXmount" resultType="java.math.BigDecimal">
  1154. SELECT
  1155. ifnull( sum( au.amount ), 0 )
  1156. FROM
  1157. sys_amount_auditing au
  1158. WHERE
  1159. au.user_id = #{userId}
  1160. AND auditing_status = #{status}
  1161. </select>
  1162. <select id="queryAdvanceAndActualDataPage"
  1163. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDataDto">
  1164. SELECT
  1165. a.ins_order_no AS subOrderNo,
  1166. iac.signing_time AS signingTime,
  1167. o.licenseno AS licenseNo,
  1168. CASE
  1169. iff.auditstatus
  1170. WHEN '0' THEN
  1171. '未审核'
  1172. WHEN '1' THEN
  1173. '已审核' ELSE ''
  1174. END AS auditstatus,
  1175. o.username AS userName,
  1176. o.userid AS userId,
  1177. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) AS haldingAmount,
  1178. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 ) AS documentaryAmount,
  1179. ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS promotionAmount,
  1180. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) + ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 ) + ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS sumAmount,
  1181. CASE
  1182. dept.management_source
  1183. WHEN '1' THEN
  1184. '渠道'
  1185. WHEN '2' THEN
  1186. '代理人' ELSE ''
  1187. END deptType
  1188. FROM
  1189. ins_fee_audit iff
  1190. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1191. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1192. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1193. LEFT JOIN sys_dept dept ON o.deptid = dept.id
  1194. WHERE
  1195. iac.orderstatus = '3'
  1196. AND (
  1197. dept.management_source = 1
  1198. OR dept.management_source = 2)
  1199. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1200. AND iac.id = #{vo.subOrderNo}
  1201. </if>
  1202. <if test="vo.userId!=null and vo.userId!= ''">
  1203. AND o.userid = #{vo.userId}
  1204. </if>
  1205. <if test="vo.userName!=null and vo.userName!= ''">
  1206. AND o.username= #{vo.userName}
  1207. </if>
  1208. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1209. AND o.licenseno = #{vo.licenseNo}
  1210. </if>
  1211. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1212. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1213. </if>
  1214. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1215. AND iff.auditstatus = #{vo.auditstatus}
  1216. </if>
  1217. <if test="vo.deptType!=null and vo.deptType!= ''">
  1218. AND dept.management_source = #{vo.deptType}
  1219. </if>
  1220. order by iac.signing_time desc
  1221. </select>
  1222. <select id="queryAdvanceAndActualDeptDataPage"
  1223. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDeptDataDto">
  1224. SELECT
  1225. b.suborder AS subOrderNo,
  1226. iac.signing_time AS signingTime,
  1227. o.licenseno AS licenseNo,
  1228. CASE
  1229. iff.auditstatus
  1230. WHEN '0' THEN
  1231. '未审核'
  1232. WHEN '1' THEN
  1233. '已审核' ELSE ''
  1234. END AS auditstatus,
  1235. o.username AS userName,
  1236. o.userid AS userId,
  1237. b.deptId AS deptId,
  1238. b.sumAmount AS sumAmount,
  1239. dept.NAME AS deptName
  1240. FROM
  1241. ins_fee_audit iff
  1242. LEFT JOIN (
  1243. SELECT
  1244. ins_order_no AS suborder,
  1245. LEFT ( dept_id, 2 ) AS deptId,
  1246. ( jq_dept_premiums_level_1 + sy_dept_premiums_level_1 + no_dept_premiums_level_1 ) AS sumAmount
  1247. FROM
  1248. ins_fee_order_new UNION ALL
  1249. SELECT
  1250. ins_order_no AS suborder,
  1251. LEFT ( dept_id, 4 ) AS deptId,
  1252. ( jq_dept_premiums_level_2 + sy_dept_premiums_level_2 + no_dept_premiums_level_2 ) AS sumAmount
  1253. FROM
  1254. ins_fee_order_new UNION ALL
  1255. SELECT
  1256. ins_order_no AS suborder,
  1257. LEFT ( dept_id, 6 ) AS deptId,
  1258. ( jq_dept_premiums_level_3 + sy_dept_premiums_level_3 + no_dept_premiums_level_3 ) AS sumAmount
  1259. FROM
  1260. ins_fee_order_new UNION ALL
  1261. SELECT
  1262. ins_order_no AS suborder,
  1263. LEFT ( dept_id, 8 ) AS deptId,
  1264. ( jq_dept_premiums_level_4 + sy_dept_premiums_level_4 + no_dept_premiums_level_4 ) AS sumAmount
  1265. FROM
  1266. ins_fee_order_new UNION ALL
  1267. SELECT
  1268. ins_order_no AS suborder,
  1269. LEFT ( dept_id, 11 ) AS deptId,
  1270. ( jq_dept_premiums_level_5 + sy_dept_premiums_level_5 + no_dept_premiums_level_5 ) AS sumAmount
  1271. FROM
  1272. ins_fee_order_new
  1273. ) b ON iff.ins_order_no = b.suborder
  1274. LEFT JOIN ins_area_company iac ON iac.id = b.suborder
  1275. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1276. LEFT JOIN sys_dept dept ON b.deptid = dept.id
  1277. WHERE
  1278. iac.orderstatus = '3'
  1279. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1280. AND iac.id = #{vo.subOrderNo}
  1281. </if>
  1282. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1283. AND o.licenseno = #{vo.licenseNo}
  1284. </if>
  1285. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1286. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1287. </if>
  1288. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1289. AND iff.auditstatus = #{vo.auditstatus}
  1290. </if>
  1291. <if test="vo.deptId!=null and vo.deptId!= ''">
  1292. AND dept.id = #{vo.deptId}
  1293. </if>
  1294. order by iac.signing_time desc
  1295. </select>
  1296. <select id="getCostSettlementExcel" resultType="com.ydtech.modules.order.entity.vo.CostSettlementExcelVo">
  1297. SELECT
  1298. io.ins_company,
  1299. sum( ifon.jq_premium ) AS jq_premium,
  1300. sum( ifon.sy_premium ) AS sy_premium,
  1301. sum( ifon.no_premium ) AS no_premium,
  1302. sum( ifon.jq_supervise_costs_premiums ) AS jq_supervise_costs_premiums,
  1303. sum( ifon.jq_other_costs_premiums ) AS jq_other_costs_premiums,
  1304. sum( ifon.sy_supervise_costs_premiums ) AS sy_supervise_costs_premiums,
  1305. sum( ifon.sy_other_costs_premiums ) AS sy_other_costs_premiums,
  1306. sum( ifon.no_supervise_costs_premiums ) AS no_supervise_costs_premiums,
  1307. sum( ifon.no_other_costs_premiums ) AS no_other_costs_premiums,
  1308. sum( ifon.jq_export_supervise_costs_premiums ) AS jq_export_supervise_costs_premiums,
  1309. sum( ifon.jq_export_other_costs_premiums ) AS jq_export_other_costs_premiums,
  1310. sum( ifon.sy_export_supervise_costs_premiums ) AS sy_export_supervise_costs_premiums,
  1311. sum( ifon.sy_export_other_costs_premiums ) AS sy_export_other_costs_premiums,
  1312. sum( ifon.no_export_supervise_costs_premiums ) AS no_export_supervise_costs_premiums,
  1313. sum( ifon.no_export_other_costs_premiums ) AS no_export_other_costs_premiums,
  1314. sum( ifon.first_detail_premiums + ifon.second_detail_premiums + ifon.third_detail_premiums) as distributing_premiums,
  1315. SUM(
  1316. ifon.jq_export_supervise_costs_premiums +
  1317. ifon.jq_export_other_costs_premiums +
  1318. ifon.sy_export_supervise_costs_premiums +
  1319. ifon.sy_export_other_costs_premiums +
  1320. ifon.no_export_supervise_costs_premiums +
  1321. ifon.no_export_other_costs_premiums +
  1322. ifon.first_detail_premiums +
  1323. ifon.second_detail_premiums +
  1324. ifon.third_detail_premiums
  1325. ) AS total_premiums
  1326. FROM
  1327. ins_fee_audit ifa
  1328. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1329. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1330. AND iac.orderstatus = 3
  1331. LEFT JOIN ins_fee_order_new ifon on ifon.ins_order_no = iac.id
  1332. LEFT JOIN sys_user su ON su.id = io.userid
  1333. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1334. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1335. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1336. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1337. WHERE
  1338. iac.id = ifa.ins_order_no
  1339. AND iac.orderstatus = 3
  1340. and ifa.auditstatus = 1
  1341. <if test="param.companyId !=null and param.companyId != ''">
  1342. AND iac.company_id = #{param.companyId}
  1343. </if>
  1344. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1345. and iac.signing_time between #{param.startTime} and #{param.endTime}
  1346. </if>
  1347. group by ins_company
  1348. </select>
  1349. <select id="getFeeReceivable" resultType="com.ydtech.modules.order.entity.vo.FeeReceivableVo">
  1350. SELECT
  1351. io.ins_company,
  1352. sum( ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 ) AS dept_premiums_level_1,
  1353. sum( ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 ) AS dept_premiums_level_2,
  1354. sum( ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 ) AS dept_premiums_level_3,
  1355. sum( ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 ) AS dept_premiums_level_4,
  1356. sum( ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 ) AS dept_premiums_level_5,
  1357. sum( ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums ) AS profit_margin_premiums,
  1358. SUM(
  1359. ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 + ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 + ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 + ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 + ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 + ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums
  1360. ) AS total_premiums
  1361. FROM
  1362. ins_fee_audit ifa
  1363. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1364. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1365. AND iac.orderstatus = 3
  1366. LEFT JOIN ins_fee_order_new ifon ON ifon.ins_order_no = iac.id
  1367. LEFT JOIN sys_user su ON su.id = io.userid
  1368. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1369. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1370. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1371. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1372. WHERE
  1373. iac.id = ifa.ins_order_no
  1374. AND iac.orderstatus = 3
  1375. AND ifa.auditstatus = 1
  1376. <if test="param.companyId !=null and param.companyId != ''">
  1377. AND iac.company_id = #{param.companyId}
  1378. </if>
  1379. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1380. AND iac.signing_time BETWEEN #{param.startTime}
  1381. AND #{param.endTime}
  1382. </if>
  1383. GROUP BY
  1384. ins_company
  1385. </select>
  1386. </mapper>