AppraiseOrderMapper.xml 9.76 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.AppraiseOrderMapper">
  <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.AppraiseOrder">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="parent_order_code" jdbcType="BIGINT" property="parentOrderCode" />
    <result column="order_code" jdbcType="BIGINT" property="orderCode" />
    <result column="client_type" jdbcType="TINYINT" property="clientType" />
    <result column="payment" jdbcType="TINYINT" property="payment" />
    <result column="amount" jdbcType="DECIMAL" property="amount" />
    <result column="ship_fee" jdbcType="DECIMAL" property="shipFee" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="create_time" jdbcType="INTEGER" property="createTime" />
    <result column="update_time" jdbcType="INTEGER" property="updateTime" />
    <result column="is_del" jdbcType="TINYINT" property="isDel" />
    <result column="channel_no" jdbcType="VARCHAR" property="channelNo" />
    <result column="attributes" jdbcType="INTEGER" property="attributes" />
    <result column="platform_delivery_status" jdbcType="TINYINT" property="platformDeliveryStatus" />
    <result column="status_cnt" jdbcType="INTEGER" property="statusCnt"/>
  </resultMap>
  <sql id="Base_Column_List">
    id, uid, parent_order_code, order_code, client_type, payment, amount, ship_fee, status, 
    create_time, update_time, is_del, channel_no, attributes, platform_delivery_status
  </sql>

  <select id="selectSubOrderList" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from appraise_order
    where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
    limit #{offset},#{limit}
  </select>


  <select id="selectSubOrderCntIncludeStatus" resultType="java.lang.Integer">
    select count(*) from appraise_order
    where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
    and status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status,jdbcType=TINYINT}
    </foreach>
  </select>


  <select id="selectSubOrderCnt" parameterType="java.lang.Long" resultType="java.lang.Integer">
    select count(*) from appraise_order
    where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
  </select>

  <select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from appraise_order
    where order_code = #{orderCode,jdbcType=INTEGER}
  </select>

  <select id="selectCntByOrderType" resultType="java.lang.Integer">
    select count(*) from appraise_order
    where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
    and is_del = 1
    and status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status,jdbcType=TINYINT}
    </foreach>
    <if test="parentOnly">
      and parent_order_code is null
    </if>

  </select>

  <select id="selectOrderListByOrderType" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from appraise_order
    where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
    and is_del = 1
    and status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status,jdbcType=TINYINT}
    </foreach>
    <if test="parentOnly">
      and parent_order_code is null
    </if>
    order by id desc  limit #{offset},#{limit}
  </select>


  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrder" useGeneratedKeys="true">
    insert into appraise_order (uid, parent_order_code, order_code, 
      client_type, payment, amount, 
      ship_fee, status, create_time, 
      update_time, is_del, channel_no, 
      attributes, platform_delivery_status)
    values (#{uid,jdbcType=INTEGER}, #{parentOrderCode,jdbcType=BIGINT}, #{orderCode,jdbcType=BIGINT}, 
      #{clientType,jdbcType=TINYINT}, #{payment,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, 
      #{shipFee,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER}, 
      #{updateTime,jdbcType=INTEGER}, #{isDel,jdbcType=TINYINT}, #{channelNo,jdbcType=VARCHAR}, 
      #{attributes,jdbcType=INTEGER}, #{platformDeliveryStatus,jdbcType=TINYINT})
  </insert>



  <insert id="insertBatch" >
    insert into appraise_order (uid, parent_order_code, order_code,
      client_type, payment, amount,
      ship_fee, status, create_time,
      update_time, is_del, channel_no,
      attributes, platform_delivery_status)
    values
    <foreach collection="records" item="record" separator=",">
      (
      #{record.uid,jdbcType=INTEGER},
      #{record.parentOrderCode,jdbcType=BIGINT},
      #{record.orderCode,jdbcType=BIGINT},
      #{record.clientType,jdbcType=TINYINT},
      #{record.payment,jdbcType=TINYINT},
      #{record.amount,jdbcType=DECIMAL},
      #{record.shipFee,jdbcType=DECIMAL},
      #{record.status,jdbcType=TINYINT},
      #{record.createTime,jdbcType=INTEGER},
      #{record.updateTime,jdbcType=INTEGER},
      #{record.isDel,jdbcType=TINYINT},
      #{record.channelNo,jdbcType=VARCHAR},
      #{record.attributes,jdbcType=INTEGER},
      #{record.platformDeliveryStatus,jdbcType=TINYINT}
      )
    </foreach>

  </insert>

  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrder" useGeneratedKeys="true">
    insert into appraise_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        uid,
      </if>
      <if test="parentOrderCode != null">
        parent_order_code,
      </if>
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="clientType != null">
        client_type,
      </if>
      <if test="payment != null">
        payment,
      </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="isDel != null">
        is_del,
      </if>
      <if test="channelNo != null">
        channel_no,
      </if>
      <if test="attributes != null">
        attributes,
      </if>
      <if test="platformDeliveryStatus != null">
        platform_delivery_status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="parentOrderCode != null">
        #{parentOrderCode,jdbcType=BIGINT},
      </if>
      <if test="orderCode != null">
        #{orderCode,jdbcType=BIGINT},
      </if>
      <if test="clientType != null">
        #{clientType,jdbcType=TINYINT},
      </if>
      <if test="payment != null">
        #{payment,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=TINYINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="isDel != null">
        #{isDel,jdbcType=TINYINT},
      </if>
      <if test="channelNo != null">
        #{channelNo,jdbcType=VARCHAR},
      </if>
      <if test="attributes != null">
        #{attributes,jdbcType=INTEGER},
      </if>
      <if test="platformDeliveryStatus != null">
        #{platformDeliveryStatus,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>


  <update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.AppraiseOrder">
    update appraise_order
    <set>
      <if test="payment != null">
        payment = #{payment,jdbcType=TINYINT},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="isDel != null">
        is_del = #{isDel,jdbcType=TINYINT},
      </if>
      <if test="platformDeliveryStatus != null">
        platform_delivery_status = #{platformDeliveryStatus,jdbcType=TINYINT},
      </if>
    </set>
    where order_code =#{orderCode,jdbcType=BIGINT}
  </update>


  <update id="updatePlatformDeliveryStatusByOrderCode">
    update appraise_order set
    platform_delivery_status = #{targetPlatformDeliveryStatus,jdbcType=INTEGER}, update_time = #{currentTime,jdbcType=INTEGER}
    where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
  </update>


  <update id="updateStatusByOrderCode">
    update appraise_order
    <set>
        status = #{targetStatus,jdbcType=TINYINT},
        update_time = #{updateTime,jdbcType=INTEGER}
    </set>
    where order_code =#{orderCode,jdbcType=BIGINT} and status = #{expectedStatus,jdbcType=TINYINT}
  </update>

  <select id="selectByOrderCodeList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from appraise_order
    where order_code in
    <foreach collection="orderList" item="orderCode" open="(" close=")" separator=",">
      #{orderCode,jdbcType=BIGINT}
    </foreach>
  </select>

  <select id="selectSubOrderStatistic" resultMap="BaseResultMap">
    select parent_order_code,status, count(*) status_cnt from ufo_order.appraise_order
    where parent_order_code = #{parentOrderCode,jdbcType=BIGINT}
    group by status
  </select>
</mapper>