InsPlyIncomeMapper.xml 103 KB

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