InsPlyIncomeMapper.xml 104 KB

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