InsFeeOrderNewMapper.xml 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  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. <choose>
  866. <when test="userList != null and userList.size>0">
  867. AND ( a.user_id = #{vo.userId} or a.user_id in
  868. <foreach collection="userList" item="item" open="(" separator="," close=")">
  869. #{item}
  870. </foreach>
  871. )
  872. </when>
  873. <otherwise>
  874. AND a.user_id = #{vo.userId}
  875. </otherwise>
  876. </choose>
  877. <if test="vo.orderNo!=null and vo.orderNo!= ''">
  878. AND o.orderno = #{vo.orderNo}
  879. </if>
  880. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  881. AND iac.id = #{vo.subOrderNo}
  882. </if>
  883. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  884. AND a.user_id = #{vo.userDLId}
  885. </if>
  886. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  887. AND o.username= #{vo.userDLName}
  888. </if>
  889. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  890. AND o.licenseno = #{vo.licenseNo}
  891. </if>
  892. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  893. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  894. </if>
  895. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  896. AND iff.auditstatus = #{vo.auditstatus}
  897. </if>
  898. <if test="vo.salesmanId!=null and vo.salesmanId!= ''">
  899. AND o.user_id = #{vo.salesmanId}
  900. </if>
  901. <if test="vo.salesmanName!=null and vo.salesmanName!= ''">
  902. AND o.username = #{vo.salesmanName}
  903. </if>
  904. <if test="vo.jqapplyno!=null and vo.jqapplyno!= ''">
  905. AND iac.jqapplyno like concat('%', #{vo.jqapplyno},'%')
  906. </if>
  907. <if test="vo.syapplyno!=null and vo.syapplyno!= ''">
  908. AND iac.syapplyno like concat('%', #{vo.syapplyno},'%')
  909. </if>
  910. <if test="vo.frameNo!=null and vo.frameNo!= ''">
  911. AND o.frameno = #{vo.frameNo}
  912. </if>
  913. <if test="vo.engineNo!=null and vo.engineNo!= ''">
  914. and JSON_EXTRACT( o.carinfo, '$.engineNo' ) = #{vo.engineNo}
  915. </if>
  916. <if test="vo.productId!=null and vo.productId!= ''">
  917. AND iac.productid = #{vo.productId}
  918. </if>
  919. <if test="vo.insuredName!=null and vo.insuredName!= ''">
  920. AND o.insuredname = #{vo.insuredName}
  921. </if>
  922. <if test="vo.companyId!=null and vo.companyId!= ''">
  923. AND iac.company_id = #{vo.companyId}
  924. </if>
  925. </sql>
  926. <select id="findMyInsuranceTGByUserId"
  927. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  928. <include refid="common_List_sql_tg"/>
  929. </select>
  930. <select id="exportMyInsuranceTGByUserId"
  931. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  932. <include refid="common_List_sql_tg"/>
  933. </select>
  934. <sql id="common_List_sql_tg">
  935. SELECT
  936. fee.subOrderNo,
  937. DATE_FORMAT(fee.signingTime, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  938. DATE_FORMAT(fee.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  939. CASE fee.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  940. fee.licenseno,
  941. fee.amount,
  942. fee.userId,
  943. fee.userName,
  944. fee.jqpremium,
  945. fee.sypremium,
  946. fee.jypremium,
  947. fee.sumpremium,
  948. fee.userLevel
  949. FROM
  950. (
  951. SELECT
  952. a.ins_order_no AS "subOrderNo",
  953. iac.signing_time AS "signingTime",
  954. o.licenseno AS "licenseno",
  955. iff.audittime AS "auditTime",
  956. iff.auditstatus AS auditstatus,
  957. o.username AS userName,
  958. o.userid AS userId,
  959. iac.jqpremium AS jqpremium,
  960. iac.sypremium AS sypremium,
  961. iac.jypremium AS jypremium,
  962. iac.sumpremium AS sumpremium,
  963. a.first_detail_premiums AS "amount",
  964. "一级代理" AS userLevel
  965. FROM
  966. ins_fee_audit iff
  967. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  968. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  969. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  970. WHERE
  971. iac.orderstatus = '3'
  972. AND a.first_level_user_id = #{vo.userId}
  973. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  974. AND iac.id = #{vo.subOrderNo}
  975. </if>
  976. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  977. AND o.userid = #{vo.userDLId}
  978. </if>
  979. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  980. AND o.username= #{vo.userDLName}
  981. </if>
  982. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  983. AND o.licenseno = #{vo.licenseNo}
  984. </if>
  985. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  986. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  987. </if>
  988. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  989. AND iff.auditstatus = #{vo.auditstatus}
  990. </if>
  991. UNION
  992. SELECT
  993. a.ins_order_no AS "subOrderNo",
  994. iac.signing_time AS "signingTime",
  995. o.licenseno AS "licenseno",
  996. iff.audittime AS "auditTime",
  997. iff.auditstatus AS auditstatus,
  998. o.username AS userName,
  999. o.userid AS userId,
  1000. iac.jqpremium AS jqpremium,
  1001. iac.sypremium AS sypremium,
  1002. iac.jypremium AS jypremium,
  1003. iac.sumpremium AS sumpremium,
  1004. a.third_detail_premiums AS "amount",
  1005. "三级级代理" AS userLevel
  1006. FROM
  1007. ins_fee_audit iff
  1008. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1009. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1010. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1011. WHERE
  1012. iac.orderstatus = '3'
  1013. AND iff.auditstatus = 0
  1014. AND a.three_level_user_id = #{vo.userId}
  1015. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1016. AND iac.id = #{vo.subOrderNo}
  1017. </if>
  1018. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1019. AND o.userid = #{vo.userDLId}
  1020. </if>
  1021. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1022. AND o.username= #{vo.userDLName}
  1023. </if>
  1024. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1025. AND o.licenseno = #{vo.licenseNo}
  1026. </if>
  1027. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1028. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1029. </if>
  1030. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1031. AND iff.auditstatus = #{vo.auditstatus}
  1032. </if>
  1033. UNION
  1034. SELECT
  1035. a.ins_order_no AS "subOrderNo",
  1036. iac.signing_time AS "signingTime",
  1037. o.licenseno AS "licenseno",
  1038. iff.audittime AS "auditTime",
  1039. iff.auditstatus AS auditstatus,
  1040. o.username AS userName,
  1041. o.userid AS userId,
  1042. iac.jqpremium AS jqpremium,
  1043. iac.sypremium AS sypremium,
  1044. iac.jypremium AS jypremium,
  1045. iac.sumpremium AS sumpremium,
  1046. a.second_detail_premiums AS "amount",
  1047. "二级代理" AS userLevel
  1048. FROM
  1049. ins_fee_audit iff
  1050. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1051. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1052. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1053. WHERE
  1054. iac.orderstatus = '3'
  1055. AND a.two_level_user_id = #{vo.userId}
  1056. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1057. AND iac.id = #{vo.subOrderNo}
  1058. </if>
  1059. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1060. AND o.userid = #{vo.userDLId}
  1061. </if>
  1062. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1063. AND o.username= #{vo.userDLName}
  1064. </if>
  1065. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1066. AND o.licenseno = #{vo.licenseNo}
  1067. </if>
  1068. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1069. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1070. </if>
  1071. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1072. AND iff.auditstatus = #{vo.auditstatus}
  1073. </if>
  1074. ) AS fee
  1075. ORDER BY
  1076. fee.signingTime DESC
  1077. </sql>
  1078. <select id="findMyAmountYSOrSSCXAmount" resultType="java.math.BigDecimal">
  1079. SELECT
  1080. ifnull(sum(
  1081. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) +
  1082. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )
  1083. ),0)
  1084. FROM
  1085. ins_fee_audit iff
  1086. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1087. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1088. left join ins_orders io on iac.orderno =io.orderno
  1089. WHERE
  1090. iac.orderstatus = '3'
  1091. and iff.auditstatus=#{vo.auditstatus}
  1092. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1093. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1094. </if>
  1095. <choose>
  1096. <when test="vo.deptId!=null and vo.deptId!= '' ">
  1097. and io.deptid like "${vo.deptId}%"
  1098. </when>
  1099. <otherwise>
  1100. AND a.user_id = #{vo.userId}
  1101. </otherwise>
  1102. </choose>
  1103. </select>
  1104. <select id="findMyAmountYSOrSSTGAmount" resultType="java.math.BigDecimal">
  1105. SELECT
  1106. ifnull(sum(fee.amount),0)
  1107. FROM
  1108. (
  1109. SELECT
  1110. a.first_detail_premiums AS "amount"
  1111. FROM
  1112. ins_fee_audit iff
  1113. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1114. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1115. WHERE
  1116. iac.orderstatus = '3'
  1117. AND a.first_level_user_id = #{vo.userId}
  1118. and iff.auditstatus = #{vo.auditstatus}
  1119. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1120. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1121. </if>
  1122. UNION
  1123. SELECT
  1124. a.third_detail_premiums AS "amount"
  1125. FROM
  1126. ins_fee_audit iff
  1127. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1128. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1129. WHERE
  1130. iac.orderstatus = '3'
  1131. AND a.three_level_user_id = #{vo.userId}
  1132. and iff.auditstatus = #{vo.auditstatus}
  1133. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1134. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1135. </if>
  1136. UNION
  1137. SELECT
  1138. a.second_detail_premiums AS "amount"
  1139. FROM
  1140. ins_fee_audit iff
  1141. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1142. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1143. WHERE
  1144. iac.orderstatus = '3'
  1145. AND a.two_level_user_id = #{vo.userId}
  1146. and iff.auditstatus = #{vo.auditstatus}
  1147. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1148. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1149. </if>
  1150. ) AS fee
  1151. </select>
  1152. <select id="findMyAmountYTXmount" resultType="java.math.BigDecimal">
  1153. SELECT
  1154. ifnull( sum( au.amount ), 0 )
  1155. FROM
  1156. sys_amount_auditing au
  1157. WHERE
  1158. au.user_id = #{userId}
  1159. AND auditing_status = #{status}
  1160. </select>
  1161. <select id="queryAdvanceAndActualDataPage"
  1162. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDataDto">
  1163. SELECT
  1164. a.ins_order_no AS subOrderNo,
  1165. iac.signing_time AS signingTime,
  1166. o.licenseno AS licenseNo,
  1167. CASE
  1168. iff.auditstatus
  1169. WHEN '0' THEN
  1170. '未审核'
  1171. WHEN '1' THEN
  1172. '已审核' ELSE ''
  1173. END AS auditstatus,
  1174. o.username AS userName,
  1175. o.userid AS userId,
  1176. 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,
  1177. 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,
  1178. ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS promotionAmount,
  1179. 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,
  1180. CASE
  1181. dept.management_source
  1182. WHEN '1' THEN
  1183. '渠道'
  1184. WHEN '2' THEN
  1185. '代理人' ELSE ''
  1186. END deptType
  1187. FROM
  1188. ins_fee_audit iff
  1189. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1190. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1191. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1192. LEFT JOIN sys_dept dept ON o.deptid = dept.id
  1193. WHERE
  1194. iac.orderstatus = '3'
  1195. AND (
  1196. dept.management_source = 1
  1197. OR dept.management_source = 2)
  1198. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1199. AND iac.id = #{vo.subOrderNo}
  1200. </if>
  1201. <if test="vo.userId!=null and vo.userId!= ''">
  1202. AND o.userid = #{vo.userId}
  1203. </if>
  1204. <if test="vo.userName!=null and vo.userName!= ''">
  1205. AND o.username= #{vo.userName}
  1206. </if>
  1207. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1208. AND o.licenseno = #{vo.licenseNo}
  1209. </if>
  1210. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1211. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1212. </if>
  1213. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1214. AND iff.auditstatus = #{vo.auditstatus}
  1215. </if>
  1216. <if test="vo.deptType!=null and vo.deptType!= ''">
  1217. AND dept.management_source = #{vo.deptType}
  1218. </if>
  1219. order by iac.signing_time desc
  1220. </select>
  1221. <select id="queryAdvanceAndActualDeptDataPage"
  1222. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDeptDataDto">
  1223. SELECT
  1224. b.suborder AS subOrderNo,
  1225. iac.signing_time AS signingTime,
  1226. o.licenseno AS licenseNo,
  1227. CASE
  1228. iff.auditstatus
  1229. WHEN '0' THEN
  1230. '未审核'
  1231. WHEN '1' THEN
  1232. '已审核' ELSE ''
  1233. END AS auditstatus,
  1234. o.username AS userName,
  1235. o.userid AS userId,
  1236. b.deptId AS deptId,
  1237. b.sumAmount AS sumAmount,
  1238. dept.NAME AS deptName
  1239. FROM
  1240. ins_fee_audit iff
  1241. LEFT JOIN (
  1242. SELECT
  1243. ins_order_no AS suborder,
  1244. LEFT ( dept_id, 2 ) AS deptId,
  1245. ( jq_dept_premiums_level_1 + sy_dept_premiums_level_1 + no_dept_premiums_level_1 ) AS sumAmount
  1246. FROM
  1247. ins_fee_order_new UNION ALL
  1248. SELECT
  1249. ins_order_no AS suborder,
  1250. LEFT ( dept_id, 4 ) AS deptId,
  1251. ( jq_dept_premiums_level_2 + sy_dept_premiums_level_2 + no_dept_premiums_level_2 ) AS sumAmount
  1252. FROM
  1253. ins_fee_order_new UNION ALL
  1254. SELECT
  1255. ins_order_no AS suborder,
  1256. LEFT ( dept_id, 6 ) AS deptId,
  1257. ( jq_dept_premiums_level_3 + sy_dept_premiums_level_3 + no_dept_premiums_level_3 ) AS sumAmount
  1258. FROM
  1259. ins_fee_order_new UNION ALL
  1260. SELECT
  1261. ins_order_no AS suborder,
  1262. LEFT ( dept_id, 8 ) AS deptId,
  1263. ( jq_dept_premiums_level_4 + sy_dept_premiums_level_4 + no_dept_premiums_level_4 ) AS sumAmount
  1264. FROM
  1265. ins_fee_order_new UNION ALL
  1266. SELECT
  1267. ins_order_no AS suborder,
  1268. LEFT ( dept_id, 11 ) AS deptId,
  1269. ( jq_dept_premiums_level_5 + sy_dept_premiums_level_5 + no_dept_premiums_level_5 ) AS sumAmount
  1270. FROM
  1271. ins_fee_order_new
  1272. ) b ON iff.ins_order_no = b.suborder
  1273. LEFT JOIN ins_area_company iac ON iac.id = b.suborder
  1274. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1275. LEFT JOIN sys_dept dept ON b.deptid = dept.id
  1276. WHERE
  1277. iac.orderstatus = '3'
  1278. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1279. AND iac.id = #{vo.subOrderNo}
  1280. </if>
  1281. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1282. AND o.licenseno = #{vo.licenseNo}
  1283. </if>
  1284. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1285. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1286. </if>
  1287. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1288. AND iff.auditstatus = #{vo.auditstatus}
  1289. </if>
  1290. <if test="vo.deptId!=null and vo.deptId!= ''">
  1291. AND dept.id = #{vo.deptId}
  1292. </if>
  1293. order by iac.signing_time desc
  1294. </select>
  1295. <select id="getCostSettlementExcel" resultType="com.ydtech.modules.order.entity.vo.CostSettlementExcelVo">
  1296. SELECT
  1297. io.ins_company,
  1298. sum( ifon.jq_premium ) AS jq_premium,
  1299. sum( ifon.sy_premium ) AS sy_premium,
  1300. sum( ifon.no_premium ) AS no_premium,
  1301. sum( ifon.jq_supervise_costs_premiums ) AS jq_supervise_costs_premiums,
  1302. sum( ifon.jq_other_costs_premiums ) AS jq_other_costs_premiums,
  1303. sum( ifon.sy_supervise_costs_premiums ) AS sy_supervise_costs_premiums,
  1304. sum( ifon.sy_other_costs_premiums ) AS sy_other_costs_premiums,
  1305. sum( ifon.no_supervise_costs_premiums ) AS no_supervise_costs_premiums,
  1306. sum( ifon.no_other_costs_premiums ) AS no_other_costs_premiums,
  1307. sum( ifon.jq_export_supervise_costs_premiums ) AS jq_export_supervise_costs_premiums,
  1308. sum( ifon.jq_export_other_costs_premiums ) AS jq_export_other_costs_premiums,
  1309. sum( ifon.sy_export_supervise_costs_premiums ) AS sy_export_supervise_costs_premiums,
  1310. sum( ifon.sy_export_other_costs_premiums ) AS sy_export_other_costs_premiums,
  1311. sum( ifon.no_export_supervise_costs_premiums ) AS no_export_supervise_costs_premiums,
  1312. sum( ifon.no_export_other_costs_premiums ) AS no_export_other_costs_premiums,
  1313. sum( ifon.first_detail_premiums + ifon.second_detail_premiums + ifon.third_detail_premiums) as distributing_premiums,
  1314. SUM(
  1315. ifon.jq_export_supervise_costs_premiums +
  1316. ifon.jq_export_other_costs_premiums +
  1317. ifon.sy_export_supervise_costs_premiums +
  1318. ifon.sy_export_other_costs_premiums +
  1319. ifon.no_export_supervise_costs_premiums +
  1320. ifon.no_export_other_costs_premiums +
  1321. ifon.first_detail_premiums +
  1322. ifon.second_detail_premiums +
  1323. ifon.third_detail_premiums
  1324. ) AS total_premiums
  1325. FROM
  1326. ins_fee_audit ifa
  1327. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1328. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1329. AND iac.orderstatus = 3
  1330. LEFT JOIN ins_fee_order_new ifon on ifon.ins_order_no = iac.id
  1331. LEFT JOIN sys_user su ON su.id = io.userid
  1332. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1333. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1334. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1335. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1336. WHERE
  1337. iac.id = ifa.ins_order_no
  1338. AND iac.orderstatus = 3
  1339. and ifa.auditstatus = 1
  1340. <if test="param.companyId !=null and param.companyId != ''">
  1341. AND iac.company_id = #{param.companyId}
  1342. </if>
  1343. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1344. and iac.signing_time between #{param.startTime} and #{param.endTime}
  1345. </if>
  1346. group by ins_company
  1347. </select>
  1348. <select id="getFeeReceivable" resultType="com.ydtech.modules.order.entity.vo.FeeReceivableVo">
  1349. SELECT
  1350. io.ins_company,
  1351. sum( ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 ) AS dept_premiums_level_1,
  1352. sum( ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 ) AS dept_premiums_level_2,
  1353. sum( ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 ) AS dept_premiums_level_3,
  1354. sum( ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 ) AS dept_premiums_level_4,
  1355. sum( ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 ) AS dept_premiums_level_5,
  1356. sum( ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums ) AS profit_margin_premiums,
  1357. SUM(
  1358. 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
  1359. ) AS total_premiums
  1360. FROM
  1361. ins_fee_audit ifa
  1362. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1363. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1364. AND iac.orderstatus = 3
  1365. LEFT JOIN ins_fee_order_new ifon ON ifon.ins_order_no = iac.id
  1366. LEFT JOIN sys_user su ON su.id = io.userid
  1367. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1368. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1369. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1370. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1371. WHERE
  1372. iac.id = ifa.ins_order_no
  1373. AND iac.orderstatus = 3
  1374. AND ifa.auditstatus = 1
  1375. <if test="param.companyId !=null and param.companyId != ''">
  1376. AND iac.company_id = #{param.companyId}
  1377. </if>
  1378. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1379. AND iac.signing_time BETWEEN #{param.startTime}
  1380. AND #{param.endTime}
  1381. </if>
  1382. GROUP BY
  1383. ins_company
  1384. </select>
  1385. </mapper>