InsPlyIncomeMapper.xml 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326
  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="jq_other_costs_premium" property="jqOtherCostsPremium"/>
  61. <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
  62. <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
  63. <result column="user_id" property="userId"/>
  64. <result column="update_user_id" property="updateUserId"/>
  65. <result column="partner_companies_id" property="partnerCompaniesId"/>
  66. <result column="partner_companies_name" property="partnerCompaniesName"/>
  67. <result column="receivable_amount" property="receivableAmount"/>
  68. <result column="insured_name" property="insuredName"/>
  69. <result column="invoicing_method" property="invoicingMethod"/>
  70. <result column="remarks" property="remarks"/>
  71. <result column="jq_start_date" property="jqStartDate"/>
  72. <result column="jq_end_date" property="jqEndDate"/>
  73. <result column="sy_start_date" property="syStartDate"/>
  74. <result column="sy_end_date" property="syEndDate"/>
  75. <result column="settle_other_status" property="settleOtherStatus"/>
  76. <result column="settlement_image_id" property="settlementImageId"/>
  77. <result column="task_id" property="taskId"/>
  78. </resultMap>
  79. <sql id="income_com">
  80. a.id as "id",
  81. a.orderno as "orderno",
  82. a.policyno as "policyno",
  83. a.dept_id as "deptId",
  84. a.riskcode as "riskcode",
  85. a.pay_date as "payDate",
  86. a.signdate as "signdate",
  87. a.company_id as "companyId",
  88. a.agreement_id as "agreementId",
  89. a.licenseno as "licenseno",
  90. a.taxamount as "taxamount",
  91. a.no_tax_premium as "noTaxPremium",
  92. a.commission_feerate as "commissionFeerate",
  93. a.other_feerate as "otherFeerate",
  94. a.commission_feevalue as "commissionFeevalue",
  95. a.other_feevalue as "otherFeevalue",
  96. a.all_fee_value as "allFeeValue",
  97. a.final_fee_value as "finalFeeValue",
  98. a.doing_fee_value as "doingFeeValue",
  99. a.voucher_number as "voucherNumber",
  100. a.contract_id as "contractId",
  101. a.contract_file_id as "contractFileId",
  102. a.handling_fees_status as "handlingFeesStatus",
  103. a.no_policyno as "noPolicyno",
  104. a.sy_policyno as "syPolicyno",
  105. a.documentary_fees_status as "documentaryFeesStatus",
  106. a.is_not_car as "isNotCar",
  107. a.is_not_documentary as "isNotDocumentary",
  108. a.invoic_amount as "invoicAmount",
  109. a.invoic_id as "invoicId",
  110. a.tax_premium as "taxPremium",
  111. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  112. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  113. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  114. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  115. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  116. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  117. a.partner_companies_id as "partnerCompaniesId",
  118. a.jq_premium as "jqPremium",
  119. a.sy_premium as "syPremium",
  120. a.no_premium as "noPremium",
  121. a.jq_no_tax_premium as "jqNoTaxPremium",
  122. a.sy_no_tax_premium as "syNoTaxPremium",
  123. a.no_no_tax_premium as "noNoTaxPremium",
  124. a.jq_receivable_proportion as "jqReceivableProportion",
  125. a.sy_receivable_proportion as "syReceivableProportion",
  126. a.no_receivable_proportion as "noReceivableProportion",
  127. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  128. a.sy_other_costs_proportion as "syOtherCostsProportion",
  129. a.no_other_costs_proportion as "noOtherCostsProportion",
  130. a.settlement_time as "settlementTime",
  131. a.update_time as "updateTime",
  132. a.settlement_user_id as "settlementUserId",
  133. a.update_user_id as "updateUserId",
  134. a.jq_other_costs_premium as "jqOtherCostsPremium",
  135. a.sy_other_costs_premium as "syOtherCostsPremium",
  136. a.no_other_costs_premium as "noOtherCostsPremium",
  137. a.partner_companies_name as "partnerCompaniesName",
  138. a.company_name as "companyName",
  139. a.receivable_amount as "receivableAmount",
  140. a.invoic_time as "invoicTime",
  141. a.insured_name as "insuredName",
  142. a.remarks as "remarks",
  143. a.jq_start_date as "jqStartDate",
  144. a.jq_end_date as "jqEndDate",
  145. a.sy_start_date as "syStartDate",
  146. a.sy_end_date as "syEndDate",
  147. a.settle_other_status as "settleOtherStatus",
  148. a.user_id as "userId",
  149. a.invoicing_method as "invoicingMethod",
  150. a.settlement_image_id as "settlementImageId",
  151. a.task_id as "taskId",
  152. a.create_time as "createTime"
  153. </sql>
  154. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  155. select
  156. su1.name as "settlementUserName",
  157. su2.name as "updateUserName",
  158. pa.agreement_name as "agreementName",
  159. pa.agreement_type as "agreementType",
  160. pa.docking_person as "dockingPerson",
  161. pa.is_external as "isExternal",
  162. upf.url as "imageUrl",
  163. su.name as "userName",
  164. b.name as "deptName",
  165. <include refid="income_com"/>
  166. from ins_ply_income a
  167. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  168. LEFT JOIN sys_user su on su.id=a.user_id
  169. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  170. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  171. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  172. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  173. LEFT JOIN sys_dept b on pa.dept_id=b.id
  174. <where>
  175. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  176. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  177. </if>
  178. <if test="agreementType !=null and agreementType !=''">
  179. and pa.agreement_type =#{agreementType}
  180. </if>
  181. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  182. and a.signdate between #{signDateStart} and #{signDateEnd}
  183. </if>
  184. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  185. and a.handling_fees_status =#{handlingFeesStatus}
  186. </if>
  187. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  188. and a.jq_receivable_proportion =#{jqReceivableProportion}
  189. </if>
  190. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  191. and a.sy_receivable_proportion =#{syReceivableProportion}
  192. </if>
  193. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  194. and a.no_receivable_proportion =#{noReceivableProportion}
  195. </if>
  196. <if test="id !=null and id !=''">
  197. and a.id =#{id}
  198. </if>
  199. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  200. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  201. </if>
  202. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  203. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  204. </if>
  205. <if test="dockingPerson !=null and dockingPerson !=''">
  206. and pa.docking_person =#{dockingPerson}
  207. </if>
  208. <if test="provinceId != null and provinceId != ''">
  209. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  210. </if>
  211. <if test="cityId != null and cityId != ''">
  212. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  213. </if>
  214. <if test="createTimeQuery != null and createTimeQuery != ''">
  215. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  216. </if>
  217. <if test="countyId != null and countyId != ''">
  218. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  219. </if>
  220. <if test="taskId != null and taskId != ''">
  221. and a.task_id = #{taskId}
  222. </if>
  223. <if test="orderno !=null and orderno !=''">
  224. and a.orderno =#{orderno}
  225. </if>
  226. <if test="companyName !=null and companyName !=''">
  227. and a.company_id =#{companyName}
  228. </if>
  229. <if test="policyno !=null and policyno !=''">
  230. and a.policyno =#{policyno}
  231. </if>
  232. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  233. and a.documentary_fees_status =#{documentaryFeesStatus}
  234. </if>
  235. <if test="isNotCar !=null and isNotCar !=''">
  236. and a.is_not_car =#{isNotCar}
  237. </if>
  238. <if test="deptId !=null and deptId !=''">
  239. and pa.dept_id =#{deptId}
  240. </if>
  241. <if test="ids != null and ids != '' and ids.length > 0">
  242. and a.id in
  243. <foreach collection="ids" item="item" open="(" separator="," close=")">
  244. #{item}
  245. </foreach>
  246. </if>
  247. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  248. and a.id in
  249. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  250. #{item}
  251. </foreach>
  252. </if>
  253. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  254. and a.id in
  255. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  256. #{item}
  257. </foreach>
  258. </if>
  259. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  260. and a.partner_companies_id in
  261. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  262. #{item}
  263. </foreach>
  264. </if>
  265. <if test="isOther !=null and isOther !=''">
  266. and a.is_not_documentary =#{isOther}
  267. </if>
  268. <if test="licenseno != null and licenseno != ''">
  269. and a.licenseno =#{licenseno}
  270. </if>
  271. <if test="syPolicyno != null and syPolicyno != ''">
  272. and a.sy_policyno =#{syPolicyno}
  273. </if>
  274. <if test="noPolicyno != null and noPolicyno != ''">
  275. and a.no_policyno =#{noPolicyno}
  276. </if>
  277. <if test="signdate !=null and signdate !=''">
  278. AND a.signdate =#{signdate}
  279. </if>
  280. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  281. AND a.partner_companies_id =#{partnerCompaniesId}
  282. </if>
  283. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  284. AND a.partner_companies_name =#{partnerCompaniesName}
  285. </if>
  286. <if test="createTime !=null and createTime !=''">
  287. AND a.create_time =#{createTime}
  288. </if>
  289. <if test="settlementTime !=null and settlementTime !=''">
  290. AND a.settlement_time =#{settlementTime}
  291. </if>
  292. <if test="settlementDate !=null and settlementDate !=''">
  293. AND a.settlement_time =#{settlementDate}
  294. </if>
  295. <if test="userId !=null and userId !=''">
  296. and a.userId =#{userId}
  297. </if>
  298. <if test="companyId !=null and companyId !=''">
  299. and a.company_id =#{companyId}
  300. </if>
  301. <if test="riskcode !=null and riskcode !=''">
  302. and a.riskcode =#{riskcode}
  303. </if>
  304. <if test="year !=null and year !=''">
  305. AND YEAR(a.signdate) =#{year}
  306. </if>
  307. <if test="month !=null and month !=''">
  308. AND month(a.signdate) =#{month}
  309. </if>
  310. <if test="day !=null and day !=''">
  311. AND day(a.signdate) =#{day}
  312. </if>
  313. <if test="insuredName !=null and insuredName !=''">
  314. AND a.insured_name =#{insuredName}
  315. </if>
  316. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  317. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  318. </if>
  319. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  320. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  321. </if>
  322. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  323. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  324. </if>
  325. </where>
  326. ORDER BY a.create_time desc
  327. </select>
  328. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  329. select
  330. pa.agreement_name as "agreementName",
  331. pa.agreement_type as "agreementType",
  332. su.name as "userName",
  333. <include refid="income_com"/>
  334. from ins_ply_income a
  335. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  336. LEFT JOIN sys_user su on su.id=a.user_id
  337. <where>
  338. <if test="id!=null and id!=''">
  339. a.id=#{id}
  340. </if>
  341. </where>
  342. </select>
  343. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  344. select
  345. count(MONTH(a.signdate)) as "totalorders",
  346. MONTH(a.signdate) as "monthSigdate",
  347. sum(a.other_feevalue) as "allLOtherFeevalue",
  348. GROUP_CONCAT(a.id) as "ids"
  349. from ins_ply_income a
  350. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  351. <where>
  352. <if test="isNotCar !=null and isNotCar !=''" >
  353. a.is_not_car =#{isNotCar}
  354. </if>
  355. <if test="isOther !=null and isOther !=''">
  356. and a.is_not_documentary =#{isOther}
  357. </if>
  358. <if test="agreementType !=null and agreementType !=''">
  359. and pa.agreement_type =#{agreementType}
  360. </if>
  361. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  362. and a.documentary_fees_status =#{documentaryFeesStatus}
  363. </if>
  364. <if test="companyId !=null and companyId !=''">
  365. and a.company_id =#{companyId}
  366. </if>
  367. <if test="year !=null and year !=''">
  368. and YEAR(a.signdate) =#{year}
  369. </if>
  370. group by MONTH(a.signdate)
  371. </where>
  372. </select>
  373. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  374. update ins_ply_income
  375. <set>
  376. <if test="contractId != null">
  377. contract_id = #{contractId},
  378. </if>
  379. <if test="voucherNumber != null">
  380. voucher_number = #{voucherNumber},
  381. </if>
  382. <if test="contractFileId != null">
  383. contract_file_id = #{contractFileId},
  384. </if>
  385. <if test="handlingFeesStatus != null">
  386. handling_fees_status = #{handlingFeesStatus}
  387. </if>
  388. <if test="documentaryFeesStatus != null">
  389. documentary_fees_status = #{documentaryFeesStatus}
  390. </if>
  391. </set>
  392. where orderno =#{orderno}
  393. </update>
  394. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  395. SELECT
  396. a.companyId as "companyId",
  397. a.totalorders as "totalorders",
  398. a.ids as "ids",
  399. a.allLOtherFeevalue as "allLOtherFeevalue"
  400. FROM
  401. (
  402. SELECT
  403. a.company_id AS "companyId",
  404. count(a.orderno) as "totalorders",
  405. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  406. GROUP_CONCAT(a.id) as "ids"
  407. FROM
  408. ins_ply_income a
  409. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  410. WHERE
  411. pa.agreement_type = '2'
  412. <if test="isNotCar !=null and isNotCar !=''" >
  413. and a.is_not_car =#{isNotCar}
  414. </if>
  415. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  416. AND a.documentary_fees_status = #{documentaryFeesStatus}
  417. </if>
  418. <if test="isOther !=null and isOther !=''">
  419. and a.is_not_documentary =#{isOther}
  420. </if>
  421. <if test="companyId !=null and companyId !=''">
  422. and a.company_id =#{companyId}
  423. </if>
  424. <if test="year !=null and year !=''">
  425. and YEAR(a.signdate) =#{year}
  426. </if>
  427. <if test="month !=null and month !=''">
  428. and month(a.signdate) =#{month}
  429. </if>
  430. GROUP BY
  431. a.company_id
  432. ) a
  433. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  434. </select>
  435. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  436. select
  437. <include refid="income_com"/>
  438. from ins_ply_income a
  439. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  440. LEFT JOIN sys_user su on su.id=a.user_id
  441. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  442. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  443. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  444. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  445. LEFT JOIN sys_dept b on pa.dept_id=b.id
  446. <where>
  447. 1=1
  448. <if test="licenseno !=null and licenseno !=''">
  449. AND a.licenseno=#{licenseno}
  450. </if>
  451. <if test="policyno !=null and policyno !=''">
  452. AND a.policyno=#{policyno}
  453. </if>
  454. <if test="syPolicyno !=null and syPolicyno !=''">
  455. AND a.sy_policyno=#{syPolicyno}
  456. </if>
  457. <if test="noPolicyno !=null and noPolicyno !=''">
  458. AND a.no_policyno=#{noPolicyno}
  459. </if>
  460. <if test="isOther !=null and isOther !=''">
  461. and a.is_not_documentary =#{isOther}
  462. </if>
  463. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  464. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  465. </if>
  466. <if test="agreementType !=null and agreementType !=''">
  467. and pa.agreement_type =#{agreementType}
  468. </if>
  469. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  470. and a.signdate between #{signDateStart} and #{signDateEnd}
  471. </if>
  472. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  473. and a.handling_fees_status =#{handlingFeesStatus}
  474. </if>
  475. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  476. and a.jq_receivable_proportion =#{jqReceivableProportion}
  477. </if>
  478. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  479. and a.sy_receivable_proportion =#{syReceivableProportion}
  480. </if>
  481. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  482. and a.no_receivable_proportion =#{noReceivableProportion}
  483. </if>
  484. <if test="id !=null and id !=''">
  485. and a.id =#{id}
  486. </if>
  487. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  488. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  489. </if>
  490. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  491. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  492. </if>
  493. <if test="dockingPerson !=null and dockingPerson !=''">
  494. and pa.docking_person =#{dockingPerson}
  495. </if>
  496. <if test="provinceId != null and provinceId != ''">
  497. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  498. </if>
  499. <if test="cityId != null and cityId != ''">
  500. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  501. </if>
  502. <if test="createTimeQuery != null and createTimeQuery != ''">
  503. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  504. </if>
  505. <if test="countyId != null and countyId != ''">
  506. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  507. </if>
  508. <if test="taskId != null and taskId != ''">
  509. and a.task_id = #{taskId}
  510. </if>
  511. <if test="orderno !=null and orderno !=''">
  512. and a.orderno =#{orderno}
  513. </if>
  514. <if test="companyName !=null and companyName !=''">
  515. and a.company_id =#{companyName}
  516. </if>
  517. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  518. and a.documentary_fees_status =#{documentaryFeesStatus}
  519. </if>
  520. <if test="isNotCar !=null and isNotCar !=''">
  521. and a.is_not_car =#{isNotCar}
  522. </if>
  523. <if test="deptId !=null and deptId !=''">
  524. and pa.dept_id =#{deptId}
  525. </if>
  526. <if test="ids != null and ids != '' and ids.length > 0">
  527. and a.id in
  528. <foreach collection="ids" item="item" open="(" separator="," close=")">
  529. #{item}
  530. </foreach>
  531. </if>
  532. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  533. and a.id in
  534. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  535. #{item}
  536. </foreach>
  537. </if>
  538. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  539. and a.id in
  540. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  541. #{item}
  542. </foreach>
  543. </if>
  544. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  545. and a.partner_companies_id in
  546. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  547. #{item}
  548. </foreach>
  549. </if>
  550. <if test="signdate !=null and signdate !=''">
  551. AND a.signdate =#{signdate}
  552. </if>
  553. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  554. AND a.partner_companies_id =#{partnerCompaniesId}
  555. </if>
  556. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  557. AND a.partner_companies_name =#{partnerCompaniesName}
  558. </if>
  559. <if test="createTime !=null and createTime !=''">
  560. AND a.create_time =#{createTime}
  561. </if>
  562. <if test="settlementTime !=null and settlementTime !=''">
  563. AND a.settlement_time =#{settlementTime}
  564. </if>
  565. <if test="settlementDate !=null and settlementDate !=''">
  566. AND a.settlement_time =#{settlementDate}
  567. </if>
  568. <if test="userId !=null and userId !=''">
  569. and a.userId =#{userId}
  570. </if>
  571. <if test="companyId !=null and companyId !=''">
  572. and a.company_id =#{companyId}
  573. </if>
  574. <if test="riskcode !=null and riskcode !=''">
  575. and a.riskcode =#{riskcode}
  576. </if>
  577. <if test="year !=null and year !=''">
  578. AND YEAR(a.signdate) =#{year}
  579. </if>
  580. <if test="month !=null and month !=''">
  581. AND month(a.signdate) =#{month}
  582. </if>
  583. <if test="day !=null and day !=''">
  584. AND day(a.signdate) =#{day}
  585. </if>
  586. <if test="insuredName !=null and insuredName !=''">
  587. AND a.insured_name =#{insuredName}
  588. </if>
  589. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  590. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  591. </if>
  592. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  593. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  594. </if>
  595. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  596. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  597. </if>
  598. </where>
  599. </select>
  600. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  601. select
  602. <include refid="income_com"/>
  603. from ins_ply_income a
  604. <where>
  605. 1=1
  606. <if test="licenseno !=null and licenseno !=''">
  607. AND a.licenseno=#{licenseno}
  608. </if>
  609. <if test="policyno !=null and policyno !=''">
  610. AND a.policyno=#{policyno}
  611. </if>
  612. <if test="syPolicyno !=null and syPolicyno !=''">
  613. AND a.sy_policyno=#{syPolicyno}
  614. </if>
  615. <if test="noPolicyno !=null and noPolicyno !=''">
  616. AND a.no_policyno=#{noPolicyno}
  617. </if>
  618. <if test="isOther !=null and isOther !=''">
  619. and a.is_not_documentary =#{isOther}
  620. </if>
  621. <if test="isNotCar !=null and isNotCar !=''">
  622. and a.is_not_car =#{isNotCar}
  623. </if>
  624. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  625. and a.handling_fees_status =#{handlingFeesStatus}
  626. </if>
  627. <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
  628. and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
  629. </if>
  630. <if test="createTimeQuery != null and createTimeQuery != ''">
  631. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  632. </if>
  633. <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
  634. and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
  635. </if>
  636. <if test="jqOtherCostsProportion !=null and jqOtherCostsProportion !=''">
  637. and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
  638. </if>
  639. <if test="syOtherCostsProportion !=null and syOtherCostsProportion !=''">
  640. and a.sy_other_costs_proportion =#{syOtherCostsProportion}
  641. </if>
  642. <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
  643. and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
  644. </if>
  645. <if test="noOtherCostsProportion !=null and noOtherCostsProportion !=''">
  646. and a.no_other_costs_proportion =#{noOtherCostsProportion}
  647. </if>
  648. <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
  649. and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
  650. </if>
  651. <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
  652. and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
  653. </if>
  654. <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
  655. and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
  656. </if>
  657. <if test="jqPremium !=null and jqPremium !=''">
  658. and a.jq_premium =#{jqPremium}
  659. </if>
  660. <if test="syPremium !=null and syPremium !=''">
  661. and a.sy_premium =#{jqPremium}
  662. </if>
  663. <if test="noPremium !=null and noPremium !=''">
  664. and a.no_premium =#{noPremium}
  665. </if>
  666. </where>
  667. limit 1
  668. </select>
  669. <select id="totalAmount" resultType="java.util.HashMap">
  670. select
  671. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  672. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  673. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  674. from ins_ply_income a
  675. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  676. <where>
  677. 1=1
  678. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  679. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  680. </if>
  681. <if test="agreementType !=null and agreementType !=''">
  682. and pa.agreement_type =#{agreementType}
  683. </if>
  684. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  685. and a.signdate between #{signDateStart} and #{signDateEnd}
  686. </if>
  687. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  688. and a.handling_fees_status =#{handlingFeesStatus}
  689. </if>
  690. <if test="orderno !=null and orderno !=''">
  691. and a.orderno =#{orderno}
  692. </if>
  693. <if test="policyno !=null and policyno !=''">
  694. and a.policyno =#{policyno}
  695. </if>
  696. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  697. and a.documentary_fees_status =#{documentaryFeesStatus}
  698. </if>
  699. <if test="createTimeQuery != null and createTimeQuery != ''">
  700. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  701. </if>
  702. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  703. and a.id in
  704. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  705. #{item}
  706. </foreach>
  707. </if>
  708. <if test="isNotCar !=null and isNotCar !=''">
  709. and a.is_not_car =#{isNotCar}
  710. </if>
  711. <if test="isOther !=null and isOther !=''">
  712. and a.is_not_documentary =#{isOther}
  713. </if>
  714. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  715. and a.licenseno in
  716. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  717. #{item}
  718. </foreach>
  719. </if>
  720. <if test="policyno != null and policyno != '' ">
  721. and a.policyno =#{policyno}
  722. </if>
  723. <if test="syPolicyno != null and syPolicyno != '' ">
  724. and a.sy_policyno =#{syPolicyno}
  725. </if>
  726. <if test="noPolicyno != null and noPolicyno != ''">
  727. and a.no_policyno =#{noPolicyno}
  728. </if>
  729. <if test="signdate !=null and signdate !=''">
  730. and a.signdate =#{signdate}
  731. </if>
  732. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  733. and a.partner_companies_id =#{partnerCompaniesId}
  734. </if>
  735. <if test="createTime !=null and createTime !=''">
  736. a.create_time =#{createTime}
  737. </if>
  738. <if test="settlementTime !=null and settlementTime !=''">
  739. a.settlement_time =#{settlementTime}
  740. </if>
  741. <if test="userId !=null and userId !=''">
  742. and a.userId =#{userId}
  743. </if>
  744. <if test="companyId !=null and companyId !=''">
  745. and a.company_id =#{companyId}
  746. </if>
  747. <if test="riskcode !=null and riskcode !=''">
  748. and a.riskcode =#{riskcode}
  749. </if>
  750. <if test="year !=null and year !=''">
  751. AND YEAR(a.signdate) =#{year}
  752. </if>
  753. <if test="month !=null and month !=''">
  754. AND month(a.signdate) =#{month}
  755. </if>
  756. <if test="day !=null and day !=''">
  757. AND day(a.signdate) =#{day}
  758. </if>
  759. </where>
  760. </select>
  761. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  762. SELECT
  763. SUM(a.commission_feevalue) AS commissionFeevalue,
  764. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  765. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  766. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  767. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  768. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  769. FROM
  770. ins_ply_income a
  771. LEFT JOIN
  772. ptl_agreement pa ON pa.id = a.agreement_id
  773. <where>
  774. 1=1
  775. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  776. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  777. </if>
  778. <if test="agreementType !=null and agreementType !=''">
  779. and pa.agreement_type =#{agreementType}
  780. </if>
  781. <if test="orderno !=null and orderno !=''">
  782. and a.orderno =#{orderno}
  783. </if>
  784. <if test="companyName !=null and companyName !=''">
  785. and a.company_id =#{companyName}
  786. </if>
  787. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  788. and a.signdate between #{signDateStart} and #{signDateEnd}
  789. </if>
  790. <if test="policyno !=null and policyno !=''">
  791. and a.policyno =#{policyno}
  792. </if>
  793. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  794. and a.handling_fees_status =#{handlingFeesStatus}
  795. </if>
  796. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  797. and a.documentary_fees_status =#{documentaryFeesStatus}
  798. </if>
  799. <if test="createTimeQuery != null and createTimeQuery != ''">
  800. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  801. </if>
  802. <if test="isNotCar !=null and isNotCar !=''">
  803. and a.is_not_car =#{isNotCar}
  804. </if>
  805. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  806. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  807. </if>
  808. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  809. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  810. </if>
  811. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  812. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  813. </if>
  814. <if test="isOther !=null and isOther !=''">
  815. and a.is_not_documentary =#{isOther}
  816. </if>
  817. <if test="licenseno != null and licenseno != '' ">
  818. and a.licenseno =#{licenseno}
  819. </if>
  820. <if test="deptId !=null and deptId !=''">
  821. and pa.dept_id =#{deptId}
  822. </if>
  823. <if test="ids != null and ids != '' and ids.length > 0">
  824. and a.id in
  825. <foreach collection="ids" item="item" open="(" separator="," close=")">
  826. #{item}
  827. </foreach>
  828. </if>
  829. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  830. and a.id in
  831. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  832. #{item}
  833. </foreach>
  834. </if>
  835. <if test="syPolicyno != null and syPolicyno != '' ">
  836. and a.sy_policyno =#{syPolicyno}
  837. </if>
  838. <if test="noPolicyno != null and noPolicyno != ''">
  839. and a.no_policyno =#{noPolicyno}
  840. </if>
  841. <if test="signdate !=null and signdate !=''">
  842. AND a.signdate =#{signdate}
  843. </if>
  844. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  845. AND a.partner_companies_id =#{partnerCompaniesId}
  846. </if>
  847. <if test="createTime !=null and createTime !=''">
  848. AND a.create_time =#{createTime}
  849. </if>
  850. <if test="settlementTime !=null and settlementTime !=''">
  851. AND a.settlement_time =#{settlementTime}
  852. </if>
  853. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  854. AND a.partner_companies_name =#{partnerCompaniesName}
  855. </if>
  856. <if test="userId !=null and userId !=''">
  857. and a.userId =#{userId}
  858. </if>
  859. <if test="companyId !=null and companyId !=''">
  860. and a.company_id =#{companyId}
  861. </if>
  862. <if test="riskcode !=null and riskcode !=''">
  863. and a.riskcode =#{riskcode}
  864. </if>
  865. <if test="year !=null and year !=''">
  866. AND YEAR(a.signdate) =#{year}
  867. </if>
  868. <if test="month !=null and month !=''">
  869. AND month(a.signdate) =#{month}
  870. </if>
  871. <if test="day !=null and day !=''">
  872. AND day(a.signdate) =#{day}
  873. </if>
  874. <if test="insuredName !=null and insuredName !=''">
  875. AND a.insured_name =#{insuredName}
  876. </if>
  877. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  878. and a.partner_companies_id in
  879. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  880. #{item}
  881. </foreach>
  882. </if>
  883. </where>
  884. </select>
  885. <select id="ptTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  886. SELECT
  887. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
  888. SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  889. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
  890. FROM
  891. ins_ply_income a
  892. LEFT JOIN
  893. ptl_agreement pa ON pa.id = a.agreement_id
  894. <where>
  895. 1=1
  896. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  897. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  898. </if>
  899. <if test="agreementType !=null and agreementType !=''">
  900. and pa.agreement_type =#{agreementType}
  901. </if>
  902. <if test="orderno !=null and orderno !=''">
  903. and a.orderno =#{orderno}
  904. </if>
  905. <if test="companyName !=null and companyName !=''">
  906. and a.company_id =#{companyName}
  907. </if>
  908. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  909. and a.signdate between #{signDateStart} and #{signDateEnd}
  910. </if>
  911. <if test="policyno !=null and policyno !=''">
  912. and a.policyno =#{policyno}
  913. </if>
  914. <if test="dockingPerson !=null and dockingPerson !=''">
  915. and pa.docking_person =#{dockingPerson}
  916. </if>
  917. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  918. and a.handling_fees_status =#{handlingFeesStatus}
  919. </if>
  920. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  921. and a.documentary_fees_status =#{documentaryFeesStatus}
  922. </if>
  923. <if test="createTimeQuery != null and createTimeQuery != ''">
  924. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  925. </if>
  926. <if test="isNotCar !=null and isNotCar !=''">
  927. and a.is_not_car =#{isNotCar}
  928. </if>
  929. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  930. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  931. </if>
  932. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  933. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  934. </if>
  935. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  936. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  937. </if>
  938. <if test="isOther !=null and isOther !=''">
  939. and a.is_not_documentary =#{isOther}
  940. </if>
  941. <if test="licenseno != null and licenseno != '' ">
  942. and a.licenseno =#{licenseno}
  943. </if>
  944. <if test="deptId !=null and deptId !=''">
  945. and pa.dept_id =#{deptId}
  946. </if>
  947. <if test="ids != null and ids != '' and ids.length > 0">
  948. and a.id in
  949. <foreach collection="ids" item="item" open="(" separator="," close=")">
  950. #{item}
  951. </foreach>
  952. </if>
  953. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  954. and a.id in
  955. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  956. #{item}
  957. </foreach>
  958. </if>
  959. <if test="syPolicyno != null and syPolicyno != '' ">
  960. and a.sy_policyno =#{syPolicyno}
  961. </if>
  962. <if test="noPolicyno != null and noPolicyno != ''">
  963. and a.no_policyno =#{noPolicyno}
  964. </if>
  965. <if test="signdate !=null and signdate !=''">
  966. AND a.signdate =#{signdate}
  967. </if>
  968. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  969. AND a.partner_companies_id =#{partnerCompaniesId}
  970. </if>
  971. <if test="createTime !=null and createTime !=''">
  972. AND a.create_time =#{createTime}
  973. </if>
  974. <if test="settlementTime !=null and settlementTime !=''">
  975. AND a.settlement_time =#{settlementTime}
  976. </if>
  977. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  978. AND a.partner_companies_name =#{partnerCompaniesName}
  979. </if>
  980. <if test="userId !=null and userId !=''">
  981. and a.userId =#{userId}
  982. </if>
  983. <if test="companyId !=null and companyId !=''">
  984. and a.company_id =#{companyId}
  985. </if>
  986. <if test="riskcode !=null and riskcode !=''">
  987. and a.riskcode =#{riskcode}
  988. </if>
  989. <if test="year !=null and year !=''">
  990. AND YEAR(a.signdate) =#{year}
  991. </if>
  992. <if test="month !=null and month !=''">
  993. AND month(a.signdate) =#{month}
  994. </if>
  995. <if test="day !=null and day !=''">
  996. AND day(a.signdate) =#{day}
  997. </if>
  998. <if test="insuredName !=null and insuredName !=''">
  999. AND a.insured_name =#{insuredName}
  1000. </if>
  1001. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1002. and a.partner_companies_id in
  1003. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1004. #{item}
  1005. </foreach>
  1006. </if>
  1007. </where>
  1008. </select>
  1009. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1010. select
  1011. a.partner_companies_id as "partnerCompaniesId",
  1012. MAX( ec.name ) AS "companyName",
  1013. sum( a.commission_feevalue ) AS "commissionFeevalue",
  1014. sum( a.other_feevalue ) AS "otherFeevalue",
  1015. SUM( IFNULL(a.commission_feevalue,0) + IFNULL (a.other_feevalue,0) ) AS "totalFeevalue",
  1016. GROUP_CONCAT(a.id) as "ids",
  1017. MAX( a.partner_companies_name) as "partnerCompaniesName",
  1018. MAX(pa.docking_person) as "dockingPerson"
  1019. from ins_ply_income a
  1020. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  1021. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1022. <where>
  1023. 1=1
  1024. <if test="agreementType !=null and agreementType!='' ">
  1025. AND pa.agreement_type =#{agreementType}
  1026. </if>
  1027. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1028. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1029. </if>
  1030. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  1031. AND a.handling_fees_status = #{handlingFeesStatus}
  1032. </if>
  1033. <if test="year !=null and year !=''">
  1034. AND YEAR(a.signdate) =#{year}
  1035. </if>
  1036. <if test="companyName !=null and companyName !=''">
  1037. and a.company_id =#{companyName}
  1038. </if>
  1039. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1040. AND a.partner_companies_name =#{partnerCompaniesName}
  1041. </if>
  1042. <if test="dockingPerson !=null and dockingPerson !=''">
  1043. and pa.docking_person =#{dockingPerson}
  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. </where>
  1052. GROUP BY a.partner_companies_id
  1053. </select>
  1054. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1055. select
  1056. sum(a.commission_feevalue) as "commissionFeevalue",
  1057. sum(a.invoic_amount) as "invoicAmount"
  1058. from ins_ply_income a
  1059. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1060. <where>
  1061. 1=1
  1062. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1063. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1064. </if>
  1065. <if test="agreementType !=null and agreementType !=''">
  1066. and pa.agreement_type =#{agreementType}
  1067. </if>
  1068. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1069. and a.handling_fees_status =#{handlingFeesStatus}
  1070. </if>
  1071. <if test="orderno !=null and orderno !=''">
  1072. and a.orderno =#{orderno}
  1073. </if>
  1074. <if test="policyno !=null and policyno !=''">
  1075. and a.policyno =#{policyno}
  1076. </if>
  1077. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1078. and a.documentary_fees_status =#{documentaryFeesStatus}
  1079. </if>
  1080. <if test="isNotCar !=null and isNotCar !=''">
  1081. and a.is_not_car =#{isNotCar}
  1082. </if>
  1083. <if test="isOther !=null and isOther !=''">
  1084. and a.is_not_documentary =#{isOther}
  1085. </if>
  1086. <if test="licenseno != null and licenseno != ''">
  1087. and a.licenseno =#{licenseno}
  1088. </if>
  1089. <if test="syPolicyno != null and syPolicyno != ''">
  1090. and a.sy_policyno =#{syPolicyno}
  1091. </if>
  1092. <if test="noPolicyno != null and noPolicyno != ''">
  1093. and a.no_policyno =#{noPolicyno}
  1094. </if>
  1095. <if test="signdate !=null and signdate !=''">
  1096. and a.signdate =#{signdate}
  1097. </if>
  1098. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1099. and a.partner_companies_id =#{partnerCompaniesId}
  1100. </if>
  1101. <if test="createTime !=null and createTime !=''">
  1102. and a.create_time =#{createTime}
  1103. </if>
  1104. <if test="createTimeQuery != null and createTimeQuery != ''">
  1105. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1106. </if>
  1107. <if test="settlementTime !=null and settlementTime !=''">
  1108. and a.settlement_time =#{settlementTime}
  1109. </if>
  1110. <if test="userId !=null and userId !=''">
  1111. and a.userId =#{userId}
  1112. </if>
  1113. <if test="companyId !=null and companyId !=''">
  1114. and a.company_id =#{companyId}
  1115. </if>
  1116. <if test="riskcode !=null and riskcode !=''">
  1117. and a.riskcode =#{riskcode}
  1118. </if>
  1119. <if test="year !=null and year !=''">
  1120. AND YEAR(a.signdate) =#{year}
  1121. </if>
  1122. <if test="month !=null and month !=''">
  1123. AND month(a.signdate) =#{month}
  1124. </if>
  1125. <if test="day !=null and day !=''">
  1126. AND day(a.signdate) =#{day}
  1127. </if>
  1128. </where>
  1129. </select>
  1130. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1131. SELECT
  1132. a.partner_companies_id AS "partnerCompaniesId",
  1133. MAX( a.company_name ) AS "companyName",
  1134. MAX( a.company_id ) AS "companyId",
  1135. MAX( a.partner_companies_name ) AS "partnerCompaniesName"
  1136. FROM
  1137. ins_ply_income a
  1138. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1139. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1140. <where>
  1141. 1=1
  1142. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1143. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1144. </if>
  1145. <if test="agreementType !=null and agreementType !=''">
  1146. and pa.agreement_type =#{agreementType}
  1147. </if>
  1148. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1149. and a.signdate between #{signDateStart} and #{signDateEnd}
  1150. </if>
  1151. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1152. and a.handling_fees_status =#{handlingFeesStatus}
  1153. </if>
  1154. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1155. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1156. </if>
  1157. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1158. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1159. </if>
  1160. <if test="dockingPerson !=null and dockingPerson !=''">
  1161. and pa.docking_person =#{dockingPerson}
  1162. </if>
  1163. <if test="provinceId != null and provinceId != ''">
  1164. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  1165. </if>
  1166. <if test="cityId != null and cityId != ''">
  1167. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  1168. </if>
  1169. <if test="countyId != null and countyId != ''">
  1170. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  1171. </if>
  1172. <if test="taskId != null and taskId != ''">
  1173. and a.task_id = #{taskId}
  1174. </if>
  1175. <if test="orderno !=null and orderno !=''">
  1176. and a.orderno =#{orderno}
  1177. </if>
  1178. <if test="companyName !=null and companyName !=''">
  1179. and a.company_id =#{companyName}
  1180. </if>
  1181. <if test="policyno !=null and policyno !=''">
  1182. and a.policyno =#{policyno}
  1183. </if>
  1184. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1185. and a.documentary_fees_status =#{documentaryFeesStatus}
  1186. </if>
  1187. <if test="createTimeQuery != null and createTimeQuery != ''">
  1188. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1189. </if>
  1190. <if test="isNotCar !=null and isNotCar !=''">
  1191. and a.is_not_car =#{isNotCar}
  1192. </if>
  1193. <if test="deptId !=null and deptId !=''">
  1194. and pa.dept_id =#{deptId}
  1195. </if>
  1196. <if test="ids != null and ids != '' and ids.length > 0">
  1197. and a.id in
  1198. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1199. #{item}
  1200. </foreach>
  1201. </if>
  1202. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  1203. and a.id in
  1204. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  1205. #{item}
  1206. </foreach>
  1207. </if>
  1208. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1209. and a.id in
  1210. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1211. #{item}
  1212. </foreach>
  1213. </if>
  1214. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1215. and a.partner_companies_id in
  1216. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1217. #{item}
  1218. </foreach>
  1219. </if>
  1220. <if test="isOther !=null and isOther !=''">
  1221. and a.is_not_documentary =#{isOther}
  1222. </if>
  1223. <if test="licenseno != null and licenseno != ''">
  1224. and a.licenseno =#{licenseno}
  1225. </if>
  1226. <if test="syPolicyno != null and syPolicyno != ''">
  1227. and a.sy_policyno =#{syPolicyno}
  1228. </if>
  1229. <if test="noPolicyno != null and noPolicyno != ''">
  1230. and a.no_policyno =#{noPolicyno}
  1231. </if>
  1232. <if test="signdate !=null and signdate !=''">
  1233. AND a.signdate =#{signdate}
  1234. </if>
  1235. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1236. AND a.partner_companies_id =#{partnerCompaniesId}
  1237. </if>
  1238. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1239. AND a.partner_companies_name =#{partnerCompaniesName}
  1240. </if>
  1241. <if test="createTime !=null and createTime !=''">
  1242. AND a.create_time =#{createTime}
  1243. </if>
  1244. <if test="settlementTime !=null and settlementTime !=''">
  1245. AND a.settlement_time =#{settlementTime}
  1246. </if>
  1247. <if test="userId !=null and userId !=''">
  1248. and a.userId =#{userId}
  1249. </if>
  1250. <if test="companyId !=null and companyId !=''">
  1251. and a.company_id =#{companyId}
  1252. </if>
  1253. <if test="riskcode !=null and riskcode !=''">
  1254. and a.riskcode =#{riskcode}
  1255. </if>
  1256. <if test="year !=null and year !=''">
  1257. AND YEAR(a.signdate) =#{year}
  1258. </if>
  1259. <if test="month !=null and month !=''">
  1260. AND month(a.signdate) =#{month}
  1261. </if>
  1262. <if test="day !=null and day !=''">
  1263. AND day(a.signdate) =#{day}
  1264. </if>
  1265. <if test="insuredName !=null and insuredName !=''">
  1266. AND a.insured_name =#{insuredName}
  1267. </if>
  1268. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1269. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1270. </if>
  1271. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1272. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1273. </if>
  1274. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1275. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1276. </if>
  1277. </where>
  1278. GROUP BY a.partner_companies_id
  1279. </select>
  1280. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1281. select
  1282. a.partner_companies_id AS "partnerCompaniesId",
  1283. a.id as "id"
  1284. from ins_ply_income a
  1285. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1286. <where>
  1287. 1=1
  1288. and a.handling_fees_status ='2'
  1289. <if test="agreementType !=null and agreementType!='' ">
  1290. AND pa.agreement_type =#{agreementType}
  1291. </if>
  1292. <if test="year !=null and year !=''">
  1293. AND YEAR(a.signdate) =#{year}
  1294. </if>
  1295. <if test="isOther !=null and isOther !=''">
  1296. and a.is_not_documentary =#{isOther}
  1297. </if>
  1298. <if test="isNotCar !=null and isNotCar !=''">
  1299. and a.is_not_car =#{isNotCar}
  1300. </if>
  1301. <if test="month !=null and month !=''">
  1302. AND month(a.signdate) =#{month}
  1303. </if>
  1304. <if test="day !=null and day !=''">
  1305. AND day(a.signdate) =#{day}
  1306. </if>
  1307. </where>
  1308. </select>
  1309. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1310. SELECT
  1311. a.partner_companies_id AS "partnerCompaniesId",
  1312. MAX( a.company_name ) AS "companyName",
  1313. MAX( a.company_id ) AS "companyId",
  1314. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  1315. IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
  1316. IFNULL(max(f.settleMentAmount) , 0.00) + IFNULL(max(d.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  1317. IFNULL(max(d.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
  1318. sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  1319. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  1320. IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
  1321. IFNULL(max(f.expendAmount),0) as "expendAmount",
  1322. sum( a.other_feevalue ) AS "otherFeevalue"
  1323. FROM
  1324. ins_ply_income a
  1325. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1326. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1327. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1328. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1329. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  1330. and a.handling_fees_status ='1'
  1331. <if test="isNotCar !=null and isNotCar !=''">
  1332. and a.is_not_car =#{isNotCar}
  1333. </if>
  1334. GROUP BY partner_companies_id
  1335. ) c ON c.partnerCompaniesId = a.partner_companies_id
  1336. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1337. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1338. WHERE a.settlement_status = '1'
  1339. and a.handling_fees_status ='1'
  1340. <if test="isNotCar !=null and isNotCar !=''">
  1341. and a.is_not_car =#{isNotCar}
  1342. </if>
  1343. GROUP BY partner_companies_id
  1344. ) d ON d.partnerCompaniesId = a.partner_companies_id
  1345. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  1346. settlement_amount ) AS "settleMentAmount",
  1347. sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
  1348. sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
  1349. SUM(a.tax_points) as "taxPoints"
  1350. FROM settlement_documentary_fees a
  1351. WHERE a.settlement_status = '2'
  1352. and a.handling_fees_status ='1'
  1353. <if test="isNotCar !=null and isNotCar !=''">
  1354. and a.is_not_car =#{isNotCar}
  1355. </if>
  1356. GROUP BY partner_companies_id
  1357. ) f ON f.partnerCompaniesId = a.partner_companies_id
  1358. <where>
  1359. 1=1
  1360. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1361. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1362. </if>
  1363. <if test="agreementType !=null and agreementType !=''">
  1364. and pa.agreement_type =#{agreementType}
  1365. </if>
  1366. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1367. and a.signdate between #{signDateStart} and #{signDateEnd}
  1368. </if>
  1369. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1370. and a.handling_fees_status =#{handlingFeesStatus}
  1371. </if>
  1372. <if test="dockingPerson !=null and dockingPerson !=''">
  1373. and pa.docking_person =#{dockingPerson}
  1374. </if>
  1375. <if test="orderno !=null and orderno !=''">
  1376. and a.orderno =#{orderno}
  1377. </if>
  1378. <if test="companyName !=null and companyName !=''">
  1379. and a.company_id =#{companyName}
  1380. </if>
  1381. <if test="policyno !=null and policyno !=''">
  1382. and a.policyno =#{policyno}
  1383. </if>
  1384. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1385. and a.documentary_fees_status =#{documentaryFeesStatus}
  1386. </if>
  1387. <if test="isNotCar !=null and isNotCar !=''">
  1388. and a.is_not_car =#{isNotCar}
  1389. </if>
  1390. <if test="isOther !=null and isOther !=''">
  1391. and a.is_not_documentary =#{isOther}
  1392. </if>
  1393. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1394. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1395. </if>
  1396. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1397. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1398. </if>
  1399. <if test="licenseno != null and licenseno != ''">
  1400. and a.licenseno =#{licenseno}
  1401. </if>
  1402. <if test="syPolicyno != null and syPolicyno != ''">
  1403. and a.sy_policyno =#{syPolicyno}
  1404. </if>
  1405. <if test="noPolicyno != null and noPolicyno != ''">
  1406. and a.no_policyno =#{noPolicyno}
  1407. </if>
  1408. <if test="signdate !=null and signdate !=''">
  1409. AND a.signdate =#{signdate}
  1410. </if>
  1411. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1412. AND a.partner_companies_id =#{partnerCompaniesId}
  1413. </if>
  1414. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1415. AND a.partner_companies_name =#{partnerCompaniesName}
  1416. </if>
  1417. <if test="createTime !=null and createTime !=''">
  1418. AND a.create_time =#{createTime}
  1419. </if>
  1420. <if test="settlementTime !=null and settlementTime !=''">
  1421. AND a.settlement_time =#{settlementTime}
  1422. </if>
  1423. <if test="createTimeQuery != null and createTimeQuery != ''">
  1424. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1425. </if>
  1426. <if test="userId !=null and userId !=''">
  1427. and a.userId =#{userId}
  1428. </if>
  1429. <if test="companyId !=null and companyId !=''">
  1430. and a.company_id =#{companyId}
  1431. </if>
  1432. <if test="riskcode !=null and riskcode !=''">
  1433. and a.riskcode =#{riskcode}
  1434. </if>
  1435. <if test="year !=null and year !=''">
  1436. AND YEAR(a.signdate) =#{year}
  1437. </if>
  1438. <if test="month !=null and month !=''">
  1439. AND month(a.signdate) =#{month}
  1440. </if>
  1441. <if test="day !=null and day !=''">
  1442. AND day(a.signdate) =#{day}
  1443. </if>
  1444. <if test="insuredName !=null and insuredName !=''">
  1445. AND a.insured_name =#{insuredName}
  1446. </if>
  1447. </where>
  1448. GROUP BY
  1449. a.partner_companies_id
  1450. </select>
  1451. <select id="getOtherIds" resultType="java.util.HashMap">
  1452. SELECT
  1453. a.id as "id",
  1454. a.partner_companies_id AS "partnerCompaniesId"
  1455. FROM
  1456. ins_ply_income a
  1457. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1458. <where>
  1459. 1=1
  1460. <if test="agreementType !=null and agreementType!='' ">
  1461. AND pa.agreement_type =#{agreementType}
  1462. </if>
  1463. <if test="year !=null and year !=''">
  1464. AND YEAR(a.signdate) =#{year}
  1465. </if>
  1466. <if test="isOther !=null and isOther !=''">
  1467. and a.is_not_documentary =#{isOther}
  1468. </if>
  1469. <if test="isNotCar !=null and isNotCar !=''">
  1470. and a.is_not_car =#{isNotCar}
  1471. </if>
  1472. <if test="month !=null and month !=''">
  1473. AND month(a.signdate) =#{month}
  1474. </if>
  1475. <if test="day !=null and day !=''">
  1476. AND day(a.signdate) =#{day}
  1477. </if>
  1478. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1479. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1480. </if>
  1481. </where>
  1482. </select>
  1483. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1484. select
  1485. pa.agreement_name as "agreementName",
  1486. su.name as "userName",
  1487. <include refid="income_com"/>
  1488. from ins_ply_income a
  1489. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1490. LEFT JOIN sys_user su on su.id=a.user_id
  1491. <where>
  1492. <if test="id !=null and id !=''">
  1493. a.id=#{id}
  1494. </if>
  1495. </where>
  1496. </select>
  1497. <select id="groupByInvoic" resultType="java.util.HashMap">
  1498. select
  1499. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  1500. MAX(invoic_id) as "invoicId",
  1501. MAX(invoic_time) as "invoicTime",
  1502. GROUP_CONCAT(a.id) as "ids"
  1503. from ins_ply_income a
  1504. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1505. LEFT JOIN sys_user su on su.id=a.user_id
  1506. <where>
  1507. 1=1
  1508. AND a.invoic_id is not null
  1509. <if test="idArr !=null and idArr!=''">
  1510. a.id IN
  1511. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  1512. #{item}
  1513. </foreach>
  1514. </if>
  1515. <if test="agreementType !=null and agreementType!='' ">
  1516. AND pa.agreement_type =#{agreementType}
  1517. </if>
  1518. <if test="year !=null and year !=''">
  1519. AND YEAR(a.signdate) =#{year}
  1520. </if>
  1521. <if test="isOther !=null and isOther !=''">
  1522. and a.is_not_documentary =#{isOther}
  1523. </if>
  1524. <if test="isNotCar !=null and isNotCar !=''">
  1525. and a.is_not_car =#{isNotCar}
  1526. </if>
  1527. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1528. and a.handling_fees_status =#{handlingFeesStatus}
  1529. </if>
  1530. <if test="month !=null and month !=''">
  1531. AND month(a.signdate) =#{month}
  1532. </if>
  1533. <if test="day !=null and day !=''">
  1534. AND day(a.signdate) =#{day}
  1535. </if>
  1536. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1537. AND a.partner_companies_id =#{partnerCompaniesId}
  1538. </if>
  1539. </where>
  1540. group by a.invoic_id
  1541. </select>
  1542. <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1543. update ins_ply_income
  1544. set handling_fees_status ='1',
  1545. settlement_time =NOW()
  1546. <where>
  1547. 1=1
  1548. <if test="split != null and split != '' and split.length > 0">
  1549. and id in
  1550. <foreach collection="split" item="item" open="(" separator="," close=")">
  1551. #{item}
  1552. </foreach>
  1553. </if>
  1554. </where>
  1555. </update>
  1556. <select id="otherTimeDetail" resultType="java.util.HashMap">
  1557. SELECT
  1558. i.YEAR as "year",
  1559. LPAD(i.monthNumber, 2, '0') as "monthNumber",
  1560. i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
  1561. IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
  1562. CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
  1563. IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
  1564. FROM (
  1565. SELECT
  1566. YEAR(a.signdate) AS YEAR,
  1567. MONTH(a.signdate) AS monthNumber,
  1568. SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
  1569. FROM ins_ply_income a
  1570. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1571. <where>
  1572. YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1573. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1574. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1575. </if>
  1576. <if test="agreementType !=null and agreementType !=''">
  1577. and pa.agreement_type =#{agreementType}
  1578. </if>
  1579. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1580. and a.signdate between #{signDateStart} and #{signDateEnd}
  1581. </if>
  1582. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1583. and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1584. </if>
  1585. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1586. and a.handling_fees_status =#{handlingFeesStatus}
  1587. </if>
  1588. <if test="dockingPerson !=null and dockingPerson !=''">
  1589. and pa.docking_person =#{dockingPerson}
  1590. </if>
  1591. <if test="cityId != null and cityId != ''">
  1592. and a.dept_id LIKE CONCAT(#{cityId}, '%')
  1593. </if>
  1594. <if test="countyId != null and countyId != ''">
  1595. and a.dept_id LIKE CONCAT(#{countyId}, '%')
  1596. </if>
  1597. <if test="orderno !=null and orderno !=''">
  1598. and a.orderno =#{orderno}
  1599. </if>
  1600. <if test="companyName !=null and companyName !=''">
  1601. and a.company_id =#{companyName}
  1602. </if>
  1603. <if test="policyno !=null and policyno !=''">
  1604. and a.policyno =#{policyno}
  1605. </if>
  1606. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1607. and a.documentary_fees_status =#{documentaryFeesStatus}
  1608. </if>
  1609. <if test="isNotCar !=null and isNotCar !=''">
  1610. and a.is_not_car =#{isNotCar}
  1611. </if>
  1612. <if test="deptId !=null and deptId !=''">
  1613. and pa.dept_id =#{deptId}
  1614. </if>
  1615. <if test="ids != null and ids != '' and ids.length > 0">
  1616. and a.id in
  1617. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1618. #{item}
  1619. </foreach>
  1620. </if>
  1621. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1622. and a.id in
  1623. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1624. #{item}
  1625. </foreach>
  1626. </if>
  1627. <if test="createTimeQuery != null and createTimeQuery != ''">
  1628. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1629. </if>
  1630. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1631. and a.partner_companies_id in
  1632. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1633. #{item}
  1634. </foreach>
  1635. </if>
  1636. <if test="isOther !=null and isOther !=''">
  1637. and a.is_not_documentary =#{isOther}
  1638. </if>
  1639. <if test="licenseno != null and licenseno != ''">
  1640. and a.licenseno =#{licenseno}
  1641. </if>
  1642. <if test="syPolicyno != null and syPolicyno != ''">
  1643. and a.sy_policyno =#{syPolicyno}
  1644. </if>
  1645. <if test="noPolicyno != null and noPolicyno != ''">
  1646. and a.no_policyno =#{noPolicyno}
  1647. </if>
  1648. <if test="signdate !=null and signdate !=''">
  1649. AND a.signdate =#{signdate}
  1650. </if>
  1651. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1652. AND a.partner_companies_id =#{partnerCompaniesId}
  1653. </if>
  1654. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1655. AND a.partner_companies_name =#{partnerCompaniesName}
  1656. </if>
  1657. <if test="createTime !=null and createTime !=''">
  1658. AND a.create_time =#{createTime}
  1659. </if>
  1660. <if test="settlementTime !=null and settlementTime !=''">
  1661. AND a.settlement_time =#{settlementTime}
  1662. </if>
  1663. <if test="userId !=null and userId !=''">
  1664. and a.userId =#{userId}
  1665. </if>
  1666. <if test="companyId !=null and companyId !=''">
  1667. and a.company_id =#{companyId}
  1668. </if>
  1669. <if test="riskcode !=null and riskcode !=''">
  1670. and a.riskcode =#{riskcode}
  1671. </if>
  1672. <if test="year !=null and year !=''">
  1673. AND YEAR(a.signdate) =#{year}
  1674. </if>
  1675. <if test="month !=null and month !=''">
  1676. AND month(a.signdate) =#{month}
  1677. </if>
  1678. <if test="day !=null and day !=''">
  1679. AND day(a.signdate) =#{day}
  1680. </if>
  1681. <if test="insuredName !=null and insuredName !=''">
  1682. AND a.insured_name =#{insuredName}
  1683. </if>
  1684. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1685. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1686. </if>
  1687. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1688. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1689. </if>
  1690. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1691. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1692. </if>
  1693. </where>
  1694. GROUP BY YEAR(a.signdate), MONTH(a.signdate)
  1695. ) i
  1696. LEFT JOIN (
  1697. SELECT
  1698. YEAR(a.signing_time) AS YEAR,
  1699. MONTH(a.signing_time) AS monthNumber,
  1700. SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
  1701. FROM settlement_documentary_fees a
  1702. <where>
  1703. YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1704. <if test="isNotCar !=null and isNotCar !=''">
  1705. and a.is_not_car =#{isNotCar}
  1706. </if>
  1707. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1708. and a.partner_companies_id in
  1709. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1710. #{item}
  1711. </foreach>
  1712. </if>
  1713. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1714. AND a.partner_companies_id =#{partnerCompaniesId}
  1715. </if>
  1716. <if test="companyName !=null and companyName !=''">
  1717. and a.company_id =#{companyName}
  1718. </if>
  1719. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1720. and a.handling_fees_status =#{handlingFeesStatus}
  1721. </if>
  1722. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1723. and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1724. </if>
  1725. </where>
  1726. GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
  1727. ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
  1728. ORDER BY i.YEAR, i.monthNumber;
  1729. </select>
  1730. <select id="platformSettlementRecord" resultType="com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto">
  1731. SELECT
  1732. DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
  1733. MAX(upf.url) as "imageUrl",
  1734. sum(a.commission_feevalue + a.other_feevalue) AS "settlementAmount"
  1735. FROM
  1736. ins_ply_income a
  1737. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1738. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  1739. <where>
  1740. pa.agreement_type ='1'
  1741. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1742. AND a.partner_companies_id =#{partnerCompaniesId}
  1743. </if>
  1744. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1745. and a.handling_fees_status =#{handlingFeesStatus}
  1746. </if>
  1747. </where>
  1748. group by a.settlement_time
  1749. </select>
  1750. <select id="getTotalPtReceivables" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1751. select
  1752. pa.agreement_type as "agreementType",
  1753. sum(a.all_fee_value) as "allFeeValue"
  1754. from ins_ply_income a
  1755. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1756. LEFT JOIN sys_user su on su.id=a.user_id
  1757. LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
  1758. LEFT JOIN sys_user su2 on su2.id=a.update_user_id
  1759. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  1760. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1761. LEFT JOIN sys_dept b on pa.dept_id=b.id
  1762. <where>
  1763. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1764. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1765. </if>
  1766. <if test="agreementType !=null and agreementType !=''">
  1767. and pa.agreement_type =#{agreementType}
  1768. </if>
  1769. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1770. and a.signdate between #{signDateStart} and #{signDateEnd}
  1771. </if>
  1772. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1773. and a.handling_fees_status =#{handlingFeesStatus}
  1774. </if>
  1775. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  1776. and a.jq_receivable_proportion =#{jqReceivableProportion}
  1777. </if>
  1778. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  1779. and a.sy_receivable_proportion =#{syReceivableProportion}
  1780. </if>
  1781. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  1782. and a.no_receivable_proportion =#{noReceivableProportion}
  1783. </if>
  1784. <if test="id !=null and id !=''">
  1785. and a.id =#{id}
  1786. </if>
  1787. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1788. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1789. </if>
  1790. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1791. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1792. </if>
  1793. <if test="dockingPerson !=null and dockingPerson !=''">
  1794. and pa.docking_person =#{dockingPerson}
  1795. </if>
  1796. <if test="provinceId != null and provinceId != ''">
  1797. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  1798. </if>
  1799. <if test="cityId != null and cityId != ''">
  1800. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  1801. </if>
  1802. <if test="createTimeQuery != null and createTimeQuery != ''">
  1803. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1804. </if>
  1805. <if test="countyId != null and countyId != ''">
  1806. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  1807. </if>
  1808. <if test="taskId != null and taskId != ''">
  1809. and a.task_id = #{taskId}
  1810. </if>
  1811. <if test="orderno !=null and orderno !=''">
  1812. and a.orderno =#{orderno}
  1813. </if>
  1814. <if test="companyName !=null and companyName !=''">
  1815. and a.company_id =#{companyName}
  1816. </if>
  1817. <if test="policyno !=null and policyno !=''">
  1818. and a.policyno =#{policyno}
  1819. </if>
  1820. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1821. and a.documentary_fees_status =#{documentaryFeesStatus}
  1822. </if>
  1823. <if test="isNotCar !=null and isNotCar !=''">
  1824. and a.is_not_car =#{isNotCar}
  1825. </if>
  1826. <if test="deptId !=null and deptId !=''">
  1827. and pa.dept_id =#{deptId}
  1828. </if>
  1829. <if test="ids != null and ids != '' and ids.length > 0">
  1830. and a.id in
  1831. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1832. #{item}
  1833. </foreach>
  1834. </if>
  1835. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  1836. and a.id in
  1837. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  1838. #{item}
  1839. </foreach>
  1840. </if>
  1841. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1842. and a.id in
  1843. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1844. #{item}
  1845. </foreach>
  1846. </if>
  1847. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1848. and a.partner_companies_id in
  1849. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1850. #{item}
  1851. </foreach>
  1852. </if>
  1853. <if test="isOther !=null and isOther !=''">
  1854. and a.is_not_documentary =#{isOther}
  1855. </if>
  1856. <if test="licenseno != null and licenseno != ''">
  1857. and a.licenseno =#{licenseno}
  1858. </if>
  1859. <if test="syPolicyno != null and syPolicyno != ''">
  1860. and a.sy_policyno =#{syPolicyno}
  1861. </if>
  1862. <if test="noPolicyno != null and noPolicyno != ''">
  1863. and a.no_policyno =#{noPolicyno}
  1864. </if>
  1865. <if test="signdate !=null and signdate !=''">
  1866. AND a.signdate =#{signdate}
  1867. </if>
  1868. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1869. AND a.partner_companies_id =#{partnerCompaniesId}
  1870. </if>
  1871. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1872. AND a.partner_companies_name =#{partnerCompaniesName}
  1873. </if>
  1874. <if test="createTime !=null and createTime !=''">
  1875. AND a.create_time =#{createTime}
  1876. </if>
  1877. <if test="settlementTime !=null and settlementTime !=''">
  1878. AND a.settlement_time =#{settlementTime}
  1879. </if>
  1880. <if test="settlementDate !=null and settlementDate !=''">
  1881. AND a.settlement_time =#{settlementDate}
  1882. </if>
  1883. <if test="userId !=null and userId !=''">
  1884. and a.userId =#{userId}
  1885. </if>
  1886. <if test="companyId !=null and companyId !=''">
  1887. and a.company_id =#{companyId}
  1888. </if>
  1889. <if test="riskcode !=null and riskcode !=''">
  1890. and a.riskcode =#{riskcode}
  1891. </if>
  1892. <if test="year !=null and year !=''">
  1893. AND YEAR(a.signdate) =#{year}
  1894. </if>
  1895. <if test="month !=null and month !=''">
  1896. AND month(a.signdate) =#{month}
  1897. </if>
  1898. <if test="day !=null and day !=''">
  1899. AND day(a.signdate) =#{day}
  1900. </if>
  1901. <if test="insuredName !=null and insuredName !=''">
  1902. AND a.insured_name =#{insuredName}
  1903. </if>
  1904. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1905. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1906. </if>
  1907. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1908. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1909. </if>
  1910. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1911. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1912. </if>
  1913. </where>
  1914. group by pa.agreement_type
  1915. </select>
  1916. <select id="ptSumGroupByMonth" resultType="java.util.HashMap">
  1917. SELECT
  1918. DATE_FORMAT( a.signdate, '%m') as "month",
  1919. sum(a.all_fee_value) as "commissionFeevalue"
  1920. FROM
  1921. ins_ply_income a
  1922. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1923. LEFT JOIN sys_user su ON su.id = a.user_id
  1924. LEFT JOIN sys_user su1 ON su1.id = a.settlement_user_id
  1925. LEFT JOIN sys_user su2 ON su2.id = a.update_user_id
  1926. LEFT JOIN ins_upload_files upf ON a.settlement_image_id = upf.id
  1927. LEFT JOIN esm_ins_company eic ON eic.id = a.partner_companies_id
  1928. LEFT JOIN sys_dept b ON pa.dept_id = b.id
  1929. <where>
  1930. 1=1
  1931. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1932. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1933. </if>
  1934. <if test="agreementType !=null and agreementType !=''">
  1935. and pa.agreement_type =#{agreementType}
  1936. </if>
  1937. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1938. and a.signdate between #{signDateStart} and #{signDateEnd}
  1939. </if>
  1940. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1941. and a.handling_fees_status =#{handlingFeesStatus}
  1942. </if>
  1943. <if test="jqReceivableProportion !=null and jqReceivableProportion !=''">
  1944. and a.jq_receivable_proportion =#{jqReceivableProportion}
  1945. </if>
  1946. <if test="syReceivableProportion !=null and syReceivableProportion !=''">
  1947. and a.sy_receivable_proportion =#{syReceivableProportion}
  1948. </if>
  1949. <if test="noReceivableProportion !=null and noReceivableProportion !=''">
  1950. and a.no_receivable_proportion =#{noReceivableProportion}
  1951. </if>
  1952. <if test="id !=null and id !=''">
  1953. and a.id =#{id}
  1954. </if>
  1955. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1956. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1957. </if>
  1958. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1959. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1960. </if>
  1961. <if test="dockingPerson !=null and dockingPerson !=''">
  1962. and pa.docking_person =#{dockingPerson}
  1963. </if>
  1964. <if test="provinceId != null and provinceId != ''">
  1965. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  1966. </if>
  1967. <if test="cityId != null and cityId != ''">
  1968. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  1969. </if>
  1970. <if test="createTimeQuery != null and createTimeQuery != ''">
  1971. and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
  1972. </if>
  1973. <if test="countyId != null and countyId != ''">
  1974. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  1975. </if>
  1976. <if test="taskId != null and taskId != ''">
  1977. and a.task_id = #{taskId}
  1978. </if>
  1979. <if test="orderno !=null and orderno !=''">
  1980. and a.orderno =#{orderno}
  1981. </if>
  1982. <if test="companyName !=null and companyName !=''">
  1983. and a.company_id =#{companyName}
  1984. </if>
  1985. <if test="policyno !=null and policyno !=''">
  1986. and a.policyno =#{policyno}
  1987. </if>
  1988. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1989. and a.documentary_fees_status =#{documentaryFeesStatus}
  1990. </if>
  1991. <if test="isNotCar !=null and isNotCar !=''">
  1992. and a.is_not_car =#{isNotCar}
  1993. </if>
  1994. <if test="deptId !=null and deptId !=''">
  1995. and pa.dept_id =#{deptId}
  1996. </if>
  1997. <if test="ids != null and ids != '' and ids.length > 0">
  1998. and a.id in
  1999. <foreach collection="ids" item="item" open="(" separator="," close=")">
  2000. #{item}
  2001. </foreach>
  2002. </if>
  2003. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  2004. and a.id in
  2005. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  2006. #{item}
  2007. </foreach>
  2008. </if>
  2009. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  2010. and a.id in
  2011. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  2012. #{item}
  2013. </foreach>
  2014. </if>
  2015. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  2016. and a.partner_companies_id in
  2017. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  2018. #{item}
  2019. </foreach>
  2020. </if>
  2021. <if test="isOther !=null and isOther !=''">
  2022. and a.is_not_documentary =#{isOther}
  2023. </if>
  2024. <if test="licenseno != null and licenseno != ''">
  2025. and a.licenseno =#{licenseno}
  2026. </if>
  2027. <if test="syPolicyno != null and syPolicyno != ''">
  2028. and a.sy_policyno =#{syPolicyno}
  2029. </if>
  2030. <if test="noPolicyno != null and noPolicyno != ''">
  2031. and a.no_policyno =#{noPolicyno}
  2032. </if>
  2033. <if test="signdate !=null and signdate !=''">
  2034. AND a.signdate =#{signdate}
  2035. </if>
  2036. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  2037. AND a.partner_companies_id =#{partnerCompaniesId}
  2038. </if>
  2039. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  2040. AND a.partner_companies_name =#{partnerCompaniesName}
  2041. </if>
  2042. <if test="createTime !=null and createTime !=''">
  2043. AND a.create_time =#{createTime}
  2044. </if>
  2045. <if test="settlementTime !=null and settlementTime !=''">
  2046. AND a.settlement_time =#{settlementTime}
  2047. </if>
  2048. <if test="settlementDate !=null and settlementDate !=''">
  2049. AND a.settlement_time =#{settlementDate}
  2050. </if>
  2051. <if test="userId !=null and userId !=''">
  2052. and a.userId =#{userId}
  2053. </if>
  2054. <if test="companyId !=null and companyId !=''">
  2055. and a.company_id =#{companyId}
  2056. </if>
  2057. <if test="riskcode !=null and riskcode !=''">
  2058. and a.riskcode =#{riskcode}
  2059. </if>
  2060. <if test="year !=null and year !=''">
  2061. AND YEAR(a.signdate) =#{year}
  2062. </if>
  2063. <if test="month !=null and month !=''">
  2064. AND month(a.signdate) =#{month}
  2065. </if>
  2066. <if test="day !=null and day !=''">
  2067. AND day(a.signdate) =#{day}
  2068. </if>
  2069. <if test="insuredName !=null and insuredName !=''">
  2070. AND a.insured_name =#{insuredName}
  2071. </if>
  2072. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  2073. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  2074. </if>
  2075. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  2076. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  2077. </if>
  2078. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  2079. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  2080. </if>
  2081. </where>
  2082. GROUP BY
  2083. DATE_FORMAT( a.signdate, '%m')
  2084. </select>
  2085. </mapper>