InsPlyIncomeMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  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. </resultMap>
  72. <sql id="income_com">
  73. a.id as "id",
  74. a.orderno as "orderno",
  75. a.policyno as "policyno",
  76. a.dept_id as "deptId",
  77. a.riskcode as "riskcode",
  78. a.pay_date as "payDate",
  79. a.signdate as "signdate",
  80. a.company_id as "companyId",
  81. a.agreement_id as "agreementId",
  82. a.licenseno as "licenseno",
  83. a.taxamount as "taxamount",
  84. a.no_tax_premium as "noTaxPremium",
  85. a.commission_feerate as "commissionFeerate",
  86. a.other_feerate as "otherFeerate",
  87. a.commission_feevalue as "commissionFeevalue",
  88. a.other_feevalue as "otherFeevalue",
  89. a.all_fee_value as "allFeeValue",
  90. a.final_fee_value as "finalFeeValue",
  91. a.doing_fee_value as "doingFeeValue",
  92. a.voucher_number as "voucherNumber",
  93. a.contract_id as "contractId",
  94. a.contract_file_id as "contractFileId",
  95. a.handling_fees_status as "handlingFeesStatus",
  96. a.no_policyno as "noPolicyno",
  97. a.sy_policyno as "syPolicyno",
  98. a.documentary_fees_status as "documentaryFeesStatus",
  99. a.is_not_car as "isNotCar",
  100. a.is_not_documentary as "isNotDocumentary",
  101. a.invoic_amount as "invoicAmount",
  102. a.invoic_id as "invoicId",
  103. a.tax_premium as "taxPremium",
  104. a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
  105. a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
  106. a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
  107. a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
  108. a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
  109. a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
  110. a.partner_companies_id as "partnerCompaniesId",
  111. a.jq_premium as "jqPremium",
  112. a.sy_premium as "syPremium",
  113. a.no_premium as "noPremium",
  114. a.jq_no_tax_premium as "jqNoTaxPremium",
  115. a.sy_no_tax_premium as "syNoTaxPremium",
  116. a.no_no_tax_premium as "noNoTaxPremium",
  117. a.jq_receivable_proportion as "jqReceivableProportion",
  118. a.sy_receivable_proportion as "syReceivableProportion",
  119. a.no_receivable_proportion as "noReceivableProportion",
  120. a.jq_other_costs_proportion as "jqOtherCostsProportion",
  121. a.sy_other_costs_proportion as "syOtherCostsProportion",
  122. a.no_other_costs_proportion as "noOtherCostsProportion",
  123. a.settlement_time as "settlementTime",
  124. a.update_time as "updateTime",
  125. a.settlement_user_id as "settlementUserId",
  126. a.update_user_id as "updateUserId",
  127. a.jq_other_costs_premium as "jqOtherCostsPremium",
  128. a.sy_other_costs_premium as "syOtherCostsPremium",
  129. a.no_other_costs_premium as "noOtherCostsPremium",
  130. a.partner_companies_name as "partnerCompaniesName",
  131. a.company_name as "companyName",
  132. a.receivable_amount as "receivableAmount",
  133. a.invoic_time as "invoicTime",
  134. a.insured_name as "insuredName",
  135. a.user_id as "userId",
  136. a.invoicing_method as "invoicingMethod",
  137. a.create_time as "createTime"
  138. </sql>
  139. <select id="queryNew" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  140. select
  141. pa.agreement_name as "agreementName",
  142. pa.agreement_type as "agreementType",
  143. pa.docking_person as "dockingPerson",
  144. su.name as "userName",
  145. <include refid="income_com"/>
  146. from ins_ply_income a
  147. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  148. LEFT JOIN sys_user su on su.id=a.user_id
  149. <where>
  150. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  151. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  152. </if>
  153. <if test="agreementType !=null and agreementType !=''">
  154. and pa.agreement_type =#{agreementType}
  155. </if>
  156. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  157. and a.signdate between #{signDateStart} and #{signDateEnd}
  158. </if>
  159. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  160. and a.handling_fees_status =#{handlingFeesStatus}
  161. </if>
  162. <if test="dockingPerson !=null and dockingPerson !=''">
  163. and pa.docking_person =#{dockingPerson}
  164. </if>
  165. <if test="orderno !=null and orderno !=''">
  166. and a.orderno =#{orderno}
  167. </if>
  168. <if test="companyName !=null and companyName !=''">
  169. and a.company_id =#{companyName}
  170. </if>
  171. <if test="policyno !=null and policyno !=''">
  172. and a.policyno =#{policyno}
  173. </if>
  174. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  175. and a.documentary_fees_status =#{documentaryFeesStatus}
  176. </if>
  177. <if test="isNotCar !=null and isNotCar !=''">
  178. and a.is_not_car =#{isNotCar}
  179. </if>
  180. <if test="isOther !=null and isOther !=''">
  181. and a.is_not_documentary =#{isOther}
  182. </if>
  183. <if test="licenseno != null and licenseno != ''">
  184. and a.licenseno =#{licenseno}
  185. </if>
  186. <if test="syPolicyno != null and syPolicyno != ''">
  187. and a.sy_policyno =#{syPolicyno}
  188. </if>
  189. <if test="noPolicyno != null and noPolicyno != ''">
  190. and a.no_policyno =#{noPolicyno}
  191. </if>
  192. <if test="signdate !=null and signdate !=''">
  193. AND a.signdate =#{signdate}
  194. </if>
  195. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  196. AND a.partner_companies_id =#{partnerCompaniesId}
  197. </if>
  198. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  199. AND a.partner_companies_name =#{partnerCompaniesName}
  200. </if>
  201. <if test="createTime !=null and createTime !=''">
  202. AND a.create_time =#{createTime}
  203. </if>
  204. <if test="settlementTime !=null and settlementTime !=''">
  205. AND a.settlement_time =#{settlementTime}
  206. </if>
  207. <if test="userId !=null and userId !=''">
  208. and a.userId =#{userId}
  209. </if>
  210. <if test="companyId !=null and companyId !=''">
  211. and a.company_id =#{companyId}
  212. </if>
  213. <if test="riskcode !=null and riskcode !=''">
  214. and a.riskcode =#{riskcode}
  215. </if>
  216. <if test="year !=null and year !=''">
  217. AND YEAR(a.signdate) =#{year}
  218. </if>
  219. <if test="month !=null and month !=''">
  220. AND month(a.signdate) =#{month}
  221. </if>
  222. <if test="day !=null and day !=''">
  223. AND day(a.signdate) =#{day}
  224. </if>
  225. <if test="insuredName !=null and insuredName !=''">
  226. AND a.insured_name =#{insuredName}
  227. </if>
  228. </where>
  229. </select>
  230. <select id="getEntityById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  231. select
  232. pa.agreement_name as "agreementName",
  233. pa.agreement_type as "agreementType",
  234. su.name as "userName",
  235. <include refid="income_com"/>
  236. from ins_ply_income a
  237. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  238. LEFT JOIN sys_user su on su.id=a.user_id
  239. <where>
  240. <if test="id!=null and id!=''">
  241. a.id=#{id}
  242. </if>
  243. </where>
  244. </select>
  245. <select id="totalQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  246. select
  247. count(MONTH(a.signdate)) as "totalorders",
  248. MONTH(a.signdate) as "monthSigdate",
  249. sum(a.other_feevalue) as "allLOtherFeevalue",
  250. GROUP_CONCAT(a.id) as "ids"
  251. from ins_ply_income a
  252. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  253. <where>
  254. <if test="isNotCar !=null and isNotCar !=''" >
  255. a.is_not_car =#{isNotCar}
  256. </if>
  257. <if test="isOther !=null and isOther !=''">
  258. and a.is_not_documentary =#{isOther}
  259. </if>
  260. <if test="agreementType !=null and agreementType !=''">
  261. and pa.agreement_type =#{agreementType}
  262. </if>
  263. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  264. and a.documentary_fees_status =#{documentaryFeesStatus}
  265. </if>
  266. <if test="companyId !=null and companyId !=''">
  267. and a.company_id =#{companyId}
  268. </if>
  269. <if test="year !=null and year !=''">
  270. and YEAR(a.signdate) =#{year}
  271. </if>
  272. group by MONTH(a.signdate)
  273. </where>
  274. </select>
  275. <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  276. update ins_ply_income
  277. <set>
  278. <if test="contractId != null">
  279. contract_id = #{contractId},
  280. </if>
  281. <if test="voucherNumber != null">
  282. voucher_number = #{voucherNumber},
  283. </if>
  284. <if test="contractFileId != null">
  285. contract_file_id = #{contractFileId},
  286. </if>
  287. <if test="handlingFeesStatus != null">
  288. handling_fees_status = #{handlingFeesStatus}
  289. </if>
  290. <if test="documentaryFeesStatus != null">
  291. documentary_fees_status = #{documentaryFeesStatus}
  292. </if>
  293. </set>
  294. where orderno =#{orderno}
  295. </update>
  296. <select id="NonSettlementQuery" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  297. SELECT
  298. a.companyId as "companyId",
  299. a.totalorders as "totalorders",
  300. a.ids as "ids",
  301. a.allLOtherFeevalue as "allLOtherFeevalue"
  302. FROM
  303. (
  304. SELECT
  305. a.company_id AS "companyId",
  306. count(a.orderno) as "totalorders",
  307. sum( a.other_feevalue ) AS "allLOtherFeevalue",
  308. GROUP_CONCAT(a.id) as "ids"
  309. FROM
  310. ins_ply_income a
  311. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  312. WHERE
  313. pa.agreement_type = '2'
  314. <if test="isNotCar !=null and isNotCar !=''" >
  315. and a.is_not_car =#{isNotCar}
  316. </if>
  317. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  318. AND a.documentary_fees_status = #{documentaryFeesStatus}
  319. </if>
  320. <if test="isOther !=null and isOther !=''">
  321. and a.is_not_documentary =#{isOther}
  322. </if>
  323. <if test="companyId !=null and companyId !=''">
  324. and a.company_id =#{companyId}
  325. </if>
  326. <if test="year !=null and year !=''">
  327. and YEAR(a.signdate) =#{year}
  328. </if>
  329. <if test="month !=null and month !=''">
  330. and month(a.signdate) =#{month}
  331. </if>
  332. GROUP BY
  333. a.company_id
  334. ) a
  335. LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
  336. </select>
  337. <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  338. select
  339. <include refid="income_com"/>
  340. from ins_ply_income a
  341. <where>
  342. 1=1
  343. <if test="licenseno !=null and licenseno !=''">
  344. AND a.licenseno=#{licenseno}
  345. </if>
  346. <if test="policyno !=null and policyno !=''">
  347. AND a.policyno=#{policyno}
  348. </if>
  349. <if test="syPolicyno !=null and syPolicyno !=''">
  350. AND a.sy_policyno=#{syPolicyno}
  351. </if>
  352. <if test="noPolicyno !=null and noPolicyno !=''">
  353. AND a.no_policyno=#{noPolicyno}
  354. </if>
  355. <if test="isOther !=null and isOther !=''">
  356. and a.is_not_documentary =#{isOther}
  357. </if>
  358. </where>
  359. </select>
  360. <select id="findByBxLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  361. select
  362. <include refid="income_com"/>
  363. from ins_ply_income a
  364. <where>
  365. 1=1
  366. <if test="licenseno !=null and licenseno !=''">
  367. AND a.licenseno=#{licenseno}
  368. </if>
  369. <if test="policyno !=null and policyno !=''">
  370. AND a.policyno=#{policyno}
  371. </if>
  372. <if test="syPolicyno !=null and syPolicyno !=''">
  373. AND a.sy_policyno=#{syPolicyno}
  374. </if>
  375. <if test="noPolicyno !=null and noPolicyno !=''">
  376. AND a.no_policyno=#{noPolicyno}
  377. </if>
  378. <if test="isOther !=null and isOther !=''">
  379. and a.is_not_documentary =#{isOther}
  380. </if>
  381. <if test="isNotCar !=null and isNotCar !=''">
  382. and a.is_not_car =#{isNotCar}
  383. </if>
  384. </where>
  385. </select>
  386. <select id="totalAmount" resultType="java.util.HashMap">
  387. select
  388. COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
  389. COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
  390. COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
  391. from ins_ply_income a
  392. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  393. <where>
  394. 1=1
  395. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  396. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  397. </if>
  398. <if test="agreementType !=null and agreementType !=''">
  399. and pa.agreement_type =#{agreementType}
  400. </if>
  401. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  402. and a.signdate between #{signDateStart} and #{signDateEnd}
  403. </if>
  404. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  405. and a.handling_fees_status =#{handlingFeesStatus}
  406. </if>
  407. <if test="orderno !=null and orderno !=''">
  408. and a.orderno =#{orderno}
  409. </if>
  410. <if test="policyno !=null and policyno !=''">
  411. and a.policyno =#{policyno}
  412. </if>
  413. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  414. and a.documentary_fees_status =#{documentaryFeesStatus}
  415. </if>
  416. <if test="selectIds != null and selectIds != '' and selectIds.size() > 0">
  417. and a.id in
  418. <foreach collection="selectIds" item="item" open="(" separator="," close=")">
  419. #{item}
  420. </foreach>
  421. </if>
  422. <if test="isNotCar !=null and isNotCar !=''">
  423. and a.is_not_car =#{isNotCar}
  424. </if>
  425. <if test="isOther !=null and isOther !=''">
  426. and a.is_not_documentary =#{isOther}
  427. </if>
  428. <if test="licenseno != null and licenseno != '' and licenseno.length > 0">
  429. and a.licenseno in
  430. <foreach collection="licenseno" item="item" open="(" separator="," close=")">
  431. #{item}
  432. </foreach>
  433. </if>
  434. <if test="policyno != null and policyno != '' ">
  435. and a.policyno =#{policyno}
  436. </if>
  437. <if test="syPolicyno != null and syPolicyno != '' ">
  438. and a.sy_policyno =#{syPolicyno}
  439. </if>
  440. <if test="noPolicyno != null and noPolicyno != ''">
  441. and a.no_policyno =#{noPolicyno}
  442. </if>
  443. <if test="signdate !=null and signdate !=''">
  444. and a.signdate =#{signdate}
  445. </if>
  446. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  447. and a.partner_companies_id =#{partnerCompaniesId}
  448. </if>
  449. <if test="createTime !=null and createTime !=''">
  450. a.create_time =#{createTime}
  451. </if>
  452. <if test="settlementTime !=null and settlementTime !=''">
  453. a.settlement_time =#{settlementTime}
  454. </if>
  455. <if test="userId !=null and userId !=''">
  456. and a.userId =#{userId}
  457. </if>
  458. <if test="companyId !=null and companyId !=''">
  459. and a.company_id =#{companyId}
  460. </if>
  461. <if test="riskcode !=null and riskcode !=''">
  462. and a.riskcode =#{riskcode}
  463. </if>
  464. <if test="year !=null and year !=''">
  465. AND YEAR(a.signdate) =#{year}
  466. </if>
  467. <if test="month !=null and month !=''">
  468. AND month(a.signdate) =#{month}
  469. </if>
  470. <if test="day !=null and day !=''">
  471. AND day(a.signdate) =#{day}
  472. </if>
  473. </where>
  474. </select>
  475. <select id="bxTotalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  476. SELECT
  477. SUM(a.commission_feevalue) AS commissionFeevalue,
  478. SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
  479. SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
  480. SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
  481. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
  482. SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
  483. FROM
  484. ins_ply_income a
  485. LEFT JOIN
  486. ptl_agreement pa ON pa.id = a.agreement_id
  487. <where>
  488. 1=1
  489. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  490. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  491. </if>
  492. <if test="agreementType !=null and agreementType !=''">
  493. and pa.agreement_type =#{agreementType}
  494. </if>
  495. <if test="orderno !=null and orderno !=''">
  496. and a.orderno =#{orderno}
  497. </if>
  498. <if test="companyName !=null and companyName !=''">
  499. and a.company_id =#{companyName}
  500. </if>
  501. <if test="signDateEnd !=null and signDateEnd!='' and signDateStart !=null and signDateStart !=''">
  502. and a.signdate between #{signDateStart} and #{signDateEnd}
  503. </if>
  504. <if test="policyno !=null and policyno !=''">
  505. and a.policyno =#{policyno}
  506. </if>
  507. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  508. and a.handling_fees_status =#{handlingFeesStatus}
  509. </if>
  510. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  511. and a.documentary_fees_status =#{documentaryFeesStatus}
  512. </if>
  513. <if test="isNotCar !=null and isNotCar !=''">
  514. and a.is_not_car =#{isNotCar}
  515. </if>
  516. <if test="isOther !=null and isOther !=''">
  517. and a.is_not_documentary =#{isOther}
  518. </if>
  519. <if test="licenseno != null and licenseno != '' ">
  520. and a.licenseno =#{licenseno}
  521. </if>
  522. <if test="syPolicyno != null and syPolicyno != '' ">
  523. and a.sy_policyno =#{syPolicyno}
  524. </if>
  525. <if test="noPolicyno != null and noPolicyno != ''">
  526. and a.no_policyno =#{noPolicyno}
  527. </if>
  528. <if test="signdate !=null and signdate !=''">
  529. AND a.signdate =#{signdate}
  530. </if>
  531. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  532. AND a.partner_companies_id =#{partnerCompaniesId}
  533. </if>
  534. <if test="createTime !=null and createTime !=''">
  535. AND a.create_time =#{createTime}
  536. </if>
  537. <if test="settlementTime !=null and settlementTime !=''">
  538. AND a.settlement_time =#{settlementTime}
  539. </if>
  540. <if test="partnerCompaniesName !=null and partnerCompaniesName !=''">
  541. AND a.partner_companies_name =#{partnerCompaniesName}
  542. </if>
  543. <if test="userId !=null and userId !=''">
  544. and a.userId =#{userId}
  545. </if>
  546. <if test="companyId !=null and companyId !=''">
  547. and a.company_id =#{companyId}
  548. </if>
  549. <if test="riskcode !=null and riskcode !=''">
  550. and a.riskcode =#{riskcode}
  551. </if>
  552. <if test="year !=null and year !=''">
  553. AND YEAR(a.signdate) =#{year}
  554. </if>
  555. <if test="month !=null and month !=''">
  556. AND month(a.signdate) =#{month}
  557. </if>
  558. <if test="day !=null and day !=''">
  559. AND day(a.signdate) =#{day}
  560. </if>
  561. <if test="insuredName !=null and insuredName !=''">
  562. AND a.insured_name =#{insuredName}
  563. </if>
  564. </where>
  565. </select>
  566. <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  567. select
  568. MAX( ec.name ) AS "companyName",
  569. sum( a.commission_feevalue ) AS "commissionFeevalue",
  570. sum( a.other_feevalue ) AS "otherFeevalue",
  571. SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
  572. GROUP_CONCAT(a.id) as "ids",
  573. MAX( a.partner_companies_name) as "partnerCompaniesName",
  574. MAX(pa.docking_person) as "dockingPerson",
  575. a.agreement_id AS "agreementId"
  576. from ins_ply_income a
  577. LEFT JOIN esm_ins_company ec on ec.id= a.company_id
  578. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  579. <where>
  580. 1=1
  581. <if test="agreementType !=null and agreementType!='' ">
  582. AND pa.agreement_type =#{agreementType}
  583. </if>
  584. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  585. AND a.documentary_fees_status = #{documentaryFeesStatus}
  586. </if>
  587. <if test="handlingFeesStatus != null and handlingFeesStatus != ''">
  588. AND handling_fees_status = #{handlingFeesStatus}
  589. </if>
  590. <if test="year !=null and year !=''">
  591. AND YEAR(a.signdate) =#{year}
  592. </if>
  593. <if test="month !=null and month !=''">
  594. AND month(a.signdate) =#{month}
  595. </if>
  596. <if test="day !=null and day !=''">
  597. AND day(a.signdate) =#{day}
  598. </if>
  599. </where>
  600. GROUP BY a.agreement_id
  601. </select>
  602. <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  603. select
  604. sum(a.commission_feevalue) as "commissionFeevalue",
  605. sum(a.invoic_amount) as "invoicAmount"
  606. from ins_ply_income a
  607. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  608. <where>
  609. 1=1
  610. <if test="startDate !=null and startDate!='' and endDate !=null and endDate !=''">
  611. and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
  612. </if>
  613. <if test="agreementType !=null and agreementType !=''">
  614. and pa.agreement_type =#{agreementType}
  615. </if>
  616. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  617. and a.handling_fees_status =#{handlingFeesStatus}
  618. </if>
  619. <if test="orderno !=null and orderno !=''">
  620. and a.orderno =#{orderno}
  621. </if>
  622. <if test="policyno !=null and policyno !=''">
  623. and a.policyno =#{policyno}
  624. </if>
  625. <if test="documentaryFeesStatus !=null and documentaryFeesStatus !=''">
  626. and a.documentary_fees_status =#{documentaryFeesStatus}
  627. </if>
  628. <if test="isNotCar !=null and isNotCar !=''">
  629. and a.is_not_car =#{isNotCar}
  630. </if>
  631. <if test="isOther !=null and isOther !=''">
  632. and a.is_not_documentary =#{isOther}
  633. </if>
  634. <if test="licenseno != null and licenseno != ''">
  635. and a.licenseno =#{licenseno}
  636. </if>
  637. <if test="syPolicyno != null and syPolicyno != ''">
  638. and a.sy_policyno =#{syPolicyno}
  639. </if>
  640. <if test="noPolicyno != null and noPolicyno != ''">
  641. and a.no_policyno =#{noPolicyno}
  642. </if>
  643. <if test="signdate !=null and signdate !=''">
  644. and a.signdate =#{signdate}
  645. </if>
  646. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  647. and a.partner_companies_id =#{partnerCompaniesId}
  648. </if>
  649. <if test="createTime !=null and createTime !=''">
  650. and a.create_time =#{createTime}
  651. </if>
  652. <if test="settlementTime !=null and settlementTime !=''">
  653. and a.settlement_time =#{settlementTime}
  654. </if>
  655. <if test="userId !=null and userId !=''">
  656. and a.userId =#{userId}
  657. </if>
  658. <if test="companyId !=null and companyId !=''">
  659. and a.company_id =#{companyId}
  660. </if>
  661. <if test="riskcode !=null and riskcode !=''">
  662. and a.riskcode =#{riskcode}
  663. </if>
  664. <if test="year !=null and year !=''">
  665. AND YEAR(a.signdate) =#{year}
  666. </if>
  667. <if test="month !=null and month !=''">
  668. AND month(a.signdate) =#{month}
  669. </if>
  670. <if test="day !=null and day !=''">
  671. AND day(a.signdate) =#{day}
  672. </if>
  673. </where>
  674. </select>
  675. <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  676. SELECT
  677. a.partner_companies_id AS "partnerCompaniesId",
  678. MAX( a.company_name ) AS "companyName",
  679. MAX( a.company_id ) AS "companyId",
  680. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  681. IFNULL ( max(c.settleMentAmount),0.00) as "allInvoicCommissionFeevalue",
  682. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  683. IFNULL ( max(d.settleMentAmount),0.00) as "invoicCommissionFeevalue",
  684. sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  685. sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  686. sum( a.commission_feevalue ) AS "commissionFeevalue"
  687. FROM
  688. ins_ply_income a
  689. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  690. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  691. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  692. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  693. and a.handling_fees_status ='0'
  694. <if test="isNotCar !=null and isNotCar !=''">
  695. and a.is_not_car =#{isNotCar}
  696. </if>
  697. GROUP BY partner_companies_id
  698. ) c ON c.partnerCompaniesId = a.partner_companies_id
  699. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  700. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  701. WHERE ( a.settlement_status = '1')
  702. and a.handling_fees_status ='0'
  703. <if test="isNotCar !=null and isNotCar !=''">
  704. and a.is_not_car =#{isNotCar}
  705. </if>
  706. GROUP BY partner_companies_id
  707. ) d ON d.partnerCompaniesId = a.partner_companies_id
  708. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  709. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  710. WHERE a.settlement_status = '2'
  711. and a.handling_fees_status ='0'
  712. <if test="isNotCar !=null and isNotCar !=''">
  713. and a.is_not_car =#{isNotCar}
  714. </if>
  715. GROUP BY partner_companies_id
  716. ) f ON f.partnerCompaniesId = a.partner_companies_id
  717. <where>
  718. 1=1
  719. <if test="agreementType !=null and agreementType!='' ">
  720. AND pa.agreement_type =#{agreementType}
  721. </if>
  722. <if test="year !=null and year !=''">
  723. AND YEAR(a.signdate) =#{year}
  724. </if>
  725. <if test="isOther !=null and isOther !=''">
  726. and a.is_not_documentary =#{isOther}
  727. </if>
  728. <if test="isNotCar !=null and isNotCar !=''">
  729. and a.is_not_car =#{isNotCar}
  730. </if>
  731. <if test="month !=null and month !=''">
  732. AND month(a.signdate) =#{month}
  733. </if>
  734. <if test="day !=null and day !=''">
  735. AND day(a.signdate) =#{day}
  736. </if>
  737. </where>
  738. GROUP BY a.partner_companies_id
  739. </select>
  740. <select id="getIncomeIdList" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  741. select
  742. a.partner_companies_id AS "partnerCompaniesId",
  743. a.id as "id"
  744. from ins_ply_income a
  745. LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
  746. <where>
  747. 1=1
  748. and a.handling_fees_status ='2'
  749. <if test="agreementType !=null and agreementType!='' ">
  750. AND pa.agreement_type =#{agreementType}
  751. </if>
  752. <if test="year !=null and year !=''">
  753. AND YEAR(a.signdate) =#{year}
  754. </if>
  755. <if test="isOther !=null and isOther !=''">
  756. and a.is_not_documentary =#{isOther}
  757. </if>
  758. <if test="isNotCar !=null and isNotCar !=''">
  759. and a.is_not_car =#{isNotCar}
  760. </if>
  761. <if test="month !=null and month !=''">
  762. AND month(a.signdate) =#{month}
  763. </if>
  764. <if test="day !=null and day !=''">
  765. AND day(a.signdate) =#{day}
  766. </if>
  767. </where>
  768. </select>
  769. <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  770. SELECT
  771. a.partner_companies_id AS "partnerCompaniesId",
  772. MAX( a.company_name ) AS "companyName",
  773. MAX( a.company_id ) AS "companyId",
  774. MAX( a.partner_companies_name ) AS "partnerCompaniesName",
  775. IFNULL ( max(c.settleMentAmount),0.00) as "allInvoicCommissionFeevalue",
  776. IFNULL(max(f.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
  777. IFNULL ( max(d.settleMentAmount),0.00) as "invoicCommissionFeevalue",
  778. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
  779. sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
  780. sum( a.other_feevalue ) AS "otherFeevalue"
  781. FROM
  782. ins_ply_income a
  783. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  784. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  785. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  786. WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
  787. and a.handling_fees_status ='1'
  788. <if test="isNotCar !=null and isNotCar !=''">
  789. and a.is_not_car =#{isNotCar}
  790. </if>
  791. GROUP BY partner_companies_id
  792. ) c ON c.partnerCompaniesId = a.partner_companies_id
  793. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
  794. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  795. WHERE ( a.settlement_status = '1')
  796. and a.handling_fees_status ='1'
  797. <if test="isNotCar !=null and isNotCar !=''">
  798. and a.is_not_car =#{isNotCar}
  799. </if>
  800. GROUP BY partner_companies_id
  801. ) d ON d.partnerCompaniesId = a.partner_companies_id
  802. LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
  803. settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
  804. WHERE a.settlement_status = '2'
  805. and a.handling_fees_status ='1'
  806. <if test="isNotCar !=null and isNotCar !=''">
  807. and a.is_not_car =#{isNotCar}
  808. </if>
  809. GROUP BY partner_companies_id
  810. ) f ON f.partnerCompaniesId = a.partner_companies_id
  811. <where>
  812. 1=1
  813. <if test="agreementType !=null and agreementType!='' ">
  814. AND pa.agreement_type =#{agreementType}
  815. </if>
  816. <if test="year !=null and year !=''">
  817. AND YEAR(a.signdate) =#{year}
  818. </if>
  819. <if test="isOther !=null and isOther !=''">
  820. and a.is_not_documentary =#{isOther}
  821. </if>
  822. <if test="isNotCar !=null and isNotCar !=''">
  823. and a.is_not_car =#{isNotCar}
  824. </if>
  825. <if test="month !=null and month !=''">
  826. AND month(a.signdate) =#{month}
  827. </if>
  828. <if test="day !=null and day !=''">
  829. AND day(a.signdate) =#{day}
  830. </if>
  831. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  832. AND a.documentary_fees_status = #{documentaryFeesStatus}
  833. </if>
  834. </where>
  835. GROUP BY
  836. a.partner_companies_id
  837. </select>
  838. <select id="getOtherIds" resultType="java.util.HashMap">
  839. SELECT
  840. a.id as "id",
  841. a.partner_companies_id AS "partnerCompaniesId"
  842. FROM
  843. ins_ply_income a
  844. LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
  845. <where>
  846. 1=1
  847. <if test="agreementType !=null and agreementType!='' ">
  848. AND pa.agreement_type =#{agreementType}
  849. </if>
  850. <if test="year !=null and year !=''">
  851. AND YEAR(a.signdate) =#{year}
  852. </if>
  853. <if test="isOther !=null and isOther !=''">
  854. and a.is_not_documentary =#{isOther}
  855. </if>
  856. <if test="isNotCar !=null and isNotCar !=''">
  857. and a.is_not_car =#{isNotCar}
  858. </if>
  859. <if test="month !=null and month !=''">
  860. AND month(a.signdate) =#{month}
  861. </if>
  862. <if test="day !=null and day !=''">
  863. AND day(a.signdate) =#{day}
  864. </if>
  865. <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
  866. AND a.documentary_fees_status = #{documentaryFeesStatus}
  867. </if>
  868. </where>
  869. </select>
  870. <select id="getById" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
  871. select
  872. pa.agreement_name as "agreementName",
  873. su.name as "userName",
  874. <include refid="income_com"/>
  875. from ins_ply_income a
  876. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  877. LEFT JOIN sys_user su on su.id=a.user_id
  878. <where>
  879. <if test="id !=null and id !=''">
  880. a.id=#{id}
  881. </if>
  882. </where>
  883. </select>
  884. <select id="groupByInvoic" resultType="java.util.HashMap">
  885. select
  886. sum(a.commission_feevalue) as "invoicCommissionFeevalue",
  887. MAX(invoic_id) as "invoicId",
  888. MAX(invoic_time) as "invoicTime",
  889. GROUP_CONCAT(a.id) as "ids"
  890. from ins_ply_income a
  891. LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
  892. LEFT JOIN sys_user su on su.id=a.user_id
  893. <where>
  894. 1=1
  895. AND a.invoic_id is not null
  896. <if test="idArr !=null and idArr!=''">
  897. a.id IN
  898. <foreach item="item" index="index" collection="idArr" open="(" separator="," close=")">
  899. #{item}
  900. </foreach>
  901. </if>
  902. <if test="agreementType !=null and agreementType!='' ">
  903. AND pa.agreement_type =#{agreementType}
  904. </if>
  905. <if test="year !=null and year !=''">
  906. AND YEAR(a.signdate) =#{year}
  907. </if>
  908. <if test="isOther !=null and isOther !=''">
  909. and a.is_not_documentary =#{isOther}
  910. </if>
  911. <if test="isNotCar !=null and isNotCar !=''">
  912. and a.is_not_car =#{isNotCar}
  913. </if>
  914. <if test="handlingFeesStatus !=null and handlingFeesStatus !=''">
  915. and a.handling_fees_status =#{handlingFeesStatus}
  916. </if>
  917. <if test="month !=null and month !=''">
  918. AND month(a.signdate) =#{month}
  919. </if>
  920. <if test="day !=null and day !=''">
  921. AND day(a.signdate) =#{day}
  922. </if>
  923. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''">
  924. AND a.partner_companies_id =#{partnerCompaniesId}
  925. </if>
  926. </where>
  927. group by a.invoic_id
  928. </select>
  929. </mapper>