<?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.order.dao.KwoTradeOrderGoodsUnitMapper">

    <select id="findGoodsUnit" resultType="com.sckw.order.model.KwoTradeOrderGoodsUnit" parameterType="java.util.Map" >
        SELECT
        id, t_order_id tOrderId, goods_id goodsId, from_unit fromUnit, to_unit toUnit,
        conversion_value conversionValue, unit, actual_amount actualAmount, remark, status,
        create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
        from kwo_trade_order_goods_unit
        where del_flag = 0
        <if test="tOrderId != null and tOrderId != ''">
            and t_order_id = #{tOrderId, jdbcType=BIGINT}
        </if>
        ORDER BY create_time desc
    </select>

    <select id="findByIdAndUnit" resultType="com.sckw.order.model.KwoTradeOrderGoodsUnit" parameterType="java.util.Map" >
        SELECT
        id, t_order_id tOrderId, goods_id goodsId, from_unit fromUnit, to_unit toUnit,
        conversion_value conversionValue, unit, actual_amount actualAmount, remark, status,
        create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
        from kwo_trade_order_goods_unit
        where del_flag = 0
        <if test="tOrderId != null and tOrderId != ''">
            and t_order_id = #{tOrderId, jdbcType=BIGINT}
        </if>
        <if test="unit != null and unit != ''">
            and unit = #{unit, jdbcType=VARCHAR}
        </if>
        ORDER BY create_time desc
    </select>
</mapper>