<?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.shinsoft.sto.mapper.ware.DistributionDetailMapper" >
  <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.ware.DistributionDetail" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="belong_id" property="belongId" jdbcType="VARCHAR" />
    <result column="distrb_id" property="distrbId" jdbcType="VARCHAR" />
    <result column="store_id" property="storeId" jdbcType="VARCHAR" />
    <result column="add_id" property="addId" jdbcType="VARCHAR" />
    <result column="add_time" property="addTime" jdbcType="TIMESTAMP" />
    <result column="modify_id" property="modifyId" jdbcType="VARCHAR" />
    <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
    <result column="cancel_id" property="cancelId" jdbcType="VARCHAR" />
    <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP" />
    <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
  </resultMap>

    <sql id="QueryWhere">
        where 1=1
        <if test="parms.distrbId != null and parms.distrbId != ''">
            and dd.distrb_id = #{parms.distrbId}
        </if>
        <if test="parms.storeId != null and parms.storeId != ''">
            and dd.store_id = #{parms.storeId}
        </if>
        and dd.cancel_flag = '0'
    </sql>

    <select id="selectDistributionDetailPage" resultMap="BaseResultMap" parameterType="map">
        select
            dd.id,
            dd.belong_id,
            dd.distrb_id,
            dd.store_id,
            dd.add_id,
            dd.add_time,
            dd.modify_id,
            dd.modify_time,
            dd.cancel_id,
            dd.cancel_time,
            dd.cancel_flag
        from T_DISTRIBUTION_DETAIL dd
        <include refid="QueryWhere"/>
        order by dd.add_time desc
    </select>
</mapper>

