<?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.business.OrderStatisWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.business.pojo.OrderStatis">
    <id column="id" property="id" />
    <id column="os_month" property="osMonth" />
    <result column="os_year" property="osYear" />
    <result column="os_start_date" property="osStartDate" />
    <result column="os_end_date" property="osEndDate" />
    <result column="os_order_totals" property="osOrderTotals" />
    <result column="os_shipping_totals" property="osShippingTotals" />
    <result column="os_order_return_totals" property="osOrderReturnTotals" />
    <result column="os_commis_totals" property="osCommisTotals" />
    <result column="os_commis_return_totals" property="osCommisReturnTotals" />
    <result column="os_store_cost_totals" property="osStoreCostTotals" />
    <result column="os_result_totals" property="osResultTotals" />
    <result column="os_create_date" property="osCreateDate" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="osYear != null">
        `os_year`,
      </if>
      <if test="osStartDate != null">
        `os_start_date`,
      </if>
      <if test="osEndDate != null">
        `os_end_date`,
      </if>
      <if test="osOrderTotals != null">
        `os_order_totals`,
      </if>
      <if test="osShippingTotals != null">
        `os_shipping_totals`,
      </if>
      <if test="osOrderReturnTotals != null">
        `os_order_return_totals`,
      </if>
      <if test="osCommisTotals != null">
        `os_commis_totals`,
      </if>
      <if test="osCommisReturnTotals != null">
        `os_commis_return_totals`,
      </if>
      <if test="osStoreCostTotals != null">
        `os_store_cost_totals`,
      </if>
      <if test="osResultTotals != null">
        `os_result_totals`,
      </if>
      <if test="osCreateDate != null">
        `os_create_date`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.idNotEquals != null">
          AND `id` != #{example.idNotEquals}
        </if>
        <if test="example.idIn != null">
          AND `id` in (${example.idIn})
        </if>
        <if test="example.osYear != null">
          AND `os_year` = #{example.osYear}
        </if>
        <if test="example.osStartDate != null">
          AND `os_start_date` = #{example.osStartDate}
        </if>
        <if test="example.osEndDate != null">
          AND `os_end_date` = #{example.osEndDate}
        </if>
        <if test="example.osOrderTotals != null">
          AND `os_order_totals` = #{example.osOrderTotals}
        </if>
        <if test="example.osShippingTotals != null">
          AND `os_shipping_totals` = #{example.osShippingTotals}
        </if>
        <if test="example.osOrderReturnTotals != null">
          AND `os_order_return_totals` = #{example.osOrderReturnTotals}
        </if>
        <if test="example.osCommisTotals != null">
          AND `os_commis_totals` = #{example.osCommisTotals}
        </if>
        <if test="example.osCommisReturnTotals != null">
          AND `os_commis_return_totals` = #{example.osCommisReturnTotals}
        </if>
        <if test="example.osStoreCostTotals != null">
          AND `os_store_cost_totals` = #{example.osStoreCostTotals}
        </if>
        <if test="example.osResultTotals != null">
          AND `os_result_totals` = #{example.osResultTotals}
        </if>
        <if test="example.osCreateDate != null">
          AND `os_create_date` = #{example.osCreateDate}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `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.business.example.OrderStatisExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `business_order_statis`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `business_order_statis`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `business_order_statis`
    <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 `business_order_statis`
    <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 `business_order_statis`
    <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 `business_order_statis`
    <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 `business_order_statis`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `business_order_statis`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.slodon.b2b2c.business.pojo.OrderStatis" useGeneratedKeys="true">
    INSERT INTO `business_order_statis`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="osYear != null">
        #{osYear},
      </if>
      <if test="osStartDate != null">
        #{osStartDate},
      </if>
      <if test="osEndDate != null">
        #{osEndDate},
      </if>
      <if test="osOrderTotals != null">
        #{osOrderTotals},
      </if>
      <if test="osShippingTotals != null">
        #{osShippingTotals},
      </if>
      <if test="osOrderReturnTotals != null">
        #{osOrderReturnTotals},
      </if>
      <if test="osCommisTotals != null">
        #{osCommisTotals},
      </if>
      <if test="osCommisReturnTotals != null">
        #{osCommisReturnTotals},
      </if>
      <if test="osStoreCostTotals != null">
        #{osStoreCostTotals},
      </if>
      <if test="osResultTotals != null">
        #{osResultTotals},
      </if>
      <if test="osCreateDate != null">
        #{osCreateDate},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `business_order_statis`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.osYear != null">
        `os_year` = #{record.osYear},
      </if>
      <if test="record.osStartDate != null">
        `os_start_date` = #{record.osStartDate},
      </if>
      <if test="record.osEndDate != null">
        `os_end_date` = #{record.osEndDate},
      </if>
      <if test="record.osOrderTotals != null">
        `os_order_totals` = #{record.osOrderTotals},
      </if>
      <if test="record.osShippingTotals != null">
        `os_shipping_totals` = #{record.osShippingTotals},
      </if>
      <if test="record.osOrderReturnTotals != null">
        `os_order_return_totals` = #{record.osOrderReturnTotals},
      </if>
      <if test="record.osCommisTotals != null">
        `os_commis_totals` = #{record.osCommisTotals},
      </if>
      <if test="record.osCommisReturnTotals != null">
        `os_commis_return_totals` = #{record.osCommisReturnTotals},
      </if>
      <if test="record.osStoreCostTotals != null">
        `os_store_cost_totals` = #{record.osStoreCostTotals},
      </if>
      <if test="record.osResultTotals != null">
        `os_result_totals` = #{record.osResultTotals},
      </if>
      <if test="record.osCreateDate != null">
        `os_create_date` = #{record.osCreateDate},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `business_order_statis`
    <trim prefix="SET" suffixOverrides=",">
      <if test="osYear != null">
        `os_year` = #{osYear},
      </if>
      <if test="osStartDate != null">
        `os_start_date` = #{osStartDate},
      </if>
      <if test="osEndDate != null">
        `os_end_date` = #{osEndDate},
      </if>
      <if test="osOrderTotals != null">
        `os_order_totals` = #{osOrderTotals},
      </if>
      <if test="osShippingTotals != null">
        `os_shipping_totals` = #{osShippingTotals},
      </if>
      <if test="osOrderReturnTotals != null">
        `os_order_return_totals` = #{osOrderReturnTotals},
      </if>
      <if test="osCommisTotals != null">
        `os_commis_totals` = #{osCommisTotals},
      </if>
      <if test="osCommisReturnTotals != null">
        `os_commis_return_totals` = #{osCommisReturnTotals},
      </if>
      <if test="osStoreCostTotals != null">
        `os_store_cost_totals` = #{osStoreCostTotals},
      </if>
      <if test="osResultTotals != null">
        `os_result_totals` = #{osResultTotals},
      </if>
      <if test="osCreateDate != null">
        `os_create_date` = #{osCreateDate},
      </if>
    </trim>
    WHERE `id` = #{id}
  </update>
</mapper>