InsFeeOrderNewMapper.xml 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  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. 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. )
  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(iff.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  831. CASE iff.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  832. o.licenseno AS "licenseno",
  833. (
  834. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 )) + (
  835. 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",
  836. a.user_id AS userId,
  837. iac.jqapplyno AS jqapplyno,
  838. iac.syapplyno AS syapplyno,
  839. iac.inscompany AS companyName,
  840. o.insuredname AS insuredName,
  841. ins.NAME AS partnerCompaniesName,
  842. o.username as userName,
  843. o.orderno as orderno,
  844. o.frameno as frameNo,
  845. JSON_EXTRACT( o.carinfo, '$.engineNo' ) as engineNo,
  846. iac.product as productId
  847. FROM
  848. ins_fee_audit iff
  849. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  850. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  851. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  852. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  853. LEFT JOIN esm_ins_company ins ON ins.id = agree.partner_companies_id
  854. WHERE
  855. iac.orderstatus = '3'
  856. <choose>
  857. <when test="userList != null and userList.size>0">
  858. AND ( a.user_id = #{vo.userId} or a.user_id in
  859. <foreach collection="userList" item="item" open="(" separator="," close=")">
  860. #{item}
  861. </foreach>
  862. )
  863. </when>
  864. <otherwise>
  865. AND a.user_id = #{vo.userId}
  866. </otherwise>
  867. </choose>
  868. <if test="vo.orderNo!=null and vo.orderNo!= ''">
  869. AND o.orderno = #{vo.orderNo}
  870. </if>
  871. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  872. AND iac.id = #{vo.subOrderNo}
  873. </if>
  874. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  875. AND a.user_id = #{vo.userDLId}
  876. </if>
  877. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  878. AND o.username= #{vo.userDLName}
  879. </if>
  880. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  881. AND o.licenseno = #{vo.licenseNo}
  882. </if>
  883. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  884. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  885. </if>
  886. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  887. AND iff.auditstatus = #{vo.auditstatus}
  888. </if>
  889. <if test="vo.salesmanId!=null and vo.salesmanId!= ''">
  890. AND o.user_id = #{vo.salesmanId}
  891. </if>
  892. <if test="vo.salesmanName!=null and vo.salesmanName!= ''">
  893. AND o.username = #{vo.salesmanName}
  894. </if>
  895. <if test="vo.jqapplyno!=null and vo.jqapplyno!= ''">
  896. AND iac.jqapplyno like concat('%', #{vo.jqapplyno},'%')
  897. </if>
  898. <if test="vo.syapplyno!=null and vo.syapplyno!= ''">
  899. AND iac.syapplyno like concat('%', #{vo.syapplyno},'%')
  900. </if>
  901. <if test="vo.frameNo!=null and vo.frameNo!= ''">
  902. AND o.frameno = #{vo.frameNo}
  903. </if>
  904. <if test="vo.engineNo!=null and vo.engineNo!= ''">
  905. and JSON_EXTRACT( o.carinfo, '$.engineNo' ) = #{vo.engineNo}
  906. </if>
  907. <if test="vo.productId!=null and vo.productId!= ''">
  908. AND iac.productid = #{vo.productId}
  909. </if>
  910. <if test="vo.insuredName!=null and vo.insuredName!= ''">
  911. AND o.insuredname = #{vo.insuredName}
  912. </if>
  913. <if test="vo.companyId!=null and vo.companyId!= ''">
  914. AND iac.company_id = #{vo.companyId}
  915. </if>
  916. </sql>
  917. <select id="findMyInsuranceTGByUserId"
  918. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  919. <include refid="common_List_sql_tg"/>
  920. </select>
  921. <select id="exportMyInsuranceTGByUserId"
  922. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  923. <include refid="common_List_sql_tg"/>
  924. </select>
  925. <sql id="common_List_sql_tg">
  926. SELECT
  927. fee.subOrderNo,
  928. DATE_FORMAT(fee.signingTime, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  929. DATE_FORMAT(fee.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  930. CASE fee.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  931. fee.licenseno,
  932. fee.amount,
  933. fee.userId,
  934. fee.userName,
  935. fee.jqpremium,
  936. fee.sypremium,
  937. fee.jypremium,
  938. fee.sumpremium,
  939. fee.userLevel
  940. FROM
  941. (
  942. SELECT
  943. a.ins_order_no AS "subOrderNo",
  944. iac.signing_time AS "signingTime",
  945. o.licenseno AS "licenseno",
  946. iff.audittime AS "auditTime",
  947. iff.auditstatus AS auditstatus,
  948. o.username AS userName,
  949. o.userid AS userId,
  950. iac.jqpremium AS jqpremium,
  951. iac.sypremium AS sypremium,
  952. iac.jypremium AS jypremium,
  953. iac.sumpremium AS sumpremium,
  954. a.first_detail_premiums AS "amount",
  955. "一级代理" AS userLevel
  956. FROM
  957. ins_fee_audit iff
  958. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  959. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  960. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  961. WHERE
  962. iac.orderstatus = '3'
  963. AND a.first_level_user_id = #{vo.userId}
  964. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  965. AND iac.id = #{vo.subOrderNo}
  966. </if>
  967. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  968. AND o.userid = #{vo.userDLId}
  969. </if>
  970. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  971. AND o.username= #{vo.userDLName}
  972. </if>
  973. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  974. AND o.licenseno = #{vo.licenseNo}
  975. </if>
  976. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  977. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  978. </if>
  979. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  980. AND iff.auditstatus = #{vo.auditstatus}
  981. </if>
  982. UNION
  983. SELECT
  984. a.ins_order_no AS "subOrderNo",
  985. iac.signing_time AS "signingTime",
  986. o.licenseno AS "licenseno",
  987. iff.audittime AS "auditTime",
  988. iff.auditstatus AS auditstatus,
  989. o.username AS userName,
  990. o.userid AS userId,
  991. iac.jqpremium AS jqpremium,
  992. iac.sypremium AS sypremium,
  993. iac.jypremium AS jypremium,
  994. iac.sumpremium AS sumpremium,
  995. a.third_detail_premiums AS "amount",
  996. "三级级代理" AS userLevel
  997. FROM
  998. ins_fee_audit iff
  999. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1000. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1001. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1002. WHERE
  1003. iac.orderstatus = '3'
  1004. AND iff.auditstatus = 0
  1005. AND a.three_level_user_id = #{vo.userId}
  1006. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1007. AND iac.id = #{vo.subOrderNo}
  1008. </if>
  1009. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1010. AND o.userid = #{vo.userDLId}
  1011. </if>
  1012. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1013. AND o.username= #{vo.userDLName}
  1014. </if>
  1015. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1016. AND o.licenseno = #{vo.licenseNo}
  1017. </if>
  1018. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1019. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1020. </if>
  1021. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1022. AND iff.auditstatus = #{vo.auditstatus}
  1023. </if>
  1024. UNION
  1025. SELECT
  1026. a.ins_order_no AS "subOrderNo",
  1027. iac.signing_time AS "signingTime",
  1028. o.licenseno AS "licenseno",
  1029. iff.audittime AS "auditTime",
  1030. iff.auditstatus AS auditstatus,
  1031. o.username AS userName,
  1032. o.userid AS userId,
  1033. iac.jqpremium AS jqpremium,
  1034. iac.sypremium AS sypremium,
  1035. iac.jypremium AS jypremium,
  1036. iac.sumpremium AS sumpremium,
  1037. a.second_detail_premiums AS "amount",
  1038. "二级代理" AS userLevel
  1039. FROM
  1040. ins_fee_audit iff
  1041. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1042. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1043. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1044. WHERE
  1045. iac.orderstatus = '3'
  1046. AND a.two_level_user_id = #{vo.userId}
  1047. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1048. AND iac.id = #{vo.subOrderNo}
  1049. </if>
  1050. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1051. AND o.userid = #{vo.userDLId}
  1052. </if>
  1053. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1054. AND o.username= #{vo.userDLName}
  1055. </if>
  1056. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1057. AND o.licenseno = #{vo.licenseNo}
  1058. </if>
  1059. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1060. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1061. </if>
  1062. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1063. AND iff.auditstatus = #{vo.auditstatus}
  1064. </if>
  1065. ) AS fee
  1066. ORDER BY
  1067. fee.signingTime DESC
  1068. </sql>
  1069. <select id="findMyAmountYSOrSSCXAmount" resultType="java.math.BigDecimal">
  1070. SELECT
  1071. ifnull(sum(
  1072. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) +
  1073. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )
  1074. ),0)
  1075. FROM
  1076. ins_fee_audit iff
  1077. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1078. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1079. WHERE
  1080. iac.orderstatus = '3'
  1081. and iff.auditstatus=#{vo.auditstatus}
  1082. AND a.user_id = #{vo.userId}
  1083. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1084. AND iac.signingTime BETWEEN #{vo.startDate} AND #{vo.endDate}
  1085. </if>
  1086. </select>
  1087. <select id="findMyAmountYSOrSSTGAmount" resultType="java.math.BigDecimal">
  1088. SELECT
  1089. ifnull(sum(fee.amount),0)
  1090. FROM
  1091. (
  1092. SELECT
  1093. a.first_detail_premiums AS "amount"
  1094. FROM
  1095. ins_fee_audit iff
  1096. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1097. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1098. WHERE
  1099. iac.orderstatus = '3'
  1100. AND a.first_level_user_id = #{vo.userId}
  1101. and iff.auditstatus = #{vo.auditstatus}
  1102. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1103. AND iac.signingTime BETWEEN #{vo.startDate} AND #{vo.endDate}
  1104. </if>
  1105. UNION
  1106. SELECT
  1107. a.third_detail_premiums AS "amount"
  1108. FROM
  1109. ins_fee_audit iff
  1110. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1111. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1112. WHERE
  1113. iac.orderstatus = '3'
  1114. AND a.three_level_user_id = #{vo.userId}
  1115. and iff.auditstatus = #{vo.auditstatus}
  1116. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1117. AND iac.signingTime BETWEEN #{vo.startDate} AND #{vo.endDate}
  1118. </if>
  1119. UNION
  1120. SELECT
  1121. a.second_detail_premiums AS "amount"
  1122. FROM
  1123. ins_fee_audit iff
  1124. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1125. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1126. WHERE
  1127. iac.orderstatus = '3'
  1128. AND a.two_level_user_id = #{vo.userId}
  1129. and iff.auditstatus = #{vo.auditstatus}
  1130. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1131. AND iac.signingTime BETWEEN #{vo.startDate} AND #{vo.endDate}
  1132. </if>
  1133. ) AS fee
  1134. </select>
  1135. <select id="findMyAmountYTXmount" resultType="java.math.BigDecimal">
  1136. SELECT
  1137. ifnull( sum( au.amount ), 0 )
  1138. FROM
  1139. sys_amount_auditing au
  1140. WHERE
  1141. au.user_id = #{userId}
  1142. AND auditing_status = '3'
  1143. </select>
  1144. </mapper>