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


  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from buyer_order
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectCntByUid" resultType="java.lang.Integer">
    select count(*) from buyer_order  where uid = #{uid,jdbcType=INTEGER}
  </select>

  <select id="selectCntByUidStatus" resultType="java.lang.Integer">
    select count(*) from buyer_order
    where uid = #{uid,jdbcType=INTEGER}
    and buyer_order_status = 1
    <if test="status != null">
      and status in
      <foreach item="item" index="index" collection="status" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
  </select>


  <select id="selectListByUidStatus" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from buyer_order
    where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
    <if test="status != null">
      and status in
      <foreach item="item" index="index" collection="status" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    order by create_time desc, update_time desc
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>


  <select id="selectByOrderCodeUid" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order
    where order_code = #{orderCode,jdbcType=BIGINT}
    and uid = #{uid,jdbcType=INTEGER}
    limit 1
  </select>

  <select id="selectByOrderCodeSellerUid" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order
    where order_code = #{orderCode,jdbcType=BIGINT}
    and seller_uid = #{sellerUid,jdbcType=INTEGER}
    and seller_order_status = 1
    limit 1
  </select>

  <select id="selectByOrderCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order
    where order_code = #{orderCode,jdbcType=BIGINT}
    and buyer_order_status = 1
    limit 1
  </select>


  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from buyer_order
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
    insert into buyer_order (uid, order_code, seller_uid, 
      client_type, payment, payment_type, 
      is_cancel, amount, ship_fee, 
      status, create_time, update_time, 
      buyer_order_status, seller_order_status, channel_no)
    values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER}, 
      #{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT},
      #{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL}, 
      #{status,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
      #{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
    insert into buyer_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        uid,
      </if>
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="sellerUid != null">
        seller_uid,
      </if>
      <if test="clientType != null">
        client_type,
      </if>
      <if test="payment != null">
        payment,
      </if>
      <if test="paymentType != null">
        payment_type,
      </if>
      <if test="isCancel != null">
        is_cancel,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="shipFee != null">
        ship_fee,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="buyerOrderStatus != null">
        buyer_order_status,
      </if>
      <if test="sellerOrderStatus != null">
        seller_order_status,
      </if>
      <if test="channelNo != null">
        channel_no,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null">
        #{orderCode,jdbcType=BIGINT},
      </if>
      <if test="sellerUid != null">
        #{sellerUid,jdbcType=INTEGER},
      </if>
      <if test="clientType != null">
        #{clientType,jdbcType=TINYINT},
      </if>
      <if test="payment != null">
        #{payment,jdbcType=INTEGER},
      </if>
      <if test="paymentType != null">
        #{paymentType,jdbcType=TINYINT},
      </if>
      <if test="isCancel != null">
        #{isCancel,jdbcType=TINYINT},
      </if>
      <if test="amount != null">
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="shipFee != null">
        #{shipFee,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="buyerOrderStatus != null">
        #{buyerOrderStatus,jdbcType=INTEGER},
      </if>
      <if test="sellerOrderStatus != null">
        #{sellerOrderStatus,jdbcType=INTEGER},
      </if>
      <if test="channelNo != null">
        #{channelNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
    update buyer_order
    <set>
      <if test="uid != null">
        uid = #{uid,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null">
        order_code = #{orderCode,jdbcType=BIGINT},
      </if>
      <if test="sellerUid != null">
        seller_uid = #{sellerUid,jdbcType=INTEGER},
      </if>
      <if test="clientType != null">
        client_type = #{clientType,jdbcType=TINYINT},
      </if>
      <if test="payment != null">
        payment = #{payment,jdbcType=INTEGER},
      </if>
      <if test="paymentType != null">
        payment_type = #{paymentType,jdbcType=TINYINT},
      </if>
      <if test="isCancel != null">
        is_cancel = #{isCancel,jdbcType=TINYINT},
      </if>
      <if test="amount != null">
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="shipFee != null">
        ship_fee = #{shipFee,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="buyerOrderStatus != null">
        buyer_order_status = #{buyerOrderStatus,jdbcType=INTEGER},
      </if>
      <if test="sellerOrderStatus != null">
        seller_order_status = #{sellerOrderStatus,jdbcType=INTEGER},
      </if>
      <if test="channelNo != null">
        channel_no = #{channelNo,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>



  <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
    update buyer_order
    set uid = #{uid,jdbcType=INTEGER},
      order_code = #{orderCode,jdbcType=BIGINT},
      seller_uid = #{sellerUid,jdbcType=INTEGER},
      client_type = #{clientType,jdbcType=TINYINT},
      payment = #{payment,jdbcType=INTEGER},
      payment_type = #{paymentType,jdbcType=TINYINT},
      is_cancel = #{isCancel,jdbcType=TINYINT},
      amount = #{amount,jdbcType=DECIMAL},
      ship_fee = #{shipFee,jdbcType=DECIMAL},
      status = #{status,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
      buyer_order_status = #{buyerOrderStatus,jdbcType=INTEGER},
      seller_order_status = #{sellerOrderStatus,jdbcType=INTEGER},
      channel_no = #{channelNo,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>


  <update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
    update buyer_order
    set
    <if test="status != null">
    status = #{status,jdbcType=INTEGER},
    </if>
    <if test="payment != null">
    payment = #{payment,jdbcType=INTEGER},
    </if>
    update_time = #{updateTime,jdbcType=INTEGER}
    where uid = #{uid,jdbcType=INTEGER}
    and order_code = #{orderCode,jdbcType=BIGINT}
  </update>


  <update id="updateBatchByOrderCodes" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
    update buyer_order
    set
    status = #{status,jdbcType=INTEGER},
    update_time = #{updateTime,jdbcType=INTEGER}
    where order_code IN
    <foreach collection="orderCodes" item="orderCode" open="(" separator="," close=")">
      #{orderCode,jdbcType=BIGINT}
    </foreach>
  </update>

  <sql id="sql_where_4_select_SellerUidStatus">
    seller_uid = #{sellerUid,jdbcType=INTEGER}
    and seller_order_status = 1
    <if test="status != null">
      and status in
      <foreach item="item" index="index" collection="status" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
  </sql>

  <select id="selectCntBySellerUidStatus" resultType="java.lang.Integer">
    select
    count(*)
    from buyer_order
    where <include refid="sql_where_4_select_SellerUidStatus"/>
  </select>


  <select id="selectListBySellerUidStatus" resultMap="BaseResultMap">
    select    <include refid="Base_Column_List" />    from buyer_order
    where <include refid="sql_where_4_select_SellerUidStatus"/>
    order by create_time desc, update_time desc
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>


  <update id="updateStatusByOrderCode">
    update buyer_order set
    status = #{targetStatus,jdbcType=INTEGER},
    update_time = #{currentTime,jdbcType=INTEGER}
    where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} and status = #{status, jdbcType=INTEGER}
  </update>

  <select id="selectOrderNumByUid" resultType="java.lang.Integer">
    select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
  </select>


  <select id="selectCntBySellerUid" resultType="java.lang.Integer">
    select count(*) from buyer_order where seller_uid = #{sellerUid,jdbcType=INTEGER}
    and seller_order_status = 1
    and status in
    <foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
      #{item}
    </foreach>
  </select>
  
  <select id="selectAllByOrderCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order
    where order_code = #{orderCode,jdbcType=BIGINT}
    limit 1
  </select>
</mapper>