InsPlyIncomeMapper.xml 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584
  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="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  184. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  185. </if>
  186. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  187. and eic.parent_id =#{provincePartnerCompaniesId}
  188. </if>
  189. <if test="dockingPerson !=null and dockingPerson !=''">
  190. and pa.docking_person =#{dockingPerson}
  191. </if>
  192. <if test="provinceId != null and provinceId != ''">
  193. and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
  194. </if>
  195. <if test="cityId != null and cityId != ''">
  196. and pa.dept_id LIKE CONCAT(#{cityId}, '%')
  197. </if>
  198. <if test="countyId != null and countyId != ''">
  199. and pa.dept_id LIKE CONCAT(#{countyId}, '%')
  200. </if>
  201. <if test="taskId != null and taskId != ''">
  202. and a.task_id = #{taskId}
  203. </if>
  204. <if test="orderno !=null and orderno !=''">
  205. and a.orderno =#{orderno}
  206. </if>
  207. <if test="companyName !=null and companyName !=''">
  208. and a.company_id =#{companyName}
  209. </if>
  210. <if test="policyno !=null and policyno !=''">
  211. and a.policyno =#{policyno}
  212. </if>
  213. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  214. and a.documentary_fees_status =#{documentaryFeesStatus}
  215. </if>
  216. <if test="isNotCar !=null and isNotCar !=''">
  217. and a.is_not_car =#{isNotCar}
  218. </if>
  219. <if test="deptId !=null and deptId !=''">
  220. and pa.dept_id =#{deptId}
  221. </if>
  222. <if test="ids != null and ids != '' and ids.length > 0">
  223. and a.id in
  224. <foreach collection="ids" item="item" open="(" separator="," close=")">
  225. #{item}
  226. </foreach>
  227. </if>
  228. <if test="incomeIds != null and incomeIds != '' and incomeIds.size() > 0">
  229. and a.id in
  230. <foreach collection="incomeIds" item="item" open="(" separator="," close=")">
  231. #{item}
  232. </foreach>
  233. </if>
  234. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  235. and a.id in
  236. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  237. #{item}
  238. </foreach>
  239. </if>
  240. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  241. and a.partner_companies_id in
  242. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  243. #{item}
  244. </foreach>
  245. </if>
  246. <if test="isOther !=null and isOther !=''">
  247. and a.is_not_documentary =#{isOther}
  248. </if>
  249. <if test="licenseno != null and licenseno != ''">
  250. and a.licenseno =#{licenseno}
  251. </if>
  252. <if test="syPolicyno != null and syPolicyno != ''">
  253. and a.sy_policyno =#{syPolicyno}
  254. </if>
  255. <if test="noPolicyno != null and noPolicyno != ''">
  256. and a.no_policyno =#{noPolicyno}
  257. </if>
  258. <if test="signdate !=null and signdate !=''">
  259. AND a.signdate =#{signdate}
  260. </if>
  261. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  262. AND a.partner_companies_id =#{partnerCompaniesId}
  263. </if>
  264. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  265. AND a.partner_companies_name =#{partnerCompaniesName}
  266. </if>
  267. <if test="createTime !=null and createTime !=''">
  268. AND a.create_time =#{createTime}
  269. </if>
  270. <if test="settlementTime !=null and settlementTime !=''">
  271. AND a.settlement_time =#{settlementTime}
  272. </if>
  273. <if test="userId !=null and userId !=''">
  274. and a.userId =#{userId}
  275. </if>
  276. <if test="companyId !=null and companyId !=''">
  277. and a.company_id =#{companyId}
  278. </if>
  279. <if test="riskcode !=null and riskcode !=''">
  280. and a.riskcode =#{riskcode}
  281. </if>
  282. <if test="year !=null and year !=''">
  283. AND YEAR(a.signdate) =#{year}
  284. </if>
  285. <if test="month !=null and month !=''">
  286. AND month(a.signdate) =#{month}
  287. </if>
  288. <if test="day !=null and day !=''">
  289. AND day(a.signdate) =#{day}
  290. </if>
  291. <if test="insuredName !=null and insuredName !=''">
  292. AND a.insured_name =#{insuredName}
  293. </if>
  294. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  295. AND DATE(a.jq_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  296. </if>
  297. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  298. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  299. </if>
  300. </where>
  301. ORDER BY a.create_time desc
  302. </select>
  303. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  304. select
  305. pa.agreement_name as "agreementName",
  306. pa.agreement_type as "agreementType",
  307. su.name as "userName",
  308. <include refid="income_com"/>
  309. from ins_ply_income a
  310. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  311. LEFT JOIN sys_user su on su.id=a.user_id
  312. <where>
  313. <if test="id!=null and id!=''">
  314. a.id=#{id}
  315. </if>
  316. </where>
  317. </select>
  318. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  319. select
  320. count(MONTH(a.signdate)) as "totalorders",
  321. MONTH(a.signdate) as "monthSigdate",
  322. sum(a.other_feevalue) as "allLOtherFeevalue",
  323. GROUP_CONCAT(a.id) as "ids"
  324. from ins_ply_income a
  325. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  326. <where>
  327. <if test="isNotCar !=null and isNotCar !=''" >
  328. a.is_not_car =#{isNotCar}
  329. </if>
  330. <if test="isOther !=null and isOther !=''">
  331. and a.is_not_documentary =#{isOther}
  332. </if>
  333. <if test="agreementType !=null and agreementType !=''">
  334. and pa.agreement_type =#{agreementType}
  335. </if>
  336. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  337. and a.documentary_fees_status =#{documentaryFeesStatus}
  338. </if>
  339. <if test="companyId !=null and companyId !=''">
  340. and a.company_id =#{companyId}
  341. </if>
  342. <if test="year !=null and year !=''">
  343. and YEAR(a.signdate) =#{year}
  344. </if>
  345. group by MONTH(a.signdate)
  346. </where>
  347. </select>
  348. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  349. update ins_ply_income
  350. <set>
  351. <if test="contractId != null">
  352. contract_id = #{contractId},
  353. </if>
  354. <if test="voucherNumber != null">
  355. voucher_number = #{voucherNumber},
  356. </if>
  357. <if test="contractFileId != null">
  358. contract_file_id = #{contractFileId},
  359. </if>
  360. <if test="handlingFeesStatus != null">
  361. handling_fees_status = #{handlingFeesStatus}
  362. </if>
  363. <if test="documentaryFeesStatus != null">
  364. documentary_fees_status = #{documentaryFeesStatus}
  365. </if>
  366. </set>
  367. where orderno =#{orderno}
  368. </update>
  369. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  370. SELECT
  371. a.companyId as "companyId",
  372. a.totalorders as "totalorders",
  373. a.ids as "ids",
  374. a.allLOtherFeevalue as "allLOtherFeevalue"
  375. FROM
  376. (
  377. SELECT
  378. a.company_id AS "companyId",
  379. count(a.orderno) as "totalorders",
  380. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  381. GROUP_CONCAT(a.id) as "ids"
  382. FROM
  383. ins_ply_income a
  384. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  385. WHERE
  386. pa.agreement_type = '2'
  387. <if test="isNotCar !=null and isNotCar !=''" >
  388. and a.is_not_car =#{isNotCar}
  389. </if>
  390. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  391. AND a.documentary_fees_status = #{documentaryFeesStatus}
  392. </if>
  393. <if test="isOther !=null and isOther !=''">
  394. and a.is_not_documentary =#{isOther}
  395. </if>
  396. <if test="companyId !=null and companyId !=''">
  397. and a.company_id =#{companyId}
  398. </if>
  399. <if test="year !=null and year !=''">
  400. and YEAR(a.signdate) =#{year}
  401. </if>
  402. <if test="month !=null and month !=''">
  403. and month(a.signdate) =#{month}
  404. </if>
  405. GROUP BY
  406. a.company_id
  407. ) a
  408. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  409. </select>
  410. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  411. select
  412. <include refid="income_com"/>
  413. from ins_ply_income a
  414. <where>
  415. 1=1
  416. <if test="licenseno !=null and licenseno !=''">
  417. AND a.licenseno=#{licenseno}
  418. </if>
  419. <if test="policyno !=null and policyno !=''">
  420. AND a.policyno=#{policyno}
  421. </if>
  422. <if test="syPolicyno !=null and syPolicyno !=''">
  423. AND a.sy_policyno=#{syPolicyno}
  424. </if>
  425. <if test="noPolicyno !=null and noPolicyno !=''">
  426. AND a.no_policyno=#{noPolicyno}
  427. </if>
  428. <if test="isOther !=null and isOther !=''">
  429. and a.is_not_documentary =#{isOther}
  430. </if>
  431. </where>
  432. </select>
  433. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  434. select
  435. <include refid="income_com"/>
  436. from ins_ply_income a
  437. <where>
  438. 1=1
  439. <if test="licenseno !=null and licenseno !=''">
  440. AND a.licenseno=#{licenseno}
  441. </if>
  442. <if test="policyno !=null and policyno !=''">
  443. AND a.policyno=#{policyno}
  444. </if>
  445. <if test="syPolicyno !=null and syPolicyno !=''">
  446. AND a.sy_policyno=#{syPolicyno}
  447. </if>
  448. <if test="noPolicyno !=null and noPolicyno !=''">
  449. AND a.no_policyno=#{noPolicyno}
  450. </if>
  451. <if test="isOther !=null and isOther !=''">
  452. and a.is_not_documentary =#{isOther}
  453. </if>
  454. <if test="isNotCar !=null and isNotCar !=''">
  455. and a.is_not_car =#{isNotCar}
  456. </if>
  457. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  458. and a.handling_fees_status =#{handlingFeesStatus}
  459. </if>
  460. <if test="jqSuperviseCostsPremiums !=null and jqSuperviseCostsPremiums !=''">
  461. and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
  462. </if>
  463. <if test="jqSuperviseCostsProportion !=null and jqSuperviseCostsProportion !=''">
  464. and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
  465. </if>
  466. <if test="jqOtherCostsProportion !=null and jqOtherCostsProportion !=''">
  467. and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
  468. </if>
  469. <if test="syOtherCostsProportion !=null and syOtherCostsProportion !=''">
  470. and a.sy_other_costs_proportion =#{syOtherCostsProportion}
  471. </if>
  472. <if test="sySuperviseCostsPremiums !=null and sySuperviseCostsPremiums !=''">
  473. and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
  474. </if>
  475. <if test="noOtherCostsProportion !=null and noOtherCostsProportion !=''">
  476. and a.no_other_costs_proportion =#{noOtherCostsProportion}
  477. </if>
  478. <if test="sySuperviseCostsProportion !=null and sySuperviseCostsProportion !=''">
  479. and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
  480. </if>
  481. <if test="noSuperviseCostsPremiums !=null and noSuperviseCostsPremiums !=''">
  482. and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
  483. </if>
  484. <if test="noSuperviseCostsProportion !=null and noSuperviseCostsProportion !=''">
  485. and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
  486. </if>
  487. <if test="jqPremium !=null and jqPremium !=''">
  488. and a.jq_premium =#{jqPremium}
  489. </if>
  490. <if test="syPremium !=null and syPremium !=''">
  491. and a.sy_premium =#{jqPremium}
  492. </if>
  493. <if test="noPremium !=null and noPremium !=''">
  494. and a.no_premium =#{noPremium}
  495. </if>
  496. </where>
  497. limit 1
  498. </select>
  499. <select id="totalAmount" resultType="java.util.HashMap">
  500. select
  501. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  502. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  503. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  504. from ins_ply_income a
  505. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  506. <where>
  507. 1=1
  508. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  509. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  510. </if>
  511. <if test="agreementType !=null and agreementType !=''">
  512. and pa.agreement_type =#{agreementType}
  513. </if>
  514. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  515. and a.signdate between #{signDateStart} and #{signDateEnd}
  516. </if>
  517. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  518. and a.handling_fees_status =#{handlingFeesStatus}
  519. </if>
  520. <if test="orderno !=null and orderno !=''">
  521. and a.orderno =#{orderno}
  522. </if>
  523. <if test="policyno !=null and policyno !=''">
  524. and a.policyno =#{policyno}
  525. </if>
  526. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  527. and a.documentary_fees_status =#{documentaryFeesStatus}
  528. </if>
  529. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  530. and a.id in
  531. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  532. #{item}
  533. </foreach>
  534. </if>
  535. <if test="isNotCar !=null and isNotCar !=''">
  536. and a.is_not_car =#{isNotCar}
  537. </if>
  538. <if test="isOther !=null and isOther !=''">
  539. and a.is_not_documentary =#{isOther}
  540. </if>
  541. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  542. and a.licenseno in
  543. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  544. #{item}
  545. </foreach>
  546. </if>
  547. <if test="policyno != null and policyno != '' ">
  548. and a.policyno =#{policyno}
  549. </if>
  550. <if test="syPolicyno != null and syPolicyno != '' ">
  551. and a.sy_policyno =#{syPolicyno}
  552. </if>
  553. <if test="noPolicyno != null and noPolicyno != ''">
  554. and a.no_policyno =#{noPolicyno}
  555. </if>
  556. <if test="signdate !=null and signdate !=''">
  557. and a.signdate =#{signdate}
  558. </if>
  559. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  560. and a.partner_companies_id =#{partnerCompaniesId}
  561. </if>
  562. <if test="createTime !=null and createTime !=''">
  563. a.create_time =#{createTime}
  564. </if>
  565. <if test="settlementTime !=null and settlementTime !=''">
  566. a.settlement_time =#{settlementTime}
  567. </if>
  568. <if test="userId !=null and userId !=''">
  569. and a.userId =#{userId}
  570. </if>
  571. <if test="companyId !=null and companyId !=''">
  572. and a.company_id =#{companyId}
  573. </if>
  574. <if test="riskcode !=null and riskcode !=''">
  575. and a.riskcode =#{riskcode}
  576. </if>
  577. <if test="year !=null and year !=''">
  578. AND YEAR(a.signdate) =#{year}
  579. </if>
  580. <if test="month !=null and month !=''">
  581. AND month(a.signdate) =#{month}
  582. </if>
  583. <if test="day !=null and day !=''">
  584. AND day(a.signdate) =#{day}
  585. </if>
  586. </where>
  587. </select>
  588. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  589. SELECT
  590. SUM(a.commission_feevalue) AS commissionFeevalue,
  591. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  592. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  593. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  594. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  595. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  596. FROM
  597. ins_ply_income a
  598. LEFT JOIN
  599. ptl_agreement pa ON pa.id = a.agreement_id
  600. <where>
  601. 1=1
  602. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  603. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  604. </if>
  605. <if test="agreementType !=null and agreementType !=''">
  606. and pa.agreement_type =#{agreementType}
  607. </if>
  608. <if test="orderno !=null and orderno !=''">
  609. and a.orderno =#{orderno}
  610. </if>
  611. <if test="companyName !=null and companyName !=''">
  612. and a.company_id =#{companyName}
  613. </if>
  614. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  615. and a.signdate between #{signDateStart} and #{signDateEnd}
  616. </if>
  617. <if test="policyno !=null and policyno !=''">
  618. and a.policyno =#{policyno}
  619. </if>
  620. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  621. and a.handling_fees_status =#{handlingFeesStatus}
  622. </if>
  623. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  624. and a.documentary_fees_status =#{documentaryFeesStatus}
  625. </if>
  626. <if test="isNotCar !=null and isNotCar !=''">
  627. and a.is_not_car =#{isNotCar}
  628. </if>
  629. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  630. AND DATE(a.jq_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  631. </if>
  632. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  633. AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
  634. </if>
  635. <if test="isOther !=null and isOther !=''">
  636. and a.is_not_documentary =#{isOther}
  637. </if>
  638. <if test="licenseno != null and licenseno != '' ">
  639. and a.licenseno =#{licenseno}
  640. </if>
  641. <if test="deptId !=null and deptId !=''">
  642. and pa.dept_id =#{deptId}
  643. </if>
  644. <if test="ids != null and ids != '' and ids.length > 0">
  645. and a.id in
  646. <foreach collection="ids" item="item" open="(" separator="," close=")">
  647. #{item}
  648. </foreach>
  649. </if>
  650. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  651. and a.id in
  652. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  653. #{item}
  654. </foreach>
  655. </if>
  656. <if test="syPolicyno != null and syPolicyno != '' ">
  657. and a.sy_policyno =#{syPolicyno}
  658. </if>
  659. <if test="noPolicyno != null and noPolicyno != ''">
  660. and a.no_policyno =#{noPolicyno}
  661. </if>
  662. <if test="signdate !=null and signdate !=''">
  663. AND a.signdate =#{signdate}
  664. </if>
  665. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  666. AND a.partner_companies_id =#{partnerCompaniesId}
  667. </if>
  668. <if test="createTime !=null and createTime !=''">
  669. AND a.create_time =#{createTime}
  670. </if>
  671. <if test="settlementTime !=null and settlementTime !=''">
  672. AND a.settlement_time =#{settlementTime}
  673. </if>
  674. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  675. AND a.partner_companies_name =#{partnerCompaniesName}
  676. </if>
  677. <if test="userId !=null and userId !=''">
  678. and a.userId =#{userId}
  679. </if>
  680. <if test="companyId !=null and companyId !=''">
  681. and a.company_id =#{companyId}
  682. </if>
  683. <if test="riskcode !=null and riskcode !=''">
  684. and a.riskcode =#{riskcode}
  685. </if>
  686. <if test="year !=null and year !=''">
  687. AND YEAR(a.signdate) =#{year}
  688. </if>
  689. <if test="month !=null and month !=''">
  690. AND month(a.signdate) =#{month}
  691. </if>
  692. <if test="day !=null and day !=''">
  693. AND day(a.signdate) =#{day}
  694. </if>
  695. <if test="insuredName !=null and insuredName !=''">
  696. AND a.insured_name =#{insuredName}
  697. </if>
  698. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  699. and a.partner_companies_id in
  700. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  701. #{item}
  702. </foreach>
  703. </if>
  704. </where>
  705. </select>
  706. <select id="ptTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  707. SELECT
  708. SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
  709. SUM( CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  710. SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
  711. FROM
  712. ins_ply_income a
  713. LEFT JOIN
  714. ptl_agreement pa ON pa.id = a.agreement_id
  715. <where>
  716. 1=1
  717. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  718. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  719. </if>
  720. <if test="agreementType !=null and agreementType !=''">
  721. and pa.agreement_type =#{agreementType}
  722. </if>
  723. <if test="orderno !=null and orderno !=''">
  724. and a.orderno =#{orderno}
  725. </if>
  726. <if test="companyName !=null and companyName !=''">
  727. and a.company_id =#{companyName}
  728. </if>
  729. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  730. and a.signdate between #{signDateStart} and #{signDateEnd}
  731. </if>
  732. <if test="policyno !=null and policyno !=''">
  733. and a.policyno =#{policyno}
  734. </if>
  735. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  736. and a.handling_fees_status =#{handlingFeesStatus}
  737. </if>
  738. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  739. and a.documentary_fees_status =#{documentaryFeesStatus}
  740. </if>
  741. <if test="isNotCar !=null and isNotCar !=''">
  742. and a.is_not_car =#{isNotCar}
  743. </if>
  744. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  745. AND a.jq_end_date BETWEEN #{jqStartDate} AND #{jqEndDate} AND a.jq_start_date &gt; = #{jqStartDate}
  746. </if>
  747. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  748. AND a.sy_start_date BETWEEN #{syStartDate} AND #{syEndDate} AND a.sy_start_date &gt; = #{syStartDate}
  749. </if>
  750. <if test="isOther !=null and isOther !=''">
  751. and a.is_not_documentary =#{isOther}
  752. </if>
  753. <if test="licenseno != null and licenseno != '' ">
  754. and a.licenseno =#{licenseno}
  755. </if>
  756. <if test="deptId !=null and deptId !=''">
  757. and pa.dept_id =#{deptId}
  758. </if>
  759. <if test="ids != null and ids != '' and ids.length > 0">
  760. and a.id in
  761. <foreach collection="ids" item="item" open="(" separator="," close=")">
  762. #{item}
  763. </foreach>
  764. </if>
  765. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  766. and a.id in
  767. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  768. #{item}
  769. </foreach>
  770. </if>
  771. <if test="syPolicyno != null and syPolicyno != '' ">
  772. and a.sy_policyno =#{syPolicyno}
  773. </if>
  774. <if test="noPolicyno != null and noPolicyno != ''">
  775. and a.no_policyno =#{noPolicyno}
  776. </if>
  777. <if test="signdate !=null and signdate !=''">
  778. AND a.signdate =#{signdate}
  779. </if>
  780. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  781. AND a.partner_companies_id =#{partnerCompaniesId}
  782. </if>
  783. <if test="createTime !=null and createTime !=''">
  784. AND a.create_time =#{createTime}
  785. </if>
  786. <if test="settlementTime !=null and settlementTime !=''">
  787. AND a.settlement_time =#{settlementTime}
  788. </if>
  789. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  790. AND a.partner_companies_name =#{partnerCompaniesName}
  791. </if>
  792. <if test="userId !=null and userId !=''">
  793. and a.userId =#{userId}
  794. </if>
  795. <if test="companyId !=null and companyId !=''">
  796. and a.company_id =#{companyId}
  797. </if>
  798. <if test="riskcode !=null and riskcode !=''">
  799. and a.riskcode =#{riskcode}
  800. </if>
  801. <if test="year !=null and year !=''">
  802. AND YEAR(a.signdate) =#{year}
  803. </if>
  804. <if test="month !=null and month !=''">
  805. AND month(a.signdate) =#{month}
  806. </if>
  807. <if test="day !=null and day !=''">
  808. AND day(a.signdate) =#{day}
  809. </if>
  810. <if test="insuredName !=null and insuredName !=''">
  811. AND a.insured_name =#{insuredName}
  812. </if>
  813. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  814. and a.partner_companies_id in
  815. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  816. #{item}
  817. </foreach>
  818. </if>
  819. </where>
  820. </select>
  821. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  822. select
  823. MAX( ec.name ) AS "companyName",
  824. sum( a.commission_feevalue ) AS "commissionFeevalue",
  825. sum( a.other_feevalue ) AS "otherFeevalue",
  826. SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
  827. GROUP_CONCAT(a.id) as "ids",
  828. MAX( a.partner_companies_name) as "partnerCompaniesName",
  829. MAX(pa.docking_person) as "dockingPerson",
  830. a.agreement_id AS "agreementId"
  831. from ins_ply_income a
  832. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  833. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  834. <where>
  835. 1=1
  836. <if test="agreementType !=null and agreementType!='' ">
  837. AND pa.agreement_type =#{agreementType}
  838. </if>
  839. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  840. AND a.documentary_fees_status = #{documentaryFeesStatus}
  841. </if>
  842. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  843. AND handling_fees_status = #{handlingFeesStatus}
  844. </if>
  845. <if test="year !=null and year !=''">
  846. AND YEAR(a.signdate) =#{year}
  847. </if>
  848. <if test="month !=null and month !=''">
  849. AND month(a.signdate) =#{month}
  850. </if>
  851. <if test="day !=null and day !=''">
  852. AND day(a.signdate) =#{day}
  853. </if>
  854. </where>
  855. GROUP BY a.agreement_id
  856. </select>
  857. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  858. select
  859. sum(a.commission_feevalue) as "commissionFeevalue",
  860. sum(a.invoic_amount) as "invoicAmount"
  861. from ins_ply_income a
  862. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  863. <where>
  864. 1=1
  865. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  866. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  867. </if>
  868. <if test="agreementType !=null and agreementType !=''">
  869. and pa.agreement_type =#{agreementType}
  870. </if>
  871. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  872. and a.handling_fees_status =#{handlingFeesStatus}
  873. </if>
  874. <if test="orderno !=null and orderno !=''">
  875. and a.orderno =#{orderno}
  876. </if>
  877. <if test="policyno !=null and policyno !=''">
  878. and a.policyno =#{policyno}
  879. </if>
  880. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  881. and a.documentary_fees_status =#{documentaryFeesStatus}
  882. </if>
  883. <if test="isNotCar !=null and isNotCar !=''">
  884. and a.is_not_car =#{isNotCar}
  885. </if>
  886. <if test="isOther !=null and isOther !=''">
  887. and a.is_not_documentary =#{isOther}
  888. </if>
  889. <if test="licenseno != null and licenseno != ''">
  890. and a.licenseno =#{licenseno}
  891. </if>
  892. <if test="syPolicyno != null and syPolicyno != ''">
  893. and a.sy_policyno =#{syPolicyno}
  894. </if>
  895. <if test="noPolicyno != null and noPolicyno != ''">
  896. and a.no_policyno =#{noPolicyno}
  897. </if>
  898. <if test="signdate !=null and signdate !=''">
  899. and a.signdate =#{signdate}
  900. </if>
  901. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  902. and a.partner_companies_id =#{partnerCompaniesId}
  903. </if>
  904. <if test="createTime !=null and createTime !=''">
  905. and a.create_time =#{createTime}
  906. </if>
  907. <if test="settlementTime !=null and settlementTime !=''">
  908. and a.settlement_time =#{settlementTime}
  909. </if>
  910. <if test="userId !=null and userId !=''">
  911. and a.userId =#{userId}
  912. </if>
  913. <if test="companyId !=null and companyId !=''">
  914. and a.company_id =#{companyId}
  915. </if>
  916. <if test="riskcode !=null and riskcode !=''">
  917. and a.riskcode =#{riskcode}
  918. </if>
  919. <if test="year !=null and year !=''">
  920. AND YEAR(a.signdate) =#{year}
  921. </if>
  922. <if test="month !=null and month !=''">
  923. AND month(a.signdate) =#{month}
  924. </if>
  925. <if test="day !=null and day !=''">
  926. AND day(a.signdate) =#{day}
  927. </if>
  928. </where>
  929. </select>
  930. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  931. SELECT
  932. a.partner_companies_id AS "partnerCompaniesId",
  933. MAX( a.company_name ) AS "companyName",
  934. MAX( a.company_id ) AS "companyId",
  935. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  936. CASE
  937. WHEN (IFNULL(MAX(d.settleMentAmount), 0.00) - IFNULL(MAX(f.settleMentAmount), 0.00)) = 0.00
  938. THEN IFNULL ( MAX(d.settleMentAmount) ,0.00)
  939. ELSE (IFNULL(MAX(d.settleMentAmount), 0.00) - IFNULL(MAX(f.settleMentAmount), 0.00))
  940. END AS "invoicCommissionFeevalue",
  941. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  942. IFNULL ( max(d.settleMentAmount),0.00) as "allInvoicCommissionFeevalue",
  943. sum(COALESCE( a.commission_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  944. sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  945. IFNULL(MAX(f.expendAmount),0.00) as "expendAmount",
  946. MAX(COALESCE( f.settleMentAmount,0.00) )-IFNULL ( max(f.expendAmount),0.00) as "taxesFees",
  947. sum( a.commission_feevalue ) AS "commissionFeevalue"
  948. FROM
  949. ins_ply_income a
  950. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  951. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  952. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  953. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  954. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  955. and a.handling_fees_status ='0'
  956. <if test="isNotCar !=null and isNotCar !=''">
  957. and a.is_not_car =#{isNotCar}
  958. </if>
  959. GROUP BY partner_companies_id
  960. ) c ON c.partnerCompaniesId = a.partner_companies_id
  961. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  962. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  963. WHERE ( a.settlement_status = '1')
  964. and a.handling_fees_status ='0'
  965. <if test="isNotCar !=null and isNotCar !=''">
  966. and a.is_not_car =#{isNotCar}
  967. </if>
  968. GROUP BY partner_companies_id
  969. ) d ON d.partnerCompaniesId = a.partner_companies_id
  970. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  971. settlement_amount ) AS "settleMentAmount" ,
  972. SUM(CASE WHEN a.invoicing_method = '0' THEN a.expend_amount ELSE 0 END) as "expendAmount",
  973. SUM(CASE WHEN a.invoicing_method = '0' THEN a.tax_points ELSE 0 END) as "taxPoints"
  974. FROM settlement_documentary_fees a
  975. WHERE a.settlement_status = '2'
  976. and a.handling_fees_status ='0'
  977. <if test="isNotCar !=null and isNotCar !=''">
  978. and a.is_not_car =#{isNotCar}
  979. </if>
  980. GROUP BY partner_companies_id
  981. ) f ON f.partnerCompaniesId = a.partner_companies_id
  982. <where>
  983. 1=1
  984. <if test="agreementType !=null and agreementType!='' ">
  985. AND pa.agreement_type =#{agreementType}
  986. </if>
  987. <if test="year !=null and year !=''">
  988. AND YEAR(a.signdate) =#{year}
  989. </if>
  990. <if test="isOther !=null and isOther !=''">
  991. and a.is_not_documentary =#{isOther}
  992. </if>
  993. <if test="isNotCar !=null and isNotCar !=''">
  994. and a.is_not_car =#{isNotCar}
  995. </if>
  996. <if test="month !=null and month !=''">
  997. AND month(a.signdate) =#{month}
  998. </if>
  999. <if test="day !=null and day !=''">
  1000. AND day(a.signdate) =#{day}
  1001. </if>
  1002. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1003. AND a.partner_companies_name =#{partnerCompaniesName}
  1004. </if>
  1005. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1006. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1007. </if>
  1008. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1009. and eic.parent_id =#{provincePartnerCompaniesId}
  1010. </if>
  1011. <if test="companyName !=null and companyName !=''">
  1012. and a.company_id =#{companyName}
  1013. </if>
  1014. </where>
  1015. GROUP BY a.partner_companies_id
  1016. </select>
  1017. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1018. select
  1019. a.partner_companies_id AS "partnerCompaniesId",
  1020. a.id as "id"
  1021. from ins_ply_income a
  1022. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  1023. <where>
  1024. 1=1
  1025. and a.handling_fees_status ='2'
  1026. <if test="agreementType !=null and agreementType!='' ">
  1027. AND pa.agreement_type =#{agreementType}
  1028. </if>
  1029. <if test="year !=null and year !=''">
  1030. AND YEAR(a.signdate) =#{year}
  1031. </if>
  1032. <if test="isOther !=null and isOther !=''">
  1033. and a.is_not_documentary =#{isOther}
  1034. </if>
  1035. <if test="isNotCar !=null and isNotCar !=''">
  1036. and a.is_not_car =#{isNotCar}
  1037. </if>
  1038. <if test="month !=null and month !=''">
  1039. AND month(a.signdate) =#{month}
  1040. </if>
  1041. <if test="day !=null and day !=''">
  1042. AND day(a.signdate) =#{day}
  1043. </if>
  1044. </where>
  1045. </select>
  1046. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1047. SELECT
  1048. a.partner_companies_id AS "partnerCompaniesId",
  1049. MAX( a.company_name ) AS "companyName",
  1050. MAX( a.company_id ) AS "companyId",
  1051. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  1052. IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
  1053. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  1054. IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
  1055. sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  1056. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  1057. IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
  1058. IFNULL(max(f.expendAmount),0) as "expendAmount",
  1059. sum( a.other_feevalue ) AS "otherFeevalue"
  1060. FROM
  1061. ins_ply_income a
  1062. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1063. LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
  1064. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1065. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1066. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  1067. and a.handling_fees_status ='1'
  1068. <if test="isNotCar !=null and isNotCar !=''">
  1069. and a.is_not_car =#{isNotCar}
  1070. </if>
  1071. GROUP BY partner_companies_id
  1072. ) c ON c.partnerCompaniesId = a.partner_companies_id
  1073. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  1074. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  1075. WHERE ( a.settlement_status = '1')
  1076. and a.handling_fees_status ='1'
  1077. <if test="isNotCar !=null and isNotCar !=''">
  1078. and a.is_not_car =#{isNotCar}
  1079. </if>
  1080. GROUP BY partner_companies_id
  1081. ) d ON d.partnerCompaniesId = a.partner_companies_id
  1082. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  1083. settlement_amount ) AS "settleMentAmount",
  1084. sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
  1085. sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
  1086. SUM(a.tax_points) as "taxPoints"
  1087. FROM settlement_documentary_fees a
  1088. WHERE a.settlement_status = '2'
  1089. and a.handling_fees_status ='1'
  1090. <if test="isNotCar !=null and isNotCar !=''">
  1091. and a.is_not_car =#{isNotCar}
  1092. </if>
  1093. GROUP BY partner_companies_id
  1094. ) f ON f.partnerCompaniesId = a.partner_companies_id
  1095. <where>
  1096. 1=1
  1097. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1098. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1099. </if>
  1100. <if test="agreementType !=null and agreementType !=''">
  1101. and pa.agreement_type =#{agreementType}
  1102. </if>
  1103. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1104. and a.signdate between #{signDateStart} and #{signDateEnd}
  1105. </if>
  1106. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1107. and a.handling_fees_status =#{handlingFeesStatus}
  1108. </if>
  1109. <if test="dockingPerson !=null and dockingPerson !=''">
  1110. and pa.docking_person =#{dockingPerson}
  1111. </if>
  1112. <if test="orderno !=null and orderno !=''">
  1113. and a.orderno =#{orderno}
  1114. </if>
  1115. <if test="companyName !=null and companyName !=''">
  1116. and a.company_id =#{companyName}
  1117. </if>
  1118. <if test="policyno !=null and policyno !=''">
  1119. and a.policyno =#{policyno}
  1120. </if>
  1121. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1122. and a.documentary_fees_status =#{documentaryFeesStatus}
  1123. </if>
  1124. <if test="isNotCar !=null and isNotCar !=''">
  1125. and a.is_not_car =#{isNotCar}
  1126. </if>
  1127. <if test="isOther !=null and isOther !=''">
  1128. and a.is_not_documentary =#{isOther}
  1129. </if>
  1130. <if test="allPartnerCompaniesId !=null and allPartnerCompaniesId !=''">
  1131. AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
  1132. </if>
  1133. <if test="provincePartnerCompaniesId !=null and provincePartnerCompaniesId !=''">
  1134. and eic.parent_id =#{provincePartnerCompaniesId}
  1135. </if>
  1136. <if test="licenseno != null and licenseno != ''">
  1137. and a.licenseno =#{licenseno}
  1138. </if>
  1139. <if test="syPolicyno != null and syPolicyno != ''">
  1140. and a.sy_policyno =#{syPolicyno}
  1141. </if>
  1142. <if test="noPolicyno != null and noPolicyno != ''">
  1143. and a.no_policyno =#{noPolicyno}
  1144. </if>
  1145. <if test="signdate !=null and signdate !=''">
  1146. AND a.signdate =#{signdate}
  1147. </if>
  1148. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1149. AND a.partner_companies_id =#{partnerCompaniesId}
  1150. </if>
  1151. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1152. AND a.partner_companies_name =#{partnerCompaniesName}
  1153. </if>
  1154. <if test="createTime !=null and createTime !=''">
  1155. AND a.create_time =#{createTime}
  1156. </if>
  1157. <if test="settlementTime !=null and settlementTime !=''">
  1158. AND a.settlement_time =#{settlementTime}
  1159. </if>
  1160. <if test="userId !=null and userId !=''">
  1161. and a.userId =#{userId}
  1162. </if>
  1163. <if test="companyId !=null and companyId !=''">
  1164. and a.company_id =#{companyId}
  1165. </if>
  1166. <if test="riskcode !=null and riskcode !=''">
  1167. and a.riskcode =#{riskcode}
  1168. </if>
  1169. <if test="year !=null and year !=''">
  1170. AND YEAR(a.signdate) =#{year}
  1171. </if>
  1172. <if test="month !=null and month !=''">
  1173. AND month(a.signdate) =#{month}
  1174. </if>
  1175. <if test="day !=null and day !=''">
  1176. AND day(a.signdate) =#{day}
  1177. </if>
  1178. <if test="insuredName !=null and insuredName !=''">
  1179. AND a.insured_name =#{insuredName}
  1180. </if>
  1181. </where>
  1182. GROUP BY
  1183. a.partner_companies_id
  1184. </select>
  1185. <select id="getOtherIds" resultType="java.util.HashMap">
  1186. SELECT
  1187. a.id as "id",
  1188. a.partner_companies_id AS "partnerCompaniesId"
  1189. FROM
  1190. ins_ply_income a
  1191. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1192. <where>
  1193. 1=1
  1194. <if test="agreementType !=null and agreementType!='' ">
  1195. AND pa.agreement_type =#{agreementType}
  1196. </if>
  1197. <if test="year !=null and year !=''">
  1198. AND YEAR(a.signdate) =#{year}
  1199. </if>
  1200. <if test="isOther !=null and isOther !=''">
  1201. and a.is_not_documentary =#{isOther}
  1202. </if>
  1203. <if test="isNotCar !=null and isNotCar !=''">
  1204. and a.is_not_car =#{isNotCar}
  1205. </if>
  1206. <if test="month !=null and month !=''">
  1207. AND month(a.signdate) =#{month}
  1208. </if>
  1209. <if test="day !=null and day !=''">
  1210. AND day(a.signdate) =#{day}
  1211. </if>
  1212. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  1213. AND a.documentary_fees_status = #{documentaryFeesStatus}
  1214. </if>
  1215. </where>
  1216. </select>
  1217. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1218. select
  1219. pa.agreement_name as "agreementName",
  1220. su.name as "userName",
  1221. <include refid="income_com"/>
  1222. from ins_ply_income a
  1223. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1224. LEFT JOIN sys_user su on su.id=a.user_id
  1225. <where>
  1226. <if test="id !=null and id !=''">
  1227. a.id=#{id}
  1228. </if>
  1229. </where>
  1230. </select>
  1231. <select id="groupByInvoic" resultType="java.util.HashMap">
  1232. select
  1233. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  1234. MAX(invoic_id) as "invoicId",
  1235. MAX(invoic_time) as "invoicTime",
  1236. GROUP_CONCAT(a.id) as "ids"
  1237. from ins_ply_income a
  1238. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  1239. LEFT JOIN sys_user su on su.id=a.user_id
  1240. <where>
  1241. 1=1
  1242. AND a.invoic_id is not null
  1243. <if test="idArr !=null and idArr!=''">
  1244. a.id IN
  1245. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  1246. #{item}
  1247. </foreach>
  1248. </if>
  1249. <if test="agreementType !=null and agreementType!='' ">
  1250. AND pa.agreement_type =#{agreementType}
  1251. </if>
  1252. <if test="year !=null and year !=''">
  1253. AND YEAR(a.signdate) =#{year}
  1254. </if>
  1255. <if test="isOther !=null and isOther !=''">
  1256. and a.is_not_documentary =#{isOther}
  1257. </if>
  1258. <if test="isNotCar !=null and isNotCar !=''">
  1259. and a.is_not_car =#{isNotCar}
  1260. </if>
  1261. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1262. and a.handling_fees_status =#{handlingFeesStatus}
  1263. </if>
  1264. <if test="month !=null and month !=''">
  1265. AND month(a.signdate) =#{month}
  1266. </if>
  1267. <if test="day !=null and day !=''">
  1268. AND day(a.signdate) =#{day}
  1269. </if>
  1270. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1271. AND a.partner_companies_id =#{partnerCompaniesId}
  1272. </if>
  1273. </where>
  1274. group by a.invoic_id
  1275. </select>
  1276. <update id="updateByIds" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  1277. update ins_ply_income
  1278. set handling_fees_status ='1',
  1279. settlement_time =NOW()
  1280. <where>
  1281. 1=1
  1282. <if test="split != null and split != '' and split.length > 0">
  1283. and id in
  1284. <foreach collection="split" item="item" open="(" separator="," close=")">
  1285. #{item}
  1286. </foreach>
  1287. </if>
  1288. </where>
  1289. </update>
  1290. <select id="otherTimeDetail" resultType="java.util.HashMap">
  1291. SELECT
  1292. i.YEAR as "year",
  1293. i.monthNumber as "monthNumber",
  1294. i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
  1295. IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
  1296. CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
  1297. IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
  1298. FROM (
  1299. SELECT
  1300. YEAR(a.signdate) AS YEAR,
  1301. MONTH(a.signdate) AS monthNumber,
  1302. SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
  1303. FROM ins_ply_income a
  1304. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  1305. <where>
  1306. YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1307. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  1308. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  1309. </if>
  1310. <if test="agreementType !=null and agreementType !=''">
  1311. and pa.agreement_type =#{agreementType}
  1312. </if>
  1313. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  1314. and a.signdate between #{signDateStart} and #{signDateEnd}
  1315. </if>
  1316. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1317. and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1318. </if>
  1319. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1320. and a.handling_fees_status =#{handlingFeesStatus}
  1321. </if>
  1322. <if test="dockingPerson !=null and dockingPerson !=''">
  1323. and pa.docking_person =#{dockingPerson}
  1324. </if>
  1325. <if test="cityId != null and cityId != ''">
  1326. and a.dept_id LIKE CONCAT(#{cityId}, '%')
  1327. </if>
  1328. <if test="countyId != null and countyId != ''">
  1329. and a.dept_id LIKE CONCAT(#{countyId}, '%')
  1330. </if>
  1331. <if test="orderno !=null and orderno !=''">
  1332. and a.orderno =#{orderno}
  1333. </if>
  1334. <if test="companyName !=null and companyName !=''">
  1335. and a.company_id =#{companyName}
  1336. </if>
  1337. <if test="policyno !=null and policyno !=''">
  1338. and a.policyno =#{policyno}
  1339. </if>
  1340. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  1341. and a.documentary_fees_status =#{documentaryFeesStatus}
  1342. </if>
  1343. <if test="isNotCar !=null and isNotCar !=''">
  1344. and a.is_not_car =#{isNotCar}
  1345. </if>
  1346. <if test="deptId !=null and deptId !=''">
  1347. and pa.dept_id =#{deptId}
  1348. </if>
  1349. <if test="ids != null and ids != '' and ids.length > 0">
  1350. and a.id in
  1351. <foreach collection="ids" item="item" open="(" separator="," close=")">
  1352. #{item}
  1353. </foreach>
  1354. </if>
  1355. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  1356. and a.id in
  1357. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  1358. #{item}
  1359. </foreach>
  1360. </if>
  1361. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1362. and a.partner_companies_id in
  1363. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1364. #{item}
  1365. </foreach>
  1366. </if>
  1367. <if test="isOther !=null and isOther !=''">
  1368. and a.is_not_documentary =#{isOther}
  1369. </if>
  1370. <if test="licenseno != null and licenseno != ''">
  1371. and a.licenseno =#{licenseno}
  1372. </if>
  1373. <if test="syPolicyno != null and syPolicyno != ''">
  1374. and a.sy_policyno =#{syPolicyno}
  1375. </if>
  1376. <if test="noPolicyno != null and noPolicyno != ''">
  1377. and a.no_policyno =#{noPolicyno}
  1378. </if>
  1379. <if test="signdate !=null and signdate !=''">
  1380. AND a.signdate =#{signdate}
  1381. </if>
  1382. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1383. AND a.partner_companies_id =#{partnerCompaniesId}
  1384. </if>
  1385. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  1386. AND a.partner_companies_name =#{partnerCompaniesName}
  1387. </if>
  1388. <if test="createTime !=null and createTime !=''">
  1389. AND a.create_time =#{createTime}
  1390. </if>
  1391. <if test="settlementTime !=null and settlementTime !=''">
  1392. AND a.settlement_time =#{settlementTime}
  1393. </if>
  1394. <if test="userId !=null and userId !=''">
  1395. and a.userId =#{userId}
  1396. </if>
  1397. <if test="companyId !=null and companyId !=''">
  1398. and a.company_id =#{companyId}
  1399. </if>
  1400. <if test="riskcode !=null and riskcode !=''">
  1401. and a.riskcode =#{riskcode}
  1402. </if>
  1403. <if test="year !=null and year !=''">
  1404. AND YEAR(a.signdate) =#{year}
  1405. </if>
  1406. <if test="month !=null and month !=''">
  1407. AND month(a.signdate) =#{month}
  1408. </if>
  1409. <if test="day !=null and day !=''">
  1410. AND day(a.signdate) =#{day}
  1411. </if>
  1412. <if test="insuredName !=null and insuredName !=''">
  1413. AND a.insured_name =#{insuredName}
  1414. </if>
  1415. <if test="jqStartDate !=null and jqStartDate != '' and jqEndDate != null and jqEndDate !=''">
  1416. AND a.jq_end_date BETWEEN #{jqStartDate} AND #{jqEndDate} AND a.jq_start_date &gt; = #{jqStartDate}
  1417. </if>
  1418. <if test="syStartDate !=null and syStartDate != '' and syEndDate != null and syEndDate !=''">
  1419. AND a.sy_start_date BETWEEN #{syStartDate} AND #{syEndDate} AND a.sy_start_date &gt; = #{syStartDate}
  1420. </if>
  1421. </where>
  1422. GROUP BY YEAR(a.signdate), MONTH(a.signdate)
  1423. ) i
  1424. LEFT JOIN (
  1425. SELECT
  1426. YEAR(a.signing_time) AS YEAR,
  1427. MONTH(a.signing_time) AS monthNumber,
  1428. SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
  1429. FROM settlement_documentary_fees a
  1430. <where>
  1431. YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
  1432. <if test="isNotCar !=null and isNotCar !=''">
  1433. and a.is_not_car =#{isNotCar}
  1434. </if>
  1435. <if test="partnerCompaniesIdList != null and partnerCompaniesIdList != '' and partnerCompaniesIdList.size() > 0">
  1436. and a.partner_companies_id in
  1437. <foreach collection="partnerCompaniesIdList" item="item" open="(" separator="," close=")">
  1438. #{item}
  1439. </foreach>
  1440. </if>
  1441. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  1442. AND a.partner_companies_id =#{partnerCompaniesId}
  1443. </if>
  1444. <if test="companyName !=null and companyName !=''">
  1445. and a.company_id =#{companyName}
  1446. </if>
  1447. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  1448. and a.handling_fees_status =#{handlingFeesStatus}
  1449. </if>
  1450. <if test="yeartsStart !=null and yeartsStart !='' and yeartsEnd !=null and yeartsEnd!=''">
  1451. and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
  1452. </if>
  1453. </where>
  1454. GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
  1455. ) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
  1456. ORDER BY i.YEAR, i.monthNumber;
  1457. </select>
  1458. </mapper>