UserOrdersMapper.xml 13.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.yoho.unions.dal.IUserOrdersDAO" >
  <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UserOrders" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="uid" property="uid" jdbcType="VARCHAR" />
    <result column="order_code" property="orderCode" jdbcType="VARCHAR" />
    <result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="yoho_coin" property="yohoCoin" jdbcType="SMALLINT" />
    <result column="coupons_num" property="couponsNum" jdbcType="SMALLINT" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="order_status" property="orderStatus" jdbcType="TINYINT" />
    <result column="channel_code" property="channelCode" jdbcType="VARCHAR" />
    <result column="append" property="append" jdbcType="VARCHAR" />
    <result column="is_valid" property="isValid" jdbcType="CHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="user_id" property="userId" jdbcType="VARCHAR" />
    <result column="mbr_name" property="mbrName" jdbcType="VARCHAR" />
    <result column="is_settle_accounts" property="isSettleAccounts" jdbcType="TINYINT" />
    <result column="settle_amount" property="settleAmount" jdbcType="DECIMAL" />
    <result column="settle_accounts_time" property="settleAccountsTime" jdbcType="INTEGER" />
    <result column="campaign_id" property="campaignId" jdbcType="INTEGER" />
    <result column="source" property="source" jdbcType="VARCHAR" />
    <result column="tracking_code" property="trackingCode" jdbcType="VARCHAR" />
    <result column="u_id" property="uId" jdbcType="INTEGER" />
    <result column="order_time" property="orderTime" jdbcType="INTEGER" />
    <result column="is_push" property="isPush" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, order_code, order_amount, amount, yoho_coin, coupons_num, create_time, order_status, 
    channel_code, append, is_valid, remark, user_id, mbr_name, is_settle_accounts, settle_amount, 
    settle_accounts_time, campaign_id, source, tracking_code, u_id, order_time, is_push
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from user_orders
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByOrderCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_orders
    where order_code = #{orderCode} limit 1
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from user_orders
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.unions.dal.model.UserOrders" >
    insert into user_orders (id, uid, order_code,
      order_amount, amount, yoho_coin,
      coupons_num, create_time, order_status,
      channel_code, append, is_valid,
      remark, user_id, mbr_name,
      is_settle_accounts, settle_amount, settle_accounts_time,
      campaign_id, source, tracking_code,
      u_id, order_time, is_push
      )
    values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{orderCode,jdbcType=VARCHAR},
      #{orderAmount,jdbcType=DECIMAL}, #{amount,jdbcType=DECIMAL}, #{yohoCoin,jdbcType=SMALLINT},
      #{couponsNum,jdbcType=SMALLINT}, #{createTime,jdbcType=INTEGER}, #{orderStatus,jdbcType=TINYINT},
      #{channelCode,jdbcType=VARCHAR}, #{append,jdbcType=VARCHAR}, #{isValid,jdbcType=CHAR},
      #{remark,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{mbrName,jdbcType=VARCHAR},
      #{isSettleAccounts,jdbcType=TINYINT}, #{settleAmount,jdbcType=DECIMAL}, #{settleAccountsTime,jdbcType=INTEGER},
      #{campaignId,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{trackingCode,jdbcType=VARCHAR},
      #{uId,jdbcType=INTEGER}, #{orderTime,jdbcType=INTEGER}, #{isPush,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UserOrders" >
    insert into user_orders
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="orderCode != null" >
        order_code,
      </if>
      <if test="orderAmount != null" >
        order_amount,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="yohoCoin != null" >
        yoho_coin,
      </if>
      <if test="couponsNum != null" >
        coupons_num,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="orderStatus != null" >
        order_status,
      </if>
      <if test="channelCode != null" >
        channel_code,
      </if>
      <if test="append != null" >
        append,
      </if>
      <if test="isValid != null" >
        is_valid,
      </if>
      <if test="remark != null" >
        remark,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="mbrName != null" >
        mbr_name,
      </if>
      <if test="isSettleAccounts != null" >
        is_settle_accounts,
      </if>
      <if test="settleAmount != null" >
        settle_amount,
      </if>
      <if test="settleAccountsTime != null" >
        settle_accounts_time,
      </if>
      <if test="campaignId != null" >
        campaign_id,
      </if>
      <if test="source != null" >
        source,
      </if>
      <if test="trackingCode != null" >
        tracking_code,
      </if>
      <if test="uId != null" >
        u_id,
      </if>
      <if test="orderTime != null" >
        order_time,
      </if>
      <if test="isPush != null" >
        is_push,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="uid != null" >
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="orderCode != null" >
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null" >
        #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="yohoCoin != null" >
        #{yohoCoin,jdbcType=SMALLINT},
      </if>
      <if test="couponsNum != null" >
        #{couponsNum,jdbcType=SMALLINT},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null" >
        #{orderStatus,jdbcType=TINYINT},
      </if>
      <if test="channelCode != null" >
        #{channelCode,jdbcType=VARCHAR},
      </if>
      <if test="append != null" >
        #{append,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null" >
        #{isValid,jdbcType=CHAR},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=VARCHAR},
      </if>
      <if test="mbrName != null" >
        #{mbrName,jdbcType=VARCHAR},
      </if>
      <if test="isSettleAccounts != null" >
        #{isSettleAccounts,jdbcType=TINYINT},
      </if>
      <if test="settleAmount != null" >
        #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAccountsTime != null" >
        #{settleAccountsTime,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null" >
        #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="source != null" >
        #{source,jdbcType=VARCHAR},
      </if>
      <if test="trackingCode != null" >
        #{trackingCode,jdbcType=VARCHAR},
      </if>
      <if test="uId != null" >
        #{uId,jdbcType=INTEGER},
      </if>
      <if test="orderTime != null" >
        #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        #{isPush,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UserOrders" >
    update user_orders
    <set >
      <if test="uid != null" >
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="orderCode != null" >
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null" >
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="yohoCoin != null" >
        yoho_coin = #{yohoCoin,jdbcType=SMALLINT},
      </if>
      <if test="couponsNum != null" >
        coupons_num = #{couponsNum,jdbcType=SMALLINT},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null" >
        order_status = #{orderStatus,jdbcType=TINYINT},
      </if>
      <if test="channelCode != null" >
        channel_code = #{channelCode,jdbcType=VARCHAR},
      </if>
      <if test="append != null" >
        append = #{append,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null" >
        is_valid = #{isValid,jdbcType=CHAR},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="userId != null" >
        user_id = #{userId,jdbcType=VARCHAR},
      </if>
      <if test="mbrName != null" >
        mbr_name = #{mbrName,jdbcType=VARCHAR},
      </if>
      <if test="isSettleAccounts != null" >
        is_settle_accounts = #{isSettleAccounts,jdbcType=TINYINT},
      </if>
      <if test="settleAmount != null" >
        settle_amount = #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAccountsTime != null" >
        settle_accounts_time = #{settleAccountsTime,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null" >
        campaign_id = #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="source != null" >
        source = #{source,jdbcType=VARCHAR},
      </if>
      <if test="trackingCode != null" >
        tracking_code = #{trackingCode,jdbcType=VARCHAR},
      </if>
      <if test="uId != null" >
        u_id = #{uId,jdbcType=INTEGER},
      </if>
      <if test="orderTime != null" >
        order_time = #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        is_push = #{isPush,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UserOrders" >
    update user_orders
    set uid = #{uid,jdbcType=VARCHAR},
      order_code = #{orderCode,jdbcType=VARCHAR},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      amount = #{amount,jdbcType=DECIMAL},
      yoho_coin = #{yohoCoin,jdbcType=SMALLINT},
      coupons_num = #{couponsNum,jdbcType=SMALLINT},
      create_time = #{createTime,jdbcType=INTEGER},
      order_status = #{orderStatus,jdbcType=TINYINT},
      channel_code = #{channelCode,jdbcType=VARCHAR},
      append = #{append,jdbcType=VARCHAR},
      is_valid = #{isValid,jdbcType=CHAR},
      remark = #{remark,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=VARCHAR},
      mbr_name = #{mbrName,jdbcType=VARCHAR},
      is_settle_accounts = #{isSettleAccounts,jdbcType=TINYINT},
      settle_amount = #{settleAmount,jdbcType=DECIMAL},
      settle_accounts_time = #{settleAccountsTime,jdbcType=INTEGER},
      campaign_id = #{campaignId,jdbcType=INTEGER},
      source = #{source,jdbcType=VARCHAR},
      tracking_code = #{trackingCode,jdbcType=VARCHAR},
      u_id = #{uId,jdbcType=INTEGER},
      order_time = #{orderTime,jdbcType=INTEGER},
      is_push = #{isPush,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="batchUpdatePush">
    update user_orders
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="is_push =case" suffix="end,">
        <foreach collection="list" item="item" index="index">
          when order_code=#{item,jdbcType=VARCHAR} then 1
        </foreach>
      </trim>
    </trim>
    where
    <foreach collection="list" separator="or" item="item" index="index" >
      order_code=#{item,jdbcType=VARCHAR}
    </foreach>
  </update>
  <select id="getExistOrderCodes" resultMap="BaseResultMap" parameterType="java.util.Set">
    select
    <include refid="Base_Column_List" />
    from user_orders
    where is_push=0 and
    order_code in
    <foreach collection="list" index="index" item="code" open="(" separator="," close=")">
      #{code}
    </foreach>
  </select>

  <select id="selectCount" resultType="java.lang.Integer">
     select count(1) from user_orders where 1 = 1
    <if test="orderCode != 0" >
       and order_code = #{orderCode}
    </if>
    <if test="unionId != null" >
      and uid = #{unionId}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    <if test="idList !=null and idList.size>0">
      and id in
      <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
  </select>

  <select id="selectUserOrderList" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from user_orders
    where 1=1
    <if test="orderCode != 0" >
      and order_code = #{orderCode}
    </if>
    <if test="unionId != null" >
      and uid = #{unionId}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    <if test="idList !=null and idList.size>0">
    and id in
    <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
      #{item}
    </foreach>
    </if> order BY  create_time desc
    limit #{startIndex},#{pageSize}
  </select>
</mapper>