InsPlyIncomeMapper.xml 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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.fnc.dao.InsPlyIncomeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.InsPlyIncome">
  6. <id column="id" property="id" />
  7. <result column="orderno" property="orderno" />
  8. <result column="policyno" property="policyno" />
  9. <result column="dept_id" property="deptId" />
  10. <result column="dept_name" property="deptName" />
  11. <result column="riskcode" property="riskcode" />
  12. <result column="pay_date" property="payDate" />
  13. <result column="company_id" property="companyId" />
  14. <result column="company_name" property="companyName" />
  15. <result column="agreement_id" property="agreementId" />
  16. <result column="licenseno" property="licenseno" />
  17. <result column="taxamount" property="taxamount" />
  18. <result column="no_tax_premium" property="noTaxPremium" />
  19. <result column="commission_feerate" property="commissionFeerate" />
  20. <result column="other_feerate" property="otherFeerate" />
  21. <result column="commission_feevalue" property="commissionFeevalue" />
  22. <result column="other_feevalue" property="otherFeevalue" />
  23. <result column="all_fee_value" property="allFeeValue" />
  24. <result column="final_fee_value" property="finalFeeValue" />
  25. <result column="doing_fee_value" property="doingFeeValue" />
  26. <result column="create_time" property="createTime" />
  27. <result column="voucher_number" property="voucherNumber"/>
  28. <result column="contract_id" property="contractId"/>
  29. <result column="contract_file_id" property="contractFileId"/>
  30. <result column="handling_fees_status" property="handlingFeesStatus"/>
  31. <result column="documentary_fees_status" property="documentaryFeesStatus"/>
  32. <result column="no_policyno" property="noPolicyno"/>
  33. <result column="sy_policyno" property="syPolicyno"/>
  34. <result column="is_not_car" property="isNotCar"/>
  35. <result column="is_not_documentary" property="isNotDocumentary"/>
  36. <result column="invoic_amount" property="invoicAmount"/>
  37. <result column="invoic_id" property="invoicId"/>
  38. <result column="tax_premium" property="taxPremium"/>
  39. <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
  40. <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
  41. <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
  42. <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
  43. <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
  44. <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
  45. <result column="jq_premium" property="jqPremium"/>
  46. <result column="sy_premium" property="syPremium"/>
  47. <result column="no_premium" property="noPremium"/>
  48. <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
  49. <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
  50. <result column="no_no_tax_premium" property="noNoTaxPremium"/>
  51. <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
  52. <result column="sy_receivable_proportion" property="syReceivableProportion"/>
  53. <result column="no_receivable_proportion" property="noReceivableProportion"/>
  54. <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
  55. <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
  56. <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
  57. <result column="settlement_time" property="settlementTime"/>
  58. <result column="update_time" property="updateTime"/>
  59. <result column="settlement_user_id" property="settlementUserId"/>
  60. <result column="update_user_id" property="updateUserId"/>
  61. <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
  62. <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
  63. <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
  64. <result column="user_id" property="userId"/>
  65. <result column="update_user_id" property="updateUserId"/>
  66. <result column="partner_companies_id" property="partnerCompaniesId"/>
  67. <result column="partner_companies_name" property="partnerCompaniesName"/>
  68. <result column="receivable_amount" property="receivableAmount"/>
  69. <result column="insured_name" property="insuredName"/>
  70. <result column="invoicing_method" property="invoicingMethod"/>
  71. <result column="remarks" property="remarks"/>
  72. <result column="jq_start_date" property="jqStartDate"/>
  73. <result column="jq_end_date" property="jqEndDate"/>
  74. <result column="sy_start_date" property="syStartDate"/>
  75. <result column="sy_end_date" property="syEndDate"/>
  76. <result column="settle_other_status" property="settleOtherStatus"/>
  77. </resultMap>
  78. <sql id="income_com">
  79. a.id as "id",
  80. a.orderno as "orderno",
  81. a.policyno as "policyno",
  82. a.dept_id as "deptId",
  83. a.riskcode as "riskcode",
  84. a.pay_date as "payDate",
  85. a.signdate as "signdate",
  86. a.company_id as "companyId",
  87. a.agreement_id as "agreementId",
  88. a.licenseno as "licenseno",
  89. a.taxamount as "taxamount",
  90. a.no_tax_premium as "noTaxPremium",
  91. a.commission_feerate as "commissionFeerate",
  92. a.other_feerate as "otherFeerate",
  93. a.commission_feevalue as "commissionFeevalue",
  94. a.other_feevalue as "otherFeevalue",
  95. a.all_fee_value as "allFeeValue",
  96. a.final_fee_value as "finalFeeValue",
  97. a.doing_fee_value as "doingFeeValue",
  98. a.voucher_number as "voucherNumber",
  99. a.contract_id as "contractId",
  100. a.contract_file_id as "contractFileId",
  101. a.handling_fees_status as "handlingFeesStatus",
  102. a.no_policyno as "noPolicyno",
  103. a.sy_policyno as "syPolicyno",
  104. a.documentary_fees_status as "documentaryFeesStatus",
  105. a.is_not_car as "isNotCar",
  106. a.is_not_documentary as "isNotDocumentary",
  107. a.invoic_amount as "invoicAmount",
  108. a.invoic_id as "invoicId",
  109. a.tax_premium as "taxPremium",
  110. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  111. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  112. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  113. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  114. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  115. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  116. a.partner_companies_id as "partnerCompaniesId",
  117. a.jq_premium as "jqPremium",
  118. a.sy_premium as "syPremium",
  119. a.no_premium as "noPremium",
  120. a.jq_no_tax_premium as "jqNoTaxPremium",
  121. a.sy_no_tax_premium as "syNoTaxPremium",
  122. a.no_no_tax_premium as "noNoTaxPremium",
  123. a.jq_receivable_proportion as "jqReceivableProportion",
  124. a.sy_receivable_proportion as "syReceivableProportion",
  125. a.no_receivable_proportion as "noReceivableProportion",
  126. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  127. a.sy_other_costs_proportion as "syOtherCostsProportion",
  128. a.no_other_costs_proportion as "noOtherCostsProportion",
  129. a.settlement_time as "settlementTime",
  130. a.update_time as "updateTime",
  131. a.settlement_user_id as "settlementUserId",
  132. a.update_user_id as "updateUserId",
  133. a.jq_other_costs_premium as "jqOtherCostsPremium",
  134. a.sy_other_costs_premium as "syOtherCostsPremium",
  135. a.no_other_costs_premium as "noOtherCostsPremium",
  136. a.partner_companies_name as "partnerCompaniesName",
  137. a.company_name as "companyName",
  138. a.receivable_amount as "receivableAmount",
  139. a.invoic_time as "invoicTime",
  140. a.insured_name as "insuredName",
  141. a.remarks as "remarks",
  142. a.jq_start_date as "jqStartDate",
  143. a.jq_end_date as "jqEndDate",
  144. a.sy_start_date as "syStartDate",
  145. a.sy_end_date as "syEndDate",
  146. a.settle_other_status as "settleOtherStatus",
  147. a.user_id as "userId",
  148. a.invoicing_method as "invoicingMethod",
  149. a.create_time as "createTime"
  150. </sql>
  151. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  152. select
  153. pa.agreement_name as "agreementName",
  154. pa.agreement_type as "agreementType",
  155. pa.docking_person as "dockingPerson",
  156. su.name as "userName",
  157. <include refid="income_com"/>
  158. from ins_ply_income a
  159. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  160. LEFT JOIN sys_user su on su.id=a.user_id
  161. <where>
  162. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  163. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  164. </if>
  165. <if test="agreementType !=null and agreementType !=''">
  166. and pa.agreement_type =#{agreementType}
  167. </if>
  168. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  169. and a.signdate between #{signDateStart} and #{signDateEnd}
  170. </if>
  171. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  172. and a.handling_fees_status =#{handlingFeesStatus}
  173. </if>
  174. <if test="dockingPerson !=null and dockingPerson !=''">
  175. and pa.docking_person =#{dockingPerson}
  176. </if>
  177. <if test="orderno !=null and orderno !=''">
  178. and a.orderno =#{orderno}
  179. </if>
  180. <if test="companyName !=null and companyName !=''">
  181. and a.company_id =#{companyName}
  182. </if>
  183. <if test="policyno !=null and policyno !=''">
  184. and a.policyno =#{policyno}
  185. </if>
  186. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  187. and a.documentary_fees_status =#{documentaryFeesStatus}
  188. </if>
  189. <if test="isNotCar !=null and isNotCar !=''">
  190. and a.is_not_car =#{isNotCar}
  191. </if>
  192. <if test="deptId !=null and deptId !=''">
  193. and pa.dept_id =#{deptId}
  194. </if>
  195. <if test="ids != null and ids != '' and ids.length > 0">
  196. and a.id in
  197. <foreach collection="ids" item="item" open="(" separator="," close=")">
  198. #{item}
  199. </foreach>
  200. </if>
  201. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  202. and a.id in
  203. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  204. #{item}
  205. </foreach>
  206. </if>
  207. <if test="isOther !=null and isOther !=''">
  208. and a.is_not_documentary =#{isOther}
  209. </if>
  210. <if test="licenseno != null and licenseno != ''">
  211. and a.licenseno =#{licenseno}
  212. </if>
  213. <if test="syPolicyno != null and syPolicyno != ''">
  214. and a.sy_policyno =#{syPolicyno}
  215. </if>
  216. <if test="noPolicyno != null and noPolicyno != ''">
  217. and a.no_policyno =#{noPolicyno}
  218. </if>
  219. <if test="signdate !=null and signdate !=''">
  220. AND a.signdate =#{signdate}
  221. </if>
  222. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  223. AND a.partner_companies_id =#{partnerCompaniesId}
  224. </if>
  225. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  226. AND a.partner_companies_name =#{partnerCompaniesName}
  227. </if>
  228. <if test="createTime !=null and createTime !=''">
  229. AND a.create_time =#{createTime}
  230. </if>
  231. <if test="settlementTime !=null and settlementTime !=''">
  232. AND a.settlement_time =#{settlementTime}
  233. </if>
  234. <if test="userId !=null and userId !=''">
  235. and a.userId =#{userId}
  236. </if>
  237. <if test="companyId !=null and companyId !=''">
  238. and a.company_id =#{companyId}
  239. </if>
  240. <if test="riskcode !=null and riskcode !=''">
  241. and a.riskcode =#{riskcode}
  242. </if>
  243. <if test="year !=null and year !=''">
  244. AND YEAR(a.signdate) =#{year}
  245. </if>
  246. <if test="month !=null and month !=''">
  247. AND month(a.signdate) =#{month}
  248. </if>
  249. <if test="day !=null and day !=''">
  250. AND day(a.signdate) =#{day}
  251. </if>
  252. <if test="insuredName !=null and insuredName !=''">
  253. AND a.insured_name =#{insuredName}
  254. </if>
  255. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  256. AND (a.jq_start_date )
  257. </if>
  258. </where>
  259. ORDER BY a.create_time desc
  260. </select>
  261. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  262. select
  263. pa.agreement_name as "agreementName",
  264. pa.agreement_type as "agreementType",
  265. su.name as "userName",
  266. <include refid="income_com"/>
  267. from ins_ply_income a
  268. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  269. LEFT JOIN sys_user su on su.id=a.user_id
  270. <where>
  271. <if test="id!=null and id!=''">
  272. a.id=#{id}
  273. </if>
  274. </where>
  275. </select>
  276. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  277. select
  278. count(MONTH(a.signdate)) as "totalorders",
  279. MONTH(a.signdate) as "monthSigdate",
  280. sum(a.other_feevalue) as "allLOtherFeevalue",
  281. GROUP_CONCAT(a.id) as "ids"
  282. from ins_ply_income a
  283. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  284. <where>
  285. <if test="isNotCar !=null and isNotCar !=''" >
  286. a.is_not_car =#{isNotCar}
  287. </if>
  288. <if test="isOther !=null and isOther !=''">
  289. and a.is_not_documentary =#{isOther}
  290. </if>
  291. <if test="agreementType !=null and agreementType !=''">
  292. and pa.agreement_type =#{agreementType}
  293. </if>
  294. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  295. and a.documentary_fees_status =#{documentaryFeesStatus}
  296. </if>
  297. <if test="companyId !=null and companyId !=''">
  298. and a.company_id =#{companyId}
  299. </if>
  300. <if test="year !=null and year !=''">
  301. and YEAR(a.signdate) =#{year}
  302. </if>
  303. group by MONTH(a.signdate)
  304. </where>
  305. </select>
  306. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  307. update ins_ply_income
  308. <set>
  309. <if test="contractId != null">
  310. contract_id = #{contractId},
  311. </if>
  312. <if test="voucherNumber != null">
  313. voucher_number = #{voucherNumber},
  314. </if>
  315. <if test="contractFileId != null">
  316. contract_file_id = #{contractFileId},
  317. </if>
  318. <if test="handlingFeesStatus != null">
  319. handling_fees_status = #{handlingFeesStatus}
  320. </if>
  321. <if test="documentaryFeesStatus != null">
  322. documentary_fees_status = #{documentaryFeesStatus}
  323. </if>
  324. </set>
  325. where orderno =#{orderno}
  326. </update>
  327. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  328. SELECT
  329. a.companyId as "companyId",
  330. a.totalorders as "totalorders",
  331. a.ids as "ids",
  332. a.allLOtherFeevalue as "allLOtherFeevalue"
  333. FROM
  334. (
  335. SELECT
  336. a.company_id AS "companyId",
  337. count(a.orderno) as "totalorders",
  338. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  339. GROUP_CONCAT(a.id) as "ids"
  340. FROM
  341. ins_ply_income a
  342. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  343. WHERE
  344. pa.agreement_type = '2'
  345. <if test="isNotCar !=null and isNotCar !=''" >
  346. and a.is_not_car =#{isNotCar}
  347. </if>
  348. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  349. AND a.documentary_fees_status = #{documentaryFeesStatus}
  350. </if>
  351. <if test="isOther !=null and isOther !=''">
  352. and a.is_not_documentary =#{isOther}
  353. </if>
  354. <if test="companyId !=null and companyId !=''">
  355. and a.company_id =#{companyId}
  356. </if>
  357. <if test="year !=null and year !=''">
  358. and YEAR(a.signdate) =#{year}
  359. </if>
  360. <if test="month !=null and month !=''">
  361. and month(a.signdate) =#{month}
  362. </if>
  363. GROUP BY
  364. a.company_id
  365. ) a
  366. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  367. </select>
  368. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  369. select
  370. <include refid="income_com"/>
  371. from ins_ply_income a
  372. <where>
  373. 1=1
  374. <if test="licenseno !=null and licenseno !=''">
  375. AND a.licenseno=#{licenseno}
  376. </if>
  377. <if test="policyno !=null and policyno !=''">
  378. AND a.policyno=#{policyno}
  379. </if>
  380. <if test="syPolicyno !=null and syPolicyno !=''">
  381. AND a.sy_policyno=#{syPolicyno}
  382. </if>
  383. <if test="noPolicyno !=null and noPolicyno !=''">
  384. AND a.no_policyno=#{noPolicyno}
  385. </if>
  386. <if test="isOther !=null and isOther !=''">
  387. and a.is_not_documentary =#{isOther}
  388. </if>
  389. </where>
  390. </select>
  391. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  392. select
  393. <include refid="income_com"/>
  394. from ins_ply_income a
  395. <where>
  396. 1=1
  397. <if test="licenseno !=null and licenseno !=''">
  398. AND a.licenseno=#{licenseno}
  399. </if>
  400. <if test="policyno !=null and policyno !=''">
  401. AND a.policyno=#{policyno}
  402. </if>
  403. <if test="syPolicyno !=null and syPolicyno !=''">
  404. AND a.sy_policyno=#{syPolicyno}
  405. </if>
  406. <if test="noPolicyno !=null and noPolicyno !=''">
  407. AND a.no_policyno=#{noPolicyno}
  408. </if>
  409. <if test="isOther !=null and isOther !=''">
  410. and a.is_not_documentary =#{isOther}
  411. </if>
  412. <if test="isNotCar !=null and isNotCar !=''">
  413. and a.is_not_car =#{isNotCar}
  414. </if>
  415. <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
  416. and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
  417. </if>
  418. <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
  419. and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
  420. </if>
  421. <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
  422. and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
  423. </if>
  424. <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
  425. and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
  426. </if>
  427. <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
  428. and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
  429. </if>
  430. <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
  431. and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
  432. </if>
  433. <if test="jqPremium !=null and jqPremium !=''">
  434. and a.jq_premium =#{jqPremium}
  435. </if>
  436. <if test="syPremium !=null and syPremium !=''">
  437. and a.sy_premium =#{jqPremium}
  438. </if>
  439. <if test="noPremium !=null and noPremium !=''">
  440. and a.no_premium =#{noPremium}
  441. </if>
  442. </where>
  443. limit 1
  444. </select>
  445. <select id="totalAmount" resultType="java.util.HashMap">
  446. select
  447. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  448. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  449. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  450. from ins_ply_income a
  451. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  452. <where>
  453. 1=1
  454. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  455. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  456. </if>
  457. <if test="agreementType !=null and agreementType !=''">
  458. and pa.agreement_type =#{agreementType}
  459. </if>
  460. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  461. and a.signdate between #{signDateStart} and #{signDateEnd}
  462. </if>
  463. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  464. and a.handling_fees_status =#{handlingFeesStatus}
  465. </if>
  466. <if test="orderno !=null and orderno !=''">
  467. and a.orderno =#{orderno}
  468. </if>
  469. <if test="policyno !=null and policyno !=''">
  470. and a.policyno =#{policyno}
  471. </if>
  472. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  473. and a.documentary_fees_status =#{documentaryFeesStatus}
  474. </if>
  475. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  476. and a.id in
  477. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  478. #{item}
  479. </foreach>
  480. </if>
  481. <if test="isNotCar !=null and isNotCar !=''">
  482. and a.is_not_car =#{isNotCar}
  483. </if>
  484. <if test="isOther !=null and isOther !=''">
  485. and a.is_not_documentary =#{isOther}
  486. </if>
  487. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  488. and a.licenseno in
  489. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  490. #{item}
  491. </foreach>
  492. </if>
  493. <if test="policyno != null and policyno != '' ">
  494. and a.policyno =#{policyno}
  495. </if>
  496. <if test="syPolicyno != null and syPolicyno != '' ">
  497. and a.sy_policyno =#{syPolicyno}
  498. </if>
  499. <if test="noPolicyno != null and noPolicyno != ''">
  500. and a.no_policyno =#{noPolicyno}
  501. </if>
  502. <if test="signdate !=null and signdate !=''">
  503. and a.signdate =#{signdate}
  504. </if>
  505. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  506. and a.partner_companies_id =#{partnerCompaniesId}
  507. </if>
  508. <if test="createTime !=null and createTime !=''">
  509. a.create_time =#{createTime}
  510. </if>
  511. <if test="settlementTime !=null and settlementTime !=''">
  512. a.settlement_time =#{settlementTime}
  513. </if>
  514. <if test="userId !=null and userId !=''">
  515. and a.userId =#{userId}
  516. </if>
  517. <if test="companyId !=null and companyId !=''">
  518. and a.company_id =#{companyId}
  519. </if>
  520. <if test="riskcode !=null and riskcode !=''">
  521. and a.riskcode =#{riskcode}
  522. </if>
  523. <if test="year !=null and year !=''">
  524. AND YEAR(a.signdate) =#{year}
  525. </if>
  526. <if test="month !=null and month !=''">
  527. AND month(a.signdate) =#{month}
  528. </if>
  529. <if test="day !=null and day !=''">
  530. AND day(a.signdate) =#{day}
  531. </if>
  532. </where>
  533. </select>
  534. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  535. SELECT
  536. SUM(a.commission_feevalue) AS commissionFeevalue,
  537. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  538. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  539. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  540. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  541. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  542. FROM
  543. ins_ply_income a
  544. LEFT JOIN
  545. ptl_agreement pa ON pa.id = a.agreement_id
  546. <where>
  547. 1=1
  548. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  549. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  550. </if>
  551. <if test="agreementType !=null and agreementType !=''">
  552. and pa.agreement_type =#{agreementType}
  553. </if>
  554. <if test="orderno !=null and orderno !=''">
  555. and a.orderno =#{orderno}
  556. </if>
  557. <if test="companyName !=null and companyName !=''">
  558. and a.company_id =#{companyName}
  559. </if>
  560. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  561. and a.signdate between #{signDateStart} and #{signDateEnd}
  562. </if>
  563. <if test="policyno !=null and policyno !=''">
  564. and a.policyno =#{policyno}
  565. </if>
  566. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  567. and a.handling_fees_status =#{handlingFeesStatus}
  568. </if>
  569. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  570. and a.documentary_fees_status =#{documentaryFeesStatus}
  571. </if>
  572. <if test="isNotCar !=null and isNotCar !=''">
  573. and a.is_not_car =#{isNotCar}
  574. </if>
  575. <if test="isOther !=null and isOther !=''">
  576. and a.is_not_documentary =#{isOther}
  577. </if>
  578. <if test="licenseno != null and licenseno != '' ">
  579. and a.licenseno =#{licenseno}
  580. </if>
  581. <if test="syPolicyno != null and syPolicyno != '' ">
  582. and a.sy_policyno =#{syPolicyno}
  583. </if>
  584. <if test="noPolicyno != null and noPolicyno != ''">
  585. and a.no_policyno =#{noPolicyno}
  586. </if>
  587. <if test="signdate !=null and signdate !=''">
  588. AND a.signdate =#{signdate}
  589. </if>
  590. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  591. AND a.partner_companies_id =#{partnerCompaniesId}
  592. </if>
  593. <if test="createTime !=null and createTime !=''">
  594. AND a.create_time =#{createTime}
  595. </if>
  596. <if test="settlementTime !=null and settlementTime !=''">
  597. AND a.settlement_time =#{settlementTime}
  598. </if>
  599. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  600. AND a.partner_companies_name =#{partnerCompaniesName}
  601. </if>
  602. <if test="userId !=null and userId !=''">
  603. and a.userId =#{userId}
  604. </if>
  605. <if test="companyId !=null and companyId !=''">
  606. and a.company_id =#{companyId}
  607. </if>
  608. <if test="riskcode !=null and riskcode !=''">
  609. and a.riskcode =#{riskcode}
  610. </if>
  611. <if test="year !=null and year !=''">
  612. AND YEAR(a.signdate) =#{year}
  613. </if>
  614. <if test="month !=null and month !=''">
  615. AND month(a.signdate) =#{month}
  616. </if>
  617. <if test="day !=null and day !=''">
  618. AND day(a.signdate) =#{day}
  619. </if>
  620. <if test="insuredName !=null and insuredName !=''">
  621. AND a.insured_name =#{insuredName}
  622. </if>
  623. </where>
  624. </select>
  625. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  626. select
  627. MAX( ec.name ) AS "companyName",
  628. sum( a.commission_feevalue ) AS "commissionFeevalue",
  629. sum( a.other_feevalue ) AS "otherFeevalue",
  630. SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
  631. GROUP_CONCAT(a.id) as "ids",
  632. MAX( a.partner_companies_name) as "partnerCompaniesName",
  633. MAX(pa.docking_person) as "dockingPerson",
  634. a.agreement_id AS "agreementId"
  635. from ins_ply_income a
  636. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  637. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  638. <where>
  639. 1=1
  640. <if test="agreementType !=null and agreementType!='' ">
  641. AND pa.agreement_type =#{agreementType}
  642. </if>
  643. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  644. AND a.documentary_fees_status = #{documentaryFeesStatus}
  645. </if>
  646. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  647. AND handling_fees_status = #{handlingFeesStatus}
  648. </if>
  649. <if test="year !=null and year !=''">
  650. AND YEAR(a.signdate) =#{year}
  651. </if>
  652. <if test="month !=null and month !=''">
  653. AND month(a.signdate) =#{month}
  654. </if>
  655. <if test="day !=null and day !=''">
  656. AND day(a.signdate) =#{day}
  657. </if>
  658. </where>
  659. GROUP BY a.agreement_id
  660. </select>
  661. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  662. select
  663. sum(a.commission_feevalue) as "commissionFeevalue",
  664. sum(a.invoic_amount) as "invoicAmount"
  665. from ins_ply_income a
  666. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  667. <where>
  668. 1=1
  669. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  670. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  671. </if>
  672. <if test="agreementType !=null and agreementType !=''">
  673. and pa.agreement_type =#{agreementType}
  674. </if>
  675. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  676. and a.handling_fees_status =#{handlingFeesStatus}
  677. </if>
  678. <if test="orderno !=null and orderno !=''">
  679. and a.orderno =#{orderno}
  680. </if>
  681. <if test="policyno !=null and policyno !=''">
  682. and a.policyno =#{policyno}
  683. </if>
  684. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  685. and a.documentary_fees_status =#{documentaryFeesStatus}
  686. </if>
  687. <if test="isNotCar !=null and isNotCar !=''">
  688. and a.is_not_car =#{isNotCar}
  689. </if>
  690. <if test="isOther !=null and isOther !=''">
  691. and a.is_not_documentary =#{isOther}
  692. </if>
  693. <if test="licenseno != null and licenseno != ''">
  694. and a.licenseno =#{licenseno}
  695. </if>
  696. <if test="syPolicyno != null and syPolicyno != ''">
  697. and a.sy_policyno =#{syPolicyno}
  698. </if>
  699. <if test="noPolicyno != null and noPolicyno != ''">
  700. and a.no_policyno =#{noPolicyno}
  701. </if>
  702. <if test="signdate !=null and signdate !=''">
  703. and a.signdate =#{signdate}
  704. </if>
  705. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  706. and a.partner_companies_id =#{partnerCompaniesId}
  707. </if>
  708. <if test="createTime !=null and createTime !=''">
  709. and a.create_time =#{createTime}
  710. </if>
  711. <if test="settlementTime !=null and settlementTime !=''">
  712. and a.settlement_time =#{settlementTime}
  713. </if>
  714. <if test="userId !=null and userId !=''">
  715. and a.userId =#{userId}
  716. </if>
  717. <if test="companyId !=null and companyId !=''">
  718. and a.company_id =#{companyId}
  719. </if>
  720. <if test="riskcode !=null and riskcode !=''">
  721. and a.riskcode =#{riskcode}
  722. </if>
  723. <if test="year !=null and year !=''">
  724. AND YEAR(a.signdate) =#{year}
  725. </if>
  726. <if test="month !=null and month !=''">
  727. AND month(a.signdate) =#{month}
  728. </if>
  729. <if test="day !=null and day !=''">
  730. AND day(a.signdate) =#{day}
  731. </if>
  732. </where>
  733. </select>
  734. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  735. SELECT
  736. a.partner_companies_id AS "partnerCompaniesId",
  737. MAX( a.company_name ) AS "companyName",
  738. MAX( a.company_id ) AS "companyId",
  739. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  740. IFNULL ( max(c.settleMentAmount),0.00) as "allInvoicCommissionFeevalue",
  741. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  742. IFNULL ( max(d.settleMentAmount),0.00) as "invoicCommissionFeevalue",
  743. sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  744. sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  745. sum( a.commission_feevalue ) AS "commissionFeevalue"
  746. FROM
  747. ins_ply_income a
  748. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  749. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  750. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  751. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  752. and a.handling_fees_status ='0'
  753. <if test="isNotCar !=null and isNotCar !=''">
  754. and a.is_not_car =#{isNotCar}
  755. </if>
  756. GROUP BY partner_companies_id
  757. ) c ON c.partnerCompaniesId = a.partner_companies_id
  758. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  759. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  760. WHERE ( a.settlement_status = '1')
  761. and a.handling_fees_status ='0'
  762. <if test="isNotCar !=null and isNotCar !=''">
  763. and a.is_not_car =#{isNotCar}
  764. </if>
  765. GROUP BY partner_companies_id
  766. ) d ON d.partnerCompaniesId = a.partner_companies_id
  767. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  768. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  769. WHERE a.settlement_status = '2'
  770. and a.handling_fees_status ='0'
  771. <if test="isNotCar !=null and isNotCar !=''">
  772. and a.is_not_car =#{isNotCar}
  773. </if>
  774. GROUP BY partner_companies_id
  775. ) f ON f.partnerCompaniesId = a.partner_companies_id
  776. <where>
  777. 1=1
  778. <if test="agreementType !=null and agreementType!='' ">
  779. AND pa.agreement_type =#{agreementType}
  780. </if>
  781. <if test="year !=null and year !=''">
  782. AND YEAR(a.signdate) =#{year}
  783. </if>
  784. <if test="isOther !=null and isOther !=''">
  785. and a.is_not_documentary =#{isOther}
  786. </if>
  787. <if test="isNotCar !=null and isNotCar !=''">
  788. and a.is_not_car =#{isNotCar}
  789. </if>
  790. <if test="month !=null and month !=''">
  791. AND month(a.signdate) =#{month}
  792. </if>
  793. <if test="day !=null and day !=''">
  794. AND day(a.signdate) =#{day}
  795. </if>
  796. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  797. AND a.partner_companies_name =#{partnerCompaniesName}
  798. </if>
  799. <if test="companyName !=null and companyName !=''">
  800. and a.company_id =#{companyName}
  801. </if>
  802. </where>
  803. GROUP BY a.partner_companies_id
  804. </select>
  805. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  806. select
  807. a.partner_companies_id AS "partnerCompaniesId",
  808. a.id as "id"
  809. from ins_ply_income a
  810. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  811. <where>
  812. 1=1
  813. and a.handling_fees_status ='2'
  814. <if test="agreementType !=null and agreementType!='' ">
  815. AND pa.agreement_type =#{agreementType}
  816. </if>
  817. <if test="year !=null and year !=''">
  818. AND YEAR(a.signdate) =#{year}
  819. </if>
  820. <if test="isOther !=null and isOther !=''">
  821. and a.is_not_documentary =#{isOther}
  822. </if>
  823. <if test="isNotCar !=null and isNotCar !=''">
  824. and a.is_not_car =#{isNotCar}
  825. </if>
  826. <if test="month !=null and month !=''">
  827. AND month(a.signdate) =#{month}
  828. </if>
  829. <if test="day !=null and day !=''">
  830. AND day(a.signdate) =#{day}
  831. </if>
  832. </where>
  833. </select>
  834. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  835. SELECT
  836. a.partner_companies_id AS "partnerCompaniesId",
  837. MAX( a.company_name ) AS "companyName",
  838. MAX( a.company_id ) AS "companyId",
  839. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  840. CASE
  841. WHEN (IFNULL(MAX(d.settleMentAmount), 0.00) - IFNULL(MAX(f.settleMentAmount), 0.00)) = 0.00
  842. THEN IFNULL ( MAX(d.settleMentAmount) ,0.00)
  843. ELSE (IFNULL(MAX(d.settleMentAmount), 0.00) - IFNULL(MAX(f.settleMentAmount), 0.00))
  844. END AS "allInvoicCommissionFeevalue",
  845. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  846. IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
  847. sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  848. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  849. MAX( f.expendAmount ) AS "expendAmount",
  850. MAX( f.taxPoints ) AS "taxPoints",
  851. sum( a.other_feevalue ) AS "otherFeevalue"
  852. FROM
  853. ins_ply_income a
  854. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  855. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  856. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  857. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  858. and a.handling_fees_status ='1'
  859. <if test="isNotCar !=null and isNotCar !=''">
  860. and a.is_not_car =#{isNotCar}
  861. </if>
  862. GROUP BY partner_companies_id
  863. ) c ON c.partnerCompaniesId = a.partner_companies_id
  864. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  865. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  866. WHERE ( a.settlement_status = '1')
  867. and a.handling_fees_status ='1'
  868. <if test="isNotCar !=null and isNotCar !=''">
  869. and a.is_not_car =#{isNotCar}
  870. </if>
  871. GROUP BY partner_companies_id
  872. ) d ON d.partnerCompaniesId = a.partner_companies_id
  873. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  874. settlement_amount ) AS "settleMentAmount", sum(a.expend_amount) as "expendAmount" , sum(a.tax_points) as "taxPoints" FROM settlement_documentary_fees a
  875. WHERE a.settlement_status = '2'
  876. and a.handling_fees_status ='1'
  877. <if test="isNotCar !=null and isNotCar !=''">
  878. and a.is_not_car =#{isNotCar}
  879. </if>
  880. GROUP BY partner_companies_id
  881. ) f ON f.partnerCompaniesId = a.partner_companies_id
  882. <where>
  883. 1=1
  884. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  885. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  886. </if>
  887. <if test="agreementType !=null and agreementType !=''">
  888. and pa.agreement_type =#{agreementType}
  889. </if>
  890. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  891. and a.signdate between #{signDateStart} and #{signDateEnd}
  892. </if>
  893. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  894. and a.handling_fees_status =#{handlingFeesStatus}
  895. </if>
  896. <if test="dockingPerson !=null and dockingPerson !=''">
  897. and pa.docking_person =#{dockingPerson}
  898. </if>
  899. <if test="orderno !=null and orderno !=''">
  900. and a.orderno =#{orderno}
  901. </if>
  902. <if test="companyName !=null and companyName !=''">
  903. and a.company_id =#{companyName}
  904. </if>
  905. <if test="policyno !=null and policyno !=''">
  906. and a.policyno =#{policyno}
  907. </if>
  908. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  909. and a.documentary_fees_status =#{documentaryFeesStatus}
  910. </if>
  911. <if test="isNotCar !=null and isNotCar !=''">
  912. and a.is_not_car =#{isNotCar}
  913. </if>
  914. <if test="isOther !=null and isOther !=''">
  915. and a.is_not_documentary =#{isOther}
  916. </if>
  917. <if test="licenseno != null and licenseno != ''">
  918. and a.licenseno =#{licenseno}
  919. </if>
  920. <if test="syPolicyno != null and syPolicyno != ''">
  921. and a.sy_policyno =#{syPolicyno}
  922. </if>
  923. <if test="noPolicyno != null and noPolicyno != ''">
  924. and a.no_policyno =#{noPolicyno}
  925. </if>
  926. <if test="signdate !=null and signdate !=''">
  927. AND a.signdate =#{signdate}
  928. </if>
  929. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  930. AND a.partner_companies_id =#{partnerCompaniesId}
  931. </if>
  932. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  933. AND a.partner_companies_name =#{partnerCompaniesName}
  934. </if>
  935. <if test="createTime !=null and createTime !=''">
  936. AND a.create_time =#{createTime}
  937. </if>
  938. <if test="settlementTime !=null and settlementTime !=''">
  939. AND a.settlement_time =#{settlementTime}
  940. </if>
  941. <if test="userId !=null and userId !=''">
  942. and a.userId =#{userId}
  943. </if>
  944. <if test="companyId !=null and companyId !=''">
  945. and a.company_id =#{companyId}
  946. </if>
  947. <if test="riskcode !=null and riskcode !=''">
  948. and a.riskcode =#{riskcode}
  949. </if>
  950. <if test="year !=null and year !=''">
  951. AND YEAR(a.signdate) =#{year}
  952. </if>
  953. <if test="month !=null and month !=''">
  954. AND month(a.signdate) =#{month}
  955. </if>
  956. <if test="day !=null and day !=''">
  957. AND day(a.signdate) =#{day}
  958. </if>
  959. <if test="insuredName !=null and insuredName !=''">
  960. AND a.insured_name =#{insuredName}
  961. </if>
  962. </where>
  963. GROUP BY
  964. a.partner_companies_id
  965. </select>
  966. <select id="getOtherIds" resultType="java.util.HashMap">
  967. SELECT
  968. a.id as "id",
  969. a.partner_companies_id AS "partnerCompaniesId"
  970. FROM
  971. ins_ply_income a
  972. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  973. <where>
  974. 1=1
  975. <if test="agreementType !=null and agreementType!='' ">
  976. AND pa.agreement_type =#{agreementType}
  977. </if>
  978. <if test="year !=null and year !=''">
  979. AND YEAR(a.signdate) =#{year}
  980. </if>
  981. <if test="isOther !=null and isOther !=''">
  982. and a.is_not_documentary =#{isOther}
  983. </if>
  984. <if test="isNotCar !=null and isNotCar !=''">
  985. and a.is_not_car =#{isNotCar}
  986. </if>
  987. <if test="month !=null and month !=''">
  988. AND month(a.signdate) =#{month}
  989. </if>
  990. <if test="day !=null and day !=''">
  991. AND day(a.signdate) =#{day}
  992. </if>
  993. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  994. AND a.documentary_fees_status = #{documentaryFeesStatus}
  995. </if>
  996. </where>
  997. </select>
  998. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  999. select
  1000. pa.agreement_name as "agreementName",
  1001. su.name as "userName",
  1002. <include refid="income_com"/>
  1003. from ins_ply_income a
  1004. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1005. LEFT JOIN sys_user su on su.id=a.user_id
  1006. <where>
  1007. <if test="id !=null and id !=''">
  1008. a.id=#{id}
  1009. </if>
  1010. </where>
  1011. </select>
  1012. <select id="groupByInvoic" resultType="java.util.HashMap">
  1013. select
  1014. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  1015. MAX(invoic_id) as "invoicId",
  1016. MAX(invoic_time) as "invoicTime",
  1017. GROUP_CONCAT(a.id) as "ids"
  1018. from ins_ply_income a
  1019. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1020. LEFT JOIN sys_user su on su.id=a.user_id
  1021. <where>
  1022. 1=1
  1023. AND a.invoic_id is not null
  1024. <if test="idArr !=null and idArr!=''">
  1025. a.id IN
  1026. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  1027. #{item}
  1028. </foreach>
  1029. </if>
  1030. <if test="agreementType !=null and agreementType!='' ">
  1031. AND pa.agreement_type =#{agreementType}
  1032. </if>
  1033. <if test="year !=null and year !=''">
  1034. AND YEAR(a.signdate) =#{year}
  1035. </if>
  1036. <if test="isOther !=null and isOther !=''">
  1037. and a.is_not_documentary =#{isOther}
  1038. </if>
  1039. <if test="isNotCar !=null and isNotCar !=''">
  1040. and a.is_not_car =#{isNotCar}
  1041. </if>
  1042. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1043. and a.handling_fees_status =#{handlingFeesStatus}
  1044. </if>
  1045. <if test="month !=null and month !=''">
  1046. AND month(a.signdate) =#{month}
  1047. </if>
  1048. <if test="day !=null and day !=''">
  1049. AND day(a.signdate) =#{day}
  1050. </if>
  1051. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1052. AND a.partner_companies_id =#{partnerCompaniesId}
  1053. </if>
  1054. </where>
  1055. group by a.invoic_id
  1056. </select>
  1057. <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1058. update ins_ply_income
  1059. set handling_fees_status ='1',
  1060. settlement_time =NOW()
  1061. <where>
  1062. 1=1
  1063. <if test="split != null and split != '' and split.length > 0">
  1064. and id in
  1065. <foreach collection="split" item="item" open="(" separator="," close=")">
  1066. #{item}
  1067. </foreach>
  1068. </if>
  1069. </where>
  1070. </update>
  1071. <select id="otherTimeDetail" resultType="java.util.HashMap">
  1072. WITH RECURSIVE months AS (
  1073. SELECT 1 AS month_num
  1074. UNION ALL
  1075. SELECT month_num + 1 FROM months WHERE month_num &lt; 12
  1076. )
  1077. SELECT
  1078. m.month_num AS monthNumber,
  1079. DATE_FORMAT(STR_TO_DATE(CONCAT(YEAR(CURDATE()), '-', LPAD(m.month_num, 2, '0'), '-01'), '%Y-%m-%d'), '%Y-%m') AS monthYear,
  1080. COALESCE(other_fees.total_other_feevalue, 0) AS "allTotalOtherFeevalue",
  1081. COALESCE(settlement_fees.total_settlement_amount, 0) AS "invoicCommissionFeevalue",
  1082. COALESCE(other_fees.total_other_feevalue, 0) - COALESCE(settlement_fees.total_settlement_amount, 0) AS "noInvoicCommissionFeevalue"
  1083. FROM
  1084. months m
  1085. LEFT JOIN (
  1086. SELECT
  1087. MONTH(a.signdate) AS month_num,
  1088. SUM(a.other_feevalue) AS total_other_feevalue
  1089. FROM
  1090. `ins_ply_income` a
  1091. INNER JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1092. <where>
  1093. 1=1
  1094. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1095. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1096. </if>
  1097. <if test="agreementType !=null and agreementType !=''">
  1098. and pa.agreement_type =#{agreementType}
  1099. </if>
  1100. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1101. and a.signdate between #{signDateStart} and #{signDateEnd}
  1102. </if>
  1103. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1104. and a.handling_fees_status =#{handlingFeesStatus}
  1105. </if>
  1106. <if test="dockingPerson !=null and dockingPerson !=''">
  1107. and pa.docking_person =#{dockingPerson}
  1108. </if>
  1109. <if test="orderno !=null and orderno !=''">
  1110. and a.orderno =#{orderno}
  1111. </if>
  1112. <if test="companyName !=null and companyName !=''">
  1113. and a.company_id =#{companyName}
  1114. </if>
  1115. <if test="policyno !=null and policyno !=''">
  1116. and a.policyno =#{policyno}
  1117. </if>
  1118. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1119. and a.documentary_fees_status =#{documentaryFeesStatus}
  1120. </if>
  1121. <if test="isNotCar !=null and isNotCar !=''">
  1122. and a.is_not_car =#{isNotCar}
  1123. </if>
  1124. <if test="isOther !=null and isOther !=''">
  1125. and a.is_not_documentary =#{isOther}
  1126. </if>
  1127. <if test="licenseno != null and licenseno != ''">
  1128. and a.licenseno =#{licenseno}
  1129. </if>
  1130. <if test="syPolicyno != null and syPolicyno != ''">
  1131. and a.sy_policyno =#{syPolicyno}
  1132. </if>
  1133. <if test="noPolicyno != null and noPolicyno != ''">
  1134. and a.no_policyno =#{noPolicyno}
  1135. </if>
  1136. <if test="signdate !=null and signdate !=''">
  1137. AND a.signdate =#{signdate}
  1138. </if>
  1139. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1140. AND a.partner_companies_id =#{partnerCompaniesId}
  1141. </if>
  1142. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1143. AND a.partner_companies_name =#{partnerCompaniesName}
  1144. </if>
  1145. <if test="createTime !=null and createTime !=''">
  1146. AND a.create_time =#{createTime}
  1147. </if>
  1148. <if test="settlementTime !=null and settlementTime !=''">
  1149. AND a.settlement_time =#{settlementTime}
  1150. </if>
  1151. <if test="userId !=null and userId !=''">
  1152. and a.userId =#{userId}
  1153. </if>
  1154. <if test="companyId !=null and companyId !=''">
  1155. and a.company_id =#{companyId}
  1156. </if>
  1157. <if test="riskcode !=null and riskcode !=''">
  1158. and a.riskcode =#{riskcode}
  1159. </if>
  1160. <if test="year !=null and year !=''">
  1161. AND YEAR(a.signdate) =#{year}
  1162. </if>
  1163. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1164. and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1165. </if>
  1166. <if test="month !=null and month !=''">
  1167. AND month(a.signdate) =#{month}
  1168. </if>
  1169. <if test="day !=null and day !=''">
  1170. AND day(a.signdate) =#{day}
  1171. </if>
  1172. <if test="insuredName !=null and insuredName !=''">
  1173. AND a.insured_name =#{insuredName}
  1174. </if>
  1175. AND YEAR(a.signdate) = YEAR(CURDATE())
  1176. </where>
  1177. GROUP BY
  1178. MONTH(a.signdate)
  1179. ) other_fees ON m.month_num = other_fees.month_num
  1180. LEFT JOIN (
  1181. SELECT
  1182. MONTH(signing_time) AS month_num,
  1183. SUM(settlement_amount) AS total_settlement_amount
  1184. FROM
  1185. settlement_documentary_fees
  1186. WHERE
  1187. settlement_status = '1'
  1188. AND handling_fees_status = '1'
  1189. <if test="isNotCar !=null and isNotCar !=''">
  1190. and is_not_car =#{isNotCar}
  1191. </if>
  1192. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1193. and DATE_FORMAT( signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1194. </if>
  1195. GROUP BY
  1196. MONTH(signing_time)
  1197. ) settlement_fees ON m.month_num = settlement_fees.month_num
  1198. ORDER BY
  1199. m.month_num;
  1200. </select>
  1201. </mapper>