<?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.boco.nbd.wios.manage.mapper.def.OrderMapper">

    <resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.Order">
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="oem_id" jdbcType="INTEGER" property="oemId"/>
        <result column="oem_agent_id" jdbcType="INTEGER" property="oemAgentId"/>
        <result column="oem_agent_info" jdbcType="VARCHAR" property="oemAgentInfo"/>
        <result column="oem_agent_contact_name" jdbcType="VARCHAR" property="oemAgentContactName"/>
        <result column="oem_agent_contact_phone" jdbcType="VARCHAR" property="oemAgentContactPhone"/>
        <result column="out_order_id" jdbcType="VARCHAR" property="outOrderId"/>
        <result column="contract_id" jdbcType="INTEGER" property="contractId"/>
        <result column="supplier_contract_id" jdbcType="INTEGER" property="supplierContractId"/>
        <result column="user_name" jdbcType="VARCHAR" property="userName"/>
        <result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
        <result column="user_sex" jdbcType="INTEGER" property="userSex"/>
        <result column="contact_name" jdbcType="VARCHAR" property="contactName"/>
        <result column="contact_phone" jdbcType="VARCHAR" property="contactPhone"/>
        <result column="region_id" jdbcType="VARCHAR" property="regionId"/>
        <result column="warehouse_id" jdbcType="VARCHAR" property="warehouseId"/>
        <result column="address" jdbcType="VARCHAR" property="address"/>
        <result column="vehicle_model" jdbcType="VARCHAR" property="vehicleModel"/>
        <result column="vehicle_chassis_no" jdbcType="VARCHAR" property="vehicleChassisNo"/>
        <result column="vehicle_vin" jdbcType="VARCHAR" property="vehicleVin"/>
        <result column="vehicle_parking_no" jdbcType="VARCHAR" property="vehicleParkingNo"/>
        <result column="vehicle_parking_status" jdbcType="VARCHAR" property="vehicleParkingStatus"/>
        <result column="survey_before_sale_enable" jdbcType="INTEGER" property="surveyBeforeSaleEnable"/>
        <result column="manu_dispatch_enable" jdbcType="INTEGER" property="manuDispatchEnable"/>
        <result column="wallbox_model" jdbcType="VARCHAR" property="wallboxModel"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
        <result column="expand_status" jdbcType="INTEGER" property="expandStatus"/>
        <result column="expand_fail_reason" jdbcType="VARCHAR" property="expandFailReason"/>
        <result column="expand_fail_operate" jdbcType="INTEGER" property="expandFailOperate"/>
        <result column="expand_remark" jdbcType="VARCHAR" property="expandRemark"/>
        <result column="survey_staff_id" jdbcType="INTEGER" property="surveyStaffId"/>
        <result column="survey_finish_time" jdbcType="TIMESTAMP" property="surveyFinishTime"/>
        <result column="survey_reserve_time" jdbcType="TIMESTAMP" property="surveyReserveTime"/>
        <result column="survey_client_name" jdbcType="VARCHAR" property="surveyClientName"/>
        <result column="survey_client_phone" jdbcType="VARCHAR" property="surveyClientPhone"/>
        <result column="survey_cams_phone" jdbcType="VARCHAR" property="surveyCamsPhone"/>
        <result column="survey_reserve_remark" jdbcType="VARCHAR" property="surveyReserveRemark"/>
        <result column="install_supplier_id" jdbcType="INTEGER" property="installSupplierId"/>
        <result column="install_staff_id" jdbcType="INTEGER" property="installStaffId"/>
        <result column="install_finish_time" jdbcType="TIMESTAMP" property="installFinishTime"/>
        <result column="install_reserve_time" jdbcType="TIMESTAMP" property="installReserveTime"/>
        <result column="install_client_name" jdbcType="VARCHAR" property="installClientName"/>
        <result column="install_client_phone" jdbcType="VARCHAR" property="installClientPhone"/>
        <result column="install_cams_phone" jdbcType="VARCHAR" property="installCamsPhone"/>
        <result column="install_reserve_remark" jdbcType="VARCHAR" property="installReserveRemark"/>
        <result column="survey_finish_fail_reason" jdbcType="VARCHAR" property="surveyFinishFailReason"/>
        <result column="survey_rectify_fail_reason" jdbcType="VARCHAR" property="surveyRectifyFailReason"/>
        <result column="install_change_fail_reason" jdbcType="VARCHAR" property="installChangeFailReason"/>
        <result column="install_finish_fail_reason" jdbcType="VARCHAR" property="installFinishFailReason"/>
        <result column="install_rectify_fail_reason" jdbcType="VARCHAR" property="installRectifyFailReason"/>
        <result column="close_order_reason" jdbcType="VARCHAR" property="closeOrderReason"/>
        <result column="install_change_attachment_files" jdbcType="VARCHAR" property="installChangeAttachmentFiles"/>
        <result column="survey_reserve_fail_info" jdbcType="VARCHAR" property="surveyReserveFailInfo"/>
        <result column="install_reserve_fail_info" jdbcType="VARCHAR" property="installReserveFailInfo"/>
        <result column="files" jdbcType="VARCHAR" property="files"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="score" jdbcType="DECIMAL" property="score"/>
        <result column="visit_content" jdbcType="VARCHAR" property="visitContent"/>
        <result column="invoice_time" jdbcType="TIMESTAMP" property="invoiceTime"/>
        <result column="estate_type" jdbcType="INTEGER" property="estateType"/>
        <result column="has_independent_parking" jdbcType="INTEGER" property="hasIndependentParking"/>
        <result column="install_position" jdbcType="INTEGER" property="installPosition"/>
        <result column="property_agree" jdbcType="INTEGER" property="propertyAgree"/>
        <result column="electric_expand" jdbcType="INTEGER" property="electricExpand"/>
        <result column="need_erect_pile" jdbcType="INTEGER" property="needErectPile"/>
        <result column="dispatch_time" jdbcType="TIMESTAMP" property="dispatchTime"/>
        <result column="survey_submit_examine_time" jdbcType="TIMESTAMP" property="surveySubmitExamineTime"/>
        <result column="survey_approve_time" jdbcType="TIMESTAMP" property="surveyApproveTime"/>
        <result column="install_submit_examine_time" jdbcType="TIMESTAMP" property="installSubmitExamineTime"/>
        <result column="install_approve_time" jdbcType="TIMESTAMP" property="installApproveTime"/>
        <result column="return_visit_time" jdbcType="TIMESTAMP" property="returnVisitTime"/>
        <result column="close_time" jdbcType="TIMESTAMP" property="closeTime"/>
        <result column="create_account" jdbcType="VARCHAR" property="createAccount"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="modify_account" jdbcType="VARCHAR" property="modifyAccount"/>
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
        <result column="item_model" jdbcType="VARCHAR" property="itemModel"/>
        <result column="survey_wallbox_model" jdbcType="VARCHAR" property="surveyWallboxModel"/>
        <result column="survey_item_model" jdbcType="VARCHAR" property="surveyItemModel"/>
        <result column="install_wallbox_model" jdbcType="VARCHAR" property="installWallboxModel"/>
        <result column="install_item_model" jdbcType="VARCHAR" property="installItemModel"/>
        <result column="survey_follow_time" jdbcType="TIMESTAMP" property="surveyFollowTime"/>
        <result column="install_follow_time" jdbcType="TIMESTAMP" property="installFollowTime"/>
        <result column="address_lat" jdbcType="VARCHAR" property="addressLat"/>
        <result column="address_lng" jdbcType="VARCHAR" property="addressLng"/>
        <result column="connect_person" property="connectPerson" jdbcType="VARCHAR"/>
        <result column="want_home_time" property="wantHomeTime" jdbcType="TIMESTAMP"/>
        <result column="install_emergency_level" property="installEmergencyLevel" jdbcType="INTEGER"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="is_connect" property="isConnect" jdbcType="INTEGER"/>
        <result column="is_need_survey" property="isNeedSurvey" jdbcType="INTEGER"/>
        <result column="shipno" property="shipno" jdbcType="VARCHAR"/>
        <result column="pack_type" property="packType" jdbcType="VARCHAR"/>
        <result column="oem_agent_name" property="oemAgentName" jdbcType="VARCHAR"/>
        <result column="install_supplier_name" property="installSupplierName" jdbcType="VARCHAR"/>
        <result column="survey_staff_name" property="surveyStaffName" jdbcType="VARCHAR"/>
        <result column="survey_staff_phone" property="surveyStaffPhone" jdbcType="VARCHAR"/>
        <result column="install_staff_name" property="installStaffName" jdbcType="VARCHAR"/>
        <result column="install_staff_phone" property="installStaffPhone" jdbcType="VARCHAR"/>
        <result column="oem_agent_code" property="oemAgentCode" jdbcType="VARCHAR"/>
        <result column="install_pack_type" property="installPackType" jdbcType="VARCHAR"/>
        <result column="survey_pack_type" property="surveyPackType" jdbcType="VARCHAR"/>
        <result column="know_after_sales_channel" property="knowAfterSalesChannel" jdbcType="INTEGER"/>
        <result column="install_length" property="installLength" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Order_Column_List">
        t
        .
        id
        , t.oem_id, t.oem_agent_id, t.oem_agent_contact_name,t.oem_agent_info, t.oem_agent_contact_phone, t.out_order_id,
  t.contract_id, t.supplier_contract_id, t.user_name, t.user_phone, t.user_sex, t.contact_name,
  t.contact_phone, case when t.region_level = 1 then t.country_id when t.region_level = 2 then t.area_id
        when t.region_level=3 then t.province_id when t.region_level=5 then t.city_id else t.region_id
        end
        as region_id,
  t.warehouse_id, t.address, t.vehicle_model, t.vehicle_chassis_no,
  t.vehicle_vin, t.vehicle_parking_no, t.vehicle_parking_status, t.survey_before_sale_enable,
  t.manu_dispatch_enable, t.wallbox_model, t.status, t.type, t.expand_status, t.expand_fail_reason,
  t.expand_fail_operate, t.expand_remark, t.survey_staff_id, t.survey_finish_time, t.survey_reserve_time,
  t.survey_client_name, t.survey_client_phone, t.survey_cams_phone, t.survey_reserve_remark,
  t.install_supplier_id, t.install_staff_id, t.install_finish_time, t.install_reserve_time,
  t.install_client_name, t.install_client_phone, t.install_cams_phone, t.install_reserve_remark,
  t.survey_finish_fail_reason, t.survey_rectify_fail_reason, t.install_change_fail_reason,
  t.install_finish_fail_reason, t.install_rectify_fail_reason, t.close_order_reason, t.install_change_attachment_files,
  t.survey_reserve_fail_info, t.install_reserve_fail_info, t.files, t.description, t.score, t.visit_content,
  t.invoice_time, t.estate_type, t.has_independent_parking, t.install_position, t.property_agree,
  t.electric_expand, t.need_erect_pile, t.dispatch_time, t.survey_submit_examine_time, t.survey_approve_time,
  t.install_submit_examine_time, t.install_approve_time, t.return_visit_time, t.close_time,
  t.create_account, t.create_time, t.modify_account, t.modify_time,
  t.item_model,t.survey_wallbox_model,t.survey_item_model,t.install_wallbox_model,t.install_item_model,
  t.survey_follow_time,t.install_follow_time,t.address_lat,t.address_lng,
  t.connect_person, t.want_home_time, t.install_emergency_level, t.remark, t.is_connect,t.is_need_survey,t.shipno,
  t.oem_agent_name,t.pack_type,t.install_supplier_name,t.survey_staff_name,t.survey_staff_phone,t.install_staff_name,
t.install_staff_phone,t.oem_agent_code,t.install_pack_type,t.survey_pack_type
    </sql>


    <sql id="Base_Column_List">
        id
        , oem_id, oem_agent_id, oem_agent_contact_name,oem_agent_info, oem_agent_contact_phone, out_order_id,
  contract_id, supplier_contract_id, user_name, user_phone, user_sex, contact_name, 
  contact_phone, case when region_level = 1 then country_id when region_level = 2 then area_id
        when region_level=3 then province_id when region_level=5 then city_id else region_id
        end
        as region_id,
  warehouse_id, address, vehicle_model, vehicle_chassis_no,
  vehicle_vin, vehicle_parking_no, vehicle_parking_status, survey_before_sale_enable, 
  manu_dispatch_enable, wallbox_model, status, type, expand_status, expand_fail_reason, 
  expand_fail_operate, expand_remark, survey_staff_id, survey_finish_time, survey_reserve_time, 
  survey_client_name, survey_client_phone, survey_cams_phone, survey_reserve_remark, 
  install_supplier_id, install_staff_id, install_finish_time, install_reserve_time, 
  install_client_name, install_client_phone, install_cams_phone, install_reserve_remark, 
  survey_finish_fail_reason, survey_rectify_fail_reason, install_change_fail_reason, 
  install_finish_fail_reason, install_rectify_fail_reason, close_order_reason, install_change_attachment_files, 
  survey_reserve_fail_info, install_reserve_fail_info, files, description, score, visit_content, 
  invoice_time, estate_type, has_independent_parking, install_position, property_agree, 
  electric_expand, need_erect_pile, dispatch_time, survey_submit_examine_time, survey_approve_time, 
  install_submit_examine_time, install_approve_time, return_visit_time, close_time, 
  create_account, create_time, modify_account, modify_time,
  item_model,survey_wallbox_model,survey_item_model,install_wallbox_model,install_item_model,
  survey_follow_time,install_follow_time,address_lat,address_lng,
  connect_person, want_home_time, install_emergency_level, remark, is_connect,is_need_survey,shipno,
  oem_agent_name,pack_type,install_supplier_name,survey_staff_name,survey_staff_phone,install_staff_name,
install_staff_phone,oem_agent_code,install_pack_type,survey_pack_type,know_after_sales_channel,install_length
    </sql>


    <delete id="delete" parameterType="java.lang.String">
        delete
        from t_order
        where id = #{id,jdbcType=VARCHAR}
    </delete>

    <insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.Order">
        insert into t_order (id, oem_id, oem_agent_id,
                             oem_agent_info, oem_agent_contact_name, oem_agent_contact_phone,
                             out_order_id, contract_id, supplier_contract_id,
                             user_name, user_phone, user_sex,
                             contact_name, contact_phone, region_id,
                             warehouse_id, address, vehicle_model,
                             vehicle_chassis_no, vehicle_vin, vehicle_parking_no,
                             vehicle_parking_status, survey_before_sale_enable,
                             manu_dispatch_enable, wallbox_model, status,
                             type, expand_status, expand_fail_reason,
                             expand_fail_operate, expand_remark, survey_staff_id,
                             survey_finish_time, survey_reserve_time,
                             survey_client_name, survey_client_phone, survey_cams_phone,
                             survey_reserve_remark, install_supplier_id,
                             install_staff_id, install_finish_time, install_reserve_time,
                             install_client_name, install_client_phone,
                             install_cams_phone, install_reserve_remark,
                             survey_finish_fail_reason, survey_rectify_fail_reason,
                             install_change_fail_reason, install_finish_fail_reason,
                             install_rectify_fail_reason, close_order_reason,
                             install_change_attachment_files, survey_reserve_fail_info,
                             install_reserve_fail_info, files, description,
                             score, visit_content, invoice_time,
                             estate_type, has_independent_parking, install_position,
                             property_agree, electric_expand, need_erect_pile,
                             dispatch_time, survey_submit_examine_time,
                             survey_approve_time, install_submit_examine_time,
                             install_approve_time, return_visit_time,
                             close_time, create_account, create_time,
                             modify_account, modify_time, item_model,
                             survey_wallbox_model, survey_item_model, install_wallbox_model,
                             install_item_model, survey_follow_time, install_follow_time,
                             address_lat, address_lng, connect_person,
                             want_home_time, install_emergency_level,
                             remark, is_connect, is_need_survey,
                             shipno)
        values (#{id,jdbcType=VARCHAR}, #{oemId,jdbcType=INTEGER}, #{oemAgentId,jdbcType=INTEGER},
                #{oemAgentInfo,jdbcType=VARCHAR}, #{oemAgentContactName,jdbcType=VARCHAR},
                #{oemAgentContactPhone,jdbcType=VARCHAR},
                #{outOrderId,jdbcType=VARCHAR}, #{contractId,jdbcType=INTEGER}, #{supplierContractId,jdbcType=INTEGER},
                #{userName,jdbcType=VARCHAR}, #{userPhone,jdbcType=VARCHAR}, #{userSex,jdbcType=INTEGER},
                #{contactName,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, #{regionId,jdbcType=VARCHAR},
                #{warehouseId,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{vehicleModel,jdbcType=VARCHAR},
                #{vehicleChassisNo,jdbcType=VARCHAR}, #{vehicleVin,jdbcType=VARCHAR},
                #{vehicleParkingNo,jdbcType=VARCHAR},
                #{vehicleParkingStatus,jdbcType=VARCHAR}, #{surveyBeforeSaleEnable,jdbcType=BIT},
                #{manuDispatchEnable,jdbcType=BIT}, #{wallboxModel,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
                #{type,jdbcType=BIT}, #{expandStatus,jdbcType=BIT}, #{expandFailReason,jdbcType=VARCHAR},
                #{expandFailOperate,jdbcType=INTEGER}, #{expandRemark,jdbcType=VARCHAR},
                #{surveyStaffId,jdbcType=INTEGER},
                #{surveyFinishTime,jdbcType=TIMESTAMP}, #{surveyReserveTime,jdbcType=TIMESTAMP},
                #{surveyClientName,jdbcType=VARCHAR}, #{surveyClientPhone,jdbcType=VARCHAR},
                #{surveyCamsPhone,jdbcType=VARCHAR},
                #{surveyReserveRemark,jdbcType=VARCHAR}, #{installSupplierId,jdbcType=INTEGER},
                #{installStaffId,jdbcType=INTEGER}, #{installFinishTime,jdbcType=TIMESTAMP},
                #{installReserveTime,jdbcType=TIMESTAMP},
                #{installClientName,jdbcType=VARCHAR}, #{installClientPhone,jdbcType=VARCHAR},
                #{installCamsPhone,jdbcType=VARCHAR}, #{installReserveRemark,jdbcType=VARCHAR},
                #{surveyFinishFailReason,jdbcType=VARCHAR}, #{surveyRectifyFailReason,jdbcType=VARCHAR},
                #{installChangeFailReason,jdbcType=VARCHAR}, #{installFinishFailReason,jdbcType=VARCHAR},
                #{installRectifyFailReason,jdbcType=VARCHAR}, #{closeOrderReason,jdbcType=VARCHAR},
                #{installChangeAttachmentFiles,jdbcType=VARCHAR}, #{surveyReserveFailInfo,jdbcType=VARCHAR},
                #{installReserveFailInfo,jdbcType=VARCHAR}, #{files,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
                #{score,jdbcType=DECIMAL}, #{visitContent,jdbcType=VARCHAR}, #{invoiceTime,jdbcType=TIMESTAMP},
                #{estateType,jdbcType=BIT}, #{hasIndependentParking,jdbcType=BIT}, #{installPosition,jdbcType=BIT},
                #{propertyAgree,jdbcType=BIT}, #{electricExpand,jdbcType=BIT}, #{needErectPile,jdbcType=BIT},
                #{dispatchTime,jdbcType=TIMESTAMP}, #{surveySubmitExamineTime,jdbcType=TIMESTAMP},
                #{surveyApproveTime,jdbcType=TIMESTAMP}, #{installSubmitExamineTime,jdbcType=TIMESTAMP},
                #{installApproveTime,jdbcType=TIMESTAMP}, #{returnVisitTime,jdbcType=TIMESTAMP},
                #{closeTime,jdbcType=TIMESTAMP}, #{createAccount,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
                #{modifyAccount,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}, #{itemModel,jdbcType=VARCHAR},
                #{surveyWallboxModel,jdbcType=VARCHAR}, #{surveyItemModel,jdbcType=VARCHAR},
                #{installWallboxModel,jdbcType=VARCHAR},
                #{installItemModel,jdbcType=VARCHAR}, #{surveyFollowTime,jdbcType=TIMESTAMP},
                #{installFollowTime,jdbcType=TIMESTAMP},
                #{addressLat,jdbcType=VARCHAR}, #{addressLng,jdbcType=VARCHAR}, #{connectPerson,jdbcType=VARCHAR},
                #{wantHomeTime,jdbcType=TIMESTAMP}, #{installEmergencyLevel,jdbcType=INTEGER},
                #{remark,jdbcType=VARCHAR}, #{isConnect,jdbcType=INTEGER}, #{isNeedSurvey,jdbcType=INTEGER},
                #{shipno,jdbcType=VARCHAR})
    </insert>


    <insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.Order">
        insert into t_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="oemId != null">
                oem_id,
            </if>
            <if test="oemAgentId != null">
                oem_agent_id,
            </if>
            <if test="oemAgentContactName != null">
                oem_agent_contact_name,
            </if>
            <if test="oemAgentInfo != null">
                oem_agent_info,
            </if>
            <if test="oemAgentContactPhone != null">
                oem_agent_contact_phone,
            </if>
            <if test="outOrderId != null">
                out_order_id,
            </if>
            <if test="contractId != null">
                contract_id,
            </if>
            <if test="supplierContractId != null">
                supplier_contract_id,
            </if>
            <if test="userName != null">
                user_name,
            </if>
            <if test="userPhone != null">
                user_phone,
            </if>
            <if test="userSex != null">
                user_sex,
            </if>
            <if test="contactName != null">
                contact_name,
            </if>
            <if test="contactPhone != null">
                contact_phone,
            </if>
            <if test="regionId != null">
                region_id,
            </if>
            <if test="warehouseId != null">
                warehouse_id,
            </if>
            <if test="address != null">
                address,
            </if>
            <if test="vehicleModel != null">
                vehicle_model,
            </if>
            <if test="vehicleChassisNo != null">
                vehicle_chassis_no,
            </if>
            <if test="vehicleVin != null">
                vehicle_vin,
            </if>
            <if test="vehicleParkingNo != null">
                vehicle_parking_no,
            </if>
            <if test="vehicleParkingStatus != null">
                vehicle_parking_status,
            </if>
            <if test="surveyBeforeSaleEnable != null">
                survey_before_sale_enable,
            </if>
            <if test="manuDispatchEnable != null">
                manu_dispatch_enable,
            </if>
            <if test="wallboxModel != null">
                wallbox_model,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="expandStatus != null">
                expand_status,
            </if>
            <if test="expandFailReason != null">
                expand_fail_reason,
            </if>
            <if test="expandFailOperate != null">
                expand_fail_operate,
            </if>
            <if test="expandRemark != null">
                expand_remark,
            </if>
            <if test="surveyStaffId != null">
                survey_staff_id,
            </if>
            <if test="surveyFinishTime != null">
                survey_finish_time,
            </if>
            <if test="surveyReserveTime != null">
                survey_reserve_time,
            </if>
            <if test="surveyClientName != null">
                survey_client_name,
            </if>
            <if test="surveyClientPhone != null">
                survey_client_phone,
            </if>
            <if test="surveyCamsPhone != null">
                survey_cams_phone,
            </if>
            <if test="surveyReserveRemark != null">
                survey_reserve_remark,
            </if>
            <if test="installSupplierId != null">
                install_supplier_id,
            </if>
            <if test="installStaffId != null">
                install_staff_id,
            </if>
            <if test="installFinishTime != null">
                install_finish_time,
            </if>
            <if test="installReserveTime != null">
                install_reserve_time,
            </if>
            <if test="installClientName != null">
                install_client_name,
            </if>
            <if test="installClientPhone != null">
                install_client_phone,
            </if>
            <if test="installCamsPhone != null">
                install_cams_phone,
            </if>
            <if test="installReserveRemark != null">
                install_reserve_remark,
            </if>
            <if test="surveyFinishFailReason != null">
                survey_finish_fail_reason,
            </if>
            <if test="surveyRectifyFailReason != null">
                survey_rectify_fail_reason,
            </if>
            <if test="installChangeFailReason != null">
                install_change_fail_reason,
            </if>
            <if test="installFinishFailReason != null">
                install_finish_fail_reason,
            </if>
            <if test="installRectifyFailReason != null">
                install_rectify_fail_reason,
            </if>
            <if test="closeOrderReason != null">
                close_order_reason,
            </if>
            <if test="installChangeAttachmentFiles != null">
                install_change_attachment_files,
            </if>
            <if test="surveyReserveFailInfo != null">
                survey_reserve_fail_info,
            </if>
            <if test="installReserveFailInfo != null">
                install_reserve_fail_info,
            </if>
            <if test="files != null">
                files,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="score != null">
                score,
            </if>
            <if test="visitContent != null">
                visit_content,
            </if>
            <if test="invoiceTime != null">
                invoice_time,
            </if>
            <if test="estateType != null">
                estate_type,
            </if>
            <if test="hasIndependentParking != null">
                has_independent_parking,
            </if>
            <if test="installPosition != null">
                install_position,
            </if>
            <if test="propertyAgree != null">
                property_agree,
            </if>
            <if test="electricExpand != null">
                electric_expand,
            </if>
            <if test="needErectPile != null">
                need_erect_pile,
            </if>
            <if test="dispatchTime != null">
                dispatch_time,
            </if>
            <if test="surveySubmitExamineTime != null">
                survey_submit_examine_time,
            </if>
            <if test="surveyApproveTime != null">
                survey_approve_time,
            </if>
            <if test="installSubmitExamineTime != null">
                install_submit_examine_time,
            </if>
            <if test="installApproveTime != null">
                install_approve_time,
            </if>
            <if test="returnVisitTime != null">
                return_visit_time,
            </if>
            <if test="closeTime != null">
                close_time,
            </if>
            <if test="createAccount != null">
                create_account,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="modifyAccount != null">
                modify_account,
            </if>
            <if test="modifyTime != null">
                modify_time,
            </if>

            <if test="itemModel != null">
                item_model,
            </if>
            <if test="surveyWallboxModel != null">
                survey_wallbox_model,
            </if>
            <if test="surveyItemModel != null">
                survey_item_model,
            </if>
            <if test="installWallboxModel != null">
                install_wallbox_model,
            </if>
            <if test="installItemModel != null">
                install_item_model,
            </if>
            <if test="surveyFollowTime != null">
                surveyFollowTime,
            </if>
            <if test="installFollowTime != null">
                installFollowTime,
            </if>
            <if test="addressLat != null">
                address_lat,
            </if>
            <if test="addressLng != null">
                address_lng,
            </if>
            <if test="connectPerson != null">
                connect_person,
            </if>
            <if test="wantHomeTime != null">
                want_home_time,
            </if>
            <if test="installEmergencyLevel != null">
                install_emergency_level,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="isConnect != null">
                is_connect,
            </if>
            <if test="isNeedSurvey != null">
                is_need_survey,
            </if>
            <if test="shipno != null">
                shipno,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="oemId != null">
                #{oemId,jdbcType=INTEGER},
            </if>
            <if test="oemAgentId != null">
                #{oemAgentId,jdbcType=INTEGER},
            </if>
            <if test="oemAgentInfo != null">
                #{oemAgentInfo,jdbcType=VARCHAR},
            </if>
            <if test="oemAgentContactName != null">
                #{oemAgentContactName,jdbcType=VARCHAR},
            </if>
            <if test="oemAgentContactPhone != null">
                #{oemAgentContactPhone,jdbcType=VARCHAR},
            </if>
            <if test="outOrderId != null">
                #{outOrderId,jdbcType=VARCHAR},
            </if>
            <if test="contractId != null">
                #{contractId,jdbcType=INTEGER},
            </if>
            <if test="supplierContractId != null">
                #{supplierContractId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                #{userName,jdbcType=VARCHAR},
            </if>
            <if test="userPhone != null">
                #{userPhone,jdbcType=VARCHAR},
            </if>
            <if test="userSex != null">
                #{userSex,jdbcType=INTEGER},
            </if>
            <if test="contactName != null">
                #{contactName,jdbcType=VARCHAR},
            </if>
            <if test="contactPhone != null">
                #{contactPhone,jdbcType=VARCHAR},
            </if>
            <if test="regionId != null">
                #{regionId,jdbcType=VARCHAR},
            </if>
            <if test="warehouseId != null">
                #{warehouseId,jdbcType=VARCHAR},
            </if>
            <if test="address != null">
                #{address,jdbcType=VARCHAR},
            </if>
            <if test="vehicleModel != null">
                #{vehicleModel,jdbcType=VARCHAR},
            </if>
            <if test="vehicleChassisNo != null">
                #{vehicleChassisNo,jdbcType=VARCHAR},
            </if>
            <if test="vehicleVin != null">
                #{vehicleVin,jdbcType=VARCHAR},
            </if>
            <if test="vehicleParkingNo != null">
                #{vehicleParkingNo,jdbcType=VARCHAR},
            </if>
            <if test="vehicleParkingStatus != null">
                #{vehicleParkingStatus,jdbcType=VARCHAR},
            </if>
            <if test="surveyBeforeSaleEnable != null">
                #{surveyBeforeSaleEnable,jdbcType=INTEGER},
            </if>
            <if test="manuDispatchEnable != null">
                #{manuDispatchEnable,jdbcType=INTEGER},
            </if>
            <if test="wallboxModel != null">
                #{wallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
            <if test="expandStatus != null">
                #{expandStatus,jdbcType=INTEGER},
            </if>
            <if test="expandFailReason != null">
                #{expandFailReason,jdbcType=VARCHAR},
            </if>
            <if test="expandFailOperate != null">
                #{expandFailOperate,jdbcType=INTEGER},
            </if>
            <if test="expandRemark != null">
                #{expandRemark,jdbcType=VARCHAR},
            </if>
            <if test="surveyStaffId != null">
                #{surveyStaffId,jdbcType=INTEGER},
            </if>
            <if test="surveyFinishTime != null">
                #{surveyFinishTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyReserveTime != null">
                #{surveyReserveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyClientName != null">
                #{surveyClientName,jdbcType=VARCHAR},
            </if>
            <if test="surveyClientPhone != null">
                #{surveyClientPhone,jdbcType=VARCHAR},
            </if>
            <if test="surveyCamsPhone != null">
                #{surveyCamsPhone,jdbcType=VARCHAR},
            </if>
            <if test="surveyReserveRemark != null">
                #{surveyReserveRemark,jdbcType=VARCHAR},
            </if>
            <if test="installSupplierId != null">
                #{installSupplierId,jdbcType=INTEGER},
            </if>
            <if test="installStaffId != null">
                #{installStaffId,jdbcType=INTEGER},
            </if>
            <if test="installFinishTime != null">
                #{installFinishTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installReserveTime != null">
                #{installReserveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installClientName != null">
                #{installClientName,jdbcType=VARCHAR},
            </if>
            <if test="installClientPhone != null">
                #{installClientPhone,jdbcType=VARCHAR},
            </if>
            <if test="installCamsPhone != null">
                #{installCamsPhone,jdbcType=VARCHAR},
            </if>
            <if test="installReserveRemark != null">
                #{installReserveRemark,jdbcType=VARCHAR},
            </if>
            <if test="surveyFinishFailReason != null">
                #{surveyFinishFailReason,jdbcType=VARCHAR},
            </if>
            <if test="surveyRectifyFailReason != null">
                #{surveyRectifyFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installChangeFailReason != null">
                #{installChangeFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installFinishFailReason != null">
                #{installFinishFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installRectifyFailReason != null">
                #{installRectifyFailReason,jdbcType=VARCHAR},
            </if>
            <if test="closeOrderReason != null">
                #{closeOrderReason,jdbcType=VARCHAR},
            </if>
            <if test="installChangeAttachmentFiles != null">
                #{installChangeAttachmentFiles,jdbcType=VARCHAR},
            </if>
            <if test="surveyReserveFailInfo != null">
                #{surveyReserveFailInfo,jdbcType=VARCHAR},
            </if>
            <if test="installReserveFailInfo != null">
                #{installReserveFailInfo,jdbcType=VARCHAR},
            </if>
            <if test="files != null">
                #{files,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                #{description,jdbcType=VARCHAR},
            </if>
            <if test="score != null">
                #{score,jdbcType=DECIMAL},
            </if>
            <if test="visitContent != null">
                #{visitContent,jdbcType=VARCHAR},
            </if>
            <if test="invoiceTime != null">
                #{invoiceTime,jdbcType=TIMESTAMP},
            </if>
            <if test="estateType != null">
                #{estateType,jdbcType=INTEGER},
            </if>
            <if test="hasIndependentParking != null">
                #{hasIndependentParking,jdbcType=INTEGER},
            </if>
            <if test="installPosition != null">
                #{installPosition,jdbcType=INTEGER},
            </if>
            <if test="propertyAgree != null">
                #{propertyAgree,jdbcType=INTEGER},
            </if>
            <if test="electricExpand != null">
                #{electricExpand,jdbcType=INTEGER},
            </if>
            <if test="needErectPile != null">
                #{needErectPile,jdbcType=INTEGER},
            </if>
            <if test="dispatchTime != null">
                #{dispatchTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveySubmitExamineTime != null">
                #{surveySubmitExamineTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyApproveTime != null">
                #{surveyApproveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installSubmitExamineTime != null">
                #{installSubmitExamineTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installApproveTime != null">
                #{installApproveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="returnVisitTime != null">
                #{returnVisitTime,jdbcType=TIMESTAMP},
            </if>
            <if test="closeTime != null">
                #{closeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createAccount != null">
                #{createAccount,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyAccount != null">
                #{modifyAccount,jdbcType=VARCHAR},
            </if>
            <if test="modifyTime != null">
                #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="itemModel != null">
                #{itemModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyWallboxModel != null">
                #{surveyWallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyItemModel != null">
                #{surveyItemModel,jdbcType=VARCHAR},
            </if>
            <if test="installWallboxModel != null">
                #{installWallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="installItemModel != null">
                #{installItemModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyFollowTime != null">
                #{surveyFollowTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installFollowTime != null">
                #{installFollowTime,jdbcType=TIMESTAMP},
            </if>
            <if test="addressLat != null">
                #{addressLat,jdbcType=VARCHAR},
            </if>
            <if test="addressLng != null">
                #{addressLng,jdbcType=VARCHAR},
            </if>
            <if test="connectPerson != null">
                #{connectPerson,jdbcType=VARCHAR},
            </if>
            <if test="wantHomeTime != null">
                #{wantHomeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installEmergencyLevel != null">
                #{installEmergencyLevel,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="isConnect != null">
                #{isConnect,jdbcType=INTEGER},
            </if>
            <if test="isNeedSurvey != null">
                #{isNeedSurvey,jdbcType=INTEGER},
            </if>
            <if test="shipno != null">
                #{shipno,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.Order">
        update t_order
        <set>
            <if test="oemId != null">
                oem_id = #{oemId,jdbcType=INTEGER},
            </if>
            <if test="oemAgentId != null">
                oem_agent_id = #{oemAgentId,jdbcType=INTEGER},
            </if>
            <if test="oemAgentInfo != null">
                oem_agent_info = #{oemAgentInfo,jdbcType=VARCHAR},
            </if>
            <if test="oemAgentContactName != null">
                oem_agent_contact_name = #{oemAgentContactName,jdbcType=VARCHAR},
            </if>
            <if test="oemAgentContactPhone != null">
                oem_agent_contact_phone = #{oemAgentContactPhone,jdbcType=VARCHAR},
            </if>
            <if test="outOrderId != null">
                out_order_id = #{outOrderId,jdbcType=VARCHAR},
            </if>
            <if test="contractId != null">
                contract_id = #{contractId,jdbcType=INTEGER},
            </if>
            <if test="supplierContractId != null">
                supplier_contract_id = #{supplierContractId,jdbcType=INTEGER},
            </if>
            <if test="userName != null">
                user_name = #{userName,jdbcType=VARCHAR},
            </if>
            <if test="userPhone != null">
                user_phone = #{userPhone,jdbcType=VARCHAR},
            </if>
            <if test="userSex != null">
                user_sex = #{userSex,jdbcType=INTEGER},
            </if>
            <if test="contactName != null">
                contact_name = #{contactName,jdbcType=VARCHAR},
            </if>
            <if test="contactPhone != null">
                contact_phone = #{contactPhone,jdbcType=VARCHAR},
            </if>
            <if test="regionId != null">
                region_id = #{regionId,jdbcType=VARCHAR},
            </if>
            <if test="warehouseId != null">
                warehouse_id = #{warehouseId,jdbcType=VARCHAR},
            </if>
            <if test="address != null">
                address = #{address,jdbcType=VARCHAR},
            </if>
            <if test="vehicleModel != null">
                vehicle_model = #{vehicleModel,jdbcType=VARCHAR},
            </if>
            <if test="vehicleChassisNo != null">
                vehicle_chassis_no = #{vehicleChassisNo,jdbcType=VARCHAR},
            </if>
            <if test="vehicleVin != null">
                vehicle_vin = #{vehicleVin,jdbcType=VARCHAR},
            </if>
            <if test="vehicleParkingNo != null">
                vehicle_parking_no = #{vehicleParkingNo,jdbcType=VARCHAR},
            </if>
            <if test="vehicleParkingStatus != null">
                vehicle_parking_status = #{vehicleParkingStatus,jdbcType=VARCHAR},
            </if>
            <if test="surveyBeforeSaleEnable != null">
                survey_before_sale_enable = #{surveyBeforeSaleEnable,jdbcType=INTEGER},
            </if>
            <if test="manuDispatchEnable != null">
                manu_dispatch_enable = #{manuDispatchEnable,jdbcType=INTEGER},
            </if>
            <if test="wallboxModel != null">
                wallbox_model = #{wallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=INTEGER},
            </if>
            <if test="expandStatus != null">
                expand_status = #{expandStatus,jdbcType=INTEGER},
            </if>
            <if test="expandFailReason != null">
                expand_fail_reason = #{expandFailReason,jdbcType=VARCHAR},
            </if>
            <if test="expandFailOperate != null">
                expand_fail_operate = #{expandFailOperate,jdbcType=INTEGER},
            </if>
            <if test="expandRemark != null">
                expand_remark = #{expandRemark,jdbcType=VARCHAR},
            </if>
            <if test="surveyStaffId != null">
                survey_staff_id = #{surveyStaffId,jdbcType=INTEGER},
            </if>
            <if test="surveyFinishTime != null">
                survey_finish_time = #{surveyFinishTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyReserveTime != null">
                survey_reserve_time = #{surveyReserveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyClientName != null">
                survey_client_name = #{surveyClientName,jdbcType=VARCHAR},
            </if>
            <if test="surveyClientPhone != null">
                survey_client_phone = #{surveyClientPhone,jdbcType=VARCHAR},
            </if>
            <if test="surveyCamsPhone != null">
                survey_cams_phone = #{surveyCamsPhone,jdbcType=VARCHAR},
            </if>
            <if test="surveyReserveRemark != null">
                survey_reserve_remark = #{surveyReserveRemark,jdbcType=VARCHAR},
            </if>
            <if test="installSupplierId != null">
                install_supplier_id = #{installSupplierId,jdbcType=INTEGER},
            </if>
            <if test="installStaffId != null">
                install_staff_id = #{installStaffId,jdbcType=INTEGER},
            </if>
            <if test="installFinishTime != null">
                install_finish_time = #{installFinishTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installReserveTime != null">
                install_reserve_time = #{installReserveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installClientName != null">
                install_client_name = #{installClientName,jdbcType=VARCHAR},
            </if>
            <if test="installClientPhone != null">
                install_client_phone = #{installClientPhone,jdbcType=VARCHAR},
            </if>
            <if test="installCamsPhone != null">
                install_cams_phone = #{installCamsPhone,jdbcType=VARCHAR},
            </if>
            <if test="installReserveRemark != null">
                install_reserve_remark = #{installReserveRemark,jdbcType=VARCHAR},
            </if>
            <if test="surveyFinishFailReason != null">
                survey_finish_fail_reason = #{surveyFinishFailReason,jdbcType=VARCHAR},
            </if>
            <if test="surveyRectifyFailReason != null">
                survey_rectify_fail_reason = #{surveyRectifyFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installChangeFailReason != null">
                install_change_fail_reason = #{installChangeFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installFinishFailReason != null">
                install_finish_fail_reason = #{installFinishFailReason,jdbcType=VARCHAR},
            </if>
            <if test="installRectifyFailReason != null">
                install_rectify_fail_reason = #{installRectifyFailReason,jdbcType=VARCHAR},
            </if>
            <if test="closeOrderReason != null">
                close_order_reason = #{closeOrderReason,jdbcType=VARCHAR},
            </if>
            <if test="installChangeAttachmentFiles != null">
                install_change_attachment_files = #{installChangeAttachmentFiles,jdbcType=VARCHAR},
            </if>
            <if test="surveyReserveFailInfo != null">
                survey_reserve_fail_info = #{surveyReserveFailInfo,jdbcType=VARCHAR},
            </if>
            <if test="installReserveFailInfo != null">
                install_reserve_fail_info = #{installReserveFailInfo,jdbcType=VARCHAR},
            </if>
            <if test="files != null">
                files = #{files,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                description = #{description,jdbcType=VARCHAR},
            </if>
            <if test="score != null">
                score = #{score,jdbcType=DECIMAL},
            </if>
            <if test="visitContent != null">
                visit_content = #{visitContent,jdbcType=VARCHAR},
            </if>
            <if test="invoiceTime != null">
                invoice_time = #{invoiceTime,jdbcType=TIMESTAMP},
            </if>
            <if test="estateType != null">
                estate_type = #{estateType,jdbcType=INTEGER},
            </if>
            <if test="hasIndependentParking != null">
                has_independent_parking = #{hasIndependentParking,jdbcType=INTEGER},
            </if>
            <if test="installPosition != null">
                install_position = #{installPosition,jdbcType=INTEGER},
            </if>
            <if test="propertyAgree != null">
                property_agree = #{propertyAgree,jdbcType=INTEGER},
            </if>
            <if test="electricExpand != null">
                electric_expand = #{electricExpand,jdbcType=INTEGER},
            </if>
            <if test="needErectPile != null">
                need_erect_pile = #{needErectPile,jdbcType=INTEGER},
            </if>
            <if test="dispatchTime != null">
                dispatch_time = #{dispatchTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveySubmitExamineTime != null">
                survey_submit_examine_time = #{surveySubmitExamineTime,jdbcType=TIMESTAMP},
            </if>
            <if test="surveyApproveTime != null">
                survey_approve_time = #{surveyApproveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installSubmitExamineTime != null">
                install_submit_examine_time = #{installSubmitExamineTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installApproveTime != null">
                install_approve_time = #{installApproveTime,jdbcType=TIMESTAMP},
            </if>
            <if test="returnVisitTime != null">
                return_visit_time = #{returnVisitTime,jdbcType=TIMESTAMP},
            </if>
            <if test="closeTime != null">
                close_time = #{closeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createAccount != null">
                create_account = #{createAccount,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyAccount != null">
                modify_account = #{modifyAccount,jdbcType=VARCHAR},
            </if>
            <if test="modifyTime != null">
                modify_time = #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="itemModel != null">
                item_model = #{itemModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyWallboxModel != null">
                survey_wallbox_model = #{surveyWallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyItemModel != null">
                survey_item_model = #{surveyItemModel,jdbcType=VARCHAR},
            </if>
            <if test="installWallboxModel != null">
                install_wallbox_model = #{installWallboxModel,jdbcType=VARCHAR},
            </if>
            <if test="installItemModel != null">
                install_item_model = #{installItemModel,jdbcType=VARCHAR},
            </if>
            <if test="surveyFollowTime != null">
                survey_follow_time = #{surveyFollowTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installFollowTime != null">
                install_follow_time = #{installFollowTime,jdbcType=TIMESTAMP},
            </if>
            <if test="addressLat != null">
                address_lat = #{addressLat,jdbcType=VARCHAR},
            </if>
            <if test="addressLng != null">
                address_lng = #{addressLng,jdbcType=VARCHAR},
            </if>
            <if test="connectPerson != null">
                connect_person = #{connectPerson,jdbcType=VARCHAR},
            </if>
            <if test="wantHomeTime != null">
                want_home_time = #{wantHomeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="installEmergencyLevel != null">
                install_emergency_level = #{installEmergencyLevel,jdbcType=INTEGER},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="isConnect != null">
                is_connect = #{isConnect,jdbcType=INTEGER},
            </if>
            <if test="isNeedSurvey != null">
                is_need_survey = #{isNeedSurvey,jdbcType=INTEGER},
            </if>
            <if test="shipno != null">
                shipno = #{shipno,jdbcType=VARCHAR},
            </if>
            <if test="knowAfterSalesChannel != null">
                know_after_sales_channel = #{knowAfterSalesChannel,jdbcType=INTEGER},
            </if>
            <if test="installLength != null">
                install_length = #{installLength,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <update id="update" parameterType="com.boco.nbd.wios.manage.entity.bo.Order">
        update t_order
        set oem_id                          = #{oemId,jdbcType=INTEGER},
            oem_agent_id                    = #{oemAgentId,jdbcType=INTEGER},
            oem_agent_contact_name          = #{oemAgentContactName,jdbcType=VARCHAR},
            oem_agent_info                  = #{oemAgentInfo,jdbcType=VARCHAR},
            oem_agent_contact_phone         = #{oemAgentContactPhone,jdbcType=VARCHAR},
            out_order_id                    = #{outOrderId,jdbcType=VARCHAR},
            contract_id                     = #{contractId,jdbcType=INTEGER},
            supplier_contract_id            = #{supplierContractId,jdbcType=INTEGER},
            user_name                       = #{userName,jdbcType=VARCHAR},
            user_phone                      = #{userPhone,jdbcType=VARCHAR},
            user_sex                        = #{userSex,jdbcType=INTEGER},
            contact_name                    = #{contactName,jdbcType=VARCHAR},
            contact_phone                   = #{contactPhone,jdbcType=VARCHAR},
            region_id                       = #{regionId,jdbcType=VARCHAR},
            warehouse_id                    = #{warehouseId,jdbcType=VARCHAR},
            address                         = #{address,jdbcType=VARCHAR},
            vehicle_model                   = #{vehicleModel,jdbcType=VARCHAR},
            vehicle_chassis_no              = #{vehicleChassisNo,jdbcType=VARCHAR},
            vehicle_vin                     = #{vehicleVin,jdbcType=VARCHAR},
            vehicle_parking_no              = #{vehicleParkingNo,jdbcType=VARCHAR},
            vehicle_parking_status          = #{vehicleParkingStatus,jdbcType=VARCHAR},
            survey_before_sale_enable       = #{surveyBeforeSaleEnable,jdbcType=INTEGER},
            manu_dispatch_enable            = #{manuDispatchEnable,jdbcType=INTEGER},
            wallbox_model                   = #{wallboxModel,jdbcType=VARCHAR},
            status                          = #{status,jdbcType=INTEGER},
            type                            = #{type,jdbcType=INTEGER},
            expand_status                   = #{expandStatus,jdbcType=INTEGER},
            expand_fail_reason              = #{expandFailReason,jdbcType=VARCHAR},
            expand_fail_operate             = #{expandFailOperate,jdbcType=INTEGER},
            expand_remark                   = #{expandRemark,jdbcType=VARCHAR},
            survey_staff_id                 = #{surveyStaffId,jdbcType=INTEGER},
            survey_finish_time              = #{surveyFinishTime,jdbcType=TIMESTAMP},
            survey_reserve_time             = #{surveyReserveTime,jdbcType=TIMESTAMP},
            survey_client_name              = #{surveyClientName,jdbcType=VARCHAR},
            survey_client_phone             = #{surveyClientPhone,jdbcType=VARCHAR},
            survey_cams_phone               = #{surveyCamsPhone,jdbcType=VARCHAR},
            survey_reserve_remark           = #{surveyReserveRemark,jdbcType=VARCHAR},
            install_supplier_id             = #{installSupplierId,jdbcType=INTEGER},
            install_staff_id                = #{installStaffId,jdbcType=INTEGER},
            install_finish_time             = #{installFinishTime,jdbcType=TIMESTAMP},
            install_reserve_time            = #{installReserveTime,jdbcType=TIMESTAMP},
            install_client_name             = #{installClientName,jdbcType=VARCHAR},
            install_client_phone            = #{installClientPhone,jdbcType=VARCHAR},
            install_cams_phone              = #{installCamsPhone,jdbcType=VARCHAR},
            install_reserve_remark          = #{installReserveRemark,jdbcType=VARCHAR},
            survey_finish_fail_reason       = #{surveyFinishFailReason,jdbcType=VARCHAR},
            survey_rectify_fail_reason      = #{surveyRectifyFailReason,jdbcType=VARCHAR},
            install_change_fail_reason      = #{installChangeFailReason,jdbcType=VARCHAR},
            install_finish_fail_reason      = #{installFinishFailReason,jdbcType=VARCHAR},
            install_rectify_fail_reason     = #{installRectifyFailReason,jdbcType=VARCHAR},
            close_order_reason              = #{closeOrderReason,jdbcType=VARCHAR},
            install_change_attachment_files = #{installChangeAttachmentFiles,jdbcType=VARCHAR},
            survey_reserve_fail_info        = #{surveyReserveFailInfo,jdbcType=VARCHAR},
            install_reserve_fail_info       = #{installReserveFailInfo,jdbcType=VARCHAR},
            files                           = #{files,jdbcType=VARCHAR},
            description                     = #{description,jdbcType=VARCHAR},
            score                           = #{score,jdbcType=DECIMAL},
            visit_content                   = #{visitContent,jdbcType=VARCHAR},
            invoice_time                    = #{invoiceTime,jdbcType=TIMESTAMP},
            estate_type                     = #{estateType,jdbcType=INTEGER},
            has_independent_parking         = #{hasIndependentParking,jdbcType=INTEGER},
            install_position                = #{installPosition,jdbcType=INTEGER},
            property_agree                  = #{propertyAgree,jdbcType=INTEGER},
            electric_expand                 = #{electricExpand,jdbcType=INTEGER},
            need_erect_pile                 = #{needErectPile,jdbcType=INTEGER},
            dispatch_time                   = #{dispatchTime,jdbcType=TIMESTAMP},
            survey_submit_examine_time      = #{surveySubmitExamineTime,jdbcType=TIMESTAMP},
            survey_approve_time             = #{surveyApproveTime,jdbcType=TIMESTAMP},
            install_submit_examine_time     = #{installSubmitExamineTime,jdbcType=TIMESTAMP},
            install_approve_time            = #{installApproveTime,jdbcType=TIMESTAMP},
            return_visit_time               = #{returnVisitTime,jdbcType=TIMESTAMP},
            close_time                      = #{closeTime,jdbcType=TIMESTAMP},
            create_account                  = #{createAccount,jdbcType=VARCHAR},
            create_time                     = #{createTime,jdbcType=TIMESTAMP},
            modify_account                  = #{modifyAccount,jdbcType=VARCHAR},
            modify_time                     = #{modifyTime,jdbcType=TIMESTAMP},
            item_model                      = #{itemModel,jdbcType=VARCHAR},
            survey_wallbox_model            = #{surveyWallboxModel,jdbcType=VARCHAR},
            survey_item_model               = #{surveyItemModel,jdbcType=VARCHAR},
            install_wallbox_model           = #{installWallboxModel,jdbcType=VARCHAR},
            install_item_model              = #{installItemModel,jdbcType=VARCHAR},
            survey_follow_time              = #{surveyFollowTime,jdbcType=TIMESTAMP},
            install_follow_time             = #{installFollowTime,jdbcType=TIMESTAMP},
            address_lat                     = #{addressLat,jdbcType=VARCHAR},
            address_lng                     = #{addressLng,jdbcType=VARCHAR},
            want_home_time                  = #{wantHomeTime,jdbcType=TIMESTAMP},
            install_emergency_level         = #{installEmergencyLevel,jdbcType=VARCHAR},
            remark                          = #{remark,jdbcType=VARCHAR},
            is_connect                      = #{isConnect,jdbcType=INTEGER},
            is_need_survey                  = #{isNeedSurvey,jdbcType=INTEGER},
            shipno                          = #{record.shipno,jdbcType=VARCHAR}
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <update id="clearInstallStaff" parameterType="java.lang.String">
        update t_order
        set install_staff_id = null
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <update id="clearSurveyFollowTime" parameterType="java.lang.String">
        update t_order
        set survey_follow_time = null
        where id = #{orderId,jdbcType=VARCHAR}
    </update>
    <update id="clearInstallFollowTime" parameterType="java.lang.String">
        update t_order
        set install_follow_time = null
        where id = #{orderId,jdbcType=VARCHAR}
    </update>

    <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_order
        where id = #{id,jdbcType=VARCHAR}
    </select>

    <select id="selectDetailById" parameterType="java.lang.String"
            resultType="com.boco.nbd.wios.manage.entity.bo.OrderVo">
        select
        <include refid="Order_Column_List"/>,
        oem.name as oemName,
        oem.code as oemCode,
        oem.organization_code as oemOrgCode,
        oem2.name as oemAgentName,
        oem2.code as oemAgentCode,
        oem2.organization_code as oemAgentOrgCode,
        sup.name as supplierName,
        staff.name as surveyStaffName,
        staff.phone as surveyStaffPhone,
        staff2.name as installStaffName,
        staff2.phone as installStaffPhone,
        case
        when region_level = 1 then country_name
        when region_level = 2 then area_name
        when region_level = 3 then province_name
        when region_level = 5 then city_name
        else region_name
        end as regionName,
        sp.secret_no as virtualUserPhone
        from t_order t
        left join t_oem oem on oem.id = t.oem_id
        left join t_oem oem2 on oem2.id = t.oem_agent_id
        left join t_supplier sup on sup.id = t.install_supplier_id
        left join t_supplier_staff staff on staff.id = t.survey_staff_id
        left join t_supplier_staff staff2 on staff2.id = t.install_staff_id
        left join t_secret_phone sp on sp.phone = t.user_phone and sp.status = 1
        where t.id = #{id}
    </select>

    <select id="selectByExample" parameterType="com.boco.nbd.wios.manage.entity.bo.OrderBo"
            resultType="com.boco.nbd.wios.manage.entity.bo.OrderVo">
        select
        <include refid="Order_Column_List"/>,
        reg.name as regionName,si.overtime_flag as overtimeFlag
        <if test="fromExport != null and fromExport == 1">
            ,oi.wallbox_no as wallboxNo
            ,oi.real_cable_meter as realCableMeter
            ,oi.predict_total_fee as predictTotalFee
            ,os.latitude
            ,os.longitude
            ,oi.wallbox_item_id as wallboxItemId
        </if>
        from t_order t
        left join t_region reg on reg.id=t.region_id
        <if test="fromExport != null and fromExport == 1">
            left join t_order_install oi on oi.order_id=t.id
            left join t_order_survey os on os.order_id=t.id
        </if>
        left join (SELECT a.* FROM (select * FROM t_system_info where account_id = 0 order by id desc) a GROUP BY
        a.third_party_id) si on si.third_party_id = t.id and si.order_status = t.status and si.overtime_flag > 0
        <where>
            <if test="id != null and id != ''">
                and t.id = #{id}
            </if>
            <if test="outOrderId != null and outOrderId != ''">
                and t.out_order_id = #{outOrderId}
            </if>
            <if test="oemId != null and oemId != ''">
                and t.oem_id = #{oemId}
            </if>
            <if test="oemAgentId != null and oemAgentId != ''">
                and t.oem_agent_id = #{oemAgentId}
            </if>
            <if test="userName != null and userName != ''">
                <bind name="userNameLike" value="'%' + userName + '%'"/>
                and t.user_name like #{userNameLike}
            </if>
            <if test="userPhone != null and userPhone != ''">
                and t.user_phone = #{userPhone}
            </if>

            <if test="status != null">
                and t.status = #{status}
            </if>
            <if test="installStaffId != null">
                and t.install_staff_id = #{installStaffId}
            </if>
            <if test="installSupplierId != null">
                and t.install_supplier_id = #{installSupplierId}
            </if>
            <if test="type != null">
                and t.type = #{type}
            </if>
            <if test="overtimeType != null">
                and si.overtime_flag = #{overtimeType}
            </if>
            <if test="regionIdList != null">
                and t.region_id in
                <foreach collection="regionIdList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="createStartTime != null and createStartTime != ''">
                and t.create_time &gt;= #{createStartTime}
            </if>
            <if test="createEndTime != null and createEndTime != ''">
                and t.create_time &lt;= #{createEndTime}
            </if>
            <if test="surveyFinishStartTime != null and surveyFinishStartTime != ''">
                and t.survey_finish_time &gt;= #{surveyFinishStartTime}
            </if>
            <if test="surveyFinishEndTime != null and surveyFinishEndTime != ''">
                and t.survey_finish_time &lt;= #{surveyFinishEndTime}
            </if>
            <if test="installFinishStartTime != null and installFinishStartTime != ''">
                and t.install_finish_time &gt;= #{installFinishStartTime}
            </if>
            <if test="installFinishEndTime != null and installFinishEndTime != ''">
                and t.install_finish_time &lt;= #{installFinishEndTime}
            </if>
            <if test="oemIdList != null">
                and t.oem_id in
                <foreach collection="oemIdList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="filterOemIds != null">
                and t.oem_id in
                <foreach collection="filterOemIds" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="filterSupplierIds != null">
                and t.install_supplier_id in
                <foreach collection="filterSupplierIds" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="statusInList != null">
                and t.status in
                <foreach collection="statusInList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="idInList != null">
                and t.id in
                <foreach collection="idInList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="scoreGt != null">
                and t.score &gt; #{scoreGt}
            </if>
            <if test="scoreLt != null">
                and t.score &lt;= #{scoreLt}
            </if>
            <if test="expandStatusInt != null and expandStatusInt == 0">
                and t.expand_status is null
            </if>
            <if test="oemAgentInfo != null and oemAgentInfo != ''">
                <bind name="oemAgentInfoLike" value="'%' + oemAgentInfo + '%'"/>
                and t.oem_agent_info like #{oemAgentInfoLike}
            </if>

            <if test="isClosed != null">
                and t.status != #{isClosed}
            </if>
            <if test="fromExport != null and fromExport == 1">
                <if test="wallboxNo != null and wallboxNo != ''">
                    and oi.wallbox_no = #{wallboxNo}
                </if>
            </if>

        </where>
        order by t.create_time desc
    </select>

    <select id="selectAll" parameterType="com.boco.nbd.wios.manage.entity.bo.OrderBo"
            resultType="com.boco.nbd.wios.manage.entity.bo.Order">
        select t.*
        from t_order t
        <where>
            <if test="id != null">
                and t.id = #{id}
            </if>
            <if test="regionId != null">
                and t.region_id = #{regionId}
            </if>
            <if test="regionIdTree != null">
                and t.region_id like '${regionIdTree}%'
            </if>
            <if test="installSupplierId != null">
                and t.install_supplier_id = #{installSupplierId}
            </if>
            <if test="status != null">
                and t.status = #{status}
            </if>
            <if test="createStartTime != null and createStartTime != ''">
                and t.create_time &gt;= #{createStartTime}
            </if>
            <if test="createEndTime != null and createEndTime != ''">
                and t.create_time &lt;= #{createEndTime}
            </if>
            <if test="statusNotInList != null">
                and t.status not in
                <foreach collection="statusNotInList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="createStartTime != null and createStartTime != ''">
                and t.create_time &gt;= #{createStartTime}
            </if>
            <if test="createEndTime != null and createEndTime != ''">
                and t.create_time &lt;= #{createEndTime}
            </if>
            <if test="month != null and month != ''">
                and date_format(t.install_finish_time,'%Y%m') = #{month}
            </if>

            <if test="quarterFirstMonth != null and quarterFirstMonth != ''">
                and date_format(t.dispatch_time,'%Y%m') &gt;= #{quarterFirstMonth}
            </if>

            <if test="quarterLastMonth != null and quarterLastMonth != ''">
                and date_format(t.dispatch_time,'%Y%m') &lt;= #{quarterLastMonth}
            </if>
            <if test="outOrderId != null and outOrderId != ''">
                and t.out_order_id = #{outOrderId}
            </if>

        </where>
        order by t.create_time desc
    </select>

    <select id="installCompleteList" parameterType="com.boco.nbd.wios.manage.entity.bo.OrderBo"
            resultType="com.boco.nbd.wios.manage.entity.bo.InstallComplete">
        select id,out_order_id,warehouse_id,status
        from t_order
        <where>
            <if test="id != null and id != ''">
                id like concat('%',#{id}, '%')
            </if>
            and status &lt; 64
        </where>
        order by create_time desc
    </select>

    <select id="selectWarrantyOrders" resultType="com.boco.nbd.wios.manage.entity.bo.WarrantyOrder">
        select tt.* from (
        SELECT
        t.id AS orderId,
        t.user_name AS userName,
        t.user_phone AS userPhone,
        t.install_finish_time AS startTime,
        oi.wallbox_no AS wallboxNo,
        DATE_ADD(t.install_finish_time,INTERVAL oc.guarantee_period MONTH) as endTime
        FROM
        t_order t
        LEFT JOIN t_order_install oi ON oi.order_id = t.id
        LEFT JOIN t_oem_contract oc ON oc.id = t.contract_id
        WHERE
        t.install_finish_time IS NOT NULL
        AND
        t.contract_id IS NOT NULL
        and
        t.type=1
        ) as tt
        <where>
            <if test="expireStartDateStr != null and expireStartDateStr != ''">
                and tt.endTime &gt;= #{expireStartDateStr}
            </if>
            <if test="expireEndDateStr != null and expireEndDateStr != ''">
                and tt.endTime &lt;= #{expireEndDateStr}
            </if>
            <if test="userName != null and userName != ''">
                and tt.userName = #{userName}
            </if>
            <if test="userPhone != null and userPhone != ''">
                and tt.userPhone = #{userPhone}
            </if>
            <if test="orderId != null and orderId != ''">
                and tt.orderId = #{orderId}
            </if>
            <if test="wallboxNo != null and wallboxNo != ''">
                and tt.wallboxNo = #{wallboxNo}
            </if>
        </where>
        <if test="orderBy==1">
            ORDER BY tt.endTime asc
        </if>
        <if test="orderBy==2">
            ORDER BY tt.endTime desc
        </if>
    </select>

    <select id="selectByCamsPhone" resultType="com.boco.nbd.wios.manage.entity.bo.OrderVo">
        select
        <include refid="Order_Column_List"/>,
        staff.name as installStaffName,
        staff.phone as installStaffPhone,
        oi.predict_total_fee as installAdditionTotalFee,
        oi.expand_fee as expandFee,
        (select count(id) > 0
        from t_operate_log l
        where l.third_party_id = t.id
        and l.name = '61') as hasOrderScore
        from t_order t
        left join t_supplier_staff staff on staff.id = t.install_staff_id
        left join t_order_install oi on oi.order_id = t.id
        where t.survey_client_phone = #{camsPhone}
        or t.user_phone = #{camsPhone}
        order by t.create_time desc
    </select>

    <!--    modify 2022-11-22
    以前的坑,survey_staff_id字段根本就没用,survey_staff_id 也存到了install_staff_id中
          staff.name as installStaffName,
        staff.phone as installStaffPhone,
          left join t_supplier_staff staff on staff.id = t.install_staff_id
    -->

    <select id="selectByCamsPhoneForApp" resultType="com.boco.nbd.wios.manage.entity.bo.OrderVo">
        select
        <include refid="Order_Column_List"/>,
        oi.predict_total_fee as installAdditionTotalFee,
        oi.expand_fee as expandFee,
        upb.id as billId,
        upb.status as billStatus,
        upb.amount as billFee,
        case when t.status = 64 then 4 when t.status = 61 then 3
        when t.status = 52 then 2 else 1
        end as appSort
        from t_order t
        left join t_order_install oi on oi.order_id = t.id
        left join t_user_pay_bill upb on upb.ref_id = t.id
        where t.status != 64 and (t.survey_cams_phone = #{camsPhone}
        or t.user_phone = #{camsPhone}
        or t.install_cams_phone = #{camsPhone})
        order by t.modify_time desc
    </select>

    <select id="countByCamsPhone" resultType="java.lang.Integer">
        select count(t.id)
        from t_order t
        where t.survey_client_phone = #{camsPhone}
           or t.user_phone = #{camsPhone}
    </select>

    <select id="selectOwnOrder" resultType="com.boco.nbd.wios.manage.entity.bo.OrderVo">
        select
        <include refid="Order_Column_List"/>,
        oem.name as oemName,
        oem2.name as oemAgentName,
        sup.name as supplierName,
        sup.level as supplierLevel,
        max(staff.name) as surveyStaffName,
        max(staff.phone) as surveyStaffPhone,
        max(staff2.name) as installStaffName,
        max(staff2.phone) as installStaffPhone,
        sp.secret_no as virtualUserPhone,
        oi.wallbox_no as wallboxNo
        from t_order t
        left join t_oem oem on oem.id=t.oem_id
        left join t_oem oem2 on oem2.id=t.oem_agent_id
        left join t_supplier sup on sup.id=t.install_supplier_id
        left join (select id,name,phone from t_supplier_staff union all select id,name,phone from wb_account) staff on
        staff.id=t.survey_staff_id
        left join (select id,name,phone from t_supplier_staff union all select id,name,phone from wb_account) staff2 on
        staff2.id=t.install_staff_id
        left join t_secret_phone sp on sp.phone=t.user_phone and sp.status=1
        left join t_order_install oi on oi.order_id=t.id
        <where>
            <if test="id != null and id !='' ">
                and t.id = #{id}
            </if>
            <if test="type != null">
                and t.type = #{type}
            </if>
            <if test="regionId != null and regionId != null">
                and t.region_id in
                <foreach collection="regionId.split(',')" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="installSupplierId != null">
                and t.install_supplier_id = #{installSupplierId}
            </if>
            <if test="staffId != null">
                and (t.survey_staff_id = #{staffId} or t.install_staff_id = #{staffId} )
            </if>
            <if test="status != null">
                and t.status = #{status}
            </if>
            <if test="statusNotInList != null and statusNotInList.size() > 0">
                and t.status not in
                <foreach collection="statusNotInList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        order by t.create_time desc
    </select>
    <select id="selectSurveyPeriodOrders" resultType="com.boco.nbd.wios.manage.entity.bo.Order">
        select
        <include refid="Base_Column_List"/>
        from t_order
        where survey_follow_time &gt;= #{dateStart}
        and survey_follow_time &lt;=#{dateEnd}
        and status != 64
    </select>
    <select id="selectInstallPeriodOrders" resultType="com.boco.nbd.wios.manage.entity.bo.Order">
        select
        <include refid="Base_Column_List"/>
        from t_order
        where install_follow_time &gt;= #{dateStart}
        and install_follow_time &lt;=#{dateEnd}
        and status != 64
    </select>

    <insert id="batchInsert" parameterType="java.util.List">
        insert into t_order (id, oem_id, oem_agent_id, oem_agent_info,
        oem_agent_contact_name, oem_agent_contact_phone,
        out_order_id, contract_id, supplier_contract_id,
        user_name, user_phone, user_sex,
        contact_name, contact_phone,region_id,
        warehouse_id, address, vehicle_model,
        vehicle_chassis_no, vehicle_vin, vehicle_parking_no,
        vehicle_parking_status, survey_before_sale_enable,
        manu_dispatch_enable, wallbox_model, status,
        type, expand_status, expand_fail_reason,
        expand_fail_operate, expand_remark, survey_staff_id,
        survey_finish_time, survey_reserve_time,
        survey_client_name, survey_client_phone, survey_cams_phone,
        survey_reserve_remark, install_supplier_id,
        install_staff_id, install_finish_time, install_reserve_time,
        install_client_name, install_client_phone,
        install_cams_phone, install_reserve_remark,
        survey_finish_fail_reason, survey_rectify_fail_reason,
        install_change_fail_reason, install_finish_fail_reason,
        install_rectify_fail_reason, close_order_reason,
        install_change_attachment_files, survey_reserve_fail_info,
        install_reserve_fail_info, files, description,
        score, visit_content, invoice_time,
        estate_type, has_independent_parking, install_position,
        property_agree, electric_expand, need_erect_pile,
        dispatch_time, survey_submit_examine_time,
        survey_approve_time, install_submit_examine_time,
        install_approve_time, return_visit_time,
        close_time, create_account, create_time,
        modify_account, modify_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.id,jdbcType=VARCHAR}, #{item.oemId,jdbcType=INTEGER}, #{item.oemAgentId,jdbcType=INTEGER},
            #{item.oemAgentInfo,jdbcType=VARCHAR},
            #{item.oemAgentContactName,jdbcType=VARCHAR}, #{item.oemAgentContactPhone,jdbcType=VARCHAR},
            #{item.outOrderId,jdbcType=VARCHAR}, #{item.contractId,jdbcType=INTEGER},
            #{item.supplierContractId,jdbcType=INTEGER},
            #{item.userName,jdbcType=VARCHAR}, #{item.userPhone,jdbcType=VARCHAR}, #{item.userSex,jdbcType=INTEGER},
            #{item.contactName,jdbcType=VARCHAR}, #{item.contactPhone,jdbcType=VARCHAR},
            #{item.regionId,jdbcType=VARCHAR},
            #{item.warehouseId,jdbcType=VARCHAR}, #{item.address,jdbcType=VARCHAR},
            #{item.vehicleModel,jdbcType=VARCHAR},
            #{item.vehicleChassisNo,jdbcType=VARCHAR}, #{item.vehicleVin,jdbcType=VARCHAR},
            #{item.vehicleParkingNo,jdbcType=VARCHAR},
            #{item.vehicleParkingStatus,jdbcType=VARCHAR}, #{item.surveyBeforeSaleEnable,jdbcType=INTEGER},
            #{item.manuDispatchEnable,jdbcType=INTEGER}, #{item.wallboxModel,jdbcType=VARCHAR},
            #{item.status,jdbcType=INTEGER},
            #{item.type,jdbcType=INTEGER}, #{item.expandStatus,jdbcType=INTEGER},
            #{item.expandFailReason,jdbcType=VARCHAR},
            #{item.expandFailOperate,jdbcType=INTEGER}, #{item.expandRemark,jdbcType=VARCHAR},
            #{item.surveyStaffId,jdbcType=INTEGER},
            #{item.surveyFinishTime,jdbcType=TIMESTAMP}, #{item.surveyReserveTime,jdbcType=TIMESTAMP},
            #{item.surveyClientName,jdbcType=VARCHAR}, #{item.surveyClientPhone,jdbcType=VARCHAR},
            #{item.surveyCamsPhone,jdbcType=VARCHAR},
            #{item.surveyReserveRemark,jdbcType=VARCHAR}, #{item.installSupplierId,jdbcType=INTEGER},
            #{item.installStaffId,jdbcType=INTEGER}, #{item.installFinishTime,jdbcType=TIMESTAMP},
            #{item.installReserveTime,jdbcType=TIMESTAMP},
            #{item.installClientName,jdbcType=VARCHAR}, #{item.installClientPhone,jdbcType=VARCHAR},
            #{item.installCamsPhone,jdbcType=VARCHAR}, #{item.installReserveRemark,jdbcType=VARCHAR},
            #{item.surveyFinishFailReason,jdbcType=VARCHAR}, #{item.surveyRectifyFailReason,jdbcType=VARCHAR},
            #{item.installChangeFailReason,jdbcType=VARCHAR}, #{item.installFinishFailReason,jdbcType=VARCHAR},
            #{item.installRectifyFailReason,jdbcType=VARCHAR}, #{item.closeOrderReason,jdbcType=VARCHAR},
            #{item.installChangeAttachmentFiles,jdbcType=VARCHAR}, #{item.surveyReserveFailInfo,jdbcType=VARCHAR},
            #{item.installReserveFailInfo,jdbcType=VARCHAR}, #{item.files,jdbcType=VARCHAR},
            #{item.description,jdbcType=VARCHAR},
            #{item.score,jdbcType=DECIMAL}, #{item.visitContent,jdbcType=VARCHAR},
            #{item.invoiceTime,jdbcType=TIMESTAMP},
            #{item.estateType,jdbcType=INTEGER}, #{item.hasIndependentParking,jdbcType=INTEGER},
            #{item.installPosition,jdbcType=INTEGER},
            #{item.propertyAgree,jdbcType=INTEGER}, #{item.electricExpand,jdbcType=INTEGER},
            #{item.needErectPile,jdbcType=INTEGER},
            #{item.dispatchTime,jdbcType=TIMESTAMP}, #{item.surveySubmitExamineTime,jdbcType=TIMESTAMP},
            #{item.surveyApproveTime,jdbcType=TIMESTAMP}, #{item.installSubmitExamineTime,jdbcType=TIMESTAMP},
            #{item.installApproveTime,jdbcType=TIMESTAMP}, #{item.returnVisitTime,jdbcType=TIMESTAMP},
            #{item.closeTime,jdbcType=TIMESTAMP}, #{item.createAccount,jdbcType=VARCHAR},
            #{item.createTime,jdbcType=TIMESTAMP},
            #{item.modifyAccount,jdbcType=VARCHAR}, #{item.modifyTime,jdbcType=TIMESTAMP})
        </foreach>
    </insert>


    <update id="updateInstallWallboxItem" parameterType="java.lang.String">
        update
            t_order
        SET t_order.install_wallbox_model=
                IF
                    (t_order.install_wallbox_model IS NULL OR LENGTH(t_order.install_wallbox_model) = 0,
                     t_order.install_wallbox_model, #{type})
        WHERE id = #{oemId}
    </update>


    <resultMap id="ContractEnumResultMap" type="com.boco.nbd.wios.manage.enums.ContractIdInfo">
        <result column="id" jdbcType="INTEGER" property="id"/>
        <result column="code" jdbcType="INTEGER" property="code"/>
    </resultMap>

    <select id="selectContractEnum" resultMap="ContractEnumResultMap">
        SELECT id,
               `code`
        FROM t_oem_contract
    </select>

</mapper>