123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <?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.ylcm.sys.mapper.AdSpecialMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.ylcm.sys.domain.AdSpecial">
- <id column="id" property="id" />
- <result column="type" property="type" />
- <result column="product_name" property="productName" />
- <result column="brand_name" property="brandName" />
- <result column="adv_master" property="advMaster" />
- <result column="media_name" property="mediaName" />
- <result column="show_env" property="showEnv" />
- <result column="tv_name" property="tvName" />
- <result column="show_time" property="showTime" />
- <result column="show_date" property="showDate" />
- <result column="show_duration" property="showDuration" />
- <result column="price" property="price" />
- <result column="phone" property="phone" />
- <result column="status" property="status" />
- <result column="crt_time" property="crtTime" />
- <result column="upd_time" property="updTime" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, type, product_name, brand_name, adv_master, media_name, show_env, tv_name, show_time, show_date, show_duration, price, phone, status, crt_time, upd_time
- </sql>
-
- <!-- 专题基本字段 -->
- <sql id="Page_Column_List">
- a.id, a.type, a.product_name, a.brand_name, a.adv_master, a.media_name, a.show_env, a.tv_name, a.show_time, a.show_date, a.show_duration, a.price, a.phone,
- b.first_ind, b.second_ind
- </sql>
-
- <sql id="WHERE_GET_PAGE">
- <trim prefix="where" prefixOverrides="and|or">
- a.status = 0 AND b.status = 0
- <if test="queryBean.type != null">
- AND a.type= #{queryBean.type}
- </if>
- <if test="queryBean.keyword != null and queryBean.keyword !='' ">
- AND (position(#{queryBean.keyword} in COALESCE(a.product_name,'')) > 0 OR position(#{queryBean.keyword} in COALESCE(a.brand_name,'')) > 0
- OR position(#{queryBean.keyword} in COALESCE(a.adv_master,'')) > 0 OR position(#{queryBean.keyword} in COALESCE(a.tv_name,'')) > 0)
- </if>
- <if test="queryBean.mediaName != null and queryBean.mediaName != ''">
- AND a.media_name= #{queryBean.mediaName}
- </if>
- <if test="queryBean.showEnv != null">
- AND a.show_env= #{queryBean.showEnv}
- </if>
- <if test="queryBean.firstInd != null and queryBean.firstInd != ''">
- AND b.first_ind= #{queryBean.firstInd}
- </if>
- <if test="queryBean.secondInd != null and queryBean.secondInd != ''">
- AND b.second_ind= #{queryBean.secondInd}
- </if>
- <if test="queryBean.startDate != null and queryBean.startDate != ''">
- <![CDATA[ AND a.show_date >= #{queryBean.startDate}]]>
- </if>
- <if test="queryBean.endDate != null and queryBean.endDate != ''">
- <![CDATA[ AND a.show_date <= #{queryBean.endDate}]]>
- </if>
- </trim>
- </sql>
-
- <select id="getPage" resultType="com.ylcm.sys.vo.AdSpecialAnalysisVO">
- SELECT
- <include refid ="Page_Column_List"/>
- FROM ad_special a
- <if test="queryBean.type != null and queryBean.type == 0">
- JOIN ad_product b on a.product_name = b.product_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <if test="queryBean.type != null and queryBean.type == 1">
- JOIN ad_platform b on a.product_name = b.platform_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <include refid ="WHERE_GET_PAGE"/>
- ORDER BY a.id DESC
- </select>
-
- <select id="getALLPage" resultType="com.ylcm.sys.vo.AdSpecialAnalysisVO">
- SELECT a.* FROM
- (
- SELECT <include refid ="Page_Column_List"/>
- FROM ad_special a
- JOIN ad_product b on a.product_name = b.product_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- <include refid ="WHERE_GET_PAGE"/>
- UNION ALL
- SELECT <include refid ="Page_Column_List"/>
- FROM ad_special a
- JOIN ad_platform b on a.product_name = b.platform_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- <include refid ="WHERE_GET_PAGE"/>
- ) a ORDER BY a.id DESC
- </select>
-
- <select id="specialTop" resultType="com.ylcm.sys.vo.AdSpecialTopVO">
- SELECT
- a.product_name as productName, b.second_ind as secondInd, sum(a.show_duration) duration, SUM(1) frequency
- FROM
- ad_special a
- <if test="type == 0">
- JOIN ad_product b on a.product_name = b.product_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <if test="type == 1">
- JOIN ad_platform b on a.product_name = b.platform_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <where>
- a.status = 0 AND b.status = 0
- <if test="type != null">
- AND a.type = #{type}
- </if>
- <if test="startDate != null and startDate != ''">
- AND a.show_date >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND #{endDate} >= a.show_date
- </if>
- </where>
- GROUP BY a.product_name,b.second_ind
- ORDER BY sum(a.show_duration) DESC LIMIT 30
- </select>
- <select id="mediaDist" resultType="com.ylcm.sys.vo.AdSpecialDistVO">
- SELECT media_name name,SUM(1) total, SUM(show_duration) duration
- FROM ad_special
- <where>
- status = 0
- <if test="type != null">
- AND type = #{type}
- </if>
- <if test="startDate != null and startDate != ''">
- AND show_date >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND #{endDate} >= show_date
- </if>
- <if test="productName != null and productName != ''">
- AND product_name = #{productName}
- </if>
- </where>
- GROUP BY media_name
- </select>
-
- <select id="tvDist" resultType="com.ylcm.sys.vo.AdSpecialDistVO">
- SELECT tv_name name,SUM(1) total, SUM(show_duration) duration
- FROM ad_special
- <where>
- status = 0 and show_env = 1
- <if test="type != null">
- AND type = #{type}
- </if>
- <if test="startDate != null and startDate != ''">
- AND show_date >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND #{endDate} >= show_date
- </if>
- <if test="productName != null and productName != ''">
- AND product_name = #{productName}
- </if>
- </where>
- GROUP BY tv_name
- </select>
-
- <select id="secondIndDist" resultType="com.ylcm.sys.vo.AdSpecialDistVO">
- SELECT
- a.product_name name,
- SUM(1) total, SUM(a.show_duration) duration
- FROM ad_special a
- <if test="type == 0">
- JOIN ad_product b on a.product_name = b.product_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <if test="type == 1">
- JOIN ad_platform b on a.product_name = b.platform_name AND COALESCE(a.brand_name, '') = COALESCE(b.brand_name, '')
- </if>
- <where>
- a.status = 0
- <if test="type != null">
- AND a.type = #{type} AND b.status = 0
- </if>
- <if test="startDate != null and startDate != ''">
- AND a.show_date >= #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND #{endDate} >= a.show_date
- </if>
- <if test="type != null and secondInd != null and secondInd != ''">
- AND b.second_ind = #{secondInd}
- </if>
- </where>
- GROUP BY a.product_name
- <if test="launch != null and launch == 0">
- ORDER BY SUM(1) DESC
- </if>
- <if test="launch != null and launch == 1">
- ORDER BY SUM(a.show_duration) DESC
- </if>
- </select>
-
- <select id="benchmarkingPage" resultType="com.ylcm.sys.vo.AdSpecialAnalysisBenchmarkingVO">
- SELECT a.id , a.product_name as productName
- <if test="queryBean.type == 0">
- ,b.name_img_url as imgUrl
- </if>
- <if test="queryBean.type == 1">
- ,b.img_url as imgUrl
- </if>
- FROM ad_special a
- <if test="queryBean.type == 0">
- LEFT JOIN ad_product b on a.product_name = b.product_name
- </if>
- <if test="queryBean.type == 1">
- LEFT JOIN ad_platform b on a.product_name = b.platform_name
- </if>
- <where>
- a.status = 0
- <if test="queryBean.type != null">
- AND a.type = #{queryBean.type} AND b.status = 0
- </if>
- <if test="queryBean.productName != null and queryBean.productName !='' ">
- AND a.product_name LIKE CONCAT('%',#{queryBean.productName},'%')
- </if>
- <if test="queryBean.idList != null and queryBean.idList.size() > 0">
- <foreach collection="queryBean.idList" item="id" open="AND a.id in (" separator="," close=")" >
- #{id}
- </foreach>
- </if>
- <if test="queryBean.productNameList != null and queryBean.productNameList.size() > 0">
- <foreach collection="queryBean.productNameList" item="productNameList" open="AND a.product_name not in (" separator="," close=")" >
- #{productNameList}
- </foreach>
- </if>
- </where>
- GROUP BY a.product_name
- ORDER BY a.crt_time DESC
- </select>
-
- <!-- 同步专题栏目/产品信息 -->
- <update id="upSyscAdSpecialProductName">
- UPDATE ad_special SET product_name = #{productName}, brand_name = #{brandName},upd_time = now()
- WHERE status = 0 AND type= #{type} AND product_name = #{oldProductName}
- <choose>
- <when test="oldBrandName != null and oldBrandName !='' ">
- AND brand_name = #{oldBrandName}
- </when>
- <otherwise>
- AND (brand_name is null OR brand_name = '')
- </otherwise>
- </choose>
- </update>
-
- </mapper>
|