<?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.slodon.b2b2c.dao.write.statistics.CategoryWeekWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.statistics.pojo.CategoryWeek">
    <id column="stats_id" property="statsId" />
    <result column="stats_time" property="statsTime" />
    <result column="web_site" property="webSite" />
    <result column="category_id" property="categoryId" />
    <result column="category_name" property="categoryName" />
    <result column="order_submit_num" property="orderSubmitNum" />
    <result column="order_submit_amount" property="orderSubmitAmount" />
    <result column="order_pay_num" property="orderPayNum" />
    <result column="sale_amount" property="saleAmount" />
    <result column="sale_num" property="saleNum" />
    <result column="return_num" property="returnNum" />
    <result column="return_product_num" property="returnProductNum" />
    <result column="return_amount" property="returnAmount" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="statsTime != null">
        `stats_time`,
      </if>
      <if test="webSite != null">
        `web_site`,
      </if>
      <if test="categoryId != null">
        `category_id`,
      </if>
      <if test="categoryName != null">
        `category_name`,
      </if>
      <if test="orderSubmitNum != null">
        `order_submit_num`,
      </if>
      <if test="orderSubmitAmount != null">
        `order_submit_amount`,
      </if>
      <if test="orderPayNum != null">
        `order_pay_num`,
      </if>
      <if test="saleAmount != null">
        `sale_amount`,
      </if>
      <if test="saleNum != null">
        `sale_num`,
      </if>
      <if test="returnNum != null">
        `return_num`,
      </if>
      <if test="returnProductNum != null">
        `return_product_num`,
      </if>
      <if test="returnAmount != null">
        `return_amount`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `stats_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.statsIdNotEquals != null">
          AND `stats_id` != #{example.statsIdNotEquals}
        </if>
        <if test="example.statsIdIn != null">
          AND `stats_id` in (${example.statsIdIn})
        </if>
        <if test="example.statsTimeAfter != null">
          AND `stats_time` <![CDATA[ >= ]]> #{example.statsTimeAfter}
        </if>
        <if test="example.statsTimeBefore != null">
          AND `stats_time` <![CDATA[ <= ]]> #{example.statsTimeBefore}
        </if>
        <if test="example.webSite != null">
          AND `web_site` = #{example.webSite}
        </if>
        <if test="example.categoryId != null">
          AND `category_id` = #{example.categoryId}
        </if>
        <if test="example.categoryName != null">
          AND `category_name` = #{example.categoryName}
        </if>
        <if test="example.categoryNameLike != null">
          AND `category_name` like concat('%',#{example.categoryNameLike},'%')
        </if>
        <if test="example.orderSubmitNum != null">
          AND `order_submit_num` = #{example.orderSubmitNum}
        </if>
        <if test="example.orderSubmitAmount != null">
          AND `order_submit_amount` = #{example.orderSubmitAmount}
        </if>
        <if test="example.orderPayNum != null">
          AND `order_pay_num` = #{example.orderPayNum}
        </if>
        <if test="example.saleAmount != null">
          AND `sale_amount` = #{example.saleAmount}
        </if>
        <if test="example.saleNum != null">
          AND `sale_num` = #{example.saleNum}
        </if>
        <if test="example.returnNum != null">
          AND `return_num` = #{example.returnNum}
        </if>
        <if test="example.returnProductNum != null">
          AND `return_product_num` = #{example.returnProductNum}
        </if>
        <if test="example.returnAmount != null">
          AND `return_amount` = #{example.returnAmount}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `stats_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.statistics.example.CategoryWeekExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `stats_category_week`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `stats_category_week`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `stats_category_week`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `stats_category_week`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `stats_category_week`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `stats_category_week`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `stats_category_week`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `stats_category_week`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="stats_id" keyProperty="statsId" parameterType="com.slodon.b2b2c.statistics.pojo.CategoryWeek" useGeneratedKeys="true">
    INSERT INTO `stats_category_week`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="statsTime != null">
        #{statsTime},
      </if>
      <if test="webSite != null">
        #{webSite},
      </if>
      <if test="categoryId != null">
        #{categoryId},
      </if>
      <if test="categoryName != null">
        #{categoryName},
      </if>
      <if test="orderSubmitNum != null">
        #{orderSubmitNum},
      </if>
      <if test="orderSubmitAmount != null">
        #{orderSubmitAmount},
      </if>
      <if test="orderPayNum != null">
        #{orderPayNum},
      </if>
      <if test="saleAmount != null">
        #{saleAmount},
      </if>
      <if test="saleNum != null">
        #{saleNum},
      </if>
      <if test="returnNum != null">
        #{returnNum},
      </if>
      <if test="returnProductNum != null">
        #{returnProductNum},
      </if>
      <if test="returnAmount != null">
        #{returnAmount},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `stats_category_week`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.statsTime != null">
        `stats_time` = #{record.statsTime},
      </if>
      <if test="record.webSite != null">
        `web_site` = #{record.webSite},
      </if>
      <if test="record.categoryId != null">
        `category_id` = #{record.categoryId},
      </if>
      <if test="record.categoryName != null">
        `category_name` = #{record.categoryName},
      </if>
      <if test="record.orderSubmitNum != null">
        `order_submit_num` = #{record.orderSubmitNum},
      </if>
      <if test="record.orderSubmitAmount != null">
        `order_submit_amount` = #{record.orderSubmitAmount},
      </if>
      <if test="record.orderPayNum != null">
        `order_pay_num` = #{record.orderPayNum},
      </if>
      <if test="record.saleAmount != null">
        `sale_amount` = #{record.saleAmount},
      </if>
      <if test="record.saleNum != null">
        `sale_num` = #{record.saleNum},
      </if>
      <if test="record.returnNum != null">
        `return_num` = #{record.returnNum},
      </if>
      <if test="record.returnProductNum != null">
        `return_product_num` = #{record.returnProductNum},
      </if>
      <if test="record.returnAmount != null">
        `return_amount` = #{record.returnAmount},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `stats_category_week`
    <trim prefix="SET" suffixOverrides=",">
      <if test="statsTime != null">
        `stats_time` = #{statsTime},
      </if>
      <if test="webSite != null">
        `web_site` = #{webSite},
      </if>
      <if test="categoryId != null">
        `category_id` = #{categoryId},
      </if>
      <if test="categoryName != null">
        `category_name` = #{categoryName},
      </if>
      <if test="orderSubmitNum != null">
        `order_submit_num` = #{orderSubmitNum},
      </if>
      <if test="orderSubmitAmount != null">
        `order_submit_amount` = #{orderSubmitAmount},
      </if>
      <if test="orderPayNum != null">
        `order_pay_num` = #{orderPayNum},
      </if>
      <if test="saleAmount != null">
        `sale_amount` = #{saleAmount},
      </if>
      <if test="saleNum != null">
        `sale_num` = #{saleNum},
      </if>
      <if test="returnNum != null">
        `return_num` = #{returnNum},
      </if>
      <if test="returnProductNum != null">
        `return_product_num` = #{returnProductNum},
      </if>
      <if test="returnAmount != null">
        `return_amount` = #{returnAmount},
      </if>
    </trim>
    WHERE `stats_id` = #{statsId}
  </update>
</mapper>