InsFeeOrderNewMapper.xml 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydtech.modules.protocols.dao.InsFeeOrderNewMapper">
  4. <resultMap id="BaseResultMap" type="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  5. <id column="id" property="id"/>
  6. <result column="ins_order_no" property="insOrderNo"/>
  7. <result column="agreement_id" property="agreementId"/>
  8. <result column="costs_id" property="costsId"/>
  9. <result column="dept_id" property="deptId"/>
  10. <result column="user_id" property="userId"/>
  11. <result column="jq_premium" property="jqPremium"/>
  12. <result column="sy_premium" property="syPremium"/>
  13. <result column="no_premium" property="noPremium"/>
  14. <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
  15. <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
  16. <result column="no_no_tax_premium" property="noNoTaxPremium"/>
  17. <result column="jq_costs_proportion" property="jqCostsProportion"/>
  18. <result column="jq_costs_premiums" property="jqCostsPremiums"/>
  19. <result column="sy_costs_proportion" property="syCostsProportion"/>
  20. <result column="sy_costs_premiums" property="syCostsPremiums"/>
  21. <result column="no_costs_proportion" property="noCostsProportion"/>
  22. <result column="no_costs_premiums" property="noCostsPremiums"/>
  23. <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
  24. <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
  25. <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
  26. <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
  27. <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
  28. <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
  29. <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
  30. <result column="jq_other_costs_premiums" property="jqOtherCostsPremiums"/>
  31. <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
  32. <result column="sy_other_costs_premiums" property="syOtherCostsPremiums"/>
  33. <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
  34. <result column="no_other_costs_premiums" property="noOtherCostsPremiums"/>
  35. <result column="jq_investment_costs_proportion" property="jqInvestmentCostsProportion"/>
  36. <result column="jq_investment_costs_premiums" property="jqInvestmentCostsPremiums"/>
  37. <result column="sy_investment_costs_proportion" property="syInvestmentCostsProportion"/>
  38. <result column="sy_investment_costs_premiums" property="syInvestmentCostsPremiums"/>
  39. <result column="jq_dept_proportion_level_1" property="jqDeptProportionLevel1"/>
  40. <result column="jq_dept_premiums_level_1" property="jqDeptPremiumsLevel1"/>
  41. <result column="sy_dept_proportion_level_1" property="syDeptProportionLevel1"/>
  42. <result column="sy_dept_premiums_level_1" property="syDeptPremiumsLevel1"/>
  43. <result column="no_dept_proportion_level_1" property="noDeptProportionLevel1"/>
  44. <result column="no_dept_premiums_level_1" property="noDeptPremiumsLevel1"/>
  45. <result column="jq_dept_proportion_level_2" property="jqDeptProportionLevel2"/>
  46. <result column="jq_dept_premiums_level_2" property="jqDeptPremiumsLevel2"/>
  47. <result column="sy_dept_proportion_level_2" property="syDeptProportionLevel2"/>
  48. <result column="sy_dept_premiums_level_2" property="syDeptPremiumsLevel2"/>
  49. <result column="no_dept_proportion_level_2" property="noDeptProportionLevel2"/>
  50. <result column="no_dept_premiums_level_2" property="noDeptPremiumsLevel2"/>
  51. <result column="jq_dept_proportion_level_3" property="jqDeptProportionLevel3"/>
  52. <result column="jq_dept_premiums_level_3" property="jqDeptPremiumsLevel3"/>
  53. <result column="sy_dept_proportion_level_3" property="syDeptProportionLevel3"/>
  54. <result column="sy_dept_premiums_level_3" property="syDeptPremiumsLevel3"/>
  55. <result column="no_dept_proportion_level_3" property="noDeptProportionLevel3"/>
  56. <result column="no_dept_premiums_level_3" property="noDeptPremiumsLevel3"/>
  57. <result column="jq_dept_proportion_level_4" property="jqDeptProportionLevel4"/>
  58. <result column="jq_dept_premiums_level_4" property="jqDeptPremiumsLevel4"/>
  59. <result column="sy_dept_proportion_level_4" property="syDeptProportionLevel4"/>
  60. <result column="sy_dept_premiums_level_4" property="syDeptPremiumsLevel4"/>
  61. <result column="no_dept_proportion_level_4" property="noDeptProportionLevel4"/>
  62. <result column="no_dept_premiums_level_4" property="noDeptPremiumsLevel4"/>
  63. <result column="jq_dept_proportion_level_5" property="jqDeptProportionLevel5"/>
  64. <result column="jq_dept_premiums_level_5" property="jqDeptPremiumsLevel5"/>
  65. <result column="sy_dept_proportion_level_5" property="syDeptProportionLevel5"/>
  66. <result column="sy_dept_premiums_level_5" property="syDeptPremiumsLevel5"/>
  67. <result column="no_dept_proportion_level_5" property="noDeptProportionLevel5"/>
  68. <result column="no_dept_premiums_level_5" property="noDeptPremiumsLevel5"/>
  69. <result column="jq_costs_export_proportion" property="jqCostsExportProportion"/>
  70. <result column="sy_costs_export_proportion" property="syCostsExportProportion"/>
  71. <result column="no_costs_export_proportion" property="noCostsExportProportion"/>
  72. <result column="jq_export_investment_proportion" property="jqExportInvestmentProportion"/>
  73. <result column="jq_export_investment_premiums" property="jqExportInvestmentPremiums"/>
  74. <result column="sy_export_investment_proportion" property="syExportInvestmentProportion"/>
  75. <result column="sy_export_investment_premiums" property="syExportInvestmentPremiums"/>
  76. <result column="first_detail_proportion" property="firstDetailProportion"/>
  77. <result column="first_detail_premiums" property="firstDetailPremiums"/>
  78. <result column="second_detail_proportion" property="secondDetailProportion"/>
  79. <result column="second_detail_premiums" property="secondDetailPremiums"/>
  80. <result column="third_detail_proportion" property="thirdDetailProportion"/>
  81. <result column="third_detail_premiums" property="thirdDetailPremiums"/>
  82. <result column="create_time" property="createTime"/>
  83. <result column="first_level_user_id" property="firstLevelUserId"/>
  84. <result column="two_level_user_id" property="twoLevelUserId"/>
  85. <result column="three_level_user_id" property="threeLevelUserId"/>
  86. <result column="distribution_status" property="distributionStatus"/>
  87. <result column="dept_distribution" property="deptDistribution"/>
  88. </resultMap>
  89. <select id="getInsFeeOrderEntity" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  90. select
  91. a.id as "id",
  92. a.ins_order_no as "insOrderNo",
  93. a.agreement_id as "agreementId",
  94. a.costs_id as "costsId",
  95. a.dept_id as "deptId",
  96. a.user_id as "userId",
  97. a.jq_premium as "jqPremium",
  98. a.sy_premium as "syPremium",
  99. a.no_premium as "noPremium",
  100. a.jq_no_tax_premium as "jqNoTaxPremium",
  101. a.sy_no_tax_premium as "syNoTaxPremium",
  102. a.no_no_tax_premium as "noNoTaxPremium",
  103. a.jq_costs_proportion as "jqCostsProportion",
  104. a.jq_costs_premiums as "jqCostsPremiums",
  105. a.sy_costs_proportion as "syCostsProportion",
  106. a.sy_costs_premiums as "syCostsPremiums",
  107. a.no_costs_proportion as "noCostsProportion",
  108. a.no_costs_premiums as "noCostsPremiums",
  109. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  110. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  111. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  112. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  113. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  114. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  115. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  116. a.jq_other_costs_premiums as "jqOtherCostsPremiums",
  117. a.sy_other_costs_proportion as "syOtherCostsProportion",
  118. a.sy_other_costs_premiums as "syOtherCostsPremiums",
  119. a.no_other_costs_proportion as "noOtherCostsProportion",
  120. a.no_other_costs_premiums as "noOtherCostsPremiums",
  121. a.jq_investment_costs_proportion as "jqInvestmentCostsProportion",
  122. a.jq_investment_costs_premiums as "jqInvestmentCostsPremiums",
  123. a.sy_investment_costs_proportion as "syInvestmentCostsProportion",
  124. a.sy_investment_costs_premiums as "syInvestmentCostsPremiums",
  125. a.jq_dept_proportion_level_1 as "jqDeptProportionLevel1",
  126. a.jq_dept_premiums_level_1 as "jqDeptPremiumsLevel1",
  127. a.sy_dept_proportion_level_1 as "syDeptProportionLevel1",
  128. a.sy_dept_premiums_level_1 as "syDeptPremiumsLevel1",
  129. a.no_dept_proportion_level_1 as "noDeptProportionLevel1",
  130. a.no_dept_premiums_level_1 as "noDeptPremiumsLevel1",
  131. a.jq_dept_proportion_level_2 as "jqDeptProportionLevel2",
  132. a.jq_dept_premiums_level_2 as "jqDeptPremiumsLevel2",
  133. a.sy_dept_proportion_level_2 as "syDeptProportionLevel2",
  134. a.sy_dept_premiums_level_2 as "syDeptPremiumsLevel2",
  135. a.no_dept_proportion_level_2 as "noDeptProportionLevel2",
  136. a.no_dept_premiums_level_2 as "noDeptPremiumsLevel2",
  137. a.jq_dept_proportion_level_3 as "jqDeptProportionLevel3",
  138. a.jq_dept_premiums_level_3 as "jqDeptPremiumsLevel3",
  139. a.sy_dept_proportion_level_3 as "syDeptProportionLevel3",
  140. a.sy_dept_premiums_level_3 as "syDeptPremiumsLevel3",
  141. a.no_dept_proportion_level_3 as "noDeptProportionLevel3",
  142. a.no_dept_premiums_level_3 as "noDeptPremiumsLevel3",
  143. a.jq_dept_proportion_level_4 as "jqDeptProportionLevel4",
  144. a.jq_dept_premiums_level_4 as "jqDeptPremiumsLevel4",
  145. a.sy_dept_proportion_level_4 as "syDeptProportionLevel4",
  146. a.sy_dept_premiums_level_4 as "syDeptPremiumsLevel4",
  147. a.no_dept_proportion_level_4 as "noDeptProportionLevel4",
  148. a.no_dept_premiums_level_4 as "noDeptPremiumsLevel4",
  149. a.jq_dept_proportion_level_5 as "jqDeptProportionLevel5",
  150. a.jq_dept_premiums_level_5 as "jqDeptPremiumsLevel5",
  151. a.sy_dept_proportion_level_5 as "syDeptProportionLevel5",
  152. a.sy_dept_premiums_level_5 as "syDeptPremiumsLevel5",
  153. a.no_dept_proportion_level_5 as "noDeptProportionLevel5",
  154. a.no_dept_premiums_level_5 as "noDeptPremiumsLevel5",
  155. a.jq_costs_export_proportion as "jqCostsExportProportion",
  156. a.sy_costs_export_proportion as "syCostsExportProportion",
  157. a.no_costs_export_proportion as "noCostsExportProportion",
  158. a.jq_export_investment_proportion as "jqExportInvestmentProportion",
  159. a.jq_export_investment_premiums as "jqExportInvestmentPremiums",
  160. a.sy_export_investment_proportion as "syExportInvestmentProportion",
  161. a.sy_export_investment_premiums as "syExportInvestmentPremiums",
  162. a.first_detail_proportion as "firstDetailProportion",
  163. a.first_detail_premiums as "firstDetailPremiums",
  164. a.second_detail_proportion as "secondDetailProportion",
  165. a.second_detail_premiums as "secondDetailPremiums",
  166. a.third_detail_proportion as "thirdDetailProportion",
  167. a.third_detail_premiums as "thirdDetailPremiums",
  168. a.create_time as "createTime",
  169. a.first_level_user_id as "firstLevelUserId",
  170. a.two_level_user_id as "twoLevelUserId",
  171. a.three_level_user_id as "threeLevelUserId",
  172. a.distribution_status as "distributionStatus",
  173. a.dept_distribution as "deptDistribution",
  174. iac.signing_time as "signingTime",
  175. io.licenseno as "licenseno"
  176. from ins_fee_order_new a
  177. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  178. LEFT JOIN ins_orders io on io.quoteno =iac.id
  179. <where>
  180. 1=1
  181. <if test="id !=null and id !=''">
  182. AND a.ins_order_no=#{id}
  183. </if>
  184. </where>
  185. </select>
  186. <select id="getByUserId" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  187. select a.* from ins_fee_order_new a
  188. <where>
  189. <if test="userId !=null and userId !=''">
  190. a.user_id =#{userId}
  191. </if>
  192. </where>
  193. </select>
  194. <select id="getByUserIdAndOrderStatusAndNoCheck" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  195. select a.* from
  196. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  197. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  198. WHERE
  199. a.user_id = #{userId}
  200. and ins.orderstatus ='3'
  201. and iff.auditstatus=0
  202. </select>
  203. <select id="getSumWillAmount" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  204. select
  205. a.ins_order_no as "id",
  206. a.user_id as "userId",
  207. ins.signing_time as "signingTime",
  208. o.licenseno as "licenseno",
  209. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  210. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  211. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  212. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  213. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  214. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  215. from
  216. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  217. left join ins_orders o ON o.orderno=ins.orderno
  218. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  219. <where>
  220. <if test="userId !=null and userId !=''">
  221. a.user_id = #{userId}
  222. </if>
  223. and ins.orderstatus ='3'
  224. and iff.auditstatus=0
  225. <if test="timeFiltering!= null and timeFiltering !=''">
  226. AND DATE_FORMAT(ins.signing_time, '%Y-%m' ) = #{timeFiltering}
  227. </if>
  228. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  229. and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
  230. </if>
  231. </where>
  232. </select>
  233. <select id="getSumWillAmountGeneralization" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  234. SELECT
  235. fee.id,
  236. fee.userId,
  237. fee.signingTime,
  238. fee.licenseno,
  239. fee.jqExportSuperviseCostsPremiums,
  240. fee.syExportSuperviseCostsPremiums,
  241. fee.noExportSuperviseCostsPremiums,
  242. fee.jqExportOtherCostsPremiums,
  243. fee.syExportOtherCostsPremiums,
  244. fee.noExportOtherCostsPremiums,
  245. fee.willAmount
  246. FROM
  247. (
  248. SELECT
  249. a.ins_order_no as "id",
  250. a.user_id as "userId",
  251. iac.signing_time as "signingTime",
  252. o.licenseno as "licenseno",
  253. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  254. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  255. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  256. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  257. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  258. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  259. a.first_detail_premiums as "willAmount"
  260. FROM
  261. ins_fee_order_new a
  262. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  263. left join ins_orders o ON o.orderno=iac.orderno
  264. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  265. <where>
  266. iff.auditstatus=0
  267. and iac.orderstatus = '3'
  268. <if test="userId!=null and userId!= ''">
  269. AND a.first_level_user_id = #{userId}
  270. </if>
  271. </where>
  272. UNION
  273. SELECT
  274. a.ins_order_no as "id",
  275. a.user_id as "userId",
  276. iac.signing_time as "signingTime",
  277. o.licenseno as "licenseno",
  278. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  279. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  280. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  281. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  282. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  283. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  284. a.third_detail_premiums as "willAmount"
  285. FROM
  286. ins_fee_order_new a
  287. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  288. left join ins_orders o ON o.orderno=iac.orderno
  289. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  290. <where>
  291. iff.auditstatus=0
  292. and iac.orderstatus = '3'
  293. <if test="userId!=null and userId!= ''">
  294. AND a.three_level_user_id = #{userId}
  295. </if>
  296. </where>
  297. UNION
  298. SELECT
  299. a.ins_order_no as "id",
  300. a.user_id as "userId",
  301. iac.signing_time as "signingTime",
  302. o.licenseno as "licenseno",
  303. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  304. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  305. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  306. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  307. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  308. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  309. a.second_detail_premiums as "willAmount"
  310. FROM
  311. ins_fee_order_new a
  312. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  313. left join ins_orders o ON o.orderno=iac.orderno
  314. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  315. <where>
  316. iff.auditstatus=0
  317. and iac.orderstatus = '3'
  318. <if test="userId!=null and userId!= ''">
  319. AND a.two_level_user_id = #{userId}
  320. </if>
  321. </where>
  322. ) AS fee
  323. </select>
  324. <select id="getByUserIdAndOrderStatusAndNoCheckType"
  325. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  326. select
  327. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  328. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  329. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  330. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  331. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  332. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  333. from
  334. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  335. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  336. WHERE
  337. a.user_id = #{userId}
  338. and ins.orderstatus ='3'
  339. <choose>
  340. <when test='type == "1"'>
  341. and iff.auditstatus=0
  342. </when>
  343. <otherwise>
  344. and iff.auditstatus=1
  345. </otherwise>
  346. </choose>
  347. </select>
  348. <select id="getSumWillAmountGeneralizationNew"
  349. resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  350. SELECT
  351. fee.id,
  352. fee.userId,
  353. fee.signingTime,
  354. fee.licenseno,
  355. fee.jqExportSuperviseCostsPremiums,
  356. fee.syExportSuperviseCostsPremiums,
  357. fee.noExportSuperviseCostsPremiums,
  358. fee.jqExportOtherCostsPremiums,
  359. fee.syExportOtherCostsPremiums,
  360. fee.noExportOtherCostsPremiums,
  361. fee.willAmount
  362. FROM
  363. (
  364. SELECT
  365. a.ins_order_no as "id",
  366. a.user_id as "userId",
  367. iac.signing_time as "signingTime",
  368. o.licenseno as "licenseno",
  369. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  370. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  371. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  372. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  373. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  374. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  375. a.first_detail_premiums as "willAmount"
  376. FROM
  377. ins_fee_order_new a
  378. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  379. left join ins_orders o ON o.orderno=iac.orderno
  380. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  381. <where>
  382. <choose>
  383. <when test='type == "1"'>
  384. iff.auditstatus=0
  385. </when>
  386. <otherwise>
  387. iff.auditstatus=1
  388. </otherwise>
  389. </choose>
  390. and iac.orderstatus = '3'
  391. <if test="userId!=null and userId!= ''">
  392. AND a.first_level_user_id = #{userId}
  393. </if>
  394. <if test="timeFiltering!= null and timeFiltering !=''">
  395. <choose>
  396. <when test='type == "1"'>
  397. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  398. </when>
  399. <otherwise>
  400. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  401. </otherwise>
  402. </choose>
  403. </if>
  404. </where>
  405. UNION
  406. SELECT
  407. a.ins_order_no as "id",
  408. a.user_id as "userId",
  409. iac.signing_time as "signingTime",
  410. o.licenseno as "licenseno",
  411. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  412. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  413. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  414. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  415. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  416. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  417. a.third_detail_premiums as "willAmount"
  418. FROM
  419. ins_fee_order_new a
  420. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  421. left join ins_orders o ON o.orderno=iac.orderno
  422. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  423. <where>
  424. <choose>
  425. <when test='type == "1"'>
  426. iff.auditstatus=0
  427. </when>
  428. <otherwise>
  429. iff.auditstatus=1
  430. </otherwise>
  431. </choose>
  432. and iac.orderstatus = '3'
  433. <if test="userId!=null and userId!= ''">
  434. AND a.three_level_user_id = #{userId}
  435. </if>
  436. <if test="timeFiltering!= null and timeFiltering !=''">
  437. <choose>
  438. <when test='type == "1"'>
  439. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  440. </when>
  441. <otherwise>
  442. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  443. </otherwise>
  444. </choose>
  445. </if>
  446. </where>
  447. UNION
  448. SELECT
  449. a.ins_order_no as "id",
  450. a.user_id as "userId",
  451. iac.signing_time as "signingTime",
  452. o.licenseno as "licenseno",
  453. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  454. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  455. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  456. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  457. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  458. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums",
  459. a.second_detail_premiums as "willAmount"
  460. FROM
  461. ins_fee_order_new a
  462. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  463. left join ins_orders o ON o.orderno=iac.orderno
  464. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  465. <where>
  466. <choose>
  467. <when test='type == "1"'>
  468. iff.auditstatus=0
  469. </when>
  470. <otherwise>
  471. iff.auditstatus=1
  472. </otherwise>
  473. </choose>
  474. and iac.orderstatus = '3'
  475. <if test="userId!=null and userId!= ''">
  476. AND a.two_level_user_id = #{userId}
  477. </if>
  478. <if test="timeFiltering!= null and timeFiltering !=''">
  479. <choose>
  480. <when test='type == "1"'>
  481. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  482. </when>
  483. <otherwise>
  484. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  485. </otherwise>
  486. </choose>
  487. </if>
  488. </where>
  489. ) AS fee
  490. </select>
  491. <select id="getSumWillAmountNew" resultType="com.ydtech.modules.protocols.entity.po.InsFeeOrderNew">
  492. select
  493. a.ins_order_no as "id",
  494. a.user_id as "userId",
  495. ins.signing_time as "signingTime",
  496. o.licenseno as "licenseno",
  497. a.jq_export_supervise_costs_premiums as "jqExportSuperviseCostsPremiums",
  498. a.sy_export_supervise_costs_premiums as "syExportSuperviseCostsPremiums",
  499. a.no_export_supervise_costs_premiums as "noExportSuperviseCostsPremiums",
  500. a.jq_export_other_costs_premiums as "jqExportOtherCostsPremiums",
  501. a.sy_export_other_costs_premiums as "syExportOtherCostsPremiums",
  502. a.no_export_other_costs_premiums as "noExportOtherCostsPremiums"
  503. from
  504. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  505. left join ins_orders o ON o.orderno=ins.orderno
  506. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  507. <where>
  508. <if test="userId !=null and userId !=''">
  509. a.user_id = #{userId}
  510. </if>
  511. and ins.orderstatus ='3'
  512. <choose>
  513. <when test='type == "1"'>
  514. and iff.auditstatus=0
  515. </when>
  516. <otherwise>
  517. and iff.auditstatus=1
  518. </otherwise>
  519. </choose>
  520. <if test="timeFiltering!= null and timeFiltering !=''">
  521. <choose>
  522. <when test='type == "1"'>
  523. AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  524. </when>
  525. <otherwise>
  526. AND DATE_FORMAT(ins.signing_time, '%Y-%m-%d' ) = #{timeFiltering}
  527. </otherwise>
  528. </choose>
  529. </if>
  530. <if test="amountType !=null and amountType !='' and amountType == 3 ">
  531. and (a.first_level_user_id is not null or a.two_level_user_id is not null or a.three_level_user_id is not null )
  532. </if>
  533. </where>
  534. </select>
  535. <select id="findMyCollectInAdvanceWillAmountByUserId"
  536. resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
  537. SELECT
  538. fee.subOrderNo,
  539. fee.signingTime,
  540. fee.licenseno,
  541. fee.amount,
  542. "1" as businessSegmentsType,
  543. "2" as transactionType,
  544. fee.createTime
  545. FROM
  546. (
  547. SELECT
  548. a.ins_order_no as "subOrderNo",
  549. iac.signing_time as "signingTime",
  550. o.licenseno as "licenseno",
  551. a.first_detail_premiums as "amount",
  552. iac.createtime as "createTime"
  553. FROM
  554. ins_fee_order_new a
  555. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  556. left join ins_orders o ON o.orderno=iac.orderno
  557. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  558. <where>
  559. iac.orderstatus = '3'
  560. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  561. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  562. </if>
  563. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  564. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  565. </if>
  566. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  567. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  568. </if>
  569. </where>
  570. UNION
  571. SELECT
  572. a.ins_order_no as "subOrderNo",
  573. iac.signing_time as "signingTime",
  574. o.licenseno as "licenseno",
  575. a.third_detail_premiums as "amount",
  576. iac.createtime as "createTime"
  577. FROM
  578. ins_fee_order_new a
  579. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  580. left join ins_orders o ON o.orderno=iac.orderno
  581. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  582. <where>
  583. iff.auditstatus=0
  584. and iac.orderstatus = '3'
  585. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  586. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  587. </if>
  588. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  589. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  590. </if>
  591. </where>
  592. UNION
  593. SELECT
  594. a.ins_order_no as "subOrderNo",
  595. iac.signing_time as "signingTime",
  596. o.licenseno as "licenseno",
  597. a.second_detail_premiums as "amount",
  598. iac.createtime as "createTime"
  599. FROM
  600. ins_fee_order_new a
  601. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  602. left join ins_orders o ON o.orderno=iac.orderno
  603. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  604. <where>
  605. iff.auditstatus=0
  606. and iac.orderstatus = '3'
  607. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  608. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  609. </if>
  610. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  611. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  612. </if>
  613. </where>
  614. ) AS fee
  615. </select>
  616. <select id="findMyCollectInAdvanceSumByUserId"
  617. resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
  618. select
  619. a.ins_order_no as "subOrderNo",
  620. ins.signing_time as "signingTime",
  621. o.licenseno as "licenseno",
  622. (ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
  623. +
  624. (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
  625. as "amount",
  626. "1" as businessSegmentsType,
  627. "1" as transactionType,
  628. ins.createtime as "createTime"
  629. from
  630. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  631. left join ins_orders o ON o.orderno=ins.orderno
  632. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  633. <where>
  634. ins.orderstatus ='3'
  635. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  636. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  637. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  638. </if>
  639. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  640. AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  641. </if>
  642. </where>
  643. </select>
  644. <select id="findMyCollectInAdvanceWillAmountByUserIdCount" resultType="java.lang.Long">
  645. SELECT
  646. count(0)
  647. FROM
  648. (
  649. SELECT
  650. a.ins_order_no as "subOrderNo",
  651. iac.signing_time as "signingTime",
  652. o.licenseno as "licenseno",
  653. a.first_detail_premiums as "amount"
  654. FROM
  655. ins_fee_order_new a
  656. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  657. left join ins_orders o ON o.orderno=iac.orderno
  658. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  659. <where>
  660. iac.orderstatus = '3'
  661. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  662. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  663. </if>
  664. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  665. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  666. </if>
  667. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  668. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  669. </if>
  670. </where>
  671. UNION
  672. SELECT
  673. a.ins_order_no as "subOrderNo",
  674. iac.signing_time as "signingTime",
  675. o.licenseno as "licenseno",
  676. a.third_detail_premiums as "amount"
  677. FROM
  678. ins_fee_order_new a
  679. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  680. left join ins_orders o ON o.orderno=iac.orderno
  681. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  682. <where>
  683. iac.orderstatus = '3'
  684. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  685. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  686. </if>
  687. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  688. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  689. </if>
  690. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  691. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  692. </if>
  693. </where>
  694. UNION
  695. SELECT
  696. a.ins_order_no as "subOrderNo",
  697. iac.signing_time as "signingTime",
  698. o.licenseno as "licenseno",
  699. a.second_detail_premiums as "amount"
  700. FROM
  701. ins_fee_order_new a
  702. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  703. left join ins_orders o ON o.orderno=iac.orderno
  704. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  705. <where>
  706. iac.orderstatus = '3'
  707. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  708. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  709. </if>
  710. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  711. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  712. </if>
  713. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  714. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  715. </if>
  716. </where>
  717. ) AS fee
  718. </select>
  719. <select id="findMyCollectInAdvanceSumByUserIdCount" resultType="java.lang.Long">
  720. select
  721. count(0)
  722. from
  723. ins_fee_order_new a left join ins_area_company ins on a.ins_order_no=ins.id
  724. left join ins_orders o ON o.orderno=ins.orderno
  725. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  726. <where>
  727. iac.orderstatus = '3'
  728. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  729. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  730. </if>
  731. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  732. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  733. AND ins.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  734. </if>
  735. </where>
  736. </select>
  737. <select id="findSumWillAmount" resultType="java.math.BigDecimal">
  738. SELECT
  739. sum(fee.amount)
  740. FROM
  741. (
  742. SELECT
  743. a.first_detail_premiums as "amount"
  744. FROM
  745. ins_fee_order_new a
  746. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  747. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  748. <where>
  749. iac.orderstatus = '3'
  750. AND iff.auditstatus =0
  751. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  752. AND a.first_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  753. </if>
  754. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  755. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  756. </if>
  757. </where>
  758. UNION
  759. SELECT
  760. a.third_detail_premiums as "amount"
  761. FROM
  762. ins_fee_order_new a
  763. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  764. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  765. <where>
  766. iac.orderstatus = '3'
  767. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  768. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  769. </if>
  770. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  771. AND a.three_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  772. </if>
  773. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  774. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  775. </if>
  776. </where>
  777. UNION
  778. SELECT
  779. a.second_detail_premiums as "amount"
  780. FROM
  781. ins_fee_order_new a
  782. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  783. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  784. <where>
  785. iac.orderstatus = '3'
  786. <if test="myCollectInAdvanceQueryDto.auditstatus!=null and myCollectInAdvanceQueryDto.auditstatus!= ''">
  787. AND iff.auditstatus = #{myCollectInAdvanceQueryDto.auditstatus}
  788. </if>
  789. <if test="myCollectInAdvanceQueryDto.userId!=null and myCollectInAdvanceQueryDto.userId!= ''">
  790. AND a.two_level_user_id = #{myCollectInAdvanceQueryDto.userId}
  791. </if>
  792. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  793. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  794. </if>
  795. </where>
  796. ) AS fee
  797. </select>
  798. <select id="findSumAmount" resultType="java.math.BigDecimal">
  799. select
  800. ifnull(sum((ifnull(a.jq_export_supervise_costs_premiums,0)+ifnull(a.sy_export_supervise_costs_premiums,0)+ifnull(a.no_export_supervise_costs_premiums,0))
  801. +
  802. (ifnull(a.jq_export_other_costs_premiums,0)+ifnull(a.sy_export_other_costs_premiums,0)+ifnull(a.no_export_other_costs_premiums,0))
  803. ),0)
  804. as "amount"
  805. from
  806. ins_fee_order_new a left join ins_area_company iac on a.ins_order_no=iac.id
  807. left join ins_orders o ON o.orderno=iac.orderno
  808. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  809. <where>
  810. iac.orderstatus = '3'
  811. AND iff.auditstatus = 0
  812. and a.user_id = #{myCollectInAdvanceQueryDto.userId}
  813. <if test="myCollectInAdvanceQueryDto.startDate!= null and myCollectInAdvanceQueryDto.startDate !='' and myCollectInAdvanceQueryDto.endDate!= null and myCollectInAdvanceQueryDto.endDate !=''">
  814. AND iac.createtime BETWEEN #{myCollectInAdvanceQueryDto.startDate} AND #{myCollectInAdvanceQueryDto.endDate}
  815. </if>
  816. </where>
  817. </select>
  818. <select id="findMyInsuranceByUserId"
  819. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
  820. <include refid="common_List_sql"/>
  821. </select>
  822. <select id="exportMyInsuranceByUserId"
  823. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsDto">
  824. <include refid="common_List_sql"/>
  825. </select>
  826. <sql id="common_List_sql">
  827. SELECT
  828. a.ins_order_no AS "subOrderNo",
  829. DATE_FORMAT(iac.signing_time, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  830. DATE_FORMAT(iac.signing_time, '%Y-%m-%d') AS "signingTimeDay",
  831. DATE_FORMAT(iff.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  832. DATE_FORMAT(iff.audittime, '%Y-%m-%d') AS "auditTimeDay",
  833. CASE iff.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  834. o.licenseno AS "licenseno",
  835. (
  836. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 )) + (
  837. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )) AS "amount",
  838. a.user_id AS userId,
  839. iac.jqapplyno AS jqapplyno,
  840. iac.syapplyno AS syapplyno,
  841. iac.inscompany AS companyName,
  842. JSON_UNQUOTE(json_extract(o.applyinfo, '$.name')) as insuredName,
  843. ins.NAME AS partnerCompaniesName,
  844. o.username as userName,
  845. o.orderno as orderno,
  846. o.frameno as frameNo,
  847. JSON_EXTRACT( o.carinfo, '$.engineNo' ) as engineNo,
  848. iac.product as productId,
  849. iac.jqpremium,
  850. iac.sypremium,
  851. iac.jypremium,
  852. iac.taxamount,
  853. a.jq_costs_export_proportion+a.jq_export_other_costs_proportion as jq_export_proportion,
  854. a.sy_costs_export_proportion+a.sy_export_other_costs_proportion as sy_export_proportion,
  855. a.no_costs_export_proportion+a.no_export_other_costs_proportion as no_export_proportion
  856. FROM
  857. ins_fee_audit iff
  858. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  859. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  860. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  861. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  862. LEFT JOIN esm_ins_company ins ON ins.id = agree.partner_companies_id
  863. WHERE
  864. iac.orderstatus = '3'
  865. and iff.auditstatus !=2
  866. <choose>
  867. <when test="userList != null and userList.size>0">
  868. AND ( a.user_id = #{vo.userId} or a.user_id in
  869. <foreach collection="userList" item="item" open="(" separator="," close=")">
  870. #{item}
  871. </foreach>
  872. )
  873. </when>
  874. <otherwise>
  875. AND a.user_id = #{vo.userId}
  876. </otherwise>
  877. </choose>
  878. <if test="vo.orderNo!=null and vo.orderNo!= ''">
  879. AND o.orderno = #{vo.orderNo}
  880. </if>
  881. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  882. AND iac.id = #{vo.subOrderNo}
  883. </if>
  884. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  885. AND a.user_id = #{vo.userDLId}
  886. </if>
  887. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  888. AND o.username= #{vo.userDLName}
  889. </if>
  890. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  891. AND o.licenseno = #{vo.licenseNo}
  892. </if>
  893. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  894. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  895. </if>
  896. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  897. AND iff.auditstatus = #{vo.auditstatus}
  898. </if>
  899. <if test="vo.salesmanId!=null and vo.salesmanId!= ''">
  900. AND o.user_id = #{vo.salesmanId}
  901. </if>
  902. <if test="vo.salesmanName!=null and vo.salesmanName!= ''">
  903. AND o.username = #{vo.salesmanName}
  904. </if>
  905. <if test="vo.jqapplyno!=null and vo.jqapplyno!= ''">
  906. AND iac.jqapplyno like concat('%', #{vo.jqapplyno},'%')
  907. </if>
  908. <if test="vo.syapplyno!=null and vo.syapplyno!= ''">
  909. AND iac.syapplyno like concat('%', #{vo.syapplyno},'%')
  910. </if>
  911. <if test="vo.frameNo!=null and vo.frameNo!= ''">
  912. AND o.frameno = #{vo.frameNo}
  913. </if>
  914. <if test="vo.engineNo!=null and vo.engineNo!= ''">
  915. and JSON_EXTRACT( o.carinfo, '$.engineNo' ) = #{vo.engineNo}
  916. </if>
  917. <if test="vo.productId!=null and vo.productId!= ''">
  918. AND iac.productid = #{vo.productId}
  919. </if>
  920. <if test="vo.insuredName!=null and vo.insuredName!= ''">
  921. AND o.insuredname = #{vo.insuredName}
  922. </if>
  923. <if test="vo.companyId!=null and vo.companyId!= ''">
  924. AND iac.company_id = #{vo.companyId}
  925. </if>
  926. order by iff.audittime desc
  927. </sql>
  928. <select id="findMyInsuranceTGByUserId"
  929. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  930. <include refid="common_List_sql_tg"/>
  931. </select>
  932. <select id="exportMyInsuranceTGByUserId"
  933. resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsTGDto">
  934. <include refid="common_List_sql_tg"/>
  935. </select>
  936. <sql id="common_List_sql_tg">
  937. SELECT
  938. fee.subOrderNo,
  939. DATE_FORMAT(fee.signingTime, '%Y-%m-%d %H:%i:%s') AS "signingTime",
  940. DATE_FORMAT(fee.audittime, '%Y-%m-%d %H:%i:%s') AS "auditTime",
  941. CASE fee.auditstatus WHEN '0' THEN '未审核' WHEN '1' THEN '已审核' ELSE '' END AS auditstatus,
  942. fee.licenseno,
  943. fee.amount,
  944. fee.userId,
  945. fee.userName,
  946. fee.jqpremium,
  947. fee.sypremium,
  948. fee.jypremium,
  949. fee.sumpremium,
  950. fee.userLevel
  951. FROM
  952. (
  953. SELECT
  954. a.ins_order_no AS "subOrderNo",
  955. iac.signing_time AS "signingTime",
  956. o.licenseno AS "licenseno",
  957. iff.audittime AS "auditTime",
  958. iff.auditstatus AS auditstatus,
  959. o.username AS userName,
  960. o.userid AS userId,
  961. iac.jqpremium AS jqpremium,
  962. iac.sypremium AS sypremium,
  963. iac.jypremium AS jypremium,
  964. iac.sumpremium AS sumpremium,
  965. a.first_detail_premiums AS "amount",
  966. "一级代理" AS userLevel
  967. FROM
  968. ins_fee_audit iff
  969. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  970. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  971. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  972. WHERE
  973. iac.orderstatus = '3'
  974. AND a.first_level_user_id = #{vo.userId}
  975. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  976. AND iac.id = #{vo.subOrderNo}
  977. </if>
  978. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  979. AND o.userid = #{vo.userDLId}
  980. </if>
  981. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  982. AND o.username= #{vo.userDLName}
  983. </if>
  984. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  985. AND o.licenseno = #{vo.licenseNo}
  986. </if>
  987. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  988. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  989. </if>
  990. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  991. AND iff.auditstatus = #{vo.auditstatus}
  992. </if>
  993. UNION
  994. SELECT
  995. a.ins_order_no AS "subOrderNo",
  996. iac.signing_time AS "signingTime",
  997. o.licenseno AS "licenseno",
  998. iff.audittime AS "auditTime",
  999. iff.auditstatus AS auditstatus,
  1000. o.username AS userName,
  1001. o.userid AS userId,
  1002. iac.jqpremium AS jqpremium,
  1003. iac.sypremium AS sypremium,
  1004. iac.jypremium AS jypremium,
  1005. iac.sumpremium AS sumpremium,
  1006. a.third_detail_premiums AS "amount",
  1007. "三级级代理" AS userLevel
  1008. FROM
  1009. ins_fee_audit iff
  1010. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1011. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1012. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1013. WHERE
  1014. iac.orderstatus = '3'
  1015. AND iff.auditstatus = 0
  1016. AND a.three_level_user_id = #{vo.userId}
  1017. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1018. AND iac.id = #{vo.subOrderNo}
  1019. </if>
  1020. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1021. AND o.userid = #{vo.userDLId}
  1022. </if>
  1023. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1024. AND o.username= #{vo.userDLName}
  1025. </if>
  1026. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1027. AND o.licenseno = #{vo.licenseNo}
  1028. </if>
  1029. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1030. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1031. </if>
  1032. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1033. AND iff.auditstatus = #{vo.auditstatus}
  1034. </if>
  1035. UNION
  1036. SELECT
  1037. a.ins_order_no AS "subOrderNo",
  1038. iac.signing_time AS "signingTime",
  1039. o.licenseno AS "licenseno",
  1040. iff.audittime AS "auditTime",
  1041. iff.auditstatus AS auditstatus,
  1042. o.username AS userName,
  1043. o.userid AS userId,
  1044. iac.jqpremium AS jqpremium,
  1045. iac.sypremium AS sypremium,
  1046. iac.jypremium AS jypremium,
  1047. iac.sumpremium AS sumpremium,
  1048. a.second_detail_premiums AS "amount",
  1049. "二级代理" AS userLevel
  1050. FROM
  1051. ins_fee_audit iff
  1052. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1053. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1054. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1055. WHERE
  1056. iac.orderstatus = '3'
  1057. AND a.two_level_user_id = #{vo.userId}
  1058. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1059. AND iac.id = #{vo.subOrderNo}
  1060. </if>
  1061. <if test="vo.userDLId!=null and vo.userDLId!= ''">
  1062. AND o.userid = #{vo.userDLId}
  1063. </if>
  1064. <if test="vo.userDLName!=null and vo.userDLName!= ''">
  1065. AND o.username= #{vo.userDLName}
  1066. </if>
  1067. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1068. AND o.licenseno = #{vo.licenseNo}
  1069. </if>
  1070. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1071. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1072. </if>
  1073. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1074. AND iff.auditstatus = #{vo.auditstatus}
  1075. </if>
  1076. ) AS fee
  1077. ORDER BY
  1078. fee.signingTime DESC
  1079. </sql>
  1080. <select id="findMyAmountYSOrSSCXAmount" resultType="java.math.BigDecimal">
  1081. SELECT
  1082. ifnull(sum(
  1083. ifnull( a.jq_export_supervise_costs_premiums, 0 )+ ifnull( a.sy_export_supervise_costs_premiums, 0 )+ ifnull( a.no_export_supervise_costs_premiums, 0 ) +
  1084. ifnull( a.jq_export_other_costs_premiums, 0 )+ ifnull( a.sy_export_other_costs_premiums, 0 )+ ifnull( a.no_export_other_costs_premiums, 0 )
  1085. ),0)
  1086. FROM
  1087. ins_fee_audit iff
  1088. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1089. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1090. left join ins_orders io on iac.orderno =io.orderno
  1091. WHERE
  1092. iac.orderstatus = '3'
  1093. and iff.auditstatus=#{vo.auditstatus}
  1094. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1095. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1096. </if>
  1097. <choose>
  1098. <when test="vo.deptId!=null and vo.deptId!= '' ">
  1099. and io.deptid like "${vo.deptId}%"
  1100. </when>
  1101. <otherwise>
  1102. AND a.user_id = #{vo.userId}
  1103. </otherwise>
  1104. </choose>
  1105. </select>
  1106. <select id="findMyAmountYSOrSSTGAmount" resultType="java.math.BigDecimal">
  1107. SELECT
  1108. ifnull(sum(fee.amount),0)
  1109. FROM
  1110. (
  1111. SELECT
  1112. a.first_detail_premiums AS "amount"
  1113. FROM
  1114. ins_fee_audit iff
  1115. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1116. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1117. WHERE
  1118. iac.orderstatus = '3'
  1119. AND a.first_level_user_id = #{vo.userId}
  1120. and iff.auditstatus = #{vo.auditstatus}
  1121. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1122. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1123. </if>
  1124. UNION
  1125. SELECT
  1126. a.third_detail_premiums AS "amount"
  1127. FROM
  1128. ins_fee_audit iff
  1129. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1130. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1131. WHERE
  1132. iac.orderstatus = '3'
  1133. AND a.three_level_user_id = #{vo.userId}
  1134. and iff.auditstatus = #{vo.auditstatus}
  1135. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1136. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1137. </if>
  1138. UNION
  1139. SELECT
  1140. a.second_detail_premiums AS "amount"
  1141. FROM
  1142. ins_fee_audit iff
  1143. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1144. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1145. WHERE
  1146. iac.orderstatus = '3'
  1147. AND a.two_level_user_id = #{vo.userId}
  1148. and iff.auditstatus = #{vo.auditstatus}
  1149. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1150. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1151. </if>
  1152. ) AS fee
  1153. </select>
  1154. <select id="findMyAmountYTXmount" resultType="java.math.BigDecimal">
  1155. SELECT
  1156. ifnull( sum( au.amount ), 0 )
  1157. FROM
  1158. sys_amount_auditing au
  1159. WHERE
  1160. au.user_id = #{userId}
  1161. AND auditing_status = #{status}
  1162. </select>
  1163. <select id="queryAdvanceAndActualDataPage"
  1164. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDataDto">
  1165. SELECT
  1166. a.ins_order_no AS subOrderNo,
  1167. iac.signing_time AS signingTime,
  1168. o.licenseno AS licenseNo,
  1169. CASE
  1170. iff.auditstatus
  1171. WHEN '0' THEN
  1172. '未审核'
  1173. WHEN '1' THEN
  1174. '已审核' ELSE ''
  1175. END AS auditstatus,
  1176. o.username AS userName,
  1177. o.userid AS userId,
  1178. 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,
  1179. 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,
  1180. ifnull( a.first_detail_premiums, 0 )+ ifnull( a.second_detail_premiums, 0 )+ ifnull( a.third_detail_premiums, 0 ) AS promotionAmount,
  1181. 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,
  1182. CASE
  1183. dept.management_source
  1184. WHEN '1' THEN
  1185. '渠道'
  1186. WHEN '2' THEN
  1187. '代理人' ELSE ''
  1188. END deptType
  1189. FROM
  1190. ins_fee_audit iff
  1191. LEFT JOIN ins_fee_order_new a ON a.ins_order_no = iff.ins_order_no
  1192. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  1193. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1194. LEFT JOIN sys_dept dept ON o.deptid = dept.id
  1195. WHERE
  1196. iac.orderstatus = '3'
  1197. AND (
  1198. dept.management_source = 1
  1199. OR dept.management_source = 2)
  1200. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1201. AND iac.id = #{vo.subOrderNo}
  1202. </if>
  1203. <if test="vo.userId!=null and vo.userId!= ''">
  1204. AND o.userid = #{vo.userId}
  1205. </if>
  1206. <if test="vo.userName!=null and vo.userName!= ''">
  1207. AND o.username= #{vo.userName}
  1208. </if>
  1209. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1210. AND o.licenseno = #{vo.licenseNo}
  1211. </if>
  1212. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1213. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1214. </if>
  1215. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1216. AND iff.auditstatus = #{vo.auditstatus}
  1217. </if>
  1218. <if test="vo.deptType!=null and vo.deptType!= ''">
  1219. AND dept.management_source = #{vo.deptType}
  1220. </if>
  1221. order by iac.signing_time desc
  1222. </select>
  1223. <select id="queryAdvanceAndActualDeptDataPage"
  1224. resultType="com.ydtech.modules.admin.model.report.financeData.AdvanceAndActualDeptDataDto">
  1225. SELECT
  1226. b.suborder AS subOrderNo,
  1227. iac.signing_time AS signingTime,
  1228. o.licenseno AS licenseNo,
  1229. CASE
  1230. iff.auditstatus
  1231. WHEN '0' THEN
  1232. '未审核'
  1233. WHEN '1' THEN
  1234. '已审核' ELSE ''
  1235. END AS auditstatus,
  1236. o.username AS userName,
  1237. o.userid AS userId,
  1238. b.deptId AS deptId,
  1239. b.sumAmount AS sumAmount,
  1240. dept.NAME AS deptName
  1241. FROM
  1242. ins_fee_audit iff
  1243. LEFT JOIN (
  1244. SELECT
  1245. ins_order_no AS suborder,
  1246. LEFT ( dept_id, 2 ) AS deptId,
  1247. ( jq_dept_premiums_level_1 + sy_dept_premiums_level_1 + no_dept_premiums_level_1 ) AS sumAmount
  1248. FROM
  1249. ins_fee_order_new UNION ALL
  1250. SELECT
  1251. ins_order_no AS suborder,
  1252. LEFT ( dept_id, 4 ) AS deptId,
  1253. ( jq_dept_premiums_level_2 + sy_dept_premiums_level_2 + no_dept_premiums_level_2 ) AS sumAmount
  1254. FROM
  1255. ins_fee_order_new UNION ALL
  1256. SELECT
  1257. ins_order_no AS suborder,
  1258. LEFT ( dept_id, 6 ) AS deptId,
  1259. ( jq_dept_premiums_level_3 + sy_dept_premiums_level_3 + no_dept_premiums_level_3 ) AS sumAmount
  1260. FROM
  1261. ins_fee_order_new UNION ALL
  1262. SELECT
  1263. ins_order_no AS suborder,
  1264. LEFT ( dept_id, 8 ) AS deptId,
  1265. ( jq_dept_premiums_level_4 + sy_dept_premiums_level_4 + no_dept_premiums_level_4 ) AS sumAmount
  1266. FROM
  1267. ins_fee_order_new UNION ALL
  1268. SELECT
  1269. ins_order_no AS suborder,
  1270. LEFT ( dept_id, 11 ) AS deptId,
  1271. ( jq_dept_premiums_level_5 + sy_dept_premiums_level_5 + no_dept_premiums_level_5 ) AS sumAmount
  1272. FROM
  1273. ins_fee_order_new
  1274. ) b ON iff.ins_order_no = b.suborder
  1275. LEFT JOIN ins_area_company iac ON iac.id = b.suborder
  1276. LEFT JOIN ins_orders o ON o.orderno = iac.orderno
  1277. LEFT JOIN sys_dept dept ON b.deptid = dept.id
  1278. WHERE
  1279. iac.orderstatus = '3'
  1280. <if test="vo.subOrderNo!=null and vo.subOrderNo!= ''">
  1281. AND iac.id = #{vo.subOrderNo}
  1282. </if>
  1283. <if test="vo.licenseNo!=null and vo.licenseNo!= ''">
  1284. AND o.licenseno = #{vo.licenseNo}
  1285. </if>
  1286. <if test="vo.startDate!=null and vo.startDate!= '' and vo.endDate!=null and vo.endDate!= ''">
  1287. AND iac.signing_time BETWEEN #{vo.startDate} AND #{vo.endDate}
  1288. </if>
  1289. <if test="vo.auditstatus!=null and vo.auditstatus!= ''">
  1290. AND iff.auditstatus = #{vo.auditstatus}
  1291. </if>
  1292. <if test="vo.deptId!=null and vo.deptId!= ''">
  1293. AND dept.id = #{vo.deptId}
  1294. </if>
  1295. order by iac.signing_time desc
  1296. </select>
  1297. <select id="getCostSettlementExcel" resultType="com.ydtech.modules.order.entity.vo.CostSettlementExcelVo">
  1298. SELECT
  1299. io.ins_company,
  1300. sum( ifon.jq_premium ) AS jq_premium,
  1301. sum( ifon.sy_premium ) AS sy_premium,
  1302. sum( ifon.no_premium ) AS no_premium,
  1303. sum( ifon.jq_supervise_costs_premiums ) AS jq_supervise_costs_premiums,
  1304. sum( ifon.jq_other_costs_premiums ) AS jq_other_costs_premiums,
  1305. sum( ifon.sy_supervise_costs_premiums ) AS sy_supervise_costs_premiums,
  1306. sum( ifon.sy_other_costs_premiums ) AS sy_other_costs_premiums,
  1307. sum( ifon.no_supervise_costs_premiums ) AS no_supervise_costs_premiums,
  1308. sum( ifon.no_other_costs_premiums ) AS no_other_costs_premiums,
  1309. sum( ifon.jq_export_supervise_costs_premiums ) AS jq_export_supervise_costs_premiums,
  1310. sum( ifon.jq_export_other_costs_premiums ) AS jq_export_other_costs_premiums,
  1311. sum( ifon.sy_export_supervise_costs_premiums ) AS sy_export_supervise_costs_premiums,
  1312. sum( ifon.sy_export_other_costs_premiums ) AS sy_export_other_costs_premiums,
  1313. sum( ifon.no_export_supervise_costs_premiums ) AS no_export_supervise_costs_premiums,
  1314. sum( ifon.no_export_other_costs_premiums ) AS no_export_other_costs_premiums,
  1315. sum( ifon.first_detail_premiums + ifon.second_detail_premiums + ifon.third_detail_premiums) as distributing_premiums,
  1316. SUM(
  1317. ifon.jq_export_supervise_costs_premiums +
  1318. ifon.jq_export_other_costs_premiums +
  1319. ifon.sy_export_supervise_costs_premiums +
  1320. ifon.sy_export_other_costs_premiums +
  1321. ifon.no_export_supervise_costs_premiums +
  1322. ifon.no_export_other_costs_premiums +
  1323. ifon.first_detail_premiums +
  1324. ifon.second_detail_premiums +
  1325. ifon.third_detail_premiums
  1326. ) AS total_premiums
  1327. FROM
  1328. ins_fee_audit ifa
  1329. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1330. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1331. AND iac.orderstatus = 3
  1332. LEFT JOIN ins_fee_order_new ifon on ifon.ins_order_no = iac.id
  1333. LEFT JOIN sys_user su ON su.id = io.userid
  1334. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1335. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1336. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1337. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1338. WHERE
  1339. iac.id = ifa.ins_order_no
  1340. AND iac.orderstatus = 3
  1341. and ifa.auditstatus = 1
  1342. <if test="param.companyId !=null and param.companyId != ''">
  1343. AND iac.company_id = #{param.companyId}
  1344. </if>
  1345. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1346. and iac.signing_time between #{param.startTime} and #{param.endTime}
  1347. </if>
  1348. group by ins_company
  1349. </select>
  1350. <select id="getFeeReceivable" resultType="com.ydtech.modules.order.entity.vo.FeeReceivableVo">
  1351. SELECT
  1352. io.ins_company,
  1353. sum( ifon.jq_dept_premiums_level_1 + ifon.sy_dept_premiums_level_1 + ifon.no_dept_premiums_level_1 ) AS dept_premiums_level_1,
  1354. sum( ifon.jq_dept_premiums_level_2 + ifon.sy_dept_premiums_level_2 + ifon.no_dept_premiums_level_2 ) AS dept_premiums_level_2,
  1355. sum( ifon.jq_dept_premiums_level_3 + ifon.sy_dept_premiums_level_3 + ifon.no_dept_premiums_level_3 ) AS dept_premiums_level_3,
  1356. sum( ifon.jq_dept_premiums_level_4 + ifon.sy_dept_premiums_level_4 + ifon.no_dept_premiums_level_4 ) AS dept_premiums_level_4,
  1357. sum( ifon.jq_dept_premiums_level_5 + ifon.sy_dept_premiums_level_5 + ifon.no_dept_premiums_level_5 ) AS dept_premiums_level_5,
  1358. sum( ifon.jq_profit_margin_premiums + ifon.sy_profit_margin_premiums + ifon.no_profit_margin_premiums ) AS profit_margin_premiums,
  1359. SUM(
  1360. 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
  1361. ) AS total_premiums
  1362. FROM
  1363. ins_fee_audit ifa
  1364. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1365. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1366. AND iac.orderstatus = 3
  1367. LEFT JOIN ins_fee_order_new ifon ON ifon.ins_order_no = iac.id
  1368. LEFT JOIN sys_user su ON su.id = io.userid
  1369. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  1370. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  1371. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1372. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1373. WHERE
  1374. iac.id = ifa.ins_order_no
  1375. AND iac.orderstatus = 3
  1376. AND ifa.auditstatus = 1
  1377. <if test="param.companyId !=null and param.companyId != ''">
  1378. AND iac.company_id = #{param.companyId}
  1379. </if>
  1380. <if test="param.startTime !=null and param.startTime != '' and param.endTime !=null and param.endTime != ''">
  1381. AND iac.signing_time BETWEEN #{param.startTime}
  1382. AND #{param.endTime}
  1383. </if>
  1384. GROUP BY
  1385. ins_company
  1386. </select>
  1387. <select id="findMyAmountYTXmountByDate" resultType="java.math.BigDecimal">
  1388. SELECT
  1389. ifnull( sum( au.amount ), 0 )
  1390. FROM
  1391. sys_amount_auditing au
  1392. <where>
  1393. au.user_id = #{userId}
  1394. AND au.auditing_status = #{status}
  1395. <if test="beginDate !=null and beginDate != '' and endDate !=null and endDate != ''">
  1396. AND au.create_time BETWEEN #{beginDate} AND #{endDate}
  1397. </if>
  1398. </where>
  1399. </select>
  1400. </mapper>