<?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.yd.dal.mapper.customer.AclPolicyholderMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclPolicyholder">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="config_level" jdbcType="INTEGER" property="configLevel" />
    <result column="product_id" jdbcType="BIGINT" property="productId" />
    <result column="plan_id" jdbcType="BIGINT" property="planId" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="policy_unit_price" jdbcType="DECIMAL" property="policyUnitPrice" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="agent_relation" jdbcType="VARCHAR" property="agentRelation" />
    <result column="has_ai_confirmed" jdbcType="INTEGER" property="hasAiConfirmed" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="is_social_insured" jdbcType="INTEGER" property="isSocialInsured" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="english_name" jdbcType="VARCHAR" property="englishName" />
    <result column="mobile_no" jdbcType="VARCHAR" property="mobileNo" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="underwrite_question_id" jdbcType="VARCHAR" property="underwriteQuestionId" />
    <result column="province_id" jdbcType="BIGINT" property="provinceId" />
    <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
    <result column="district_id" jdbcType="BIGINT" property="districtId" />
    <result column="district_name" jdbcType="VARCHAR" property="districtName" />
    <result column="city_id" jdbcType="BIGINT" property="cityId" />
    <result column="city_name" jdbcType="VARCHAR" property="cityName" />
    <result column="birth_province_id" jdbcType="BIGINT" property="birthProvinceId" />
    <result column="birth_province_name" jdbcType="VARCHAR" property="birthProvinceName" />
    <result column="birth_city_id" jdbcType="BIGINT" property="birthCityId" />
    <result column="birth_city_name" jdbcType="VARCHAR" property="birthCityName" />
    <result column="birth_district_id" jdbcType="BIGINT" property="birthDistrictId" />
    <result column="birth_district_name" jdbcType="VARCHAR" property="birthDistrictName" />
    <result column="birth_address" jdbcType="VARCHAR" property="birthAddress" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="occupation_id" jdbcType="BIGINT" property="occupationId" />
    <result column="occupation_name" jdbcType="VARCHAR" property="occupationName" />
    <result column="id_type_id" jdbcType="BIGINT" property="idTypeId" />
    <result column="id_type" jdbcType="VARCHAR" property="idType" />
    <result column="id_no" jdbcType="VARCHAR" property="idNo" />
    <result column="gender" jdbcType="INTEGER" property="gender" />
    <result column="relation_id" jdbcType="BIGINT" property="relationId" />
    <result column="relation_type" jdbcType="VARCHAR" property="relationType" />
    <result column="birth_date" jdbcType="DATE" property="birthDate" />
    <result column="insured_seq" jdbcType="INTEGER" property="insuredSeq" />
    <result column="flag" jdbcType="VARCHAR" property="flag" />
    <result column="insuree_height" jdbcType="DECIMAL" property="insureeHeight" />
    <result column="insuree_weight" jdbcType="DECIMAL" property="insureeWeight" />
    <result column="insuree_total" jdbcType="INTEGER" property="insureeTotal" />
    <result column="is_id_longterm" jdbcType="INTEGER" property="isIdLongterm" />
    <result column="id_effective_from" jdbcType="DATE" property="idEffectiveFrom" />
    <result column="id_effective_to" jdbcType="DATE" property="idEffectiveTo" />
    <result column="bank_id" jdbcType="BIGINT" property="bankId" />
    <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
    <result column="bank_holder" jdbcType="VARCHAR" property="bankHolder" />
    <result column="bank_no" jdbcType="VARCHAR" property="bankNo" />
    <result column="bank_mobile_no" jdbcType="VARCHAR" property="bankMobileNo" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
    <result column="id_areamap_id" jdbcType="BIGINT" property="idAreamapId" />
    <result column="id_areamap" jdbcType="VARCHAR" property="idAreamap" />
    <result column="resident_tax_type" jdbcType="INTEGER" property="residentTaxType" />
    <result column="id_card_front" jdbcType="VARCHAR" property="idCardFront" />
    <result column="id_card_back" jdbcType="VARCHAR" property="idCardBack" />
    <result column="salary_type" jdbcType="VARCHAR" property="salaryType" />
    <result column="salary" jdbcType="DECIMAL" property="salary" />
    <result column="bank_city_id" jdbcType="BIGINT" property="bankCityId" />
    <result column="id_no_back" jdbcType="VARCHAR" property="idNoBack" />
    <result column="post_code" jdbcType="VARCHAR" property="postCode" />
    <result column="contact_name" jdbcType="VARCHAR" property="contactName" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.yd.dal.entity.customer.AclPolicyholder">
    <result column="remark" jdbcType="LONGVARCHAR" property="remark" />
  </resultMap>
  <sql id="Base_Column_List">
    id, config_level, product_id, plan_id, customer_id, order_id, policy_unit_price, 
    `type`, agent_relation, has_ai_confirmed, `status`, is_social_insured, `name`, english_name, 
    mobile_no, email, underwrite_question_id, province_id, province_name, district_id, 
    district_name, city_id, city_name, birth_province_id, birth_province_name, birth_city_id, 
    birth_city_name, birth_district_id, birth_district_name, birth_address, address, 
    occupation_id, occupation_name, id_type_id, id_type, id_no, gender, relation_id, 
    relation_type, birth_date, insured_seq, flag, insuree_height, insuree_weight, insuree_total, 
    is_id_longterm, id_effective_from, id_effective_to, bank_id, bank_name, bank_holder, 
    bank_no, bank_mobile_no, created_at, created_by, updated_at, updated_by, id_areamap_id, 
    id_areamap, resident_tax_type, id_card_front, id_card_back, salary_type, salary, 
    bank_city_id, id_no_back, post_code, contact_name
  </sql>
  <sql id="Blob_Column_List">
    remark
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from ag_acl_policyholder
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_policyholder
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPolicyholder" useGeneratedKeys="true">
    insert into ag_acl_policyholder (config_level, product_id, plan_id, 
      customer_id, order_id, policy_unit_price, 
      `type`, agent_relation, has_ai_confirmed, 
      `status`, is_social_insured, `name`, 
      english_name, mobile_no, email, 
      underwrite_question_id, province_id, province_name, 
      district_id, district_name, city_id, 
      city_name, birth_province_id, birth_province_name, 
      birth_city_id, birth_city_name, birth_district_id, 
      birth_district_name, birth_address, address, 
      occupation_id, occupation_name, id_type_id, 
      id_type, id_no, gender, 
      relation_id, relation_type, birth_date, 
      insured_seq, flag, insuree_height, 
      insuree_weight, insuree_total, is_id_longterm, 
      id_effective_from, id_effective_to, bank_id, 
      bank_name, bank_holder, bank_no, 
      bank_mobile_no, created_at, created_by, 
      updated_at, updated_by, id_areamap_id, 
      id_areamap, resident_tax_type, id_card_front, 
      id_card_back, salary_type, salary, 
      bank_city_id, id_no_back, post_code, 
      contact_name, remark)
    values (#{configLevel,jdbcType=INTEGER}, #{productId,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, 
      #{customerId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{policyUnitPrice,jdbcType=DECIMAL}, 
      #{type,jdbcType=INTEGER}, #{agentRelation,jdbcType=VARCHAR}, #{hasAiConfirmed,jdbcType=INTEGER}, 
      #{status,jdbcType=INTEGER}, #{isSocialInsured,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
      #{englishName,jdbcType=VARCHAR}, #{mobileNo,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, 
      #{underwriteQuestionId,jdbcType=VARCHAR}, #{provinceId,jdbcType=BIGINT}, #{provinceName,jdbcType=VARCHAR}, 
      #{districtId,jdbcType=BIGINT}, #{districtName,jdbcType=VARCHAR}, #{cityId,jdbcType=BIGINT}, 
      #{cityName,jdbcType=VARCHAR}, #{birthProvinceId,jdbcType=BIGINT}, #{birthProvinceName,jdbcType=VARCHAR}, 
      #{birthCityId,jdbcType=BIGINT}, #{birthCityName,jdbcType=VARCHAR}, #{birthDistrictId,jdbcType=BIGINT}, 
      #{birthDistrictName,jdbcType=VARCHAR}, #{birthAddress,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, 
      #{occupationId,jdbcType=BIGINT}, #{occupationName,jdbcType=VARCHAR}, #{idTypeId,jdbcType=BIGINT}, 
      #{idType,jdbcType=VARCHAR}, #{idNo,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER}, 
      #{relationId,jdbcType=BIGINT}, #{relationType,jdbcType=VARCHAR}, #{birthDate,jdbcType=DATE}, 
      #{insuredSeq,jdbcType=INTEGER}, #{flag,jdbcType=VARCHAR}, #{insureeHeight,jdbcType=DECIMAL}, 
      #{insureeWeight,jdbcType=DECIMAL}, #{insureeTotal,jdbcType=INTEGER}, #{isIdLongterm,jdbcType=INTEGER}, 
      #{idEffectiveFrom,jdbcType=DATE}, #{idEffectiveTo,jdbcType=DATE}, #{bankId,jdbcType=BIGINT}, 
      #{bankName,jdbcType=VARCHAR}, #{bankHolder,jdbcType=VARCHAR}, #{bankNo,jdbcType=VARCHAR}, 
      #{bankMobileNo,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, 
      #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}, #{idAreamapId,jdbcType=BIGINT}, 
      #{idAreamap,jdbcType=VARCHAR}, #{residentTaxType,jdbcType=INTEGER}, #{idCardFront,jdbcType=VARCHAR}, 
      #{idCardBack,jdbcType=VARCHAR}, #{salaryType,jdbcType=VARCHAR}, #{salary,jdbcType=DECIMAL}, 
      #{bankCityId,jdbcType=BIGINT}, #{idNoBack,jdbcType=VARCHAR}, #{postCode,jdbcType=VARCHAR}, 
      #{contactName,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPolicyholder" useGeneratedKeys="true">
    insert into ag_acl_policyholder
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="configLevel != null">
        config_level,
      </if>
      <if test="productId != null">
        product_id,
      </if>
      <if test="planId != null">
        plan_id,
      </if>
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="policyUnitPrice != null">
        policy_unit_price,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="agentRelation != null">
        agent_relation,
      </if>
      <if test="hasAiConfirmed != null">
        has_ai_confirmed,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="isSocialInsured != null">
        is_social_insured,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="englishName != null">
        english_name,
      </if>
      <if test="mobileNo != null">
        mobile_no,
      </if>
      <if test="email != null">
        email,
      </if>
      <if test="underwriteQuestionId != null">
        underwrite_question_id,
      </if>
      <if test="provinceId != null">
        province_id,
      </if>
      <if test="provinceName != null">
        province_name,
      </if>
      <if test="districtId != null">
        district_id,
      </if>
      <if test="districtName != null">
        district_name,
      </if>
      <if test="cityId != null">
        city_id,
      </if>
      <if test="cityName != null">
        city_name,
      </if>
      <if test="birthProvinceId != null">
        birth_province_id,
      </if>
      <if test="birthProvinceName != null">
        birth_province_name,
      </if>
      <if test="birthCityId != null">
        birth_city_id,
      </if>
      <if test="birthCityName != null">
        birth_city_name,
      </if>
      <if test="birthDistrictId != null">
        birth_district_id,
      </if>
      <if test="birthDistrictName != null">
        birth_district_name,
      </if>
      <if test="birthAddress != null">
        birth_address,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="occupationId != null">
        occupation_id,
      </if>
      <if test="occupationName != null">
        occupation_name,
      </if>
      <if test="idTypeId != null">
        id_type_id,
      </if>
      <if test="idType != null">
        id_type,
      </if>
      <if test="idNo != null">
        id_no,
      </if>
      <if test="gender != null">
        gender,
      </if>
      <if test="relationId != null">
        relation_id,
      </if>
      <if test="relationType != null">
        relation_type,
      </if>
      <if test="birthDate != null">
        birth_date,
      </if>
      <if test="insuredSeq != null">
        insured_seq,
      </if>
      <if test="flag != null">
        flag,
      </if>
      <if test="insureeHeight != null">
        insuree_height,
      </if>
      <if test="insureeWeight != null">
        insuree_weight,
      </if>
      <if test="insureeTotal != null">
        insuree_total,
      </if>
      <if test="isIdLongterm != null">
        is_id_longterm,
      </if>
      <if test="idEffectiveFrom != null">
        id_effective_from,
      </if>
      <if test="idEffectiveTo != null">
        id_effective_to,
      </if>
      <if test="bankId != null">
        bank_id,
      </if>
      <if test="bankName != null">
        bank_name,
      </if>
      <if test="bankHolder != null">
        bank_holder,
      </if>
      <if test="bankNo != null">
        bank_no,
      </if>
      <if test="bankMobileNo != null">
        bank_mobile_no,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="idAreamapId != null">
        id_areamap_id,
      </if>
      <if test="idAreamap != null">
        id_areamap,
      </if>
      <if test="residentTaxType != null">
        resident_tax_type,
      </if>
      <if test="idCardFront != null">
        id_card_front,
      </if>
      <if test="idCardBack != null">
        id_card_back,
      </if>
      <if test="salaryType != null">
        salary_type,
      </if>
      <if test="salary != null">
        salary,
      </if>
      <if test="bankCityId != null">
        bank_city_id,
      </if>
      <if test="idNoBack != null">
        id_no_back,
      </if>
      <if test="postCode != null">
        post_code,
      </if>
      <if test="contactName != null">
        contact_name,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="configLevel != null">
        #{configLevel,jdbcType=INTEGER},
      </if>
      <if test="productId != null">
        #{productId,jdbcType=BIGINT},
      </if>
      <if test="planId != null">
        #{planId,jdbcType=BIGINT},
      </if>
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="policyUnitPrice != null">
        #{policyUnitPrice,jdbcType=DECIMAL},
      </if>
      <if test="type != null">
        #{type,jdbcType=INTEGER},
      </if>
      <if test="agentRelation != null">
        #{agentRelation,jdbcType=VARCHAR},
      </if>
      <if test="hasAiConfirmed != null">
        #{hasAiConfirmed,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="isSocialInsured != null">
        #{isSocialInsured,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="englishName != null">
        #{englishName,jdbcType=VARCHAR},
      </if>
      <if test="mobileNo != null">
        #{mobileNo,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        #{email,jdbcType=VARCHAR},
      </if>
      <if test="underwriteQuestionId != null">
        #{underwriteQuestionId,jdbcType=VARCHAR},
      </if>
      <if test="provinceId != null">
        #{provinceId,jdbcType=BIGINT},
      </if>
      <if test="provinceName != null">
        #{provinceName,jdbcType=VARCHAR},
      </if>
      <if test="districtId != null">
        #{districtId,jdbcType=BIGINT},
      </if>
      <if test="districtName != null">
        #{districtName,jdbcType=VARCHAR},
      </if>
      <if test="cityId != null">
        #{cityId,jdbcType=BIGINT},
      </if>
      <if test="cityName != null">
        #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="birthProvinceId != null">
        #{birthProvinceId,jdbcType=BIGINT},
      </if>
      <if test="birthProvinceName != null">
        #{birthProvinceName,jdbcType=VARCHAR},
      </if>
      <if test="birthCityId != null">
        #{birthCityId,jdbcType=BIGINT},
      </if>
      <if test="birthCityName != null">
        #{birthCityName,jdbcType=VARCHAR},
      </if>
      <if test="birthDistrictId != null">
        #{birthDistrictId,jdbcType=BIGINT},
      </if>
      <if test="birthDistrictName != null">
        #{birthDistrictName,jdbcType=VARCHAR},
      </if>
      <if test="birthAddress != null">
        #{birthAddress,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="occupationId != null">
        #{occupationId,jdbcType=BIGINT},
      </if>
      <if test="occupationName != null">
        #{occupationName,jdbcType=VARCHAR},
      </if>
      <if test="idTypeId != null">
        #{idTypeId,jdbcType=BIGINT},
      </if>
      <if test="idType != null">
        #{idType,jdbcType=VARCHAR},
      </if>
      <if test="idNo != null">
        #{idNo,jdbcType=VARCHAR},
      </if>
      <if test="gender != null">
        #{gender,jdbcType=INTEGER},
      </if>
      <if test="relationId != null">
        #{relationId,jdbcType=BIGINT},
      </if>
      <if test="relationType != null">
        #{relationType,jdbcType=VARCHAR},
      </if>
      <if test="birthDate != null">
        #{birthDate,jdbcType=DATE},
      </if>
      <if test="insuredSeq != null">
        #{insuredSeq,jdbcType=INTEGER},
      </if>
      <if test="flag != null">
        #{flag,jdbcType=VARCHAR},
      </if>
      <if test="insureeHeight != null">
        #{insureeHeight,jdbcType=DECIMAL},
      </if>
      <if test="insureeWeight != null">
        #{insureeWeight,jdbcType=DECIMAL},
      </if>
      <if test="insureeTotal != null">
        #{insureeTotal,jdbcType=INTEGER},
      </if>
      <if test="isIdLongterm != null">
        #{isIdLongterm,jdbcType=INTEGER},
      </if>
      <if test="idEffectiveFrom != null">
        #{idEffectiveFrom,jdbcType=DATE},
      </if>
      <if test="idEffectiveTo != null">
        #{idEffectiveTo,jdbcType=DATE},
      </if>
      <if test="bankId != null">
        #{bankId,jdbcType=BIGINT},
      </if>
      <if test="bankName != null">
        #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="bankHolder != null">
        #{bankHolder,jdbcType=VARCHAR},
      </if>
      <if test="bankNo != null">
        #{bankNo,jdbcType=VARCHAR},
      </if>
      <if test="bankMobileNo != null">
        #{bankMobileNo,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
      <if test="idAreamapId != null">
        #{idAreamapId,jdbcType=BIGINT},
      </if>
      <if test="idAreamap != null">
        #{idAreamap,jdbcType=VARCHAR},
      </if>
      <if test="residentTaxType != null">
        #{residentTaxType,jdbcType=INTEGER},
      </if>
      <if test="idCardFront != null">
        #{idCardFront,jdbcType=VARCHAR},
      </if>
      <if test="idCardBack != null">
        #{idCardBack,jdbcType=VARCHAR},
      </if>
      <if test="salaryType != null">
        #{salaryType,jdbcType=VARCHAR},
      </if>
      <if test="salary != null">
        #{salary,jdbcType=DECIMAL},
      </if>
      <if test="bankCityId != null">
        #{bankCityId,jdbcType=BIGINT},
      </if>
      <if test="idNoBack != null">
        #{idNoBack,jdbcType=VARCHAR},
      </if>
      <if test="postCode != null">
        #{postCode,jdbcType=VARCHAR},
      </if>
      <if test="contactName != null">
        #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclPolicyholder">
    update ag_acl_policyholder
    <set>
      <if test="configLevel != null">
        config_level = #{configLevel,jdbcType=INTEGER},
      </if>
      <if test="productId != null">
        product_id = #{productId,jdbcType=BIGINT},
      </if>
      <if test="planId != null">
        plan_id = #{planId,jdbcType=BIGINT},
      </if>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="policyUnitPrice != null">
        policy_unit_price = #{policyUnitPrice,jdbcType=DECIMAL},
      </if>
      <if test="type != null">
        `type` = #{type,jdbcType=INTEGER},
      </if>
      <if test="agentRelation != null">
        agent_relation = #{agentRelation,jdbcType=VARCHAR},
      </if>
      <if test="hasAiConfirmed != null">
        has_ai_confirmed = #{hasAiConfirmed,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="isSocialInsured != null">
        is_social_insured = #{isSocialInsured,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="englishName != null">
        english_name = #{englishName,jdbcType=VARCHAR},
      </if>
      <if test="mobileNo != null">
        mobile_no = #{mobileNo,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="underwriteQuestionId != null">
        underwrite_question_id = #{underwriteQuestionId,jdbcType=VARCHAR},
      </if>
      <if test="provinceId != null">
        province_id = #{provinceId,jdbcType=BIGINT},
      </if>
      <if test="provinceName != null">
        province_name = #{provinceName,jdbcType=VARCHAR},
      </if>
      <if test="districtId != null">
        district_id = #{districtId,jdbcType=BIGINT},
      </if>
      <if test="districtName != null">
        district_name = #{districtName,jdbcType=VARCHAR},
      </if>
      <if test="cityId != null">
        city_id = #{cityId,jdbcType=BIGINT},
      </if>
      <if test="cityName != null">
        city_name = #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="birthProvinceId != null">
        birth_province_id = #{birthProvinceId,jdbcType=BIGINT},
      </if>
      <if test="birthProvinceName != null">
        birth_province_name = #{birthProvinceName,jdbcType=VARCHAR},
      </if>
      <if test="birthCityId != null">
        birth_city_id = #{birthCityId,jdbcType=BIGINT},
      </if>
      <if test="birthCityName != null">
        birth_city_name = #{birthCityName,jdbcType=VARCHAR},
      </if>
      <if test="birthDistrictId != null">
        birth_district_id = #{birthDistrictId,jdbcType=BIGINT},
      </if>
      <if test="birthDistrictName != null">
        birth_district_name = #{birthDistrictName,jdbcType=VARCHAR},
      </if>
      <if test="birthAddress != null">
        birth_address = #{birthAddress,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="occupationId != null">
        occupation_id = #{occupationId,jdbcType=BIGINT},
      </if>
      <if test="occupationName != null">
        occupation_name = #{occupationName,jdbcType=VARCHAR},
      </if>
      <if test="idTypeId != null">
        id_type_id = #{idTypeId,jdbcType=BIGINT},
      </if>
      <if test="idType != null">
        id_type = #{idType,jdbcType=VARCHAR},
      </if>
      <if test="idNo != null">
        id_no = #{idNo,jdbcType=VARCHAR},
      </if>
      <if test="gender != null">
        gender = #{gender,jdbcType=INTEGER},
      </if>
      <if test="relationId != null">
        relation_id = #{relationId,jdbcType=BIGINT},
      </if>
      <if test="relationType != null">
        relation_type = #{relationType,jdbcType=VARCHAR},
      </if>
      <if test="birthDate != null">
        birth_date = #{birthDate,jdbcType=DATE},
      </if>
      <if test="insuredSeq != null">
        insured_seq = #{insuredSeq,jdbcType=INTEGER},
      </if>
      <if test="flag != null">
        flag = #{flag,jdbcType=VARCHAR},
      </if>
      <if test="insureeHeight != null">
        insuree_height = #{insureeHeight,jdbcType=DECIMAL},
      </if>
      <if test="insureeWeight != null">
        insuree_weight = #{insureeWeight,jdbcType=DECIMAL},
      </if>
      <if test="insureeTotal != null">
        insuree_total = #{insureeTotal,jdbcType=INTEGER},
      </if>
      <if test="isIdLongterm != null">
        is_id_longterm = #{isIdLongterm,jdbcType=INTEGER},
      </if>
      <if test="idEffectiveFrom != null">
        id_effective_from = #{idEffectiveFrom,jdbcType=DATE},
      </if>
      <if test="idEffectiveTo != null">
        id_effective_to = #{idEffectiveTo,jdbcType=DATE},
      </if>
      <if test="bankId != null">
        bank_id = #{bankId,jdbcType=BIGINT},
      </if>
      <if test="bankName != null">
        bank_name = #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="bankHolder != null">
        bank_holder = #{bankHolder,jdbcType=VARCHAR},
      </if>
      <if test="bankNo != null">
        bank_no = #{bankNo,jdbcType=VARCHAR},
      </if>
      <if test="bankMobileNo != null">
        bank_mobile_no = #{bankMobileNo,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
      <if test="idAreamapId != null">
        id_areamap_id = #{idAreamapId,jdbcType=BIGINT},
      </if>
      <if test="idAreamap != null">
        id_areamap = #{idAreamap,jdbcType=VARCHAR},
      </if>
      <if test="residentTaxType != null">
        resident_tax_type = #{residentTaxType,jdbcType=INTEGER},
      </if>
      <if test="idCardFront != null">
        id_card_front = #{idCardFront,jdbcType=VARCHAR},
      </if>
      <if test="idCardBack != null">
        id_card_back = #{idCardBack,jdbcType=VARCHAR},
      </if>
      <if test="salaryType != null">
        salary_type = #{salaryType,jdbcType=VARCHAR},
      </if>
      <if test="salary != null">
        salary = #{salary,jdbcType=DECIMAL},
      </if>
      <if test="bankCityId != null">
        bank_city_id = #{bankCityId,jdbcType=BIGINT},
      </if>
      <if test="idNoBack != null">
        id_no_back = #{idNoBack,jdbcType=VARCHAR},
      </if>
      <if test="postCode != null">
        post_code = #{postCode,jdbcType=VARCHAR},
      </if>
      <if test="contactName != null">
        contact_name = #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.yd.dal.entity.customer.AclPolicyholder">
    update ag_acl_policyholder
    set config_level = #{configLevel,jdbcType=INTEGER},
      product_id = #{productId,jdbcType=BIGINT},
      plan_id = #{planId,jdbcType=BIGINT},
      customer_id = #{customerId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      policy_unit_price = #{policyUnitPrice,jdbcType=DECIMAL},
      `type` = #{type,jdbcType=INTEGER},
      agent_relation = #{agentRelation,jdbcType=VARCHAR},
      has_ai_confirmed = #{hasAiConfirmed,jdbcType=INTEGER},
      `status` = #{status,jdbcType=INTEGER},
      is_social_insured = #{isSocialInsured,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      english_name = #{englishName,jdbcType=VARCHAR},
      mobile_no = #{mobileNo,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      underwrite_question_id = #{underwriteQuestionId,jdbcType=VARCHAR},
      province_id = #{provinceId,jdbcType=BIGINT},
      province_name = #{provinceName,jdbcType=VARCHAR},
      district_id = #{districtId,jdbcType=BIGINT},
      district_name = #{districtName,jdbcType=VARCHAR},
      city_id = #{cityId,jdbcType=BIGINT},
      city_name = #{cityName,jdbcType=VARCHAR},
      birth_province_id = #{birthProvinceId,jdbcType=BIGINT},
      birth_province_name = #{birthProvinceName,jdbcType=VARCHAR},
      birth_city_id = #{birthCityId,jdbcType=BIGINT},
      birth_city_name = #{birthCityName,jdbcType=VARCHAR},
      birth_district_id = #{birthDistrictId,jdbcType=BIGINT},
      birth_district_name = #{birthDistrictName,jdbcType=VARCHAR},
      birth_address = #{birthAddress,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      occupation_id = #{occupationId,jdbcType=BIGINT},
      occupation_name = #{occupationName,jdbcType=VARCHAR},
      id_type_id = #{idTypeId,jdbcType=BIGINT},
      id_type = #{idType,jdbcType=VARCHAR},
      id_no = #{idNo,jdbcType=VARCHAR},
      gender = #{gender,jdbcType=INTEGER},
      relation_id = #{relationId,jdbcType=BIGINT},
      relation_type = #{relationType,jdbcType=VARCHAR},
      birth_date = #{birthDate,jdbcType=DATE},
      insured_seq = #{insuredSeq,jdbcType=INTEGER},
      flag = #{flag,jdbcType=VARCHAR},
      insuree_height = #{insureeHeight,jdbcType=DECIMAL},
      insuree_weight = #{insureeWeight,jdbcType=DECIMAL},
      insuree_total = #{insureeTotal,jdbcType=INTEGER},
      is_id_longterm = #{isIdLongterm,jdbcType=INTEGER},
      id_effective_from = #{idEffectiveFrom,jdbcType=DATE},
      id_effective_to = #{idEffectiveTo,jdbcType=DATE},
      bank_id = #{bankId,jdbcType=BIGINT},
      bank_name = #{bankName,jdbcType=VARCHAR},
      bank_holder = #{bankHolder,jdbcType=VARCHAR},
      bank_no = #{bankNo,jdbcType=VARCHAR},
      bank_mobile_no = #{bankMobileNo,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT},
      id_areamap_id = #{idAreamapId,jdbcType=BIGINT},
      id_areamap = #{idAreamap,jdbcType=VARCHAR},
      resident_tax_type = #{residentTaxType,jdbcType=INTEGER},
      id_card_front = #{idCardFront,jdbcType=VARCHAR},
      id_card_back = #{idCardBack,jdbcType=VARCHAR},
      salary_type = #{salaryType,jdbcType=VARCHAR},
      salary = #{salary,jdbcType=DECIMAL},
      bank_city_id = #{bankCityId,jdbcType=BIGINT},
      id_no_back = #{idNoBack,jdbcType=VARCHAR},
      post_code = #{postCode,jdbcType=VARCHAR},
      contact_name = #{contactName,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclPolicyholder">
    update ag_acl_policyholder
    set config_level = #{configLevel,jdbcType=INTEGER},
      product_id = #{productId,jdbcType=BIGINT},
      plan_id = #{planId,jdbcType=BIGINT},
      customer_id = #{customerId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      policy_unit_price = #{policyUnitPrice,jdbcType=DECIMAL},
      `type` = #{type,jdbcType=INTEGER},
      agent_relation = #{agentRelation,jdbcType=VARCHAR},
      has_ai_confirmed = #{hasAiConfirmed,jdbcType=INTEGER},
      `status` = #{status,jdbcType=INTEGER},
      is_social_insured = #{isSocialInsured,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      english_name = #{englishName,jdbcType=VARCHAR},
      mobile_no = #{mobileNo,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      underwrite_question_id = #{underwriteQuestionId,jdbcType=VARCHAR},
      province_id = #{provinceId,jdbcType=BIGINT},
      province_name = #{provinceName,jdbcType=VARCHAR},
      district_id = #{districtId,jdbcType=BIGINT},
      district_name = #{districtName,jdbcType=VARCHAR},
      city_id = #{cityId,jdbcType=BIGINT},
      city_name = #{cityName,jdbcType=VARCHAR},
      birth_province_id = #{birthProvinceId,jdbcType=BIGINT},
      birth_province_name = #{birthProvinceName,jdbcType=VARCHAR},
      birth_city_id = #{birthCityId,jdbcType=BIGINT},
      birth_city_name = #{birthCityName,jdbcType=VARCHAR},
      birth_district_id = #{birthDistrictId,jdbcType=BIGINT},
      birth_district_name = #{birthDistrictName,jdbcType=VARCHAR},
      birth_address = #{birthAddress,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      occupation_id = #{occupationId,jdbcType=BIGINT},
      occupation_name = #{occupationName,jdbcType=VARCHAR},
      id_type_id = #{idTypeId,jdbcType=BIGINT},
      id_type = #{idType,jdbcType=VARCHAR},
      id_no = #{idNo,jdbcType=VARCHAR},
      gender = #{gender,jdbcType=INTEGER},
      relation_id = #{relationId,jdbcType=BIGINT},
      relation_type = #{relationType,jdbcType=VARCHAR},
      birth_date = #{birthDate,jdbcType=DATE},
      insured_seq = #{insuredSeq,jdbcType=INTEGER},
      flag = #{flag,jdbcType=VARCHAR},
      insuree_height = #{insureeHeight,jdbcType=DECIMAL},
      insuree_weight = #{insureeWeight,jdbcType=DECIMAL},
      insuree_total = #{insureeTotal,jdbcType=INTEGER},
      is_id_longterm = #{isIdLongterm,jdbcType=INTEGER},
      id_effective_from = #{idEffectiveFrom,jdbcType=DATE},
      id_effective_to = #{idEffectiveTo,jdbcType=DATE},
      bank_id = #{bankId,jdbcType=BIGINT},
      bank_name = #{bankName,jdbcType=VARCHAR},
      bank_holder = #{bankHolder,jdbcType=VARCHAR},
      bank_no = #{bankNo,jdbcType=VARCHAR},
      bank_mobile_no = #{bankMobileNo,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT},
      id_areamap_id = #{idAreamapId,jdbcType=BIGINT},
      id_areamap = #{idAreamap,jdbcType=VARCHAR},
      resident_tax_type = #{residentTaxType,jdbcType=INTEGER},
      id_card_front = #{idCardFront,jdbcType=VARCHAR},
      id_card_back = #{idCardBack,jdbcType=VARCHAR},
      salary_type = #{salaryType,jdbcType=VARCHAR},
      salary = #{salary,jdbcType=DECIMAL},
      bank_city_id = #{bankCityId,jdbcType=BIGINT},
      id_no_back = #{idNoBack,jdbcType=VARCHAR},
      post_code = #{postCode,jdbcType=VARCHAR},
      contact_name = #{contactName,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="findByOrderId" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from ag_acl_policyholder
    where order_id = #{orderId,jdbcType=BIGINT}
  </select>

  <resultMap id="customerHolder" type="com.yd.api.practitioner.vo.practitionerCustomer.CustomerHolder">
    <result column="id" jdbcType="BIGINT" property="customerId"/>
    <result column="name" jdbcType="VARCHAR" property="name"/>
    <result column="mobile_no" jdbcType="VARCHAR" property="mobileNo" typeHandler="com.yd.util.deshandler.DESTypeHandler"/>
    <result column="gender" jdbcType="VARCHAR" property="gender"/>
    <result column="birth_date" jdbcType="VARCHAR" property="birthDate"/>
    <result column="relation_type" jdbcType="VARCHAR" property="relationType"/>
  </resultMap>
  <select id="queryThisPractitiionerAllPolicyHolderList" resultMap="customerHolder">
    select  c.id,
            c.name,
            c.mobile_no ,
            (case c.gender when 1 then '男' when 2 then '女'  else c.gender END) gender,
            c.birth_date
    from
    (select  distinct t.customer_id
      from ag_acl_policyholder t
      left join ag_po_order o on o.id = t.order_id
      where 1 = 1
      and o.status = 3
      and t.type = 2
      and t.order_id in
      <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
        #{item}
      </foreach>
    ) h left join ag_acl_customer c on h.customer_id = c.id
  </select>

  <select id="queryInsuredListByHolderCustomerId" resultMap="customerHolder">
    select
        c.customer_id id,
        c.name,
        c.mobile_no ,
        (case c.gender when 1 then '男' when 2 then '女'  else c.gender END) gender,
        c.birth_date,
        c.relation_type
	from
		(select h.name, h.id_type_id, h.id_no, max(h.id) id
			from ag_acl_policyholder h
			left join ag_po_order o on o.id = h.order_id
			left join ag_acl_customer_fortune f on o.id = f.order_id and f.drop_option_code = 'S01'
			where h.type = 3
			and o.status = 3
			and f.customer_id = #{practitionerCustomerId,jdbcType=BIGINT}
			and h.order_id in
			(select t1.order_id from ag_acl_policyholder t1 where t1.customer_id = #{holderCustomerId,jdbcType=BIGINT} and t1.type = 2)
			GROUP BY h.name, h.id_type_id, h.id_no
		) t
	left join ag_acl_policyholder c on t.id = c.id
  </select>

  <sql id="customerPolicyInfoFields">
    o.id as orderId,
    o.order_no as orderNo ,
    o.policy_no as policyNo ,
    p.name as holderName,
    o.destination as destination,
    date_format(o.order_date, '%Y-%m-%d %H:%i:%s') as orderDate,
    date_format(o.effective_start_date, '%Y-%m-%d %H:%i:%s') as startDate,
    date_format(o.effective_end_date, '%Y-%m-%d %H:%i:%s') as endDate,
    o.order_price as orderPrice,
    o.plan_id as planId,
    o.product_id as productId ,
    IF(o.effective_end_date &gt;= NOW(),'有效','无效') isValid,
    a.name planName,
    b.name productName
  </sql>
  <select id="queryPolicyListByHolderCustomerId" resultType="com.yd.dal.entity.order.CustomerPolicyInfo">
    SELECT
    <include refid="customerPolicyInfoFields"/>
    FROM ag_po_order o
    inner JOIN ag_acl_customer_fortune f
            ON o.id = f.order_id and f.drop_option_code = 'S01' and o.status = 3 and o.order_price &gt; 0 and o.insurer_id != 888 and o.policy_no is not null
    inner JOIN ag_acl_policyholder p ON o.id = p.order_id and p.type = 2
    left join ag_product_plan a on o.plan_id = a.id
    left join ag_product b on o.product_id = b.id
    WHERE 1=1
        and p.customer_id = #{holderCustomerId,jdbcType=BIGINT}
        and f.customer_id = #{practitionerCustomerId,jdbcType=BIGINT}

    UNION ALL

    SELECT
    <include refid="customerPolicyInfoFields"/>
    FROM
    (select o.*
        from  ag_po_quotation_vehicle_relation v
        left join ag_po_order o on o.quotation_id = v.quotation_id
        where v.customer_id = #{practitionerCustomerId,jdbcType=BIGINT}
    ) o
    inner JOIN ag_acl_policyholder p ON o.id = p.order_id and p.type = 2
    left join ag_product_plan a on o.plan_id = a.id
    left join ag_product b on o.product_id = b.id
    WHERE 1=1
        and p.customer_id = #{holderCustomerId,jdbcType=BIGINT}
  </select>

  <select id="queryUsefulInfo" resultMap="customerHolder">
      select  h.customer_id id,
              h.name,
              h.mobile_no ,
              (case h.gender when 1 then '男' when 2 then '女'  else h.gender END) gender,
              h.birth_date,
              h.relation_type
      from ag_acl_policyholder h
      where h.name is not null and h.birth_date is not null and h.relation_type is not null
      <if test="customerId != null">
        and h.customer_id = #{customerId,jdbcType=BIGINT}
      </if>
      <if test="type != null">
        and h.type = #{type,jdbcType=INTEGER}
      </if>
      limit 0,1
  </select>

</mapper>