<?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.gree.mall.manager.commonmapper.MarketingMaterialsVisitCustomMapper">


    <select id="getMaterialsTag" resultType="com.gree.mall.manager.plus.entity.Tag">
        SELECT t.*
        from marketing_materials_tag mmt
        join tag t on t.tag_id=mmt.tag_id
        where mmt.marketing_materials_id=#{materialsId}
    </select>

    <select id="getDynamicMaterialsVisitStatistics" resultType="com.gree.mall.manager.bean.marketing.DynamicMaterialsVisitStatisticsBean">
        SELECT nick_name             as username,
               send_user_name        as adminUsername,
               create_time           as newTime,
               count(1)              as totalCount
        FROM `marketing_materials_visit`
        where marketing_materials_id = #{dynamicMaterialsId}
              <if test="beginTime != null and endTime != null">
                and create_time BETWEEN #{beginTime} and #{endTime}
              </if>
        group by user_id
        order by create_time desc
    </select>

</mapper>