StorageDepositMapper.xml 4.64 KB
<?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.yoho.order.dal.StorageDepositMapper">
    <resultMap id="BaseResultMap" type="com.yoho.order.model.StorageDeposit">
      <result column="id" property="id" jdbcType="INTEGER" />
      <result column="product_id" property="productId" jdbcType="INTEGER" />
      <result column="goods_id" property="goodsId" jdbcType="INTEGER" />
      <result column="storage_id" property="storageId" jdbcType="INTEGER" />
      <result column="deposit_code" property="depositCode" jdbcType="VARCHAR" />
      <result column="shelf_code" property="shelfCode" jdbcType="VARCHAR" />
      <result column="owner_uid" property="ownerUid" jdbcType="INTEGER" />
      <result column="order_code" property="orderCode" jdbcType="BIGINT" />
      <result column="skup" property="skup" jdbcType="INTEGER" />
      <result column="status" property="status" jdbcType="INTEGER" />
      <result column="order_status" property="order_status" jdbcType="INTEGER" />
      <result column="update_time" property="updateTime" jdbcType="INTEGER" />
      <result column="create_time" property="createTime" jdbcType="INTEGER" />
      <result column="deposit_start_time" property="depositStartTime" jdbcType="INTEGER" />
      <result column="deposit_end_time" property="depositEndTime" jdbcType="INTEGER" />
      <result column="edit_pid" property="editPid" jdbcType="INTEGER" />
      <result column="out_type" property="outType" jdbcType="INTEGER" />
    </resultMap>

    <sql id="Base_Column_List">
        id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code, 
        skup, status, order_status, update_time, create_time, deposit_start_time,
        deposit_end_time, edit_pid, out_type
    </sql>
    
    <insert id="insert" parameterType="com.yoho.order.model.StorageDeposit">
        insert into storage_deposit(id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code, 
        skup, status, order_status, update_time, create_time, deposit_start_time,
        deposit_end_time, edit_pid, out_type)
        values (#{id}, #{productId}, #{goodsId}, #{storageId}, #{depositCode}, #{shelfCode}, #{ownerUid}, #{orderCode},
        #{skup}, #{status}, #{orderStatus}, #{updateTime}, #{createTime}, #{depositStartTime}, #{depositEndTime}, #{editPid}, #{outType})
    </insert>

    <select id="bindShelfCode" resultType="java.lang.Integer">
        update storage_deposit set shelf_code=#{shelfCode} 
        where deposit_code=#{depositCode}
    </select>
    
    <select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
        select count(1)   
        from storage_deposit a
        <if test="depotNo != null">
        LEFT JOIN buyer_order_goods b
        ON( b.order_code=a.order_code) 
        LEFT JOIN seller_order_goods c
        ON( c.id=b.skup) 
        </if>
        where 1=1 
        <if test="list != null and list.size()>0">
           and a.status in 
           <foreach collection="list" item="status" open="(" close=")" separator=",">
              #{status}
           </foreach>
        </if>
        <if test="depotNo != null">
           and c.depot_no=#{depotNo}
        </if>
    </select>
    
    <sql id="Query_Order_Sql" >
     <if test="storageDepositReq.statusList != null and storageDepositReq.statusList.size() >0">
         and a.status in 
         <foreach collection="storageDepositReq.statusList" item="status" open="(" close=")" separator=",">
            #{status}
         </foreach>
     </if>
     <if test="storageDepositReq.status != null">
         and a.status = #{storageDepositReq.status}
     </if>
     <if test="storageDepositReq.depositCode != null and storageDepositReq.depositCode != '' ">
         and a.deposit_code = #{storageDepositReq.depositCode}
     </if>
     <if test="storageDepositReq.orderCode != null and storageDepositReq.orderCode != '' ">
         and a.order_code = #{storageDepositReq.orderCode}
     </if>
    </sql>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.StorageDepositReq">
        select a.*
        from storage_deposit a 
        <if test="storageDepositReq.depotNo != null">
        LEFT JOIN buyer_order_goods b
        ON( b.order_code=a.order_code) 
        LEFT JOIN seller_order_goods c
        ON( c.id=b.skup)
        </if>
        where 1=1 
        <include refid="Query_Order_Sql" />
        <if test="storageDepositReq.start!=null and storageDepositReq.size != null">
         limit #{storageDepositReq.start},#{storageDepositReq.size}
        </if>
    </select>
    
</mapper>