UnionShareOrdersMapper.xml 12.1 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.unions.dal.UnionShareOrdersMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareOrders" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="order_code" property="orderCode" jdbcType="VARCHAR" />
    <result column="settlement_code" property="settlementCode" jdbcType="VARCHAR" />
    <result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="last_order_amount" property="lastOrderAmount" jdbcType="DECIMAL" />
    <result column="order_time" property="orderTime" jdbcType="INTEGER" />
    <result column="is_new" property="isNew" jdbcType="TINYINT" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="update_time" property="updateTime" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, order_code,settlement_code, promote_uid, status, last_order_amount, order_time, is_new, amount, create_time,
    update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from union_share_orders
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByCode" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where order_code = #{orderCode,jdbcType=VARCHAR}
    limit 1
  </select>
  <select id="selectCountByCondition" resultType="java.lang.Integer" >
    select count(1) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
  </select>
  <select id="selectAmountByStatus" resultType="java.math.BigDecimal" >
    select IFNULL(sum(amount),0) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status in
    <foreach collection="statusList" item="item" separator="," index="index" open="(" close=")">
      #{item}
    </foreach>
  </select>
  <select id="selectAmountBySettleCode" resultType="java.math.BigDecimal" >
    select IFNULL(sum(amount),0) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and settlement_code = #{settlementCode,jdbcType=VARCHAR}
  </select>
  <select id="selectListByCondition" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
    limit #{offset}, #{rows}
  </select>
  <select id="selectListByIds" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where id in
    <foreach collection="list" open="(" close=")" item="id" separator=",">
      #{id}
    </foreach>
  </select>
  <select id="selectOrderCodesByCondition" resultType="java.lang.String" >
    select order_code from union_share_orders
    where settlement_code = #{settlementCode,jdbcType=VARCHAR}
    limit #{offset}, #{rows}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from union_share_orders
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    insert into union_share_orders (id, order_code,settlement_code, promote_uid,
      status, last_order_amount, order_time, 
      is_new, amount, create_time, 
      update_time)
    values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{settlementCode,jdbcType=VARCHAR}, #{promoteUid,jdbcType=INTEGER},
      #{status,jdbcType=VARCHAR}, #{lastOrderAmount,jdbcType=DECIMAL}, #{orderTime,jdbcType=INTEGER}, 
      #{isNew,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER},
      #{updateTime,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    insert into union_share_orders
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="orderCode != null" >
        order_code,
      </if>
      <if test="settlementCode != null" >
        settlement_code,
      </if>
      <if test="promoteUid != null" >
        promote_uid,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="lastOrderAmount != null" >
        last_order_amount,
      </if>
      <if test="orderTime != null" >
        order_time,
      </if>
      <if test="isNew != null" >
        is_new,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null" >
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="settlementCode != null" >
        #{settlementCode,jdbcType=VARCHAR},
      </if>
      <if test="promoteUid != null" >
        #{promoteUid,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="lastOrderAmount != null" >
        #{lastOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderTime != null" >
        #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isNew != null" >
        #{isNew,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    update union_share_orders
    <set >
      <if test="orderCode != null" >
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="settlementCode != null" >
        settlement_code = #{settlementCode,jdbcType=VARCHAR},
      </if>
      <if test="promoteUid != null" >
        promote_uid = #{promoteUid,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="lastOrderAmount != null" >
        last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderTime != null" >
        order_time = #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isNew != null" >
        is_new = #{isNew,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectCountByUids" resultType="int">
    select count(*) from union_share_orders where 1=1
    <if test="uids!=null and uids.size()>0">
      and promote_uid in
      <foreach collection="uids" open="(" close=")" item="uid" separator=",">
        #{uid}
      </foreach>
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
  </select>
  <select id="selectAllListByUids" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from union_share_orders where 1=1
    <if test="uids!=null and uids.size()>0">
      and promote_uid in
      <foreach collection="uids" open="(" close=")" item="uid" separator=",">
        #{uid}
      </foreach>
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    order BY  create_time desc
  </select>
  <select id="selectListByUids" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from union_share_orders where 1=1
    <if test="uids!=null and uids.size()>0">
      and promote_uid in
      <foreach collection="uids" open="(" close=")" item="uid" separator=",">
        #{uid}
      </foreach>
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    order BY  create_time desc
    limit #{startIndex},#{pageSize}
  </select>
  <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    update union_share_orders
    set order_code = #{orderCode,jdbcType=VARCHAR},
      settlement_code = #{settlementCode,jdbcType=VARCHAR},
      promote_uid = #{promoteUid,jdbcType=INTEGER},
      status = #{status,jdbcType=VARCHAR},
      last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
      order_time = #{orderTime,jdbcType=INTEGER},
      is_new = #{isNew,jdbcType=TINYINT},
      amount = #{amount,jdbcType=DECIMAL},
      create_time = #{createTime,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateStatusById" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>
  <update id="updateStatusByUid" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
    <if test="settlementCode != null">
      settlement_code = #{settlementCode,jdbcType=VARCHAR},
    </if>
      update_time = #{updateTime,jdbcType=INTEGER}
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>
  <update id="updateStatusByCode" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=INTEGER}
    where settlement_code = #{settlementCode,jdbcType=VARCHAR} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>

  <select id="selectRecentlyOrderLimitTen" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{uid,jdbcType=INTEGER}
    order by order_time desc
    limit 0,10
  </select>

  <select id="selectOrderList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{params.uid,jdbcType=INTEGER}
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
      AND status != 100
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 1">
      AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 2">
      AND status = 20
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 3">
      AND status IN (30,40)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 0">
      AND status IN (10,20,30,40)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 1">
      AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 2">
      AND status = 20
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 3">
      AND status IN (30,40)
    </if>
    <if test="params.tab1 != null and params.tab1 == 3">
      AND status IN (91,92,93)
    </if>
    order by order_time desc
    limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER}
  </select>
</mapper>