<?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.bailuntec.mapper.DcDailySalesMapper">
  <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku" />
    <result column="bailun_sku_title_cn" jdbcType="VARCHAR" property="bailunSkuTitleCn" />
    <result column="warehouse_name" jdbcType="VARCHAR" property="warehouseName" />
    <result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode" />
    <result column="bailun_category_id" jdbcType="INTEGER" property="bailunCategoryId" />
    <result column="oneday_total_sales" jdbcType="INTEGER" property="onedayTotalSales" />
    <result column="sevenday_total_sales" jdbcType="INTEGER" property="sevendayTotalSales" />
    <result column="fourteenday_total_sales" jdbcType="INTEGER" property="fourteendayTotalSales" />
    <result column="thirtyday_total_sales" jdbcType="INTEGER" property="thirtydayTotalSales" />
    <result column="sevenday_average_sales" jdbcType="DECIMAL" property="sevendayAverageSales" />
    <result column="fourteenday_average_sales" jdbcType="DECIMAL" property="fourteendayAverageSales" />
    <result column="thirtyday_average_sales" jdbcType="DECIMAL" property="thirtydayAverageSales" />
    <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
    <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
    <result column="global_company_id" jdbcType="INTEGER" property="globalCompanyId" />
    <result column="global_company_code" jdbcType="VARCHAR" property="globalCompanyCode" />
    <result column="global_company_name" jdbcType="VARCHAR" property="globalCompanyName" />
    <result column="record_date" jdbcType="DATE" property="recordDate" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    id, bailun_sku, bailun_sku_title_cn, warehouse_name, warehouse_code, bailun_category_id, 
    oneday_total_sales, sevenday_total_sales, fourteenday_total_sales, thirtyday_total_sales, 
    sevenday_average_sales, fourteenday_average_sales, thirtyday_average_sales, gmt_create, 
    gmt_modified, global_company_id, global_company_code, global_company_name, record_date
  </sql>
  <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcDailySalesExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from dc_daily_sales
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="rows != null">
      <if test="offset != null">
        limit ${offset}, ${rows}
      </if>
      <if test="offset == null">
        limit ${rows}
      </if>
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from dc_daily_sales
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from dc_daily_sales
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.DcDailySalesExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from dc_daily_sales
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into dc_daily_sales (id, bailun_sku, bailun_sku_title_cn, 
      warehouse_name, warehouse_code, bailun_category_id, 
      oneday_total_sales, sevenday_total_sales, fourteenday_total_sales, 
      thirtyday_total_sales, sevenday_average_sales, 
      fourteenday_average_sales, thirtyday_average_sales, 
      gmt_create, gmt_modified, global_company_id, 
      global_company_code, global_company_name, record_date
      )
    values (#{id,jdbcType=INTEGER}, #{bailunSku,jdbcType=VARCHAR}, #{bailunSkuTitleCn,jdbcType=VARCHAR}, 
      #{warehouseName,jdbcType=VARCHAR}, #{warehouseCode,jdbcType=VARCHAR}, #{bailunCategoryId,jdbcType=INTEGER}, 
      #{onedayTotalSales,jdbcType=INTEGER}, #{sevendayTotalSales,jdbcType=INTEGER}, #{fourteendayTotalSales,jdbcType=INTEGER}, 
      #{thirtydayTotalSales,jdbcType=INTEGER}, #{sevendayAverageSales,jdbcType=DECIMAL}, 
      #{fourteendayAverageSales,jdbcType=DECIMAL}, #{thirtydayAverageSales,jdbcType=DECIMAL}, 
      #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{globalCompanyId,jdbcType=INTEGER},
      #{globalCompanyCode,jdbcType=VARCHAR}, #{globalCompanyName,jdbcType=VARCHAR}, #{recordDate,jdbcType=DATE}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into dc_daily_sales
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="bailunSku != null">
        bailun_sku,
      </if>
      <if test="bailunSkuTitleCn != null">
        bailun_sku_title_cn,
      </if>
      <if test="warehouseName != null">
        warehouse_name,
      </if>
      <if test="warehouseCode != null">
        warehouse_code,
      </if>
      <if test="bailunCategoryId != null">
        bailun_category_id,
      </if>
      <if test="onedayTotalSales != null">
        oneday_total_sales,
      </if>
      <if test="sevendayTotalSales != null">
        sevenday_total_sales,
      </if>
      <if test="fourteendayTotalSales != null">
        fourteenday_total_sales,
      </if>
      <if test="thirtydayTotalSales != null">
        thirtyday_total_sales,
      </if>
      <if test="sevendayAverageSales != null">
        sevenday_average_sales,
      </if>
      <if test="fourteendayAverageSales != null">
        fourteenday_average_sales,
      </if>
      <if test="thirtydayAverageSales != null">
        thirtyday_average_sales,
      </if>
      <if test="gmtCreate != null">
        gmt_create,
      </if>
      <if test="gmtModified != null">
        gmt_modified,
      </if>
      <if test="globalCompanyId != null">
        global_company_id,
      </if>
      <if test="globalCompanyCode != null">
        global_company_code,
      </if>
      <if test="globalCompanyName != null">
        global_company_name,
      </if>
      <if test="recordDate != null">
        record_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="bailunSku != null">
        #{bailunSku,jdbcType=VARCHAR},
      </if>
      <if test="bailunSkuTitleCn != null">
        #{bailunSkuTitleCn,jdbcType=VARCHAR},
      </if>
      <if test="warehouseName != null">
        #{warehouseName,jdbcType=VARCHAR},
      </if>
      <if test="warehouseCode != null">
        #{warehouseCode,jdbcType=VARCHAR},
      </if>
      <if test="bailunCategoryId != null">
        #{bailunCategoryId,jdbcType=INTEGER},
      </if>
      <if test="onedayTotalSales != null">
        #{onedayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayTotalSales != null">
        #{sevendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="fourteendayTotalSales != null">
        #{fourteendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="thirtydayTotalSales != null">
        #{thirtydayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayAverageSales != null">
        #{sevendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="fourteendayAverageSales != null">
        #{fourteendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="thirtydayAverageSales != null">
        #{thirtydayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="gmtCreate != null">
        #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null">
        #{gmtModified,jdbcType=TIMESTAMP},
      </if>
      <if test="globalCompanyId != null">
        #{globalCompanyId,jdbcType=INTEGER},
      </if>
      <if test="globalCompanyCode != null">
        #{globalCompanyCode,jdbcType=VARCHAR},
      </if>
      <if test="globalCompanyName != null">
        #{globalCompanyName,jdbcType=VARCHAR},
      </if>
      <if test="recordDate != null">
        #{recordDate,jdbcType=DATE},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.bailuntec.domain.example.DcDailySalesExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from dc_daily_sales
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update dc_daily_sales
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.bailunSku != null">
        bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
      </if>
      <if test="record.bailunSkuTitleCn != null">
        bailun_sku_title_cn = #{record.bailunSkuTitleCn,jdbcType=VARCHAR},
      </if>
      <if test="record.warehouseName != null">
        warehouse_name = #{record.warehouseName,jdbcType=VARCHAR},
      </if>
      <if test="record.warehouseCode != null">
        warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
      </if>
      <if test="record.bailunCategoryId != null">
        bailun_category_id = #{record.bailunCategoryId,jdbcType=INTEGER},
      </if>
      <if test="record.onedayTotalSales != null">
        oneday_total_sales = #{record.onedayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="record.sevendayTotalSales != null">
        sevenday_total_sales = #{record.sevendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="record.fourteendayTotalSales != null">
        fourteenday_total_sales = #{record.fourteendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="record.thirtydayTotalSales != null">
        thirtyday_total_sales = #{record.thirtydayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="record.sevendayAverageSales != null">
        sevenday_average_sales = #{record.sevendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="record.fourteendayAverageSales != null">
        fourteenday_average_sales = #{record.fourteendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="record.thirtydayAverageSales != null">
        thirtyday_average_sales = #{record.thirtydayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="record.gmtCreate != null">
        gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.gmtModified != null">
        gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP},
      </if>
      <if test="record.globalCompanyId != null">
        global_company_id = #{record.globalCompanyId,jdbcType=INTEGER},
      </if>
      <if test="record.globalCompanyCode != null">
        global_company_code = #{record.globalCompanyCode,jdbcType=VARCHAR},
      </if>
      <if test="record.globalCompanyName != null">
        global_company_name = #{record.globalCompanyName,jdbcType=VARCHAR},
      </if>
      <if test="record.recordDate != null">
        record_date = #{record.recordDate,jdbcType=DATE},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update dc_daily_sales
    set id = #{record.id,jdbcType=INTEGER},
      bailun_sku = #{record.bailunSku,jdbcType=VARCHAR},
      bailun_sku_title_cn = #{record.bailunSkuTitleCn,jdbcType=VARCHAR},
      warehouse_name = #{record.warehouseName,jdbcType=VARCHAR},
      warehouse_code = #{record.warehouseCode,jdbcType=VARCHAR},
      bailun_category_id = #{record.bailunCategoryId,jdbcType=INTEGER},
      oneday_total_sales = #{record.onedayTotalSales,jdbcType=INTEGER},
      sevenday_total_sales = #{record.sevendayTotalSales,jdbcType=INTEGER},
      fourteenday_total_sales = #{record.fourteendayTotalSales,jdbcType=INTEGER},
      thirtyday_total_sales = #{record.thirtydayTotalSales,jdbcType=INTEGER},
      sevenday_average_sales = #{record.sevendayAverageSales,jdbcType=DECIMAL},
      fourteenday_average_sales = #{record.fourteendayAverageSales,jdbcType=DECIMAL},
      thirtyday_average_sales = #{record.thirtydayAverageSales,jdbcType=DECIMAL},
      gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
      gmt_modified = #{record.gmtModified,jdbcType=TIMESTAMP},
      global_company_id = #{record.globalCompanyId,jdbcType=INTEGER},
      global_company_code = #{record.globalCompanyCode,jdbcType=VARCHAR},
      global_company_name = #{record.globalCompanyName,jdbcType=VARCHAR},
      record_date = #{record.recordDate,jdbcType=DATE}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update dc_daily_sales
    <set>
      <if test="bailunSku != null">
        bailun_sku = #{bailunSku,jdbcType=VARCHAR},
      </if>
      <if test="bailunSkuTitleCn != null">
        bailun_sku_title_cn = #{bailunSkuTitleCn,jdbcType=VARCHAR},
      </if>
      <if test="warehouseName != null">
        warehouse_name = #{warehouseName,jdbcType=VARCHAR},
      </if>
      <if test="warehouseCode != null">
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
      </if>
      <if test="bailunCategoryId != null">
        bailun_category_id = #{bailunCategoryId,jdbcType=INTEGER},
      </if>
      <if test="onedayTotalSales != null">
        oneday_total_sales = #{onedayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayTotalSales != null">
        sevenday_total_sales = #{sevendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="fourteendayTotalSales != null">
        fourteenday_total_sales = #{fourteendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="thirtydayTotalSales != null">
        thirtyday_total_sales = #{thirtydayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayAverageSales != null">
        sevenday_average_sales = #{sevendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="fourteendayAverageSales != null">
        fourteenday_average_sales = #{fourteendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="thirtydayAverageSales != null">
        thirtyday_average_sales = #{thirtydayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="gmtCreate != null">
        gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null">
        gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
      </if>
      <if test="globalCompanyId != null">
        global_company_id = #{globalCompanyId,jdbcType=INTEGER},
      </if>
      <if test="globalCompanyCode != null">
        global_company_code = #{globalCompanyCode,jdbcType=VARCHAR},
      </if>
      <if test="globalCompanyName != null">
        global_company_name = #{globalCompanyName,jdbcType=VARCHAR},
      </if>
      <if test="recordDate != null">
        record_date = #{recordDate,jdbcType=DATE},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update dc_daily_sales
    set bailun_sku = #{bailunSku,jdbcType=VARCHAR},
      bailun_sku_title_cn = #{bailunSkuTitleCn,jdbcType=VARCHAR},
      warehouse_name = #{warehouseName,jdbcType=VARCHAR},
      warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
      bailun_category_id = #{bailunCategoryId,jdbcType=INTEGER},
      oneday_total_sales = #{onedayTotalSales,jdbcType=INTEGER},
      sevenday_total_sales = #{sevendayTotalSales,jdbcType=INTEGER},
      fourteenday_total_sales = #{fourteendayTotalSales,jdbcType=INTEGER},
      thirtyday_total_sales = #{thirtydayTotalSales,jdbcType=INTEGER},
      sevenday_average_sales = #{sevendayAverageSales,jdbcType=DECIMAL},
      fourteenday_average_sales = #{fourteendayAverageSales,jdbcType=DECIMAL},
      thirtyday_average_sales = #{thirtydayAverageSales,jdbcType=DECIMAL},
      gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
      gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
      global_company_id = #{globalCompanyId,jdbcType=INTEGER},
      global_company_code = #{globalCompanyCode,jdbcType=VARCHAR},
      global_company_name = #{globalCompanyName,jdbcType=VARCHAR},
      record_date = #{recordDate,jdbcType=DATE}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      @project https://github.com/itfsw/mybatis-generator-plugin
    -->
    insert into dc_daily_sales
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="bailunSku != null">
        bailun_sku,
      </if>
      <if test="bailunSkuTitleCn != null">
        bailun_sku_title_cn,
      </if>
      <if test="warehouseName != null">
        warehouse_name,
      </if>
      <if test="warehouseCode != null">
        warehouse_code,
      </if>
      <if test="bailunCategoryId != null">
        bailun_category_id,
      </if>
      <if test="onedayTotalSales != null">
        oneday_total_sales,
      </if>
      <if test="sevendayTotalSales != null">
        sevenday_total_sales,
      </if>
      <if test="fourteendayTotalSales != null">
        fourteenday_total_sales,
      </if>
      <if test="thirtydayTotalSales != null">
        thirtyday_total_sales,
      </if>
      <if test="sevendayAverageSales != null">
        sevenday_average_sales,
      </if>
      <if test="fourteendayAverageSales != null">
        fourteenday_average_sales,
      </if>
      <if test="thirtydayAverageSales != null">
        thirtyday_average_sales,
      </if>
      <if test="gmtCreate != null">
        gmt_create,
      </if>
      <if test="gmtModified != null">
        gmt_modified,
      </if>
      <if test="globalCompanyId != null">
        global_company_id,
      </if>
      <if test="globalCompanyCode != null">
        global_company_code,
      </if>
      <if test="globalCompanyName != null">
        global_company_name,
      </if>
      <if test="recordDate != null">
        record_date,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="bailunSku != null">
        #{bailunSku,jdbcType=VARCHAR},
      </if>
      <if test="bailunSkuTitleCn != null">
        #{bailunSkuTitleCn,jdbcType=VARCHAR},
      </if>
      <if test="warehouseName != null">
        #{warehouseName,jdbcType=VARCHAR},
      </if>
      <if test="warehouseCode != null">
        #{warehouseCode,jdbcType=VARCHAR},
      </if>
      <if test="bailunCategoryId != null">
        #{bailunCategoryId,jdbcType=INTEGER},
      </if>
      <if test="onedayTotalSales != null">
        #{onedayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayTotalSales != null">
        #{sevendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="fourteendayTotalSales != null">
        #{fourteendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="thirtydayTotalSales != null">
        #{thirtydayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayAverageSales != null">
        #{sevendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="fourteendayAverageSales != null">
        #{fourteendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="thirtydayAverageSales != null">
        #{thirtydayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="gmtCreate != null">
        #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null">
        #{gmtModified,jdbcType=TIMESTAMP},
      </if>
      <if test="globalCompanyId != null">
        #{globalCompanyId,jdbcType=INTEGER},
      </if>
      <if test="globalCompanyCode != null">
        #{globalCompanyCode,jdbcType=VARCHAR},
      </if>
      <if test="globalCompanyName != null">
        #{globalCompanyName,jdbcType=VARCHAR},
      </if>
      <if test="recordDate != null">
        #{recordDate,jdbcType=DATE},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="bailunSku != null">
        bailun_sku = #{bailunSku,jdbcType=VARCHAR},
      </if>
      <if test="bailunSkuTitleCn != null">
        bailun_sku_title_cn = #{bailunSkuTitleCn,jdbcType=VARCHAR},
      </if>
      <if test="warehouseName != null">
        warehouse_name = #{warehouseName,jdbcType=VARCHAR},
      </if>
      <if test="warehouseCode != null">
        warehouse_code = #{warehouseCode,jdbcType=VARCHAR},
      </if>
      <if test="bailunCategoryId != null">
        bailun_category_id = #{bailunCategoryId,jdbcType=INTEGER},
      </if>
      <if test="onedayTotalSales != null">
        oneday_total_sales = #{onedayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayTotalSales != null">
        sevenday_total_sales = #{sevendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="fourteendayTotalSales != null">
        fourteenday_total_sales = #{fourteendayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="thirtydayTotalSales != null">
        thirtyday_total_sales = #{thirtydayTotalSales,jdbcType=INTEGER},
      </if>
      <if test="sevendayAverageSales != null">
        sevenday_average_sales = #{sevendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="fourteendayAverageSales != null">
        fourteenday_average_sales = #{fourteendayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="thirtydayAverageSales != null">
        thirtyday_average_sales = #{thirtydayAverageSales,jdbcType=DECIMAL},
      </if>
      <if test="gmtCreate != null">
        gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null">
        gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
      </if>
      <if test="globalCompanyId != null">
        global_company_id = #{globalCompanyId,jdbcType=INTEGER},
      </if>
      <if test="globalCompanyCode != null">
        global_company_code = #{globalCompanyCode,jdbcType=VARCHAR},
      </if>
      <if test="globalCompanyName != null">
        global_company_name = #{globalCompanyName,jdbcType=VARCHAR},
      </if>
      <if test="recordDate != null">
        record_date = #{recordDate,jdbcType=DATE},
      </if>
    </trim>
  </insert>
  <insert id="upsert" parameterType="com.bailuntec.domain.entity.DcDailySales">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      @project https://github.com/itfsw/mybatis-generator-plugin
    -->
    insert into dc_daily_sales
    (id, bailun_sku, bailun_sku_title_cn, warehouse_name, warehouse_code, bailun_category_id, 
      oneday_total_sales, sevenday_total_sales, fourteenday_total_sales, thirtyday_total_sales, 
      sevenday_average_sales, fourteenday_average_sales, thirtyday_average_sales, gmt_create, 
      gmt_modified, global_company_id, global_company_code, global_company_name, record_date
      )
    values
    (#{id,jdbcType=INTEGER}, #{bailunSku,jdbcType=VARCHAR}, #{bailunSkuTitleCn,jdbcType=VARCHAR}, 
      #{warehouseName,jdbcType=VARCHAR}, #{warehouseCode,jdbcType=VARCHAR}, #{bailunCategoryId,jdbcType=INTEGER}, 
      #{onedayTotalSales,jdbcType=INTEGER}, #{sevendayTotalSales,jdbcType=INTEGER}, #{fourteendayTotalSales,jdbcType=INTEGER}, 
      #{thirtydayTotalSales,jdbcType=INTEGER}, #{sevendayAverageSales,jdbcType=DECIMAL}, 
      #{fourteendayAverageSales,jdbcType=DECIMAL}, #{thirtydayAverageSales,jdbcType=DECIMAL}, 
      #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{globalCompanyId,jdbcType=INTEGER},
      #{globalCompanyCode,jdbcType=VARCHAR}, #{globalCompanyName,jdbcType=VARCHAR}, #{recordDate,jdbcType=DATE}
      )
    on duplicate key update 
    id = #{id,jdbcType=INTEGER}, 
    bailun_sku = #{bailunSku,jdbcType=VARCHAR}, 
    bailun_sku_title_cn = #{bailunSkuTitleCn,jdbcType=VARCHAR}, 
    warehouse_name = #{warehouseName,jdbcType=VARCHAR}, 
    warehouse_code = #{warehouseCode,jdbcType=VARCHAR}, 
    bailun_category_id = #{bailunCategoryId,jdbcType=INTEGER}, 
    oneday_total_sales = #{onedayTotalSales,jdbcType=INTEGER}, 
    sevenday_total_sales = #{sevendayTotalSales,jdbcType=INTEGER}, 
    fourteenday_total_sales = #{fourteendayTotalSales,jdbcType=INTEGER}, 
    thirtyday_total_sales = #{thirtydayTotalSales,jdbcType=INTEGER}, 
    sevenday_average_sales = #{sevendayAverageSales,jdbcType=DECIMAL}, 
    fourteenday_average_sales = #{fourteendayAverageSales,jdbcType=DECIMAL}, 
    thirtyday_average_sales = #{thirtydayAverageSales,jdbcType=DECIMAL}, 
    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
    global_company_id = #{globalCompanyId,jdbcType=INTEGER}, 
    global_company_code = #{globalCompanyCode,jdbcType=VARCHAR}, 
    global_company_name = #{globalCompanyName,jdbcType=VARCHAR}, 
    record_date = #{recordDate,jdbcType=DATE}
  </insert>
  <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcDailySalesExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      @project https://github.com/itfsw/mybatis-generator-plugin
    -->
    select
    <include refid="Base_Column_List" />
    from dc_daily_sales
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    limit 1
  </select>

  <insert id="calculateSales" >
    INSERT `dc_daily_sales`  (
    `bailun_sku` ,
    `warehouse_code` ,
    `warehouse_name` ,
    `bailun_sku_title_cn`  ,
    `bailun_category_id` ,
    `oneday_total_sales`,
    `sevenday_total_sales`,
    `fourteenday_total_sales`,
    `thirtyday_total_sales`,
    `sevenday_average_sales`,
    `fourteenday_average_sales`,
    `thirtyday_average_sales`,
    `record_date`)
    SELECT
    bailun_sku,
    warehouse_code,
    warehouse_name,
    bailun_sku_title_cn,
    bailun_category_id,
    oneday_sales,
    sevenday_sales,
    fourteenday_sales,
    thirtyday_sales,
    ROUND(sevenday_sales / 7, 2),
    ROUND(fourteenday_sales / 14, 2),
    ROUND(thirtyday_sales / 30, 2),
    DATE_SUB(CURDATE(),INTERVAL 1 day)
    FROM (
    SELECT
    bailun_sku,
    warehouse_code,
    warehouse_name,
    bailun_sku_title_cn,
    bailun_category_id,
    sum( CASE WHEN ( paid_time >= DATE_SUB( CURDATE(), INTERVAL 1 DAY ) ) THEN bailun_sku_quantity_ordered ELSE 0 END ) AS 'oneday_sales',
    sum( CASE WHEN ( paid_time >= DATE_SUB( CURDATE(), INTERVAL 7 DAY ) ) THEN bailun_sku_quantity_ordered ELSE 0 END ) AS 'sevenday_sales',
    sum( CASE WHEN ( paid_time >= DATE_SUB( CURDATE(), INTERVAL 14 DAY ) ) THEN bailun_sku_quantity_ordered ELSE 0 END ) AS 'fourteenday_sales',
    sum( CASE WHEN ( paid_time >= DATE_SUB( CURDATE(), INTERVAL 30 DAY ) ) THEN bailun_sku_quantity_ordered ELSE 0 END ) AS 'thirtyday_sales'
    FROM
    `dc_base_oms_sku`
    WHERE
    paid_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY )
    AND paid_time &lt; CURDATE()
    AND bailun_order_status in ('Handling','Finished')
    AND has_delete = 0
    AND has_scalp = 0
    GROUP BY
    bailun_sku,
    warehouse_code
    ) t
  </insert>
</mapper>