<?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.hzs.sale.order.mapper.SaOrderSyncMapper">

    <!-- 查询订单同步记录列表 -->
    <select id="queryList" resultType="com.hzs.sale.order.vo.SaOrderSyncVO">
        select 
            sos.pk_id,
            sos.order_code,
            sos.body_detail,
            sos.creation_time,
            sos.status
        from sa_order_sync sos
        <where>
            <if test="param.pkId != null">
                and sos.pk_id = #{param.pkId}
            </if>
            <if test="param.orderCode != null and param.orderCode != ''">
                and sos.order_code like #{param.orderCode} || '%'
            </if>
            <if test="param.status != null">
                and sos.status = #{param.status}
            </if>
            <if test="param.startDate != null and param.startDate != ''">
                and sos.creation_time >= to_date(#{param.startDate}, 'yyyy-mm-dd')
            </if>
            <if test="param.endDate != null and param.endDate != ''">
                and sos.creation_time &lt; to_date(#{param.endDate}, 'yyyy-mm-dd') + 1
            </if>
        </where>
        order by sos.creation_time desc
    </select>

</mapper>