<?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.sckw.usual.mapper.KwWaybillOrderAddressMapper">

    <select id="findByAddress" resultType="com.sckw.usual.entity.KwWaybillOrderAddress" >
        select
            id, t_order_id tOrderId, address_type addressType, `name`, `type`, contacts, phone, city_code cityCode, city_name cityName,
            detail_address detailAddress, lat, lng, fence, entry_type entryType, remark, `status`, create_by createBy, create_time createTime,
            update_by updateBy, update_time updateTime
        from kw_waybill_order_address
        where del_flag = 0
          and t_order_id = #{tOrderId, jdbcType=BIGINT}
          and address_type = #{addressType, jdbcType=INTEGER}
    </select>

    <insert id="insertBatch" parameterType="com.sckw.usual.entity.KwWaybillOrderAddress">
        insert into kw_waybill_order_address
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            order_id,
            w_subtask_id,
            l_address_id,
            address_type,
            `name`,
            type,
            contacts,
            phone,
            city_code,
            city_name,
            detail_address,
            lat,
            lng,
            fence,
            entry_type,
            plan_time,
            entrust_amount,
            sort,
            remark,
            `status`,
            create_by
        </trim>
        values
        <foreach collection="list" item="item" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id},
                #{item.orderId},
                #{item.wSubtaskId},
                #{item.lAddressId},
                #{item.addressType},
                #{item.name},
                #{item.type},
                #{item.contacts},
                #{item.phone},
                #{item.cityCode},
                #{item.cityName},
                #{item.detailAddress},
                #{item.lat},
                #{item.lng},
                #{item.fence},
                #{item.entryType},
                #{item.planTime},
                #{item.entrustAmount},
                #{item.sort},
                #{item.remark},
                #{item.status},
                #{item.createBy}
            </trim>
        </foreach>


    </insert>

</mapper>