InsPlyIncomeMapper.xml 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydtech.modules.fnc.dao.InsPlyIncomeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.InsPlyIncome">
  6. <id column="id" property="id" />
  7. <result column="orderno" property="orderno" />
  8. <result column="policyno" property="policyno" />
  9. <result column="dept_id" property="deptId" />
  10. <result column="dept_name" property="deptName" />
  11. <result column="riskcode" property="riskcode" />
  12. <result column="pay_date" property="payDate" />
  13. <result column="company_id" property="companyId" />
  14. <result column="company_name" property="companyName" />
  15. <result column="agreement_id" property="agreementId" />
  16. <result column="licenseno" property="licenseno" />
  17. <result column="taxamount" property="taxamount" />
  18. <result column="no_tax_premium" property="noTaxPremium" />
  19. <result column="commission_feerate" property="commissionFeerate" />
  20. <result column="other_feerate" property="otherFeerate" />
  21. <result column="commission_feevalue" property="commissionFeevalue" />
  22. <result column="other_feevalue" property="otherFeevalue" />
  23. <result column="all_fee_value" property="allFeeValue" />
  24. <result column="final_fee_value" property="finalFeeValue" />
  25. <result column="doing_fee_value" property="doingFeeValue" />
  26. <result column="create_time" property="createTime" />
  27. <result column="voucher_number" property="voucherNumber"/>
  28. <result column="contract_id" property="contractId"/>
  29. <result column="contract_file_id" property="contractFileId"/>
  30. <result column="handling_fees_status" property="handlingFeesStatus"/>
  31. <result column="documentary_fees_status" property="documentaryFeesStatus"/>
  32. <result column="no_policyno" property="noPolicyno"/>
  33. <result column="sy_policyno" property="syPolicyno"/>
  34. <result column="is_not_car" property="isNotCar"/>
  35. <result column="is_not_documentary" property="isNotDocumentary"/>
  36. <result column="invoic_amount" property="invoicAmount"/>
  37. <result column="invoic_id" property="invoicId"/>
  38. <result column="tax_premium" property="taxPremium"/>
  39. <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
  40. <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
  41. <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
  42. <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
  43. <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
  44. <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
  45. <result column="jq_premium" property="jqPremium"/>
  46. <result column="sy_premium" property="syPremium"/>
  47. <result column="no_premium" property="noPremium"/>
  48. <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
  49. <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
  50. <result column="no_no_tax_premium" property="noNoTaxPremium"/>
  51. <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
  52. <result column="sy_receivable_proportion" property="syReceivableProportion"/>
  53. <result column="no_receivable_proportion" property="noReceivableProportion"/>
  54. <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
  55. <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
  56. <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
  57. <result column="settlement_time" property="settlementTime"/>
  58. <result column="update_time" property="updateTime"/>
  59. <result column="settlement_user_id" property="settlementUserId"/>
  60. <result column="update_user_id" property="updateUserId"/>
  61. <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
  62. <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
  63. <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
  64. <result column="user_id" property="userId"/>
  65. <result column="update_user_id" property="updateUserId"/>
  66. <result column="partner_companies_id" property="partnerCompaniesId"/>
  67. <result column="partner_companies_name" property="partnerCompaniesName"/>
  68. <result column="receivable_amount" property="receivableAmount"/>
  69. <result column="insured_name" property="insuredName"/>
  70. <result column="invoicing_method" property="invoicingMethod"/>
  71. <result column="remarks" property="remarks"/>
  72. <result column="jq_start_date" property="jqStartDate"/>
  73. <result column="jq_end_date" property="jqEndDate"/>
  74. <result column="sy_start_date" property="syStartDate"/>
  75. <result column="sy_end_date" property="syEndDate"/>
  76. <result column="settle_other_status" property="settleOtherStatus"/>
  77. <result column="settlement_image_id" property="settlementImageId"/>
  78. <result column="task_id" property="taskId"/>
  79. </resultMap>
  80. <sql id="income_com">
  81. a.id as "id",
  82. a.orderno as "orderno",
  83. a.policyno as "policyno",
  84. a.dept_id as "deptId",
  85. a.riskcode as "riskcode",
  86. a.pay_date as "payDate",
  87. a.signdate as "signdate",
  88. a.company_id as "companyId",
  89. a.agreement_id as "agreementId",
  90. a.licenseno as "licenseno",
  91. a.taxamount as "taxamount",
  92. a.no_tax_premium as "noTaxPremium",
  93. a.commission_feerate as "commissionFeerate",
  94. a.other_feerate as "otherFeerate",
  95. a.commission_feevalue as "commissionFeevalue",
  96. a.other_feevalue as "otherFeevalue",
  97. a.all_fee_value as "allFeeValue",
  98. a.final_fee_value as "finalFeeValue",
  99. a.doing_fee_value as "doingFeeValue",
  100. a.voucher_number as "voucherNumber",
  101. a.contract_id as "contractId",
  102. a.contract_file_id as "contractFileId",
  103. a.handling_fees_status as "handlingFeesStatus",
  104. a.no_policyno as "noPolicyno",
  105. a.sy_policyno as "syPolicyno",
  106. a.documentary_fees_status as "documentaryFeesStatus",
  107. a.is_not_car as "isNotCar",
  108. a.is_not_documentary as "isNotDocumentary",
  109. a.invoic_amount as "invoicAmount",
  110. a.invoic_id as "invoicId",
  111. a.tax_premium as "taxPremium",
  112. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  113. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  114. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  115. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  116. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  117. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  118. a.partner_companies_id as "partnerCompaniesId",
  119. a.jq_premium as "jqPremium",
  120. a.sy_premium as "syPremium",
  121. a.no_premium as "noPremium",
  122. a.jq_no_tax_premium as "jqNoTaxPremium",
  123. a.sy_no_tax_premium as "syNoTaxPremium",
  124. a.no_no_tax_premium as "noNoTaxPremium",
  125. a.jq_receivable_proportion as "jqReceivableProportion",
  126. a.sy_receivable_proportion as "syReceivableProportion",
  127. a.no_receivable_proportion as "noReceivableProportion",
  128. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  129. a.sy_other_costs_proportion as "syOtherCostsProportion",
  130. a.no_other_costs_proportion as "noOtherCostsProportion",
  131. a.settlement_time as "settlementTime",
  132. a.update_time as "updateTime",
  133. a.settlement_user_id as "settlementUserId",
  134. a.update_user_id as "updateUserId",
  135. a.jq_other_costs_premium as "jqOtherCostsPremium",
  136. a.sy_other_costs_premium as "syOtherCostsPremium",
  137. a.no_other_costs_premium as "noOtherCostsPremium",
  138. a.partner_companies_name as "partnerCompaniesName",
  139. a.company_name as "companyName",
  140. a.receivable_amount as "receivableAmount",
  141. a.invoic_time as "invoicTime",
  142. a.insured_name as "insuredName",
  143. a.remarks as "remarks",
  144. a.jq_start_date as "jqStartDate",
  145. a.jq_end_date as "jqEndDate",
  146. a.sy_start_date as "syStartDate",
  147. a.sy_end_date as "syEndDate",
  148. a.settle_other_status as "settleOtherStatus",
  149. a.user_id as "userId",
  150. a.invoicing_method as "invoicingMethod",
  151. a.settlement_image_id as "settlementImageId",
  152. a.task_id as "taskId",
  153. a.create_time as "createTime"
  154. </sql>
  155. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  156. select
  157. pa.agreement_name as "agreementName",
  158. pa.agreement_type as "agreementType",
  159. pa.docking_person as "dockingPerson",
  160. upf.url as "imageUrl",
  161. su.name as "userName",
  162. b.name as "deptName",
  163. <include refid="income_com"/>
  164. from ins_ply_income a
  165. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  166. LEFT JOIN sys_user su on su.id=a.user_id
  167. LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
  168. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  169. LEFT JOIN sys_dept b on pa.dept_id=b.id
  170. <where>
  171. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  172. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  173. </if>
  174. <if test="agreementType !=null and agreementType !=''">
  175. and pa.agreement_type =#{agreementType}
  176. </if>
  177. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  178. and a.signdate between #{signDateStart} and #{signDateEnd}
  179. </if>
  180. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  181. and a.handling_fees_status =#{handlingFeesStatus}
  182. </if>
  183. <if test="id !=null and id !=''">
  184. and a.id =#{id}
  185. </if>
  186. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  187. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  188. </if>
  189. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  190. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  191. </if>
  192. <if test="dockingPerson !=null and dockingPerson !=''">
  193. and pa.docking_person =#{dockingPerson}
  194. </if>
  195. <if test="provinceId != null and provinceId != ''">
  196. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  197. </if>
  198. <if test="cityId != null and cityId != ''">
  199. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  200. </if>
  201. <if test="countyId != null and countyId != ''">
  202. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  203. </if>
  204. <if test="taskId != null and taskId != ''">
  205. and a.task_id = #{taskId}
  206. </if>
  207. <if test="orderno !=null and orderno !=''">
  208. and a.orderno =#{orderno}
  209. </if>
  210. <if test="companyName !=null and companyName !=''">
  211. and a.company_id =#{companyName}
  212. </if>
  213. <if test="policyno !=null and policyno !=''">
  214. and a.policyno =#{policyno}
  215. </if>
  216. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  217. and a.documentary_fees_status =#{documentaryFeesStatus}
  218. </if>
  219. <if test="isNotCar !=null and isNotCar !=''">
  220. and a.is_not_car =#{isNotCar}
  221. </if>
  222. <if test="deptId !=null and deptId !=''">
  223. and pa.dept_id =#{deptId}
  224. </if>
  225. <if test="ids != null and ids != '' and ids.length > 0">
  226. and a.id in
  227. <foreach collection="ids" item="item" open="(" separator="," close=")">
  228. #{item}
  229. </foreach>
  230. </if>
  231. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  232. and a.id in
  233. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  234. #{item}
  235. </foreach>
  236. </if>
  237. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  238. and a.id in
  239. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  240. #{item}
  241. </foreach>
  242. </if>
  243. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  244. and a.partner_companies_id in
  245. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  246. #{item}
  247. </foreach>
  248. </if>
  249. <if test="isOther !=null and isOther !=''">
  250. and a.is_not_documentary =#{isOther}
  251. </if>
  252. <if test="licenseno != null and licenseno != ''">
  253. and a.licenseno =#{licenseno}
  254. </if>
  255. <if test="syPolicyno != null and syPolicyno != ''">
  256. and a.sy_policyno =#{syPolicyno}
  257. </if>
  258. <if test="noPolicyno != null and noPolicyno != ''">
  259. and a.no_policyno =#{noPolicyno}
  260. </if>
  261. <if test="signdate !=null and signdate !=''">
  262. AND a.signdate =#{signdate}
  263. </if>
  264. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  265. AND a.partner_companies_id =#{partnerCompaniesId}
  266. </if>
  267. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  268. AND a.partner_companies_name =#{partnerCompaniesName}
  269. </if>
  270. <if test="createTime !=null and createTime !=''">
  271. AND a.create_time =#{createTime}
  272. </if>
  273. <if test="settlementTime !=null and settlementTime !=''">
  274. AND a.settlement_time =#{settlementTime}
  275. </if>
  276. <if test="userId !=null and userId !=''">
  277. and a.userId =#{userId}
  278. </if>
  279. <if test="companyId !=null and companyId !=''">
  280. and a.company_id =#{companyId}
  281. </if>
  282. <if test="riskcode !=null and riskcode !=''">
  283. and a.riskcode =#{riskcode}
  284. </if>
  285. <if test="year !=null and year !=''">
  286. AND YEAR(a.signdate) =#{year}
  287. </if>
  288. <if test="month !=null and month !=''">
  289. AND month(a.signdate) =#{month}
  290. </if>
  291. <if test="day !=null and day !=''">
  292. AND day(a.signdate) =#{day}
  293. </if>
  294. <if test="insuredName !=null and insuredName !=''">
  295. AND a.insured_name =#{insuredName}
  296. </if>
  297. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  298. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  299. </if>
  300. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  301. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  302. </if>
  303. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  304. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  305. </if>
  306. </where>
  307. ORDER BY a.create_time desc
  308. </select>
  309. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  310. select
  311. pa.agreement_name as "agreementName",
  312. pa.agreement_type as "agreementType",
  313. su.name as "userName",
  314. <include refid="income_com"/>
  315. from ins_ply_income a
  316. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  317. LEFT JOIN sys_user su on su.id=a.user_id
  318. <where>
  319. <if test="id!=null and id!=''">
  320. a.id=#{id}
  321. </if>
  322. </where>
  323. </select>
  324. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  325. select
  326. count(MONTH(a.signdate)) as "totalorders",
  327. MONTH(a.signdate) as "monthSigdate",
  328. sum(a.other_feevalue) as "allLOtherFeevalue",
  329. GROUP_CONCAT(a.id) as "ids"
  330. from ins_ply_income a
  331. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  332. <where>
  333. <if test="isNotCar !=null and isNotCar !=''" >
  334. a.is_not_car =#{isNotCar}
  335. </if>
  336. <if test="isOther !=null and isOther !=''">
  337. and a.is_not_documentary =#{isOther}
  338. </if>
  339. <if test="agreementType !=null and agreementType !=''">
  340. and pa.agreement_type =#{agreementType}
  341. </if>
  342. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  343. and a.documentary_fees_status =#{documentaryFeesStatus}
  344. </if>
  345. <if test="companyId !=null and companyId !=''">
  346. and a.company_id =#{companyId}
  347. </if>
  348. <if test="year !=null and year !=''">
  349. and YEAR(a.signdate) =#{year}
  350. </if>
  351. group by MONTH(a.signdate)
  352. </where>
  353. </select>
  354. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  355. update ins_ply_income
  356. <set>
  357. <if test="contractId != null">
  358. contract_id = #{contractId},
  359. </if>
  360. <if test="voucherNumber != null">
  361. voucher_number = #{voucherNumber},
  362. </if>
  363. <if test="contractFileId != null">
  364. contract_file_id = #{contractFileId},
  365. </if>
  366. <if test="handlingFeesStatus != null">
  367. handling_fees_status = #{handlingFeesStatus}
  368. </if>
  369. <if test="documentaryFeesStatus != null">
  370. documentary_fees_status = #{documentaryFeesStatus}
  371. </if>
  372. </set>
  373. where orderno =#{orderno}
  374. </update>
  375. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  376. SELECT
  377. a.companyId as "companyId",
  378. a.totalorders as "totalorders",
  379. a.ids as "ids",
  380. a.allLOtherFeevalue as "allLOtherFeevalue"
  381. FROM
  382. (
  383. SELECT
  384. a.company_id AS "companyId",
  385. count(a.orderno) as "totalorders",
  386. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  387. GROUP_CONCAT(a.id) as "ids"
  388. FROM
  389. ins_ply_income a
  390. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  391. WHERE
  392. pa.agreement_type = '2'
  393. <if test="isNotCar !=null and isNotCar !=''" >
  394. and a.is_not_car =#{isNotCar}
  395. </if>
  396. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  397. AND a.documentary_fees_status = #{documentaryFeesStatus}
  398. </if>
  399. <if test="isOther !=null and isOther !=''">
  400. and a.is_not_documentary =#{isOther}
  401. </if>
  402. <if test="companyId !=null and companyId !=''">
  403. and a.company_id =#{companyId}
  404. </if>
  405. <if test="year !=null and year !=''">
  406. and YEAR(a.signdate) =#{year}
  407. </if>
  408. <if test="month !=null and month !=''">
  409. and month(a.signdate) =#{month}
  410. </if>
  411. GROUP BY
  412. a.company_id
  413. ) a
  414. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  415. </select>
  416. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  417. select
  418. <include refid="income_com"/>
  419. from ins_ply_income a
  420. <where>
  421. 1=1
  422. <if test="licenseno !=null and licenseno !=''">
  423. AND a.licenseno=#{licenseno}
  424. </if>
  425. <if test="policyno !=null and policyno !=''">
  426. AND a.policyno=#{policyno}
  427. </if>
  428. <if test="syPolicyno !=null and syPolicyno !=''">
  429. AND a.sy_policyno=#{syPolicyno}
  430. </if>
  431. <if test="noPolicyno !=null and noPolicyno !=''">
  432. AND a.no_policyno=#{noPolicyno}
  433. </if>
  434. <if test="isOther !=null and isOther !=''">
  435. and a.is_not_documentary =#{isOther}
  436. </if>
  437. </where>
  438. </select>
  439. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  440. select
  441. <include refid="income_com"/>
  442. from ins_ply_income a
  443. <where>
  444. 1=1
  445. <if test="licenseno !=null and licenseno !=''">
  446. AND a.licenseno=#{licenseno}
  447. </if>
  448. <if test="policyno !=null and policyno !=''">
  449. AND a.policyno=#{policyno}
  450. </if>
  451. <if test="syPolicyno !=null and syPolicyno !=''">
  452. AND a.sy_policyno=#{syPolicyno}
  453. </if>
  454. <if test="noPolicyno !=null and noPolicyno !=''">
  455. AND a.no_policyno=#{noPolicyno}
  456. </if>
  457. <if test="isOther !=null and isOther !=''">
  458. and a.is_not_documentary =#{isOther}
  459. </if>
  460. <if test="isNotCar !=null and isNotCar !=''">
  461. and a.is_not_car =#{isNotCar}
  462. </if>
  463. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  464. and a.handling_fees_status =#{handlingFeesStatus}
  465. </if>
  466. <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
  467. and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
  468. </if>
  469. <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
  470. and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
  471. </if>
  472. <if test="jqOtherCostsProportion !=null and jqOtherCostsProportion !=''">
  473. and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
  474. </if>
  475. <if test="syOtherCostsProportion !=null and syOtherCostsProportion !=''">
  476. and a.sy_other_costs_proportion =#{syOtherCostsProportion}
  477. </if>
  478. <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
  479. and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
  480. </if>
  481. <if test="noOtherCostsProportion !=null and noOtherCostsProportion !=''">
  482. and a.no_other_costs_proportion =#{noOtherCostsProportion}
  483. </if>
  484. <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
  485. and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
  486. </if>
  487. <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
  488. and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
  489. </if>
  490. <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
  491. and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
  492. </if>
  493. <if test="jqPremium !=null and jqPremium !=''">
  494. and a.jq_premium =#{jqPremium}
  495. </if>
  496. <if test="syPremium !=null and syPremium !=''">
  497. and a.sy_premium =#{jqPremium}
  498. </if>
  499. <if test="noPremium !=null and noPremium !=''">
  500. and a.no_premium =#{noPremium}
  501. </if>
  502. </where>
  503. limit 1
  504. </select>
  505. <select id="totalAmount" resultType="java.util.HashMap">
  506. select
  507. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  508. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  509. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  510. from ins_ply_income a
  511. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  512. <where>
  513. 1=1
  514. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  515. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  516. </if>
  517. <if test="agreementType !=null and agreementType !=''">
  518. and pa.agreement_type =#{agreementType}
  519. </if>
  520. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  521. and a.signdate between #{signDateStart} and #{signDateEnd}
  522. </if>
  523. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  524. and a.handling_fees_status =#{handlingFeesStatus}
  525. </if>
  526. <if test="orderno !=null and orderno !=''">
  527. and a.orderno =#{orderno}
  528. </if>
  529. <if test="policyno !=null and policyno !=''">
  530. and a.policyno =#{policyno}
  531. </if>
  532. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  533. and a.documentary_fees_status =#{documentaryFeesStatus}
  534. </if>
  535. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  536. and a.id in
  537. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  538. #{item}
  539. </foreach>
  540. </if>
  541. <if test="isNotCar !=null and isNotCar !=''">
  542. and a.is_not_car =#{isNotCar}
  543. </if>
  544. <if test="isOther !=null and isOther !=''">
  545. and a.is_not_documentary =#{isOther}
  546. </if>
  547. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  548. and a.licenseno in
  549. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  550. #{item}
  551. </foreach>
  552. </if>
  553. <if test="policyno != null and policyno != '' ">
  554. and a.policyno =#{policyno}
  555. </if>
  556. <if test="syPolicyno != null and syPolicyno != '' ">
  557. and a.sy_policyno =#{syPolicyno}
  558. </if>
  559. <if test="noPolicyno != null and noPolicyno != ''">
  560. and a.no_policyno =#{noPolicyno}
  561. </if>
  562. <if test="signdate !=null and signdate !=''">
  563. and a.signdate =#{signdate}
  564. </if>
  565. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  566. and a.partner_companies_id =#{partnerCompaniesId}
  567. </if>
  568. <if test="createTime !=null and createTime !=''">
  569. a.create_time =#{createTime}
  570. </if>
  571. <if test="settlementTime !=null and settlementTime !=''">
  572. a.settlement_time =#{settlementTime}
  573. </if>
  574. <if test="userId !=null and userId !=''">
  575. and a.userId =#{userId}
  576. </if>
  577. <if test="companyId !=null and companyId !=''">
  578. and a.company_id =#{companyId}
  579. </if>
  580. <if test="riskcode !=null and riskcode !=''">
  581. and a.riskcode =#{riskcode}
  582. </if>
  583. <if test="year !=null and year !=''">
  584. AND YEAR(a.signdate) =#{year}
  585. </if>
  586. <if test="month !=null and month !=''">
  587. AND month(a.signdate) =#{month}
  588. </if>
  589. <if test="day !=null and day !=''">
  590. AND day(a.signdate) =#{day}
  591. </if>
  592. </where>
  593. </select>
  594. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  595. SELECT
  596. SUM(a.commission_feevalue) AS commissionFeevalue,
  597. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  598. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  599. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  600. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  601. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  602. FROM
  603. ins_ply_income a
  604. LEFT JOIN
  605. ptl_agreement pa ON pa.id = a.agreement_id
  606. <where>
  607. 1=1
  608. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  609. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  610. </if>
  611. <if test="agreementType !=null and agreementType !=''">
  612. and pa.agreement_type =#{agreementType}
  613. </if>
  614. <if test="orderno !=null and orderno !=''">
  615. and a.orderno =#{orderno}
  616. </if>
  617. <if test="companyName !=null and companyName !=''">
  618. and a.company_id =#{companyName}
  619. </if>
  620. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  621. and a.signdate between #{signDateStart} and #{signDateEnd}
  622. </if>
  623. <if test="policyno !=null and policyno !=''">
  624. and a.policyno =#{policyno}
  625. </if>
  626. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  627. and a.handling_fees_status =#{handlingFeesStatus}
  628. </if>
  629. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  630. and a.documentary_fees_status =#{documentaryFeesStatus}
  631. </if>
  632. <if test="isNotCar !=null and isNotCar !=''">
  633. and a.is_not_car =#{isNotCar}
  634. </if>
  635. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  636. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  637. </if>
  638. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  639. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  640. </if>
  641. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  642. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  643. </if>
  644. <if test="isOther !=null and isOther !=''">
  645. and a.is_not_documentary =#{isOther}
  646. </if>
  647. <if test="licenseno != null and licenseno != '' ">
  648. and a.licenseno =#{licenseno}
  649. </if>
  650. <if test="deptId !=null and deptId !=''">
  651. and pa.dept_id =#{deptId}
  652. </if>
  653. <if test="ids != null and ids != '' and ids.length > 0">
  654. and a.id in
  655. <foreach collection="ids" item="item" open="(" separator="," close=")">
  656. #{item}
  657. </foreach>
  658. </if>
  659. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  660. and a.id in
  661. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  662. #{item}
  663. </foreach>
  664. </if>
  665. <if test="syPolicyno != null and syPolicyno != '' ">
  666. and a.sy_policyno =#{syPolicyno}
  667. </if>
  668. <if test="noPolicyno != null and noPolicyno != ''">
  669. and a.no_policyno =#{noPolicyno}
  670. </if>
  671. <if test="signdate !=null and signdate !=''">
  672. AND a.signdate =#{signdate}
  673. </if>
  674. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  675. AND a.partner_companies_id =#{partnerCompaniesId}
  676. </if>
  677. <if test="createTime !=null and createTime !=''">
  678. AND a.create_time =#{createTime}
  679. </if>
  680. <if test="settlementTime !=null and settlementTime !=''">
  681. AND a.settlement_time =#{settlementTime}
  682. </if>
  683. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  684. AND a.partner_companies_name =#{partnerCompaniesName}
  685. </if>
  686. <if test="userId !=null and userId !=''">
  687. and a.userId =#{userId}
  688. </if>
  689. <if test="companyId !=null and companyId !=''">
  690. and a.company_id =#{companyId}
  691. </if>
  692. <if test="riskcode !=null and riskcode !=''">
  693. and a.riskcode =#{riskcode}
  694. </if>
  695. <if test="year !=null and year !=''">
  696. AND YEAR(a.signdate) =#{year}
  697. </if>
  698. <if test="month !=null and month !=''">
  699. AND month(a.signdate) =#{month}
  700. </if>
  701. <if test="day !=null and day !=''">
  702. AND day(a.signdate) =#{day}
  703. </if>
  704. <if test="insuredName !=null and insuredName !=''">
  705. AND a.insured_name =#{insuredName}
  706. </if>
  707. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  708. and a.partner_companies_id in
  709. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  710. #{item}
  711. </foreach>
  712. </if>
  713. </where>
  714. </select>
  715. <select id="ptTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  716. SELECT
  717. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
  718. SUM( CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  719. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
  720. FROM
  721. ins_ply_income a
  722. LEFT JOIN
  723. ptl_agreement pa ON pa.id = a.agreement_id
  724. <where>
  725. 1=1
  726. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  727. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  728. </if>
  729. <if test="agreementType !=null and agreementType !=''">
  730. and pa.agreement_type =#{agreementType}
  731. </if>
  732. <if test="orderno !=null and orderno !=''">
  733. and a.orderno =#{orderno}
  734. </if>
  735. <if test="companyName !=null and companyName !=''">
  736. and a.company_id =#{companyName}
  737. </if>
  738. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  739. and a.signdate between #{signDateStart} and #{signDateEnd}
  740. </if>
  741. <if test="policyno !=null and policyno !=''">
  742. and a.policyno =#{policyno}
  743. </if>
  744. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  745. and a.handling_fees_status =#{handlingFeesStatus}
  746. </if>
  747. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  748. and a.documentary_fees_status =#{documentaryFeesStatus}
  749. </if>
  750. <if test="isNotCar !=null and isNotCar !=''">
  751. and a.is_not_car =#{isNotCar}
  752. </if>
  753. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  754. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  755. </if>
  756. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  757. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  758. </if>
  759. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  760. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  761. </if>
  762. <if test="isOther !=null and isOther !=''">
  763. and a.is_not_documentary =#{isOther}
  764. </if>
  765. <if test="licenseno != null and licenseno != '' ">
  766. and a.licenseno =#{licenseno}
  767. </if>
  768. <if test="deptId !=null and deptId !=''">
  769. and pa.dept_id =#{deptId}
  770. </if>
  771. <if test="ids != null and ids != '' and ids.length > 0">
  772. and a.id in
  773. <foreach collection="ids" item="item" open="(" separator="," close=")">
  774. #{item}
  775. </foreach>
  776. </if>
  777. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  778. and a.id in
  779. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  780. #{item}
  781. </foreach>
  782. </if>
  783. <if test="syPolicyno != null and syPolicyno != '' ">
  784. and a.sy_policyno =#{syPolicyno}
  785. </if>
  786. <if test="noPolicyno != null and noPolicyno != ''">
  787. and a.no_policyno =#{noPolicyno}
  788. </if>
  789. <if test="signdate !=null and signdate !=''">
  790. AND a.signdate =#{signdate}
  791. </if>
  792. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  793. AND a.partner_companies_id =#{partnerCompaniesId}
  794. </if>
  795. <if test="createTime !=null and createTime !=''">
  796. AND a.create_time =#{createTime}
  797. </if>
  798. <if test="settlementTime !=null and settlementTime !=''">
  799. AND a.settlement_time =#{settlementTime}
  800. </if>
  801. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  802. AND a.partner_companies_name =#{partnerCompaniesName}
  803. </if>
  804. <if test="userId !=null and userId !=''">
  805. and a.userId =#{userId}
  806. </if>
  807. <if test="companyId !=null and companyId !=''">
  808. and a.company_id =#{companyId}
  809. </if>
  810. <if test="riskcode !=null and riskcode !=''">
  811. and a.riskcode =#{riskcode}
  812. </if>
  813. <if test="year !=null and year !=''">
  814. AND YEAR(a.signdate) =#{year}
  815. </if>
  816. <if test="month !=null and month !=''">
  817. AND month(a.signdate) =#{month}
  818. </if>
  819. <if test="day !=null and day !=''">
  820. AND day(a.signdate) =#{day}
  821. </if>
  822. <if test="insuredName !=null and insuredName !=''">
  823. AND a.insured_name =#{insuredName}
  824. </if>
  825. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  826. and a.partner_companies_id in
  827. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  828. #{item}
  829. </foreach>
  830. </if>
  831. </where>
  832. </select>
  833. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  834. select
  835. MAX(a.partner_companies_id) as "partnerCompaniesId",
  836. MAX( ec.name ) AS "companyName",
  837. sum( a.commission_feevalue ) AS "commissionFeevalue",
  838. sum( a.other_feevalue ) AS "otherFeevalue",
  839. SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
  840. GROUP_CONCAT(a.id) as "ids",
  841. MAX( a.partner_companies_name) as "partnerCompaniesName",
  842. MAX(pa.docking_person) as "dockingPerson",
  843. a.agreement_id AS "agreementId"
  844. from ins_ply_income a
  845. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  846. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  847. <where>
  848. 1=1
  849. <if test="agreementType !=null and agreementType!='' ">
  850. AND pa.agreement_type =#{agreementType}
  851. </if>
  852. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  853. AND a.documentary_fees_status = #{documentaryFeesStatus}
  854. </if>
  855. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  856. AND a.handling_fees_status = #{handlingFeesStatus}
  857. </if>
  858. <if test="year !=null and year !=''">
  859. AND YEAR(a.signdate) =#{year}
  860. </if>
  861. <if test="companyName !=null and companyName !=''">
  862. and a.company_id =#{companyName}
  863. </if>
  864. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  865. AND a.partner_companies_name =#{partnerCompaniesName}
  866. </if>
  867. <if test="dockingPerson !=null and dockingPerson !=''">
  868. and pa.docking_person =#{dockingPerson}
  869. </if>
  870. <if test="month !=null and month !=''">
  871. AND month(a.signdate) =#{month}
  872. </if>
  873. <if test="day !=null and day !=''">
  874. AND day(a.signdate) =#{day}
  875. </if>
  876. </where>
  877. GROUP BY a.agreement_id
  878. </select>
  879. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  880. select
  881. sum(a.commission_feevalue) as "commissionFeevalue",
  882. sum(a.invoic_amount) as "invoicAmount"
  883. from ins_ply_income a
  884. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  885. <where>
  886. 1=1
  887. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  888. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  889. </if>
  890. <if test="agreementType !=null and agreementType !=''">
  891. and pa.agreement_type =#{agreementType}
  892. </if>
  893. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  894. and a.handling_fees_status =#{handlingFeesStatus}
  895. </if>
  896. <if test="orderno !=null and orderno !=''">
  897. and a.orderno =#{orderno}
  898. </if>
  899. <if test="policyno !=null and policyno !=''">
  900. and a.policyno =#{policyno}
  901. </if>
  902. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  903. and a.documentary_fees_status =#{documentaryFeesStatus}
  904. </if>
  905. <if test="isNotCar !=null and isNotCar !=''">
  906. and a.is_not_car =#{isNotCar}
  907. </if>
  908. <if test="isOther !=null and isOther !=''">
  909. and a.is_not_documentary =#{isOther}
  910. </if>
  911. <if test="licenseno != null and licenseno != ''">
  912. and a.licenseno =#{licenseno}
  913. </if>
  914. <if test="syPolicyno != null and syPolicyno != ''">
  915. and a.sy_policyno =#{syPolicyno}
  916. </if>
  917. <if test="noPolicyno != null and noPolicyno != ''">
  918. and a.no_policyno =#{noPolicyno}
  919. </if>
  920. <if test="signdate !=null and signdate !=''">
  921. and a.signdate =#{signdate}
  922. </if>
  923. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  924. and a.partner_companies_id =#{partnerCompaniesId}
  925. </if>
  926. <if test="createTime !=null and createTime !=''">
  927. and a.create_time =#{createTime}
  928. </if>
  929. <if test="settlementTime !=null and settlementTime !=''">
  930. and a.settlement_time =#{settlementTime}
  931. </if>
  932. <if test="userId !=null and userId !=''">
  933. and a.userId =#{userId}
  934. </if>
  935. <if test="companyId !=null and companyId !=''">
  936. and a.company_id =#{companyId}
  937. </if>
  938. <if test="riskcode !=null and riskcode !=''">
  939. and a.riskcode =#{riskcode}
  940. </if>
  941. <if test="year !=null and year !=''">
  942. AND YEAR(a.signdate) =#{year}
  943. </if>
  944. <if test="month !=null and month !=''">
  945. AND month(a.signdate) =#{month}
  946. </if>
  947. <if test="day !=null and day !=''">
  948. AND day(a.signdate) =#{day}
  949. </if>
  950. </where>
  951. </select>
  952. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  953. SELECT
  954. a.partner_companies_id AS "partnerCompaniesId",
  955. MAX( a.company_name ) AS "companyName",
  956. MAX( a.company_id ) AS "companyId",
  957. MAX( a.partner_companies_name ) AS "partnerCompaniesName"
  958. FROM
  959. ins_ply_income a
  960. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  961. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  962. <where>
  963. 1=1
  964. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  965. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  966. </if>
  967. <if test="agreementType !=null and agreementType !=''">
  968. and pa.agreement_type =#{agreementType}
  969. </if>
  970. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  971. and a.signdate between #{signDateStart} and #{signDateEnd}
  972. </if>
  973. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  974. and a.handling_fees_status =#{handlingFeesStatus}
  975. </if>
  976. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  977. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  978. </if>
  979. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  980. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  981. </if>
  982. <if test="dockingPerson !=null and dockingPerson !=''">
  983. and pa.docking_person =#{dockingPerson}
  984. </if>
  985. <if test="provinceId != null and provinceId != ''">
  986. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  987. </if>
  988. <if test="cityId != null and cityId != ''">
  989. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  990. </if>
  991. <if test="countyId != null and countyId != ''">
  992. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  993. </if>
  994. <if test="taskId != null and taskId != ''">
  995. and a.task_id = #{taskId}
  996. </if>
  997. <if test="orderno !=null and orderno !=''">
  998. and a.orderno =#{orderno}
  999. </if>
  1000. <if test="companyName !=null and companyName !=''">
  1001. and a.company_id =#{companyName}
  1002. </if>
  1003. <if test="policyno !=null and policyno !=''">
  1004. and a.policyno =#{policyno}
  1005. </if>
  1006. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1007. and a.documentary_fees_status =#{documentaryFeesStatus}
  1008. </if>
  1009. <if test="isNotCar !=null and isNotCar !=''">
  1010. and a.is_not_car =#{isNotCar}
  1011. </if>
  1012. <if test="deptId !=null and deptId !=''">
  1013. and pa.dept_id =#{deptId}
  1014. </if>
  1015. <if test="ids != null and ids != '' and ids.length > 0">
  1016. and a.id in
  1017. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1018. #{item}
  1019. </foreach>
  1020. </if>
  1021. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  1022. and a.id in
  1023. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  1024. #{item}
  1025. </foreach>
  1026. </if>
  1027. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1028. and a.id in
  1029. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1030. #{item}
  1031. </foreach>
  1032. </if>
  1033. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1034. and a.partner_companies_id in
  1035. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1036. #{item}
  1037. </foreach>
  1038. </if>
  1039. <if test="isOther !=null and isOther !=''">
  1040. and a.is_not_documentary =#{isOther}
  1041. </if>
  1042. <if test="licenseno != null and licenseno != ''">
  1043. and a.licenseno =#{licenseno}
  1044. </if>
  1045. <if test="syPolicyno != null and syPolicyno != ''">
  1046. and a.sy_policyno =#{syPolicyno}
  1047. </if>
  1048. <if test="noPolicyno != null and noPolicyno != ''">
  1049. and a.no_policyno =#{noPolicyno}
  1050. </if>
  1051. <if test="signdate !=null and signdate !=''">
  1052. AND a.signdate =#{signdate}
  1053. </if>
  1054. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1055. AND a.partner_companies_id =#{partnerCompaniesId}
  1056. </if>
  1057. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1058. AND a.partner_companies_name =#{partnerCompaniesName}
  1059. </if>
  1060. <if test="createTime !=null and createTime !=''">
  1061. AND a.create_time =#{createTime}
  1062. </if>
  1063. <if test="settlementTime !=null and settlementTime !=''">
  1064. AND a.settlement_time =#{settlementTime}
  1065. </if>
  1066. <if test="userId !=null and userId !=''">
  1067. and a.userId =#{userId}
  1068. </if>
  1069. <if test="companyId !=null and companyId !=''">
  1070. and a.company_id =#{companyId}
  1071. </if>
  1072. <if test="riskcode !=null and riskcode !=''">
  1073. and a.riskcode =#{riskcode}
  1074. </if>
  1075. <if test="year !=null and year !=''">
  1076. AND YEAR(a.signdate) =#{year}
  1077. </if>
  1078. <if test="month !=null and month !=''">
  1079. AND month(a.signdate) =#{month}
  1080. </if>
  1081. <if test="day !=null and day !=''">
  1082. AND day(a.signdate) =#{day}
  1083. </if>
  1084. <if test="insuredName !=null and insuredName !=''">
  1085. AND a.insured_name =#{insuredName}
  1086. </if>
  1087. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1088. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1089. </if>
  1090. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1091. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1092. </if>
  1093. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1094. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1095. </if>
  1096. </where>
  1097. GROUP BY a.partner_companies_id
  1098. </select>
  1099. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1100. select
  1101. a.partner_companies_id AS "partnerCompaniesId",
  1102. a.id as "id"
  1103. from ins_ply_income a
  1104. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1105. <where>
  1106. 1=1
  1107. and a.handling_fees_status ='2'
  1108. <if test="agreementType !=null and agreementType!='' ">
  1109. AND pa.agreement_type =#{agreementType}
  1110. </if>
  1111. <if test="year !=null and year !=''">
  1112. AND YEAR(a.signdate) =#{year}
  1113. </if>
  1114. <if test="isOther !=null and isOther !=''">
  1115. and a.is_not_documentary =#{isOther}
  1116. </if>
  1117. <if test="isNotCar !=null and isNotCar !=''">
  1118. and a.is_not_car =#{isNotCar}
  1119. </if>
  1120. <if test="month !=null and month !=''">
  1121. AND month(a.signdate) =#{month}
  1122. </if>
  1123. <if test="day !=null and day !=''">
  1124. AND day(a.signdate) =#{day}
  1125. </if>
  1126. </where>
  1127. </select>
  1128. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1129. SELECT
  1130. a.partner_companies_id AS "partnerCompaniesId",
  1131. MAX( a.company_name ) AS "companyName",
  1132. MAX( a.company_id ) AS "companyId",
  1133. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  1134. IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
  1135. IFNULL(max(f.settleMentAmount) , 0.00) + IFNULL(max(d.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  1136. IFNULL(max(d.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
  1137. sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  1138. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  1139. IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
  1140. IFNULL(max(f.expendAmount),0) as "expendAmount",
  1141. sum( a.other_feevalue ) AS "otherFeevalue"
  1142. FROM
  1143. ins_ply_income a
  1144. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1145. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1146. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1147. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1148. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  1149. and a.handling_fees_status ='1'
  1150. <if test="isNotCar !=null and isNotCar !=''">
  1151. and a.is_not_car =#{isNotCar}
  1152. </if>
  1153. GROUP BY partner_companies_id
  1154. ) c ON c.partnerCompaniesId = a.partner_companies_id
  1155. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1156. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1157. WHERE a.settlement_status = '1'
  1158. and a.handling_fees_status ='1'
  1159. <if test="isNotCar !=null and isNotCar !=''">
  1160. and a.is_not_car =#{isNotCar}
  1161. </if>
  1162. GROUP BY partner_companies_id
  1163. ) d ON d.partnerCompaniesId = a.partner_companies_id
  1164. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  1165. settlement_amount ) AS "settleMentAmount",
  1166. sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
  1167. sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
  1168. SUM(a.tax_points) as "taxPoints"
  1169. FROM settlement_documentary_fees a
  1170. WHERE a.settlement_status = '2'
  1171. and a.handling_fees_status ='1'
  1172. <if test="isNotCar !=null and isNotCar !=''">
  1173. and a.is_not_car =#{isNotCar}
  1174. </if>
  1175. GROUP BY partner_companies_id
  1176. ) f ON f.partnerCompaniesId = a.partner_companies_id
  1177. <where>
  1178. 1=1
  1179. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1180. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1181. </if>
  1182. <if test="agreementType !=null and agreementType !=''">
  1183. and pa.agreement_type =#{agreementType}
  1184. </if>
  1185. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1186. and a.signdate between #{signDateStart} and #{signDateEnd}
  1187. </if>
  1188. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1189. and a.handling_fees_status =#{handlingFeesStatus}
  1190. </if>
  1191. <if test="dockingPerson !=null and dockingPerson !=''">
  1192. and pa.docking_person =#{dockingPerson}
  1193. </if>
  1194. <if test="orderno !=null and orderno !=''">
  1195. and a.orderno =#{orderno}
  1196. </if>
  1197. <if test="companyName !=null and companyName !=''">
  1198. and a.company_id =#{companyName}
  1199. </if>
  1200. <if test="policyno !=null and policyno !=''">
  1201. and a.policyno =#{policyno}
  1202. </if>
  1203. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1204. and a.documentary_fees_status =#{documentaryFeesStatus}
  1205. </if>
  1206. <if test="isNotCar !=null and isNotCar !=''">
  1207. and a.is_not_car =#{isNotCar}
  1208. </if>
  1209. <if test="isOther !=null and isOther !=''">
  1210. and a.is_not_documentary =#{isOther}
  1211. </if>
  1212. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1213. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1214. </if>
  1215. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1216. and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
  1217. </if>
  1218. <if test="licenseno != null and licenseno != ''">
  1219. and a.licenseno =#{licenseno}
  1220. </if>
  1221. <if test="syPolicyno != null and syPolicyno != ''">
  1222. and a.sy_policyno =#{syPolicyno}
  1223. </if>
  1224. <if test="noPolicyno != null and noPolicyno != ''">
  1225. and a.no_policyno =#{noPolicyno}
  1226. </if>
  1227. <if test="signdate !=null and signdate !=''">
  1228. AND a.signdate =#{signdate}
  1229. </if>
  1230. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1231. AND a.partner_companies_id =#{partnerCompaniesId}
  1232. </if>
  1233. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1234. AND a.partner_companies_name =#{partnerCompaniesName}
  1235. </if>
  1236. <if test="createTime !=null and createTime !=''">
  1237. AND a.create_time =#{createTime}
  1238. </if>
  1239. <if test="settlementTime !=null and settlementTime !=''">
  1240. AND a.settlement_time =#{settlementTime}
  1241. </if>
  1242. <if test="userId !=null and userId !=''">
  1243. and a.userId =#{userId}
  1244. </if>
  1245. <if test="companyId !=null and companyId !=''">
  1246. and a.company_id =#{companyId}
  1247. </if>
  1248. <if test="riskcode !=null and riskcode !=''">
  1249. and a.riskcode =#{riskcode}
  1250. </if>
  1251. <if test="year !=null and year !=''">
  1252. AND YEAR(a.signdate) =#{year}
  1253. </if>
  1254. <if test="month !=null and month !=''">
  1255. AND month(a.signdate) =#{month}
  1256. </if>
  1257. <if test="day !=null and day !=''">
  1258. AND day(a.signdate) =#{day}
  1259. </if>
  1260. <if test="insuredName !=null and insuredName !=''">
  1261. AND a.insured_name =#{insuredName}
  1262. </if>
  1263. </where>
  1264. GROUP BY
  1265. a.partner_companies_id
  1266. </select>
  1267. <select id="getOtherIds" resultType="java.util.HashMap">
  1268. SELECT
  1269. a.id as "id",
  1270. a.partner_companies_id AS "partnerCompaniesId"
  1271. FROM
  1272. ins_ply_income a
  1273. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1274. <where>
  1275. 1=1
  1276. <if test="agreementType !=null and agreementType!='' ">
  1277. AND pa.agreement_type =#{agreementType}
  1278. </if>
  1279. <if test="year !=null and year !=''">
  1280. AND YEAR(a.signdate) =#{year}
  1281. </if>
  1282. <if test="isOther !=null and isOther !=''">
  1283. and a.is_not_documentary =#{isOther}
  1284. </if>
  1285. <if test="isNotCar !=null and isNotCar !=''">
  1286. and a.is_not_car =#{isNotCar}
  1287. </if>
  1288. <if test="month !=null and month !=''">
  1289. AND month(a.signdate) =#{month}
  1290. </if>
  1291. <if test="day !=null and day !=''">
  1292. AND day(a.signdate) =#{day}
  1293. </if>
  1294. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1295. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1296. </if>
  1297. </where>
  1298. </select>
  1299. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1300. select
  1301. pa.agreement_name as "agreementName",
  1302. su.name as "userName",
  1303. <include refid="income_com"/>
  1304. from ins_ply_income a
  1305. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1306. LEFT JOIN sys_user su on su.id=a.user_id
  1307. <where>
  1308. <if test="id !=null and id !=''">
  1309. a.id=#{id}
  1310. </if>
  1311. </where>
  1312. </select>
  1313. <select id="groupByInvoic" resultType="java.util.HashMap">
  1314. select
  1315. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  1316. MAX(invoic_id) as "invoicId",
  1317. MAX(invoic_time) as "invoicTime",
  1318. GROUP_CONCAT(a.id) as "ids"
  1319. from ins_ply_income a
  1320. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1321. LEFT JOIN sys_user su on su.id=a.user_id
  1322. <where>
  1323. 1=1
  1324. AND a.invoic_id is not null
  1325. <if test="idArr !=null and idArr!=''">
  1326. a.id IN
  1327. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  1328. #{item}
  1329. </foreach>
  1330. </if>
  1331. <if test="agreementType !=null and agreementType!='' ">
  1332. AND pa.agreement_type =#{agreementType}
  1333. </if>
  1334. <if test="year !=null and year !=''">
  1335. AND YEAR(a.signdate) =#{year}
  1336. </if>
  1337. <if test="isOther !=null and isOther !=''">
  1338. and a.is_not_documentary =#{isOther}
  1339. </if>
  1340. <if test="isNotCar !=null and isNotCar !=''">
  1341. and a.is_not_car =#{isNotCar}
  1342. </if>
  1343. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1344. and a.handling_fees_status =#{handlingFeesStatus}
  1345. </if>
  1346. <if test="month !=null and month !=''">
  1347. AND month(a.signdate) =#{month}
  1348. </if>
  1349. <if test="day !=null and day !=''">
  1350. AND day(a.signdate) =#{day}
  1351. </if>
  1352. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1353. AND a.partner_companies_id =#{partnerCompaniesId}
  1354. </if>
  1355. </where>
  1356. group by a.invoic_id
  1357. </select>
  1358. <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1359. update ins_ply_income
  1360. set handling_fees_status ='1',
  1361. settlement_time =NOW()
  1362. <where>
  1363. 1=1
  1364. <if test="split != null and split != '' and split.length > 0">
  1365. and id in
  1366. <foreach collection="split" item="item" open="(" separator="," close=")">
  1367. #{item}
  1368. </foreach>
  1369. </if>
  1370. </where>
  1371. </update>
  1372. <select id="otherTimeDetail" resultType="java.util.HashMap">
  1373. SELECT
  1374. i.YEAR as "year",
  1375. LPAD(i.monthNumber, 2, '0') as "monthNumber",
  1376. i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
  1377. IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
  1378. CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
  1379. IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
  1380. FROM (
  1381. SELECT
  1382. YEAR(a.signdate) AS YEAR,
  1383. MONTH(a.signdate) AS monthNumber,
  1384. SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
  1385. FROM ins_ply_income a
  1386. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1387. <where>
  1388. YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1389. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1390. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1391. </if>
  1392. <if test="agreementType !=null and agreementType !=''">
  1393. and pa.agreement_type =#{agreementType}
  1394. </if>
  1395. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1396. and a.signdate between #{signDateStart} and #{signDateEnd}
  1397. </if>
  1398. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1399. and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1400. </if>
  1401. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1402. and a.handling_fees_status =#{handlingFeesStatus}
  1403. </if>
  1404. <if test="dockingPerson !=null and dockingPerson !=''">
  1405. and pa.docking_person =#{dockingPerson}
  1406. </if>
  1407. <if test="cityId != null and cityId != ''">
  1408. and a.dept_id LIKE CONCAT(#{cityId}, '%')
  1409. </if>
  1410. <if test="countyId != null and countyId != ''">
  1411. and a.dept_id LIKE CONCAT(#{countyId}, '%')
  1412. </if>
  1413. <if test="orderno !=null and orderno !=''">
  1414. and a.orderno =#{orderno}
  1415. </if>
  1416. <if test="companyName !=null and companyName !=''">
  1417. and a.company_id =#{companyName}
  1418. </if>
  1419. <if test="policyno !=null and policyno !=''">
  1420. and a.policyno =#{policyno}
  1421. </if>
  1422. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1423. and a.documentary_fees_status =#{documentaryFeesStatus}
  1424. </if>
  1425. <if test="isNotCar !=null and isNotCar !=''">
  1426. and a.is_not_car =#{isNotCar}
  1427. </if>
  1428. <if test="deptId !=null and deptId !=''">
  1429. and pa.dept_id =#{deptId}
  1430. </if>
  1431. <if test="ids != null and ids != '' and ids.length > 0">
  1432. and a.id in
  1433. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1434. #{item}
  1435. </foreach>
  1436. </if>
  1437. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1438. and a.id in
  1439. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1440. #{item}
  1441. </foreach>
  1442. </if>
  1443. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1444. and a.partner_companies_id in
  1445. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1446. #{item}
  1447. </foreach>
  1448. </if>
  1449. <if test="isOther !=null and isOther !=''">
  1450. and a.is_not_documentary =#{isOther}
  1451. </if>
  1452. <if test="licenseno != null and licenseno != ''">
  1453. and a.licenseno =#{licenseno}
  1454. </if>
  1455. <if test="syPolicyno != null and syPolicyno != ''">
  1456. and a.sy_policyno =#{syPolicyno}
  1457. </if>
  1458. <if test="noPolicyno != null and noPolicyno != ''">
  1459. and a.no_policyno =#{noPolicyno}
  1460. </if>
  1461. <if test="signdate !=null and signdate !=''">
  1462. AND a.signdate =#{signdate}
  1463. </if>
  1464. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1465. AND a.partner_companies_id =#{partnerCompaniesId}
  1466. </if>
  1467. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1468. AND a.partner_companies_name =#{partnerCompaniesName}
  1469. </if>
  1470. <if test="createTime !=null and createTime !=''">
  1471. AND a.create_time =#{createTime}
  1472. </if>
  1473. <if test="settlementTime !=null and settlementTime !=''">
  1474. AND a.settlement_time =#{settlementTime}
  1475. </if>
  1476. <if test="userId !=null and userId !=''">
  1477. and a.userId =#{userId}
  1478. </if>
  1479. <if test="companyId !=null and companyId !=''">
  1480. and a.company_id =#{companyId}
  1481. </if>
  1482. <if test="riskcode !=null and riskcode !=''">
  1483. and a.riskcode =#{riskcode}
  1484. </if>
  1485. <if test="year !=null and year !=''">
  1486. AND YEAR(a.signdate) =#{year}
  1487. </if>
  1488. <if test="month !=null and month !=''">
  1489. AND month(a.signdate) =#{month}
  1490. </if>
  1491. <if test="day !=null and day !=''">
  1492. AND day(a.signdate) =#{day}
  1493. </if>
  1494. <if test="insuredName !=null and insuredName !=''">
  1495. AND a.insured_name =#{insuredName}
  1496. </if>
  1497. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1498. AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
  1499. </if>
  1500. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1501. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  1502. </if>
  1503. <if test="yearStrat !=null and yearStrat != '' and yearEnd != null and yearEnd !=''">
  1504. AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
  1505. </if>
  1506. </where>
  1507. GROUP BY YEAR(a.signdate), MONTH(a.signdate)
  1508. ) i
  1509. LEFT JOIN (
  1510. SELECT
  1511. YEAR(a.signing_time) AS YEAR,
  1512. MONTH(a.signing_time) AS monthNumber,
  1513. SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
  1514. FROM settlement_documentary_fees a
  1515. <where>
  1516. YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1517. <if test="isNotCar !=null and isNotCar !=''">
  1518. and a.is_not_car =#{isNotCar}
  1519. </if>
  1520. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1521. and a.partner_companies_id in
  1522. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1523. #{item}
  1524. </foreach>
  1525. </if>
  1526. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1527. AND a.partner_companies_id =#{partnerCompaniesId}
  1528. </if>
  1529. <if test="companyName !=null and companyName !=''">
  1530. and a.company_id =#{companyName}
  1531. </if>
  1532. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1533. and a.handling_fees_status =#{handlingFeesStatus}
  1534. </if>
  1535. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1536. and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1537. </if>
  1538. </where>
  1539. GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
  1540. ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
  1541. ORDER BY i.YEAR, i.monthNumber;
  1542. </select>
  1543. <select id="platformSettlementRecord" resultType="com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto">
  1544. SELECT
  1545. DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
  1546. SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue"
  1547. FROM
  1548. ins_ply_income a
  1549. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1550. <where>
  1551. pa.agreement_type ='1'
  1552. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1553. AND a.partner_companies_id =#{partnerCompaniesId}
  1554. </if>
  1555. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1556. and a.handling_fees_status =#{handlingFeesStatus}
  1557. </if>
  1558. </where>
  1559. </select>
  1560. </mapper>