| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.jzg.organization.mapper.InsFeeFollowOrderMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.jzg.commons.entity.finance.po.InsFeeFollowOrder">
- <id column="id" property="id" />
- <result column="year" property="year" />
- <result column="month" property="month" />
- <result column="company_id" property="companyId" />
- <result column="partner_company_id" property="partnerCompanyId" />
- <result column="receivable_premium" property="receivablePremium" />
- <result column="signing_time" property="signingTime" />
- <result column="invoiced" property="invoiced" />
- <result column="uninvoiced" property="uninvoiced" />
- <result column="invoiced_amount_time" property="invoicedAmountTime" />
- <result column="reconciliation_amount" property="reconciliationAmount" />
- <result column="falsely_increased_difference" property="falselyIncreasedDifference" />
- <result column="falsely_increased_reason" property="falselyIncreasedReason" />
- <result column="system_code" property="systemCode" />
- <!-- 继承自 BaseModel 的公共字段 -->
- <result column="create_by" property="createBy" />
- <result column="create_time" property="createTime" />
- <result column="update_by" property="updateBy" />
- <result column="update_time" property="updateTime" />
- <result column="is_delete" property="isDelete" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, `year`, `month`, company_id, partner_company_id, receivable_premium,
- signing_time, invoiced, uninvoiced, invoiced_amount_time, reconciliation_amount,
- falsely_increased_difference, falsely_increased_reason, system_code,
- create_by, create_time, update_by, update_time, is_delete
- </sql>
- <!-- 根据主键查询 -->
- <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List" />
- FROM ins_fee_follow_order
- WHERE id = #{id} AND is_delete = 0
- </select>
- <select id="selectFollowCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
- SELECT
- ffo.partner_company_id AS partnerCompanyId,
- ffo.id AS followId,
- ffo.year,
- ffo.month,
- ffo.invoice_type,
- inv.id AS invoiceId,
- sett.id AS settlementId
- FROM ins_fee_follow_order ffo
- -- 跟单订单关联发票中间表
- INNER JOIN ins_ply_follow_invoice_link link
- ON ffo.id = link.follow_id AND link.is_delete = 0
- -- 关联发票主表
- INNER JOIN ins_ply_income_invoice inv
- ON link.invoice_id = inv.id AND inv.is_delete = 0
- -- 左连结算表(无结算数据时金额为0)
- LEFT JOIN ins_ply_income_invoice_settlement sett
- ON inv.id = sett.invoice_id AND sett.is_delete = 0
- <where>
- ffo.is_delete = 0
- -- 保险公司companyId筛选
- <if test="query.companyIdList != null and query.companyIdList.size() > 0" >
- AND ffo.partner_company_id in
- <foreach collection="query.companyIdList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="query.companyId != null and query.companyId != ''" >
- AND ffo.partner_company_id = #{query.companyId}
- </if>
- -- 跟单订单创建时间范围
- <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
- AND ffo.create_time BETWEEN #{query.startTime} AND #{query.endTime}
- </if>
- -- 发票状态筛选
- <if test="query.status != null">
- AND inv.status = #{query.status}
- </if>
- -- 开票时间范围
- <if test="query.invoiceStartTime != null and query.invoiceStartTime != '' and query.invoiceEndTime != null and query.invoiceEndTime != ''">
- AND inv.invoice_time BETWEEN #{query.invoiceStartTime} AND #{query.invoiceEndTime}
- </if>
- -- 结算创建时间范围(子查询过滤结算时间)
- <if test="query.settlementStartTime != null and query.settlementStartTime != '' and query.settlementEndTime != null and query.settlementEndTime != ''">
- AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
- </if>
- </where>
- </select>
- </mapper>
|