BuyerOrderMapper.xml 3.04 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.BuyerOrderMapper">
    <resultMap id="BaseResultMap" type="com.yoho.order.model.BuyerOrder">
      <result column="id" property="id" jdbcType="INTEGER" />
      <result column="uid" property="uid" jdbcType="INTEGER" />
      <result column="order_code" property="orderCode" jdbcType="BIGINT" />
      <result column="seller_uid" property="sellerUid" jdbcType="INTEGER" />
      <result column="client_type" property="clientType" jdbcType="TINYINT" />
      <result column="payment" property="payment" jdbcType="TINYINT" />
      <result column="payment_type" property="paymentType" jdbcType="TINYINT" />
      <result column="is_cancel" property="isCancel" jdbcType="TINYINT" />
      <result column="amount" property="uid" jdbcType="DECIMAL" />
      <result column="ship_fee" property="shipFee" jdbcType="DECIMAL" />
      <result column="status" property="status" jdbcType="TINYINT" />
      <result column="create_time" property="createTime" jdbcType="INTEGER" />
      <result column="update_time" property="updateTime" jdbcType="INTEGER" />
      <result column="order_status" property="orderStatus" jdbcType="TINYINT" />
      <result column="channel_no" property="channelNo" jdbcType="VARCHAR" />
    </resultMap>
    
    <sql id="Base_Column_List">
        id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel,
        amount, ship_fee, status, create_time, update_time, order_status, channel_no
    </sql>

    <select id="selectById" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from buyer_order where id = #{id}
    </select>
    
    <select id="selectCountByStatus" resultType="java.lang.Integer">
        select count(1)   
        from buyer_order where status in 
        <foreach collection="list" item="status" open="(" close=")" separator=",">
        #{status}
      </foreach>
    </select>
    
    <sql id="Query_Order_Sql" >
     <if test="buyerOrderReq.statusList != null and buyerOrderReq.statusList.size() > 0">
         and status in 
        <foreach collection="buyerOrderReq.statusList" item="status" open="(" close=")" separator=",">
        #{status}
      </foreach>
     </if>
  </sql>
    
    <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
        select count(1)   
        from buyer_order 
        where 1=1 
        <include refid="Query_Order_Sql" />
    </select>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.BuyerOrderReq">
        select <include refid="Base_Column_List" />  
        from buyer_order 
        where 1=1 
        <include refid="Query_Order_Sql" />
        order by create_time desc 
        <if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
        limit #{buyerOrderReq.start},#{buyerOrderReq.size}
        </if>
    </select>
    

</mapper>