<?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.order.PoOrderMapper">
    <resultMap id="BaseResultMap" type="com.yd.dal.entity.order.PoOrder">
        <!--@mbg.generated-->
        <!--@Table ag_po_order-->
        <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="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="order_date" jdbcType="TIMESTAMP" property="orderDate"/>
        <result column="order_price" jdbcType="DECIMAL" property="orderPrice"/>
        <result column="quotation_id" jdbcType="BIGINT" property="quotationId"/>
        <result column="quote_no" jdbcType="BIGINT" property="quoteNo"/>
        <result column="product_category_id" jdbcType="BIGINT" property="productCategoryId"/>
        <result column="destination" jdbcType="VARCHAR" property="destination"/>
        <result column="destination_continent_id" jdbcType="BIGINT" property="destinationContinentId"/>
        <result column="destination_region_id" jdbcType="BIGINT" property="destinationRegionId"/>
        <result column="destination_country_id" jdbcType="BIGINT" property="destinationCountryId"/>
        <result column="effective_start_date" jdbcType="TIMESTAMP" property="effectiveStartDate"/>
        <result column="effective_end_date" jdbcType="TIMESTAMP" property="effectiveEndDate"/>
        <result column="cover_length" jdbcType="INTEGER" property="coverLength"/>
        <result column="cover_adult_qty" jdbcType="INTEGER" property="coverAdultQty"/>
        <result column="cover_underage_qty" jdbcType="INTEGER" property="coverUnderageQty"/>
        <result column="payment_method_id" jdbcType="BIGINT" property="paymentMethodId"/>
        <result column="pay_url" jdbcType="VARCHAR" property="payUrl"/>
        <result column="pay_from" jdbcType="INTEGER" property="payFrom"/>
        <result column="insurer_pdf_url" jdbcType="VARCHAR" property="insurerPdfUrl"/>
        <result column="is_msg_sent" jdbcType="INTEGER" property="isMsgSent"/>
        <result column="is_car_tax" jdbcType="INTEGER" property="isCarTax"/>
        <result column="commission_rate" jdbcType="DECIMAL" property="commissionRate"/>
        <result column="commission_amount" jdbcType="DECIMAL" property="commissionAmount"/>
        <result column="fyc_rate" jdbcType="DECIMAL" property="fycRate"/>
        <result column="fyc_amount" jdbcType="DECIMAL" property="fycAmount"/>
        <result column="b2c_rate" jdbcType="DECIMAL" property="b2cRate"/>
        <result column="grade_commission_rate" jdbcType="DECIMAL" property="gradeCommissionRate"/>
        <result column="referral_rate" jdbcType="DECIMAL" property="referralRate"/>
        <result column="referral_amount" jdbcType="DECIMAL" property="referralAmount"/>
        <result column="policy_id" jdbcType="BIGINT" property="policyId"/>
        <result column="policy_no" jdbcType="VARCHAR" property="policyNo"/>
        <result column="mkt_campaign" jdbcType="VARCHAR" property="mktCampaign"/>
        <result column="mkt_task" jdbcType="VARCHAR" property="mktTask"/>
        <result column="is_converted" jdbcType="INTEGER" property="isConverted"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="payment_status" jdbcType="INTEGER" property="paymentStatus"/>
        <result column="flag" jdbcType="VARCHAR" property="flag"/>
        <result column="customer_id" jdbcType="BIGINT" property="customerId"/>
        <result column="referral_customer_id" jdbcType="BIGINT" property="referralCustomerId"/>
        <result column="share_code" jdbcType="VARCHAR" property="shareCode"/>
        <result column="insurer_id" jdbcType="BIGINT" property="insurerId"/>
        <result column="data_source" jdbcType="VARCHAR" property="dataSource"/>
        <result column="is_social_insured" jdbcType="INTEGER" property="isSocialInsured"/>
        <result column="cover_term" jdbcType="INTEGER" property="coverTerm"/>
        <result column="payment_term" jdbcType="INTEGER" property="paymentTerm"/>
        <result column="payment_term_unit" jdbcType="VARCHAR" property="paymentTermUnit"/>
        <result column="pay_interval" jdbcType="INTEGER" property="payInterval"/>
        <result column="view_flag" jdbcType="VARCHAR" property="viewFlag"/>
        <result column="dynamic_field_a" jdbcType="VARCHAR" property="dynamicFieldA"/>
        <result column="dynamic_field_b" jdbcType="VARCHAR" property="dynamicFieldB"/>
        <result column="dynamic_field_c" jdbcType="VARCHAR" property="dynamicFieldC"/>
        <result column="dynamic_field_d" jdbcType="VARCHAR" property="dynamicFieldD"/>
        <result column="plate_no" jdbcType="VARCHAR" property="plateNo"/>
        <result column="memo" jdbcType="LONGVARCHAR" property="memo"/>
        <result column="product_table_request_json" jdbcType="LONGVARCHAR" property="productTableRequestJson"/>
        <result column="verified_seats" jdbcType="INTEGER" property="verifiedSeats"/>
        <result column="frame_no" jdbcType="VARCHAR" property="frameNo"/>
        <result column="subject_province_id" jdbcType="BIGINT" property="subjectProvinceId"/>
        <result column="subject_city_id" jdbcType="BIGINT" property="subjectCityId"/>
        <result column="subject_address" jdbcType="VARCHAR" property="subjectAddress"/>
        <result column="room_qty" jdbcType="VARCHAR" property="roomQty"/>
        <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="source_channel" jdbcType="VARCHAR" property="sourceChannel"/>
        <result column="source_plan_name" jdbcType="VARCHAR" property="sourcePlanName"/>
        <result column="source_publishdate" jdbcType="VARCHAR" property="sourcePublishdate"/>
        <result column="source_article" jdbcType="VARCHAR" property="sourceArticle"/>
        <result column="ip_address" jdbcType="VARCHAR" property="ipAddress"/>
        <result column="ip_region" jdbcType="VARCHAR" property="ipRegion"/>
        <result column="renew_order_id" jdbcType="BIGINT" property="renewOrderId"/>
        <result column="is_renew_complete" jdbcType="INTEGER" property="isRenewComplete"/>
        <result column="is_pay_to_yd" jdbcType="INTEGER" property="isPayToYd"/>
        <result column="auto_pay_flag" jdbcType="VARCHAR" property="autoPayFlag"/>
        <result column="commission_check_id" jdbcType="BIGINT" property="commissionCheckId"/>
        <result column="commission_check_status" jdbcType="VARCHAR" property="commissionCheckStatus"/>
        <result column="commission_check_at" jdbcType="TIMESTAMP" property="commissionCheckAt"/>
        <result column="commission_check_by" jdbcType="BIGINT" property="commissionCheckBy"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, config_level, product_id, plan_id, order_no, order_date, order_price, quotation_id,
        quote_no, product_category_id, destination, destination_continent_id, destination_region_id,
        destination_country_id, effective_start_date, effective_end_date, cover_length, cover_adult_qty,
        cover_underage_qty, payment_method_id, pay_url, pay_from, insurer_pdf_url, is_msg_sent,
        is_car_tax, commission_rate, commission_amount, fyc_rate, fyc_amount,
        b2c_rate, grade_commission_rate, referral_rate, referral_amount, policy_id, policy_no,
        mkt_campaign, mkt_task, is_converted, `status`, payment_status, flag, customer_id,
        referral_customer_id, share_code, insurer_id, data_source, is_social_insured, cover_term,
        payment_term, payment_term_unit, pay_interval, view_flag, dynamic_field_a, dynamic_field_b,
        dynamic_field_c, dynamic_field_d, plate_no, memo, product_table_request_json, verified_seats,
        frame_no, subject_province_id, subject_city_id, subject_address, room_qty, created_at,
        created_by, updated_at, updated_by, source_channel, source_plan_name, source_publishdate,
        source_article, ip_address, ip_region, renew_order_id, is_renew_complete, is_pay_to_yd,
        auto_pay_flag, commission_check_id, commission_check_status, commission_check_at, commission_check_by
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from ag_po_order
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete from ag_po_order
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.order.PoOrder"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into ag_po_order (config_level, product_id, plan_id,
        order_no, order_date, order_price,
        quotation_id, quote_no, product_category_id,
        destination, destination_continent_id, destination_region_id,
        destination_country_id, effective_start_date,
        effective_end_date, cover_length, cover_adult_qty,
        cover_underage_qty, payment_method_id, pay_url,
        pay_from, insurer_pdf_url, is_msg_sent,
        is_car_tax, commission_rate,
        commission_amount, fyc_rate, fyc_amount,
        b2c_rate, grade_commission_rate, referral_rate,
        referral_amount, policy_id, policy_no,
        mkt_campaign, mkt_task, is_converted,
        `status`, payment_status, flag,
        customer_id, referral_customer_id, share_code,
        insurer_id, data_source, is_social_insured,
        cover_term, payment_term, payment_term_unit,
        pay_interval, view_flag, dynamic_field_a,
        dynamic_field_b, dynamic_field_c, dynamic_field_d,
        plate_no, memo, product_table_request_json,
        verified_seats, frame_no, subject_province_id,
        subject_city_id, subject_address, room_qty,
        created_at, created_by, updated_at,
        updated_by, source_channel, source_plan_name,
        source_publishdate, source_article, ip_address,
        ip_region, renew_order_id, is_renew_complete,
        is_pay_to_yd, auto_pay_flag)
        values (#{configLevel,jdbcType=INTEGER}, #{productId,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT},
        #{orderNo,jdbcType=VARCHAR}, #{orderDate,jdbcType=TIMESTAMP}, #{orderPrice,jdbcType=DECIMAL},
        #{quotationId,jdbcType=BIGINT}, #{quoteNo,jdbcType=BIGINT}, #{productCategoryId,jdbcType=BIGINT},
        #{destination,jdbcType=VARCHAR}, #{destinationContinentId,jdbcType=BIGINT},
        #{destinationRegionId,jdbcType=BIGINT},
        #{destinationCountryId,jdbcType=BIGINT}, #{effectiveStartDate,jdbcType=TIMESTAMP},
        #{effectiveEndDate,jdbcType=TIMESTAMP}, #{coverLength,jdbcType=INTEGER}, #{coverAdultQty,jdbcType=INTEGER},
        #{coverUnderageQty,jdbcType=INTEGER}, #{paymentMethodId,jdbcType=BIGINT}, #{payUrl,jdbcType=VARCHAR},
        #{payFrom,jdbcType=INTEGER}, #{insurerPdfUrl,jdbcType=VARCHAR}, #{isMsgSent,jdbcType=INTEGER},
        #{isCarTax,jdbcType=INTEGER}, #{ydValueAddedTax,jdbcType=DECIMAL}, #{commissionRate,jdbcType=DECIMAL},
        #{commissionAmount,jdbcType=DECIMAL}, #{fycRate,jdbcType=DECIMAL}, #{fycAmount,jdbcType=DECIMAL},
        #{b2cRate,jdbcType=DECIMAL}, #{gradeCommissionRate,jdbcType=DECIMAL}, #{referralRate,jdbcType=DECIMAL},
        #{referralAmount,jdbcType=DECIMAL}, #{policyId,jdbcType=BIGINT}, #{policyNo,jdbcType=VARCHAR},
        #{mktCampaign,jdbcType=VARCHAR}, #{mktTask,jdbcType=VARCHAR}, #{isConverted,jdbcType=INTEGER},
        #{status,jdbcType=INTEGER}, #{paymentStatus,jdbcType=INTEGER}, #{flag,jdbcType=VARCHAR},
        #{customerId,jdbcType=BIGINT}, #{referralCustomerId,jdbcType=BIGINT}, #{shareCode,jdbcType=VARCHAR},
        #{insurerId,jdbcType=BIGINT}, #{dataSource,jdbcType=VARCHAR}, #{isSocialInsured,jdbcType=INTEGER},
        #{coverTerm,jdbcType=INTEGER}, #{paymentTerm,jdbcType=INTEGER}, #{paymentTermUnit,jdbcType=VARCHAR},
        #{payInterval,jdbcType=INTEGER}, #{viewFlag,jdbcType=VARCHAR}, #{dynamicFieldA,jdbcType=VARCHAR},
        #{dynamicFieldB,jdbcType=VARCHAR}, #{dynamicFieldC,jdbcType=VARCHAR}, #{dynamicFieldD,jdbcType=VARCHAR},
        #{plateNo,jdbcType=VARCHAR}, #{memo,jdbcType=LONGVARCHAR}, #{productTableRequestJson,jdbcType=LONGVARCHAR},
        #{verifiedSeats,jdbcType=INTEGER}, #{frameNo,jdbcType=VARCHAR}, #{subjectProvinceId,jdbcType=BIGINT},
        #{subjectCityId,jdbcType=BIGINT}, #{subjectAddress,jdbcType=VARCHAR}, #{roomQty,jdbcType=VARCHAR},
        #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP},
        #{updatedBy,jdbcType=BIGINT}, #{sourceChannel,jdbcType=VARCHAR}, #{sourcePlanName,jdbcType=VARCHAR},
        #{sourcePublishdate,jdbcType=VARCHAR}, #{sourceArticle,jdbcType=VARCHAR}, #{ipAddress,jdbcType=VARCHAR},
        #{ipRegion,jdbcType=VARCHAR}, #{renewOrderId,jdbcType=BIGINT}, #{isRenewComplete,jdbcType=INTEGER},
        #{isPayToYd,jdbcType=INTEGER}, #{autoPayFlag,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.order.PoOrder"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into ag_po_order
        <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="orderNo != null">
                order_no,
            </if>
            <if test="orderDate != null">
                order_date,
            </if>
            <if test="orderPrice != null">
                order_price,
            </if>
            <if test="quotationId != null">
                quotation_id,
            </if>
            <if test="quoteNo != null">
                quote_no,
            </if>
            <if test="productCategoryId != null">
                product_category_id,
            </if>
            <if test="destination != null">
                destination,
            </if>
            <if test="destinationContinentId != null">
                destination_continent_id,
            </if>
            <if test="destinationRegionId != null">
                destination_region_id,
            </if>
            <if test="destinationCountryId != null">
                destination_country_id,
            </if>
            <if test="effectiveStartDate != null">
                effective_start_date,
            </if>
            <if test="effectiveEndDate != null">
                effective_end_date,
            </if>
            <if test="coverLength != null">
                cover_length,
            </if>
            <if test="coverAdultQty != null">
                cover_adult_qty,
            </if>
            <if test="coverUnderageQty != null">
                cover_underage_qty,
            </if>
            <if test="paymentMethodId != null">
                payment_method_id,
            </if>
            <if test="payUrl != null">
                pay_url,
            </if>
            <if test="payFrom != null">
                pay_from,
            </if>
            <if test="insurerPdfUrl != null">
                insurer_pdf_url,
            </if>
            <if test="isMsgSent != null">
                is_msg_sent,
            </if>
            <if test="isCarTax != null">
                is_car_tax,
            </if>
            <if test="commissionRate != null">
                commission_rate,
            </if>
            <if test="commissionAmount != null">
                commission_amount,
            </if>
            <if test="fycRate != null">
                fyc_rate,
            </if>
            <if test="fycAmount != null">
                fyc_amount,
            </if>
            <if test="b2cRate != null">
                b2c_rate,
            </if>
            <if test="gradeCommissionRate != null">
                grade_commission_rate,
            </if>
            <if test="referralRate != null">
                referral_rate,
            </if>
            <if test="referralAmount != null">
                referral_amount,
            </if>
            <if test="policyId != null">
                policy_id,
            </if>
            <if test="policyNo != null">
                policy_no,
            </if>
            <if test="mktCampaign != null">
                mkt_campaign,
            </if>
            <if test="mktTask != null">
                mkt_task,
            </if>
            <if test="isConverted != null">
                is_converted,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="paymentStatus != null">
                payment_status,
            </if>
            <if test="flag != null">
                flag,
            </if>
            <if test="customerId != null">
                customer_id,
            </if>
            <if test="referralCustomerId != null">
                referral_customer_id,
            </if>
            <if test="shareCode != null">
                share_code,
            </if>
            <if test="insurerId != null">
                insurer_id,
            </if>
            <if test="dataSource != null">
                data_source,
            </if>
            <if test="isSocialInsured != null">
                is_social_insured,
            </if>
            <if test="coverTerm != null">
                cover_term,
            </if>
            <if test="paymentTerm != null">
                payment_term,
            </if>
            <if test="paymentTermUnit != null">
                payment_term_unit,
            </if>
            <if test="payInterval != null">
                pay_interval,
            </if>
            <if test="viewFlag != null">
                view_flag,
            </if>
            <if test="dynamicFieldA != null">
                dynamic_field_a,
            </if>
            <if test="dynamicFieldB != null">
                dynamic_field_b,
            </if>
            <if test="dynamicFieldC != null">
                dynamic_field_c,
            </if>
            <if test="dynamicFieldD != null">
                dynamic_field_d,
            </if>
            <if test="plateNo != null">
                plate_no,
            </if>
            <if test="memo != null">
                memo,
            </if>
            <if test="productTableRequestJson != null">
                product_table_request_json,
            </if>
            <if test="verifiedSeats != null">
                verified_seats,
            </if>
            <if test="frameNo != null">
                frame_no,
            </if>
            <if test="subjectProvinceId != null">
                subject_province_id,
            </if>
            <if test="subjectCityId != null">
                subject_city_id,
            </if>
            <if test="subjectAddress != null">
                subject_address,
            </if>
            <if test="roomQty != null">
                room_qty,
            </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="sourceChannel != null">
                source_channel,
            </if>
            <if test="sourcePlanName != null">
                source_plan_name,
            </if>
            <if test="sourcePublishdate != null">
                source_publishdate,
            </if>
            <if test="sourceArticle != null">
                source_article,
            </if>
            <if test="ipAddress != null">
                ip_address,
            </if>
            <if test="ipRegion != null">
                ip_region,
            </if>
            <if test="renewOrderId != null">
                renew_order_id,
            </if>
            <if test="isRenewComplete != null">
                is_renew_complete,
            </if>
            <if test="isPayToYd != null">
                is_pay_to_yd,
            </if>
            <if test="autoPayFlag != null">
                auto_pay_flag,
            </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="orderNo != null">
                #{orderNo,jdbcType=VARCHAR},
            </if>
            <if test="orderDate != null">
                #{orderDate,jdbcType=TIMESTAMP},
            </if>
            <if test="orderPrice != null">
                #{orderPrice,jdbcType=DECIMAL},
            </if>
            <if test="quotationId != null">
                #{quotationId,jdbcType=BIGINT},
            </if>
            <if test="quoteNo != null">
                #{quoteNo,jdbcType=BIGINT},
            </if>
            <if test="productCategoryId != null">
                #{productCategoryId,jdbcType=BIGINT},
            </if>
            <if test="destination != null">
                #{destination,jdbcType=VARCHAR},
            </if>
            <if test="destinationContinentId != null">
                #{destinationContinentId,jdbcType=BIGINT},
            </if>
            <if test="destinationRegionId != null">
                #{destinationRegionId,jdbcType=BIGINT},
            </if>
            <if test="destinationCountryId != null">
                #{destinationCountryId,jdbcType=BIGINT},
            </if>
            <if test="effectiveStartDate != null">
                #{effectiveStartDate,jdbcType=TIMESTAMP},
            </if>
            <if test="effectiveEndDate != null">
                #{effectiveEndDate,jdbcType=TIMESTAMP},
            </if>
            <if test="coverLength != null">
                #{coverLength,jdbcType=INTEGER},
            </if>
            <if test="coverAdultQty != null">
                #{coverAdultQty,jdbcType=INTEGER},
            </if>
            <if test="coverUnderageQty != null">
                #{coverUnderageQty,jdbcType=INTEGER},
            </if>
            <if test="paymentMethodId != null">
                #{paymentMethodId,jdbcType=BIGINT},
            </if>
            <if test="payUrl != null">
                #{payUrl,jdbcType=VARCHAR},
            </if>
            <if test="payFrom != null">
                #{payFrom,jdbcType=INTEGER},
            </if>
            <if test="insurerPdfUrl != null">
                #{insurerPdfUrl,jdbcType=VARCHAR},
            </if>
            <if test="isMsgSent != null">
                #{isMsgSent,jdbcType=INTEGER},
            </if>
            <if test="isCarTax != null">
                #{isCarTax,jdbcType=INTEGER},
            </if>
            <if test="ydValueAddedTax != null">
                #{ydValueAddedTax,jdbcType=DECIMAL},
            </if>
            <if test="commissionRate != null">
                #{commissionRate,jdbcType=DECIMAL},
            </if>
            <if test="commissionAmount != null">
                #{commissionAmount,jdbcType=DECIMAL},
            </if>
            <if test="fycRate != null">
                #{fycRate,jdbcType=DECIMAL},
            </if>
            <if test="fycAmount != null">
                #{fycAmount,jdbcType=DECIMAL},
            </if>
            <if test="b2cRate != null">
                #{b2cRate,jdbcType=DECIMAL},
            </if>
            <if test="gradeCommissionRate != null">
                #{gradeCommissionRate,jdbcType=DECIMAL},
            </if>
            <if test="referralRate != null">
                #{referralRate,jdbcType=DECIMAL},
            </if>
            <if test="referralAmount != null">
                #{referralAmount,jdbcType=DECIMAL},
            </if>
            <if test="policyId != null">
                #{policyId,jdbcType=BIGINT},
            </if>
            <if test="policyNo != null">
                #{policyNo,jdbcType=VARCHAR},
            </if>
            <if test="mktCampaign != null">
                #{mktCampaign,jdbcType=VARCHAR},
            </if>
            <if test="mktTask != null">
                #{mktTask,jdbcType=VARCHAR},
            </if>
            <if test="isConverted != null">
                #{isConverted,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="paymentStatus != null">
                #{paymentStatus,jdbcType=INTEGER},
            </if>
            <if test="flag != null">
                #{flag,jdbcType=VARCHAR},
            </if>
            <if test="customerId != null">
                #{customerId,jdbcType=BIGINT},
            </if>
            <if test="referralCustomerId != null">
                #{referralCustomerId,jdbcType=BIGINT},
            </if>
            <if test="shareCode != null">
                #{shareCode,jdbcType=VARCHAR},
            </if>
            <if test="insurerId != null">
                #{insurerId,jdbcType=BIGINT},
            </if>
            <if test="dataSource != null">
                #{dataSource,jdbcType=VARCHAR},
            </if>
            <if test="isSocialInsured != null">
                #{isSocialInsured,jdbcType=INTEGER},
            </if>
            <if test="coverTerm != null">
                #{coverTerm,jdbcType=INTEGER},
            </if>
            <if test="paymentTerm != null">
                #{paymentTerm,jdbcType=INTEGER},
            </if>
            <if test="paymentTermUnit != null">
                #{paymentTermUnit,jdbcType=VARCHAR},
            </if>
            <if test="payInterval != null">
                #{payInterval,jdbcType=INTEGER},
            </if>
            <if test="viewFlag != null">
                #{viewFlag,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldA != null">
                #{dynamicFieldA,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldB != null">
                #{dynamicFieldB,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldC != null">
                #{dynamicFieldC,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldD != null">
                #{dynamicFieldD,jdbcType=VARCHAR},
            </if>
            <if test="plateNo != null">
                #{plateNo,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                #{memo,jdbcType=LONGVARCHAR},
            </if>
            <if test="productTableRequestJson != null">
                #{productTableRequestJson,jdbcType=LONGVARCHAR},
            </if>
            <if test="verifiedSeats != null">
                #{verifiedSeats,jdbcType=INTEGER},
            </if>
            <if test="frameNo != null">
                #{frameNo,jdbcType=VARCHAR},
            </if>
            <if test="subjectProvinceId != null">
                #{subjectProvinceId,jdbcType=BIGINT},
            </if>
            <if test="subjectCityId != null">
                #{subjectCityId,jdbcType=BIGINT},
            </if>
            <if test="subjectAddress != null">
                #{subjectAddress,jdbcType=VARCHAR},
            </if>
            <if test="roomQty != null">
                #{roomQty,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="sourceChannel != null">
                #{sourceChannel,jdbcType=VARCHAR},
            </if>
            <if test="sourcePlanName != null">
                #{sourcePlanName,jdbcType=VARCHAR},
            </if>
            <if test="sourcePublishdate != null">
                #{sourcePublishdate,jdbcType=VARCHAR},
            </if>
            <if test="sourceArticle != null">
                #{sourceArticle,jdbcType=VARCHAR},
            </if>
            <if test="ipAddress != null">
                #{ipAddress,jdbcType=VARCHAR},
            </if>
            <if test="ipRegion != null">
                #{ipRegion,jdbcType=VARCHAR},
            </if>
            <if test="renewOrderId != null">
                #{renewOrderId,jdbcType=BIGINT},
            </if>
            <if test="isRenewComplete != null">
                #{isRenewComplete,jdbcType=INTEGER},
            </if>
            <if test="isPayToYd != null">
                #{isPayToYd,jdbcType=INTEGER},
            </if>
            <if test="autoPayFlag != null">
                #{autoPayFlag,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.order.PoOrder">
        <!--@mbg.generated-->
        update ag_po_order
        <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="orderNo != null">
                order_no = #{orderNo,jdbcType=VARCHAR},
            </if>
            <if test="orderDate != null">
                order_date = #{orderDate,jdbcType=TIMESTAMP},
            </if>
            <if test="orderPrice != null">
                order_price = #{orderPrice,jdbcType=DECIMAL},
            </if>
            <if test="quotationId != null">
                quotation_id = #{quotationId,jdbcType=BIGINT},
            </if>
            <if test="quoteNo != null">
                quote_no = #{quoteNo,jdbcType=BIGINT},
            </if>
            <if test="productCategoryId != null">
                product_category_id = #{productCategoryId,jdbcType=BIGINT},
            </if>
            <if test="destination != null">
                destination = #{destination,jdbcType=VARCHAR},
            </if>
            <if test="destinationContinentId != null">
                destination_continent_id = #{destinationContinentId,jdbcType=BIGINT},
            </if>
            <if test="destinationRegionId != null">
                destination_region_id = #{destinationRegionId,jdbcType=BIGINT},
            </if>
            <if test="destinationCountryId != null">
                destination_country_id = #{destinationCountryId,jdbcType=BIGINT},
            </if>
            <if test="effectiveStartDate != null">
                effective_start_date = #{effectiveStartDate,jdbcType=TIMESTAMP},
            </if>
            <if test="effectiveEndDate != null">
                effective_end_date = #{effectiveEndDate,jdbcType=TIMESTAMP},
            </if>
            <if test="coverLength != null">
                cover_length = #{coverLength,jdbcType=INTEGER},
            </if>
            <if test="coverAdultQty != null">
                cover_adult_qty = #{coverAdultQty,jdbcType=INTEGER},
            </if>
            <if test="coverUnderageQty != null">
                cover_underage_qty = #{coverUnderageQty,jdbcType=INTEGER},
            </if>
            <if test="paymentMethodId != null">
                payment_method_id = #{paymentMethodId,jdbcType=BIGINT},
            </if>
            <if test="payUrl != null">
                pay_url = #{payUrl,jdbcType=VARCHAR},
            </if>
            <if test="payFrom != null">
                pay_from = #{payFrom,jdbcType=INTEGER},
            </if>
            <if test="insurerPdfUrl != null">
                insurer_pdf_url = #{insurerPdfUrl,jdbcType=VARCHAR},
            </if>
            <if test="isMsgSent != null">
                is_msg_sent = #{isMsgSent,jdbcType=INTEGER},
            </if>
            <if test="isCarTax != null">
                is_car_tax = #{isCarTax,jdbcType=INTEGER},
            </if>
            <if test="commissionRate != null">
                commission_rate = #{commissionRate,jdbcType=DECIMAL},
            </if>
            <if test="commissionAmount != null">
                commission_amount = #{commissionAmount,jdbcType=DECIMAL},
            </if>
            <if test="fycRate != null">
                fyc_rate = #{fycRate,jdbcType=DECIMAL},
            </if>
            <if test="fycAmount != null">
                fyc_amount = #{fycAmount,jdbcType=DECIMAL},
            </if>
            <if test="b2cRate != null">
                b2c_rate = #{b2cRate,jdbcType=DECIMAL},
            </if>
            <if test="gradeCommissionRate != null">
                grade_commission_rate = #{gradeCommissionRate,jdbcType=DECIMAL},
            </if>
            <if test="referralRate != null">
                referral_rate = #{referralRate,jdbcType=DECIMAL},
            </if>
            <if test="referralAmount != null">
                referral_amount = #{referralAmount,jdbcType=DECIMAL},
            </if>
            <if test="policyId != null">
                policy_id = #{policyId,jdbcType=BIGINT},
            </if>
            <if test="policyNo != null">
                policy_no = #{policyNo,jdbcType=VARCHAR},
            </if>
            <if test="mktCampaign != null">
                mkt_campaign = #{mktCampaign,jdbcType=VARCHAR},
            </if>
            <if test="mktTask != null">
                mkt_task = #{mktTask,jdbcType=VARCHAR},
            </if>
            <if test="isConverted != null">
                is_converted = #{isConverted,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=INTEGER},
            </if>
            <if test="paymentStatus != null">
                payment_status = #{paymentStatus,jdbcType=INTEGER},
            </if>
            <if test="flag != null">
                flag = #{flag,jdbcType=VARCHAR},
            </if>
            <if test="customerId != null">
                customer_id = #{customerId,jdbcType=BIGINT},
            </if>
            <if test="referralCustomerId != null">
                referral_customer_id = #{referralCustomerId,jdbcType=BIGINT},
            </if>
            <if test="shareCode != null">
                share_code = #{shareCode,jdbcType=VARCHAR},
            </if>
            <if test="insurerId != null">
                insurer_id = #{insurerId,jdbcType=BIGINT},
            </if>
            <if test="dataSource != null">
                data_source = #{dataSource,jdbcType=VARCHAR},
            </if>
            <if test="isSocialInsured != null">
                is_social_insured = #{isSocialInsured,jdbcType=INTEGER},
            </if>
            <if test="coverTerm != null">
                cover_term = #{coverTerm,jdbcType=INTEGER},
            </if>
            <if test="paymentTerm != null">
                payment_term = #{paymentTerm,jdbcType=INTEGER},
            </if>
            <if test="paymentTermUnit != null">
                payment_term_unit = #{paymentTermUnit,jdbcType=VARCHAR},
            </if>
            <if test="payInterval != null">
                pay_interval = #{payInterval,jdbcType=INTEGER},
            </if>
            <if test="viewFlag != null">
                view_flag = #{viewFlag,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldA != null">
                dynamic_field_a = #{dynamicFieldA,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldB != null">
                dynamic_field_b = #{dynamicFieldB,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldC != null">
                dynamic_field_c = #{dynamicFieldC,jdbcType=VARCHAR},
            </if>
            <if test="dynamicFieldD != null">
                dynamic_field_d = #{dynamicFieldD,jdbcType=VARCHAR},
            </if>
            <if test="plateNo != null">
                plate_no = #{plateNo,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                memo = #{memo,jdbcType=LONGVARCHAR},
            </if>
            <if test="productTableRequestJson != null">
                product_table_request_json = #{productTableRequestJson,jdbcType=LONGVARCHAR},
            </if>
            <if test="verifiedSeats != null">
                verified_seats = #{verifiedSeats,jdbcType=INTEGER},
            </if>
            <if test="frameNo != null">
                frame_no = #{frameNo,jdbcType=VARCHAR},
            </if>
            <if test="subjectProvinceId != null">
                subject_province_id = #{subjectProvinceId,jdbcType=BIGINT},
            </if>
            <if test="subjectCityId != null">
                subject_city_id = #{subjectCityId,jdbcType=BIGINT},
            </if>
            <if test="subjectAddress != null">
                subject_address = #{subjectAddress,jdbcType=VARCHAR},
            </if>
            <if test="roomQty != null">
                room_qty = #{roomQty,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="sourceChannel != null">
                source_channel = #{sourceChannel,jdbcType=VARCHAR},
            </if>
            <if test="sourcePlanName != null">
                source_plan_name = #{sourcePlanName,jdbcType=VARCHAR},
            </if>
            <if test="sourcePublishdate != null">
                source_publishdate = #{sourcePublishdate,jdbcType=VARCHAR},
            </if>
            <if test="sourceArticle != null">
                source_article = #{sourceArticle,jdbcType=VARCHAR},
            </if>
            <if test="ipAddress != null">
                ip_address = #{ipAddress,jdbcType=VARCHAR},
            </if>
            <if test="ipRegion != null">
                ip_region = #{ipRegion,jdbcType=VARCHAR},
            </if>
            <if test="renewOrderId != null">
                renew_order_id = #{renewOrderId,jdbcType=BIGINT},
            </if>
            <if test="isRenewComplete != null">
                is_renew_complete = #{isRenewComplete,jdbcType=INTEGER},
            </if>
            <if test="isPayToYd != null">
                is_pay_to_yd = #{isPayToYd,jdbcType=INTEGER},
            </if>
            <if test="autoPayFlag != null">
                auto_pay_flag = #{autoPayFlag,jdbcType=VARCHAR},
            </if>

            <if test="commissionCheckId != null">
                commission_check_id = #{commissionCheckId,jdbcType=BIGINT},
            </if>
            <if test="commissionCheckStatus != null">
                commission_check_status = #{commissionCheckStatus,jdbcType=VARCHAR},
            </if>
            <if test="commissionCheckAt != null">
                commission_check_at = #{commissionCheckAt,jdbcType=TIMESTAMP},
            </if>
            <if test="commissionCheckBy != null">
                commission_check_by = #{commissionCheckBy,jdbcType=BIGINT},
            </if>

        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.order.PoOrder">
        <!--@mbg.generated-->
        update ag_po_order
        set config_level = #{configLevel,jdbcType=INTEGER},
        product_id = #{productId,jdbcType=BIGINT},
        plan_id = #{planId,jdbcType=BIGINT},
        order_no = #{orderNo,jdbcType=VARCHAR},
        order_date = #{orderDate,jdbcType=TIMESTAMP},
        order_price = #{orderPrice,jdbcType=DECIMAL},
        quotation_id = #{quotationId,jdbcType=BIGINT},
        quote_no = #{quoteNo,jdbcType=BIGINT},
        product_category_id = #{productCategoryId,jdbcType=BIGINT},
        destination = #{destination,jdbcType=VARCHAR},
        destination_continent_id = #{destinationContinentId,jdbcType=BIGINT},
        destination_region_id = #{destinationRegionId,jdbcType=BIGINT},
        destination_country_id = #{destinationCountryId,jdbcType=BIGINT},
        effective_start_date = #{effectiveStartDate,jdbcType=TIMESTAMP},
        effective_end_date = #{effectiveEndDate,jdbcType=TIMESTAMP},
        cover_length = #{coverLength,jdbcType=INTEGER},
        cover_adult_qty = #{coverAdultQty,jdbcType=INTEGER},
        cover_underage_qty = #{coverUnderageQty,jdbcType=INTEGER},
        payment_method_id = #{paymentMethodId,jdbcType=BIGINT},
        pay_url = #{payUrl,jdbcType=VARCHAR},
        pay_from = #{payFrom,jdbcType=INTEGER},
        insurer_pdf_url = #{insurerPdfUrl,jdbcType=VARCHAR},
        is_msg_sent = #{isMsgSent,jdbcType=INTEGER},
        is_car_tax = #{isCarTax,jdbcType=INTEGER},
        commission_rate = #{commissionRate,jdbcType=DECIMAL},
        commission_amount = #{commissionAmount,jdbcType=DECIMAL},
        fyc_rate = #{fycRate,jdbcType=DECIMAL},
        fyc_amount = #{fycAmount,jdbcType=DECIMAL},
        b2c_rate = #{b2cRate,jdbcType=DECIMAL},
        grade_commission_rate = #{gradeCommissionRate,jdbcType=DECIMAL},
        referral_rate = #{referralRate,jdbcType=DECIMAL},
        referral_amount = #{referralAmount,jdbcType=DECIMAL},
        policy_id = #{policyId,jdbcType=BIGINT},
        policy_no = #{policyNo,jdbcType=VARCHAR},
        mkt_campaign = #{mktCampaign,jdbcType=VARCHAR},
        mkt_task = #{mktTask,jdbcType=VARCHAR},
        is_converted = #{isConverted,jdbcType=INTEGER},
        `status` = #{status,jdbcType=INTEGER},
        payment_status = #{paymentStatus,jdbcType=INTEGER},
        flag = #{flag,jdbcType=VARCHAR},
        customer_id = #{customerId,jdbcType=BIGINT},
        referral_customer_id = #{referralCustomerId,jdbcType=BIGINT},
        share_code = #{shareCode,jdbcType=VARCHAR},
        insurer_id = #{insurerId,jdbcType=BIGINT},
        data_source = #{dataSource,jdbcType=VARCHAR},
        is_social_insured = #{isSocialInsured,jdbcType=INTEGER},
        cover_term = #{coverTerm,jdbcType=INTEGER},
        payment_term = #{paymentTerm,jdbcType=INTEGER},
        payment_term_unit = #{paymentTermUnit,jdbcType=VARCHAR},
        pay_interval = #{payInterval,jdbcType=INTEGER},
        view_flag = #{viewFlag,jdbcType=VARCHAR},
        dynamic_field_a = #{dynamicFieldA,jdbcType=VARCHAR},
        dynamic_field_b = #{dynamicFieldB,jdbcType=VARCHAR},
        dynamic_field_c = #{dynamicFieldC,jdbcType=VARCHAR},
        dynamic_field_d = #{dynamicFieldD,jdbcType=VARCHAR},
        plate_no = #{plateNo,jdbcType=VARCHAR},
        memo = #{memo,jdbcType=LONGVARCHAR},
        product_table_request_json = #{productTableRequestJson,jdbcType=LONGVARCHAR},
        verified_seats = #{verifiedSeats,jdbcType=INTEGER},
        frame_no = #{frameNo,jdbcType=VARCHAR},
        subject_province_id = #{subjectProvinceId,jdbcType=BIGINT},
        subject_city_id = #{subjectCityId,jdbcType=BIGINT},
        subject_address = #{subjectAddress,jdbcType=VARCHAR},
        room_qty = #{roomQty,jdbcType=VARCHAR},
        created_at = #{createdAt,jdbcType=TIMESTAMP},
        created_by = #{createdBy,jdbcType=BIGINT},
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
        updated_by = #{updatedBy,jdbcType=BIGINT},
        source_channel = #{sourceChannel,jdbcType=VARCHAR},
        source_plan_name = #{sourcePlanName,jdbcType=VARCHAR},
        source_publishdate = #{sourcePublishdate,jdbcType=VARCHAR},
        source_article = #{sourceArticle,jdbcType=VARCHAR},
        ip_address = #{ipAddress,jdbcType=VARCHAR},
        ip_region = #{ipRegion,jdbcType=VARCHAR},
        renew_order_id = #{renewOrderId,jdbcType=BIGINT},
        is_renew_complete = #{isRenewComplete,jdbcType=INTEGER},
        is_pay_to_yd = #{isPayToYd,jdbcType=INTEGER},
        auto_pay_flag = #{autoPayFlag,jdbcType=VARCHAR}
        where id = #{id,jdbcType=BIGINT}
    </update>

    <select id="findByStatusAndShareCodeInGroupByCustomerId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from ag_po_order
        where
        status = #{status}
        <if test="customerShareCodes != null">
            and share_code in
            <foreach close=")" collection="customerShareCodes" index="index" item="item" open="(" separator=",">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="findPolicyInfoByCustomerId" resultType="com.yd.dal.entity.order.CustomerPolicyInfo">
        SELECT
        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,
        f.referral_amount as referralAmount,
        f.order_price as orderPrice,
        o.plan_id as planId,
        o.product_id as productId ,
        f.id as fortuneId
        FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id and o.status = 3 and o.order_price
        &gt; 0 and o.insurer_id != 888
        inner JOIN ag_acl_policyholder p ON o.id = p.order_id and p.type = 2
        WHERE f.drop_option_code = 'S01' AND f.customer_id = #{customerId,jdbcType=BIGINT}
        <choose>
            <when test="time == 1">
                and DATE_FORMAT(f.order_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
            </when>
            <when test="time == 3">
                and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now())
            </when>
            <when test="time == 2">
                and YEAR(f.order_date) = YEAR(now())
            </when>
            <otherwise>
            </otherwise>
        </choose>
    </select>
    <select id="findPolicyInfoByMobileNoE" resultType="com.yd.dal.entity.order.CustomerPolicyInfo">
        SELECT
        policy.INS_MST_ID as orderNo ,
        policy.INS_MST_POLICY_NUM as policyNo ,
        c.CUS_MST_NAME as holderName,
        date_format(policy.INS_MST_ACCEPT_DATE, '%Y-%m-%d %H:%i:%s') as orderDate,
        date_format(policy.INS_MST_EFFECT_DATE, '%Y-%m-%d %H:%i:%s') as startDate,
        date_format(policy.INS_MST_INVALID_DATE, '%Y-%m-%d %H:%i:%s') as endDate,
        sum(m.MON025_405) as referralAmount,
        sum(m.MON025_401) as orderPrice,
        m.MON025_004 as productName
        FROM sal001 p INNER JOIN MON025 m on m.MON025_007 = p.SAL_MST_ID AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
        inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id
        inner join cus001 c on policy.FK_CUS_PRO_ID = c.CUS_MST_ID
        WHERE p.SAL_MST_MOBILE like concat(concat('%',#{mobileNo,jdbcType=VARCHAR}),'%')
        <choose>
            <when test="time == 1">
                and DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
            </when>
            <when test="time == 3">
                and QUARTER(policy.INS_MST_ACCEPT_DATE) = QUARTER(NOW()) AND
                year(policy.INS_MST_ACCEPT_DATE)=year(now())
            </when>
            <when test="time == 2">
                and YEAR(policy.INS_MST_ACCEPT_DATE) = YEAR(now())
            </when>
            <otherwise>
            </otherwise>
        </choose>
        group by policy.ins_mst_id
    </select>
    <select id="findOrderNoByPolicyNo" resultType="java.lang.String">
      select
        INS_MST_ID
      from ins001
      where INS_MST_POLICY_NUM = #{policyNo,jdbcType=VARCHAR};
    </select>
    <select id="findPolicyDetailsInfoByOrderNoE" resultType="com.yd.dal.entity.order.PolicyDetailInfoE">
      SELECT
        policy.INS_MST_ID as orderNo , -- 订单号
        policy.INS_MST_POLICY_NUM as policyNo , -- 保单号
        policy.INS_MST_STATUS as policyStatus, -- 保单状态
        date_format(policy.INS_MST_ACCEPT_DATE, '%Y-%m-%d %H:%i:%s') as orderDate, -- 下单日期
        date_format(policy.INS_MST_EFFECT_DATE, '%Y-%m-%d %H:%i:%s') as startDate, -- 保险起期
        date_format(policy.INS_MST_INVALID_DATE, '%Y-%m-%d %H:%i:%s') as endDate, -- 保险止期
        product.PRD_MST_ID as productId , -- 产品编号
        product.PRD_MST_INS_CODE as productCode , -- 产品code
        product.PRD_MST_PRO_NAME as productName , -- 产品名字
        insurer.PRD_SUP_ID as insurerId , -- 保险公司编号
        insurer.PRD_SUP_NAME as insurerName , -- 保险公司名称
        holder.CUS_MST_NAME as holderName, -- 投保人姓名
        holder.CUS_MST_POSTTYPE as holderIdNoType, -- 投保人证件类型
        holder.CUS_MST_ID as holderId, -- 投保人编码
        holder.CUS_MST_ID_NUM as holderIdNo, -- 投保人编码
        holder.CUS_MST_SEX as holderSex, -- 投保人性别
        date_format(holder.CUS_MST_BIRTHDAY, '%Y-%m-%d') as holderBirthday, -- 投保人出生年月
        holder.CUS_MST_CELL_NUM as holderMobileNo, -- 投保人手机号码
        insured.CUS_MST_NAME as insuredName, -- 被保人姓名
        insured.CUS_MST_ID as insuredId, -- 被保人编码
        insured.CUS_MST_POSTTYPE as insuredIdNoType, -- 被保人证件类型
        insured.CUS_MST_ID_NUM as insuredIdNo, -- 被保人编码
        insured.CUS_MST_SEX as insuredSex, -- 被保人性别
        date_format(insured.CUS_MST_BIRTHDAY, '%Y-%m-%d') as insuredBirthday, -- 被保人出生年月
        insured.CUS_MST_CELL_NUM as insuredMobileNo, -- 被保人手机号码
        m.MON025_405 as commission, -- 佣金
        m.MON025_404 as commissionRate, -- 佣金率
        m.MON025_004 as productId, -- 产品ID
        m.MON025_401 as premium, -- 保费
        m.MON025_101 as policyType, -- 保单类型
        m.MON025_102 as payFrequency, -- 缴费频率
        m.MON025_109 as payCommissionStatus, -- 发佣状态
        m.mon025_108 as commissionType -- 佣金项目代码
      FROM ins001 policy  INNER JOIN MON025 m on m.MON025_002 = policy.INS_MST_ID AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
                          inner join cus001 holder on policy.FK_CUS_PRO_ID = holder.CUS_MST_ID
                          inner join cus001 insured on policy.FK_CUS_PRO_ID = insured.CUS_MST_ID
                          inner join prd001 product on m.MON025_004 = product.PRD_MST_ID
                          inner join prd004 insurer on product.FK_PRD_SUP_ID = insurer.PRD_SUP_ID
      WHERE policy.INS_MST_ID = #{orderNo,jdbcType=VARCHAR};
  </select>
    <select id="findPolicyFactorByOrderNosE" resultType="com.yd.dal.entity.order.PolicyFactorInfoE">
        SELECT policy2.FK_INS_MST_ID as orderNo, -- 保单id
        policy2.FK_PRD_MST_ID as productId, -- 产品ID
        policy2.INS_IND_RELATIONSHIP as relationship,-- 与被保人关系
        policy2.INS_IND_INSURED_AMOUNT as insuredAmount, -- 保费
        policy2.INS_IND_AMOUNT_UNIT as amountUnit, -- 保费单位
        policy2.INS_IND_PERIOD as period -- 缴费年限
        from ins002 policy2 where policy2.FK_INS_MST_ID in
        <foreach close=")" collection="orderNoList" index="index" item="item" open="(" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="findByIdAndStatus" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from ag_po_order
        where id = #{id,jdbcType=BIGINT} and status = #{status,jdbcType=INTEGER}
    </select>

    <select id="findByIds" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from ag_po_order
        where id in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="findVehiclePolicyInfoByCustomerId" resultType="java.lang.Long">
        select o.id
        from  ag_po_quotation_vehicle_relation v
        left join ag_po_order o on o.quotation_id = v.quotation_id
        where v.customer_id = #{customerId,jdbcType=BIGINT}
    </select>

</mapper>