InsFeeFollowOrderMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.jzg.organization.mapper.InsFeeFollowOrderMapper">
  6. <!-- 通用查询映射结果 -->
  7. <resultMap id="BaseResultMap" type="com.jzg.commons.entity.finance.po.InsFeeFollowOrder">
  8. <id column="id" property="id" />
  9. <result column="year" property="year" />
  10. <result column="month" property="month" />
  11. <result column="company_id" property="companyId" />
  12. <result column="partner_company_id" property="partnerCompanyId" />
  13. <result column="receivable_premium" property="receivablePremium" />
  14. <result column="signing_time" property="signingTime" />
  15. <result column="invoiced" property="invoiced" />
  16. <result column="uninvoiced" property="uninvoiced" />
  17. <result column="invoiced_amount_time" property="invoicedAmountTime" />
  18. <result column="reconciliation_amount" property="reconciliationAmount" />
  19. <result column="falsely_increased_difference" property="falselyIncreasedDifference" />
  20. <result column="falsely_increased_reason" property="falselyIncreasedReason" />
  21. <result column="system_code" property="systemCode" />
  22. <!-- 继承自 BaseModel 的公共字段 -->
  23. <result column="create_by" property="createBy" />
  24. <result column="create_time" property="createTime" />
  25. <result column="update_by" property="updateBy" />
  26. <result column="update_time" property="updateTime" />
  27. <result column="is_delete" property="isDelete" />
  28. </resultMap>
  29. <!-- 通用查询结果列 -->
  30. <sql id="Base_Column_List">
  31. id, `year`, `month`, company_id, partner_company_id, receivable_premium,
  32. signing_time, invoiced, uninvoiced, invoiced_amount_time, reconciliation_amount,
  33. falsely_increased_difference, falsely_increased_reason, system_code,
  34. create_by, create_time, update_by, update_time, is_delete
  35. </sql>
  36. <!-- 根据主键查询 -->
  37. <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
  38. SELECT
  39. <include refid="Base_Column_List" />
  40. FROM ins_fee_follow_order
  41. WHERE id = #{id} AND is_delete = 0
  42. </select>
  43. <select id="selectFollowCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
  44. SELECT
  45. ffo.partner_company_id AS partnerCompanyId,
  46. ffo.id AS followId,
  47. ffo.year,
  48. ffo.month,
  49. ffo.invoice_type,
  50. inv.id AS invoiceId,
  51. sett.id AS settlementId
  52. FROM ins_fee_follow_order ffo
  53. -- 跟单订单关联发票中间表
  54. INNER JOIN ins_ply_follow_invoice_link link
  55. ON ffo.id = link.follow_id AND link.is_delete = 0
  56. -- 关联发票主表
  57. INNER JOIN ins_ply_income_invoice inv
  58. ON link.invoice_id = inv.id AND inv.is_delete = 0
  59. -- 左连结算表(无结算数据时金额为0)
  60. LEFT JOIN ins_ply_income_invoice_settlement sett
  61. ON inv.id = sett.invoice_id AND sett.is_delete = 0
  62. <where>
  63. ffo.is_delete = 0
  64. -- 保险公司companyId筛选
  65. <if test="query.companyIdList != null and query.companyIdList.size() > 0" >
  66. AND ffo.partner_company_id in
  67. <foreach collection="query.companyIdList" item="item" open="(" separator="," close=")">
  68. #{item}
  69. </foreach>
  70. </if>
  71. <if test="query.companyId != null and query.companyId != ''" >
  72. AND ffo.partner_company_id = #{query.companyId}
  73. </if>
  74. -- 跟单订单创建时间范围
  75. <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
  76. AND ffo.create_time BETWEEN #{query.startTime} AND #{query.endTime}
  77. </if>
  78. -- 发票状态筛选
  79. <if test="query.status != null">
  80. AND inv.status = #{query.status}
  81. </if>
  82. -- 开票时间范围
  83. <if test="query.invoiceStartTime != null and query.invoiceStartTime != '' and query.invoiceEndTime != null and query.invoiceEndTime != ''">
  84. AND inv.invoice_time BETWEEN #{query.invoiceStartTime} AND #{query.invoiceEndTime}
  85. </if>
  86. -- 结算创建时间范围(子查询过滤结算时间)
  87. <if test="query.settlementStartTime != null and query.settlementStartTime != '' and query.settlementEndTime != null and query.settlementEndTime != ''">
  88. AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
  89. </if>
  90. </where>
  91. </select>
  92. </mapper>