BuyerOrderMapper.xml 4.65 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="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, 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 a.status in 
         <foreach collection="buyerOrderReq.statusList" item="status" open="(" close=")" separator=",">
            #{status}
         </foreach>
     </if>
     <if test="buyerOrderReq.orderCode != null and buyerOrderReq.orderCode != '' ">
         and a.order_code = #{buyerOrderReq.orderCode}
     </if>
     <if test="buyerOrderReq.uid != null and buyerOrderReq.uid != 0 ">
         and a.uid = #{buyerOrderReq.uid}
     </if>
     <if test="buyerOrderReq.status != null ">
         and a.status = #{buyerOrderReq.status}
     </if>
     <if test="buyerOrderReq.productId != null and buyerOrderReq.productId != 0 ">
         and c.product_id = #{buyerOrderReq.productId}
     </if>
     <if test="buyerOrderReq.storageId != null and buyerOrderReq.storageId != 0 ">
         and c.storage_id = #{buyerOrderReq.storageId}
     </if>
     <if test="buyerOrderReq.skup != null and buyerOrderReq.skup != 0 ">
         and c.id = #{buyerOrderReq.skup}
     </if>
     <if test="buyerOrderReq.depotNo != null and buyerOrderReq.depotNo != 0 ">
         and c.depot_no = #{buyerOrderReq.depotNo}
     </if>
     <if test="buyerOrderReq.mobile != null and buyerOrderReq.mobile != '' ">
         and (a.uid = #{buyerOrderReq.sellerUid} or a.seller_uid = #{buyerOrderReq.sellerUid})
     </if>
  </sql>
    
    <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
        select count(a.id)   
        from buyer_order a 
        <if test="(buyerOrderReq.depotNo != null) or (buyerOrderReq.productId != null) or (buyerOrderReq.storageId != null) or (buyerOrderReq.skup != 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" />
    </select>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.BuyerOrderReq">
        select a.*
        from buyer_order a 
        <if test="(buyerOrderReq.depotNo != null) or (buyerOrderReq.productId != null) or (buyerOrderReq.storageId != null) or (buyerOrderReq.skup != 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" />
        order by a.create_time desc 
        <if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
        limit #{buyerOrderReq.start},#{buyerOrderReq.size}
        </if>
    </select>
    

</mapper>