<?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.KwOrderUsualLandTransportAmountMapper">

    <select id="findByAddress" parameterType="com.sckw.usual.entity.KwOrderUsualLandTransportAddress"
            resultType="com.sckw.usual.entity.KwOrderUsualLandTransportAmount" >
        select
        kloa1.id, kloa1.order_id orderId, kloa1.address_id lAddressId, kloa1.amount, kloa1.subcontract_amount subcontractAmount,
        kloa1.entrust_amount entrustAmount, kloa1.load_amount loadAmount, kloa1.unload_amount unloadAmount, kloa1.ignore_amount ignoreAmount,
        kloa1.load_time loadTime, kloa1.unload_time unloadTime, kloa1.total_load_amount totalLoadAmount, kloa1.total_unload_amount totalUnloadAmount
        from kw_order_usual_land_transport_amount kloa1
        left join kw_order_usual_land_transport_address kloa2 on kloa2.id = kloa1.address_id
        where kloa1.del_flag = 0 and kloa2.del_flag = 0
        <if test="orderId != null and orderId !=''">
            and kloa1.order_id = #{orderId, jdbcType=BIGINT}
        </if>
        <if test="addressType != null and addressType !=''">
            and kloa2.address_type = #{addressType, jdbcType=INTEGER}
        </if>
    </select>


    <select id="findByLAddressId" resultType="com.sckw.usual.entity.KwOrderUsualLandTransportAmount" >
        select
            id, order_id orderId, address_id addressId, amount, subcontract_amount subcontractAmount,
            entrust_amount entrustAmount, load_amount loadAmount, unload_amount unloadAmount, ignore_amount ignoreAmount,
            load_time loadTime, unload_time unloadTime, total_load_amount totalLoadAmount, total_unload_amount totalUnloadAmount
        from kw_order_usual_land_transport_amount
        where del_flag = 0
          and address_id = #{lAddressId, jdbcType=BIGINT}
    </select>
</mapper>