<?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.TerminalYearWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.statistics.pojo.TerminalYear">
    <id column="stats_id" property="statsId" />
    <result column="stats_time" property="statsTime" />
    <result column="terminal_name" property="terminalName" />
    <result column="terminal_code" property="terminalCode" />
    <result column="visitor_num" property="visitorNum" />
    <result column="new_visitor_num" property="newVisitorNum" />
    <result column="view_num" property="viewNum" />
    <result column="order_submit_num" property="orderSubmitNum" />
    <result column="order_submit_amount" property="orderSubmitAmount" />
    <result column="order_submit_member_num" property="orderSubmitMemberNum" />
    <result column="order_submit_atv" property="orderSubmitAtv" />
    <result column="order_pay_num" property="orderPayNum" />
    <result column="order_pay_amount" property="orderPayAmount" />
    <result column="order_pay_member_num" property="orderPayMemberNum" />
    <result column="order_pay_atv" property="orderPayAtv" />
    <result column="pv_submit_rate" property="pvSubmitRate" />
    <result column="pv_pay_rate" property="pvPayRate" />
    <result column="submit_pay_rate" property="submitPayRate" />
    <result column="new_member_num" property="newMemberNum" />
    <result column="recharge_member_num" property="rechargeMemberNum" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="statsTime != null">
        `stats_time`,
      </if>
      <if test="terminalName != null">
        `terminal_name`,
      </if>
      <if test="terminalCode != null">
        `terminal_code`,
      </if>
      <if test="visitorNum != null">
        `visitor_num`,
      </if>
      <if test="newVisitorNum != null">
        `new_visitor_num`,
      </if>
      <if test="viewNum != null">
        `view_num`,
      </if>
      <if test="orderSubmitNum != null">
        `order_submit_num`,
      </if>
      <if test="orderSubmitAmount != null">
        `order_submit_amount`,
      </if>
      <if test="orderSubmitMemberNum != null">
        `order_submit_member_num`,
      </if>
      <if test="orderSubmitAtv != null">
        `order_submit_atv`,
      </if>
      <if test="orderPayNum != null">
        `order_pay_num`,
      </if>
      <if test="orderPayAmount != null">
        `order_pay_amount`,
      </if>
      <if test="orderPayMemberNum != null">
        `order_pay_member_num`,
      </if>
      <if test="orderPayAtv != null">
        `order_pay_atv`,
      </if>
      <if test="pvSubmitRate != null">
        `pv_submit_rate`,
      </if>
      <if test="pvPayRate != null">
        `pv_pay_rate`,
      </if>
      <if test="submitPayRate != null">
        `submit_pay_rate`,
      </if>
      <if test="newMemberNum != null">
        `new_member_num`,
      </if>
      <if test="rechargeMemberNum != null">
        `recharge_member_num`,
      </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.terminalName != null">
          AND `terminal_name` = #{example.terminalName}
        </if>
        <if test="example.terminalNameLike != null">
          AND `terminal_name` like concat('%',#{example.terminalNameLike},'%')
        </if>
        <if test="example.terminalCode != null">
          AND `terminal_code` = #{example.terminalCode}
        </if>
        <if test="example.visitorNum != null">
          AND `visitor_num` = #{example.visitorNum}
        </if>
        <if test="example.newVisitorNum != null">
          AND `new_visitor_num` = #{example.newVisitorNum}
        </if>
        <if test="example.viewNum != null">
          AND `view_num` = #{example.viewNum}
        </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.orderSubmitMemberNum != null">
          AND `order_submit_member_num` = #{example.orderSubmitMemberNum}
        </if>
        <if test="example.orderSubmitAtv != null">
          AND `order_submit_atv` = #{example.orderSubmitAtv}
        </if>
        <if test="example.orderPayNum != null">
          AND `order_pay_num` = #{example.orderPayNum}
        </if>
        <if test="example.orderPayAmount != null">
          AND `order_pay_amount` = #{example.orderPayAmount}
        </if>
        <if test="example.orderPayMemberNum != null">
          AND `order_pay_member_num` = #{example.orderPayMemberNum}
        </if>
        <if test="example.orderPayAtv != null">
          AND `order_pay_atv` = #{example.orderPayAtv}
        </if>
        <if test="example.pvSubmitRate != null">
          AND `pv_submit_rate` = #{example.pvSubmitRate}
        </if>
        <if test="example.pvPayRate != null">
          AND `pv_pay_rate` = #{example.pvPayRate}
        </if>
        <if test="example.submitPayRate != null">
          AND `submit_pay_rate` = #{example.submitPayRate}
        </if>
        <if test="example.newMemberNum != null">
          AND `new_member_num` = #{example.newMemberNum}
        </if>
        <if test="example.rechargeMemberNum != null">
          AND `recharge_member_num` = #{example.rechargeMemberNum}
        </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.TerminalYearExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `stats_terminal_year`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `stats_terminal_year`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `stats_terminal_year`
    <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_terminal_year`
    <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_terminal_year`
    <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_terminal_year`
    <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_terminal_year`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `stats_terminal_year`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="stats_id" keyProperty="statsId" parameterType="com.slodon.b2b2c.statistics.pojo.TerminalYear" useGeneratedKeys="true">
    INSERT INTO `stats_terminal_year`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="statsTime != null">
        #{statsTime},
      </if>
      <if test="terminalName != null">
        #{terminalName},
      </if>
      <if test="terminalCode != null">
        #{terminalCode},
      </if>
      <if test="visitorNum != null">
        #{visitorNum},
      </if>
      <if test="newVisitorNum != null">
        #{newVisitorNum},
      </if>
      <if test="viewNum != null">
        #{viewNum},
      </if>
      <if test="orderSubmitNum != null">
        #{orderSubmitNum},
      </if>
      <if test="orderSubmitAmount != null">
        #{orderSubmitAmount},
      </if>
      <if test="orderSubmitMemberNum != null">
        #{orderSubmitMemberNum},
      </if>
      <if test="orderSubmitAtv != null">
        #{orderSubmitAtv},
      </if>
      <if test="orderPayNum != null">
        #{orderPayNum},
      </if>
      <if test="orderPayAmount != null">
        #{orderPayAmount},
      </if>
      <if test="orderPayMemberNum != null">
        #{orderPayMemberNum},
      </if>
      <if test="orderPayAtv != null">
        #{orderPayAtv},
      </if>
      <if test="pvSubmitRate != null">
        #{pvSubmitRate},
      </if>
      <if test="pvPayRate != null">
        #{pvPayRate},
      </if>
      <if test="submitPayRate != null">
        #{submitPayRate},
      </if>
      <if test="newMemberNum != null">
        #{newMemberNum},
      </if>
      <if test="rechargeMemberNum != null">
        #{rechargeMemberNum},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `stats_terminal_year`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.statsTime != null">
        `stats_time` = #{record.statsTime},
      </if>
      <if test="record.terminalName != null">
        `terminal_name` = #{record.terminalName},
      </if>
      <if test="record.terminalCode != null">
        `terminal_code` = #{record.terminalCode},
      </if>
      <if test="record.visitorNum != null">
        `visitor_num` = #{record.visitorNum},
      </if>
      <if test="record.newVisitorNum != null">
        `new_visitor_num` = #{record.newVisitorNum},
      </if>
      <if test="record.viewNum != null">
        `view_num` = #{record.viewNum},
      </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.orderSubmitMemberNum != null">
        `order_submit_member_num` = #{record.orderSubmitMemberNum},
      </if>
      <if test="record.orderSubmitAtv != null">
        `order_submit_atv` = #{record.orderSubmitAtv},
      </if>
      <if test="record.orderPayNum != null">
        `order_pay_num` = #{record.orderPayNum},
      </if>
      <if test="record.orderPayAmount != null">
        `order_pay_amount` = #{record.orderPayAmount},
      </if>
      <if test="record.orderPayMemberNum != null">
        `order_pay_member_num` = #{record.orderPayMemberNum},
      </if>
      <if test="record.orderPayAtv != null">
        `order_pay_atv` = #{record.orderPayAtv},
      </if>
      <if test="record.pvSubmitRate != null">
        `pv_submit_rate` = #{record.pvSubmitRate},
      </if>
      <if test="record.pvPayRate != null">
        `pv_pay_rate` = #{record.pvPayRate},
      </if>
      <if test="record.submitPayRate != null">
        `submit_pay_rate` = #{record.submitPayRate},
      </if>
      <if test="record.newMemberNum != null">
        `new_member_num` = #{record.newMemberNum},
      </if>
      <if test="record.rechargeMemberNum != null">
        `recharge_member_num` = #{record.rechargeMemberNum},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `stats_terminal_year`
    <trim prefix="SET" suffixOverrides=",">
      <if test="statsTime != null">
        `stats_time` = #{statsTime},
      </if>
      <if test="terminalName != null">
        `terminal_name` = #{terminalName},
      </if>
      <if test="terminalCode != null">
        `terminal_code` = #{terminalCode},
      </if>
      <if test="visitorNum != null">
        `visitor_num` = #{visitorNum},
      </if>
      <if test="newVisitorNum != null">
        `new_visitor_num` = #{newVisitorNum},
      </if>
      <if test="viewNum != null">
        `view_num` = #{viewNum},
      </if>
      <if test="orderSubmitNum != null">
        `order_submit_num` = #{orderSubmitNum},
      </if>
      <if test="orderSubmitAmount != null">
        `order_submit_amount` = #{orderSubmitAmount},
      </if>
      <if test="orderSubmitMemberNum != null">
        `order_submit_member_num` = #{orderSubmitMemberNum},
      </if>
      <if test="orderSubmitAtv != null">
        `order_submit_atv` = #{orderSubmitAtv},
      </if>
      <if test="orderPayNum != null">
        `order_pay_num` = #{orderPayNum},
      </if>
      <if test="orderPayAmount != null">
        `order_pay_amount` = #{orderPayAmount},
      </if>
      <if test="orderPayMemberNum != null">
        `order_pay_member_num` = #{orderPayMemberNum},
      </if>
      <if test="orderPayAtv != null">
        `order_pay_atv` = #{orderPayAtv},
      </if>
      <if test="pvSubmitRate != null">
        `pv_submit_rate` = #{pvSubmitRate},
      </if>
      <if test="pvPayRate != null">
        `pv_pay_rate` = #{pvPayRate},
      </if>
      <if test="submitPayRate != null">
        `submit_pay_rate` = #{submitPayRate},
      </if>
      <if test="newMemberNum != null">
        `new_member_num` = #{newMemberNum},
      </if>
      <if test="rechargeMemberNum != null">
        `recharge_member_num` = #{rechargeMemberNum},
      </if>
    </trim>
    WHERE `stats_id` = #{statsId}
  </update>
</mapper>