<?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="cn.superdesk.uniorder.dao.mapper.channel.UnifiedChannelProfitSyncMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSync">

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="sync_id" jdbcType="BIGINT" property="syncId" />
    <result column="channel_id" jdbcType="BIGINT" property="channelId" />
    <result column="organization_id" jdbcType="BIGINT" property="organizationId" />
    <result column="business_code" jdbcType="VARCHAR" property="businessCode" />
    <result column="sync_time" jdbcType="TIMESTAMP" property="syncTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
    <result column="begin_date" jdbcType="TIMESTAMP" property="beginDate" />
    <result column="end_date" jdbcType="TIMESTAMP" property="endDate" />
    <result column="proportion" jdbcType="DECIMAL" property="proportion" />
    <result column="is_bind_virt" jdbcType="TINYINT" property="isBindVirt" />
    <result column="virt_ids" jdbcType="VARCHAR" property="virtIds" />
  </resultMap>
  <sql id="Example_Where_Clause">

    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">

    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">

    id, sync_id, channel_id, organization_id, business_code, sync_time, create_time, 
    create_user_id, update_time, update_user_id, begin_date, end_date, proportion, is_bind_virt, 
    virt_ids
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSyncExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from unified_channel_profit_sync
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">

    select 
    <include refid="Base_Column_List" />
    from unified_channel_profit_sync
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

    delete from unified_channel_profit_sync
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSyncExample">

    delete from unified_channel_profit_sync
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSync">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_profit_sync (sync_id, channel_id, organization_id, 
      business_code, sync_time, create_time, 
      create_user_id, update_time, update_user_id, 
      begin_date, end_date, proportion, 
      is_bind_virt, virt_ids)
    values (#{syncId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{organizationId,jdbcType=BIGINT}, 
      #{businessCode,jdbcType=VARCHAR}, #{syncTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT}, 
      #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, #{proportion,jdbcType=DECIMAL}, 
      #{isBindVirt,jdbcType=TINYINT}, #{virtIds,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSync">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_profit_sync
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="syncId != null">
        sync_id,
      </if>
      <if test="channelId != null">
        channel_id,
      </if>
      <if test="organizationId != null">
        organization_id,
      </if>
      <if test="businessCode != null">
        business_code,
      </if>
      <if test="syncTime != null">
        sync_time,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUserId != null">
        update_user_id,
      </if>
      <if test="beginDate != null">
        begin_date,
      </if>
      <if test="endDate != null">
        end_date,
      </if>
      <if test="proportion != null">
        proportion,
      </if>
      <if test="isBindVirt != null">
        is_bind_virt,
      </if>
      <if test="virtIds != null">
        virt_ids,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="syncId != null">
        #{syncId,jdbcType=BIGINT},
      </if>
      <if test="channelId != null">
        #{channelId,jdbcType=BIGINT},
      </if>
      <if test="organizationId != null">
        #{organizationId,jdbcType=BIGINT},
      </if>
      <if test="businessCode != null">
        #{businessCode,jdbcType=VARCHAR},
      </if>
      <if test="syncTime != null">
        #{syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        #{updateUserId,jdbcType=BIGINT},
      </if>
      <if test="beginDate != null">
        #{beginDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null">
        #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="proportion != null">
        #{proportion,jdbcType=DECIMAL},
      </if>
      <if test="isBindVirt != null">
        #{isBindVirt,jdbcType=TINYINT},
      </if>
      <if test="virtIds != null">
        #{virtIds,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSyncExample" resultType="java.lang.Long">

    select count(*) from unified_channel_profit_sync
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">

    update unified_channel_profit_sync
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.syncId != null">
        sync_id = #{record.syncId,jdbcType=BIGINT},
      </if>
      <if test="record.channelId != null">
        channel_id = #{record.channelId,jdbcType=BIGINT},
      </if>
      <if test="record.organizationId != null">
        organization_id = #{record.organizationId,jdbcType=BIGINT},
      </if>
      <if test="record.businessCode != null">
        business_code = #{record.businessCode,jdbcType=VARCHAR},
      </if>
      <if test="record.syncTime != null">
        sync_time = #{record.syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId,jdbcType=BIGINT},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserId != null">
        update_user_id = #{record.updateUserId,jdbcType=BIGINT},
      </if>
      <if test="record.beginDate != null">
        begin_date = #{record.beginDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.endDate != null">
        end_date = #{record.endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.proportion != null">
        proportion = #{record.proportion,jdbcType=DECIMAL},
      </if>
      <if test="record.isBindVirt != null">
        is_bind_virt = #{record.isBindVirt,jdbcType=TINYINT},
      </if>
      <if test="record.virtIds != null">
        virt_ids = #{record.virtIds,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">

    update unified_channel_profit_sync
    set id = #{record.id,jdbcType=BIGINT},
      sync_id = #{record.syncId,jdbcType=BIGINT},
      channel_id = #{record.channelId,jdbcType=BIGINT},
      organization_id = #{record.organizationId,jdbcType=BIGINT},
      business_code = #{record.businessCode,jdbcType=VARCHAR},
      sync_time = #{record.syncTime,jdbcType=TIMESTAMP},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_user_id = #{record.createUserId,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{record.updateUserId,jdbcType=BIGINT},
      begin_date = #{record.beginDate,jdbcType=TIMESTAMP},
      end_date = #{record.endDate,jdbcType=TIMESTAMP},
      proportion = #{record.proportion,jdbcType=DECIMAL},
      is_bind_virt = #{record.isBindVirt,jdbcType=TINYINT},
      virt_ids = #{record.virtIds,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSync">

    update unified_channel_profit_sync
    <set>
      <if test="syncId != null">
        sync_id = #{syncId,jdbcType=BIGINT},
      </if>
      <if test="channelId != null">
        channel_id = #{channelId,jdbcType=BIGINT},
      </if>
      <if test="organizationId != null">
        organization_id = #{organizationId,jdbcType=BIGINT},
      </if>
      <if test="businessCode != null">
        business_code = #{businessCode,jdbcType=VARCHAR},
      </if>
      <if test="syncTime != null">
        sync_time = #{syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        update_user_id = #{updateUserId,jdbcType=BIGINT},
      </if>
      <if test="beginDate != null">
        begin_date = #{beginDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null">
        end_date = #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="proportion != null">
        proportion = #{proportion,jdbcType=DECIMAL},
      </if>
      <if test="isBindVirt != null">
        is_bind_virt = #{isBindVirt,jdbcType=TINYINT},
      </if>
      <if test="virtIds != null">
        virt_ids = #{virtIds,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitSync">

    update unified_channel_profit_sync
    set sync_id = #{syncId,jdbcType=BIGINT},
      channel_id = #{channelId,jdbcType=BIGINT},
      organization_id = #{organizationId,jdbcType=BIGINT},
      business_code = #{businessCode,jdbcType=VARCHAR},
      sync_time = #{syncTime,jdbcType=TIMESTAMP},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT},
      begin_date = #{beginDate,jdbcType=TIMESTAMP},
      end_date = #{endDate,jdbcType=TIMESTAMP},
      proportion = #{proportion,jdbcType=DECIMAL},
      is_bind_virt = #{isBindVirt,jdbcType=TINYINT},
      virt_ids = #{virtIds,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>