<?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.read.statistics.PlatformHourReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.statistics.pojo.PlatformHour">
    <id column="stats_id" property="statsId" />
    <result column="stats_time" property="statsTime" />
    <result column="web_site" property="webSite" />
    <result column="visitor_num" property="visitorNum" />
    <result column="new_visitor_num" property="newVisitorNum" />
    <result column="view_num" property="viewNum" />
    <result column="store_visitor_num" property="storeVisitorNum" />
    <result column="store_view_num" property="storeViewNum" />
    <result column="goods_visitor_num" property="goodsVisitorNum" />
    <result column="goods_view_num" property="goodsViewNum" />
    <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="saling_goods_num" property="salingGoodsNum" />
    <result column="new_goods_num" property="newGoodsNum" />
    <result column="new_brand_num" property="newBrandNum" />
    <result column="new_member_num" property="newMemberNum" />
    <result column="recharge_member_num" property="rechargeMemberNum" />
    <result column="new_store_num" property="newStoreNum" />
  </resultMap>
  <!--按照主键值进行操作-->
  <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.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.storeVisitorNum != null">
          AND `store_visitor_num` = #{example.storeVisitorNum}
        </if>
        <if test="example.storeViewNum != null">
          AND `store_view_num` = #{example.storeViewNum}
        </if>
        <if test="example.goodsVisitorNum != null">
          AND `goods_visitor_num` = #{example.goodsVisitorNum}
        </if>
        <if test="example.goodsViewNum != null">
          AND `goods_view_num` = #{example.goodsViewNum}
        </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.salingGoodsNum != null">
          AND `saling_goods_num` = #{example.salingGoodsNum}
        </if>
        <if test="example.salingGoodsNumLike != null">
          AND `saling_goods_num` like concat('%',#{example.salingGoodsNumLike},'%')
        </if>
        <if test="example.newGoodsNum != null">
          AND `new_goods_num` = #{example.newGoodsNum}
        </if>
        <if test="example.newGoodsNumLike != null">
          AND `new_goods_num` like concat('%',#{example.newGoodsNumLike},'%')
        </if>
        <if test="example.newBrandNum != null">
          AND `new_brand_num` = #{example.newBrandNum}
        </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>
        <if test="example.newStoreNum != null">
          AND `new_store_num` = #{example.newStoreNum}
        </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.PlatformHourExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `stats_platform_hour`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `stats_platform_hour`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `stats_platform_hour`
    <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_platform_hour`
    <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_platform_hour`
    <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_platform_hour`
    <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="getPlatformTrendList" resultType="com.slodon.b2b2c.vo.statistics.MovableGoodsVO">
    SELECT
    DATE_FORMAT( stats_time, '%H:%i' ) AS statsTime,
    new_goods_num AS newGoodsNum,
    saling_goods_num AS movableGoodsNum,
    order_submit_num AS orderSubmitNum,
    order_pay_num AS orderPayNum,
    new_member_num AS newMemberNum,
    new_store_num AS newStoreNum,
    order_pay_amount AS orderPayAmount,
    order_submit_amount AS orderSubmitAmount,
    visitor_num AS visitorNum,
    view_num AS viewNum
    FROM `stats_platform_hour`
    <include refid="whereCondition" />
    ORDER BY statsTime ASC
  </select>
</mapper>