<?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.ltgk.boat.mapper.DsBoatInsuranceMapper">
    <select id="getBoatInsuranceList" resultType="com.ltgk.boat.domain.entity.DsBoatInsurance">
        SELECT
        ins.id,
        ins.boat_id,
        ins.boat_name,
        ins.insurance_type,
        ins.insurance_code,
        ins.insurance_company,
        ins.insurance_status,
        ins.issue_date,
        ins.insurance_start_time,
        ins.insurance_end_time,
        ins.total_insurance_amount,
        ins.total_insurance_premiums,
        ins.insurance_holder,
        ins.holder_phone,
        ins.insurance_beneficiary,
        ins.beneficiary_phone,
        ins.picture,
        ins.create_by,
        ins.create_at,
        ins.update_by,
        ins.update_at,
        ins.del_flag,
        ins.remark
        FROM
        ds_boat_insurance AS ins
        INNER JOIN ds_boat_data AS bd ON bd.boat_name = ins.boat_name
        WHERE
        ins.del_flag =0
        <if test="params.boatName != null and params.boatName != ''">
            and ins.boat_name like concat('%',#{params.boatName},'%')
        </if>
        <if test="params.insuranceType != null and params.insuranceType != ''">
            and ins.insurance_type like concat('%',#{params.insuranceType},'%')
        </if>
        <if test="params.insuranceStatus != null and params.insuranceStatus != ''">
            and ins.insurance_status like concat('%',#{params.insuranceStatus},'%')
        </if>
        <if test="params.operatorUserId != null and params.operatorUserId != ''">
            and bd.operator_user_id = #{params.operatorUserId}
        </if>
        order by ins.update_at desc
    </select>

    <select id="selectCount" resultType="java.lang.Long">
        SELECT count(id)
        FROM ds_boat_insurance
        WHERE del_flag = 0
          and insurance_end_time &lt;= #{date}
    </select>

    <select id="getBoatInsuranceOverDueList" resultType="com.ltgk.boat.domain.vo.BoatInsuranceOverDueVo">
        select ins.boat_name as boatName,ins.insurance_type as insuranceType,ins.insurance_code as insuranceCode,
        ins.insurance_company as insuranceCompany,ins.insurance_status as insuranceStatus,ins.insurance_start_time as
        insuranceStartTime,
        ins.insurance_end_time as insuranceEndTime,ins.insurance_holder as insuranceHolder,ins.holder_phone as
        holderPhone,
        ins.insurance_beneficiary as insuranceBeneficiary,ins.beneficiary_phone as beneficiary,
        ins.picture from ds_boat_insurance as ins
        where ins.del_flag = 0 and ins.insurance_end_time &lt; #{date}
        <if test="boatName != null and boatName != ''">
            and ins.boat_name like concat('%',#{boatName},'%')
        </if>
        <if test="insuranceType != null and insuranceType != ''">
            and ins.insurance_type like concat('%',#{insuranceType},'%')
        </if>
    </select>
</mapper>