|
@@ -1,7 +1,7 @@
|
|
|
<?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.caimei365.tools.mapper.CmBehaviorRecordMapper">
|
|
|
- <insert id="insertRecord">
|
|
|
+ <insert id="insertRecord" parameterType="com.caimei365.tools.model.po.CmBehaviorRecordPo" useGeneratedKeys="true" keyProperty="recordID">
|
|
|
INSERT INTO cm_behavior_record (IP, userID, pagePath, pageType, pageLabel, behaviorType, productID, accessTime, accessDuration, accessDate,referer,accessSource,accessClient,isReckon,region,userAgent,delFlag)
|
|
|
VALUES(#{IP},#{userId},#{pagePath},#{pageType},#{pageLabel},#{behaviorType},#{productId},#{accessTime},#{accessDuration},#{accessDate},#{referer},#{accessSource},#{accessClient},#{isReckon},#{region},#{userAgent},#{delFlag})
|
|
|
</insert>
|
|
@@ -186,58 +186,227 @@
|
|
|
userID = #{userId}
|
|
|
WHERE recordID = #{recordID}
|
|
|
</update>
|
|
|
- <select id="selYesterdayList">
|
|
|
- INSERT INTO cm_behavior_record_index (IP, userID, clubID, lastAccessTime, companyType, corporateName,
|
|
|
- contacts, phoneNumber, spName, number, consultName, consultMobile, behaviorType, productID, accessTime, accessDuration, accessDate, accessClient, region, delFlag)
|
|
|
+ <select id="selYesterdayList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
|
|
|
SELECT
|
|
|
- b.IP,
|
|
|
- b.userID,
|
|
|
- c.clubID,
|
|
|
- MAX(b.accessTime) AS lastAccessTime,
|
|
|
- (
|
|
|
- CASE WHEN u.userIdentity = 2 THEN 2
|
|
|
- WHEN u.userIdentity = 4 THEN 2
|
|
|
- WHEN u.userIdentity = 3 THEN 3
|
|
|
- WHEN b.userID = 0 THEN 1
|
|
|
- END)AS companyType,
|
|
|
- (
|
|
|
- CASE WHEN b.userID = 0 THEN ''
|
|
|
- WHEN u.userIdentity = 2 THEN c.name
|
|
|
- when u.userIdentity = 3 then s.name
|
|
|
- WHEN u.userIdentity = 4 THEN IF(c.name != u.userName,c.name,'')
|
|
|
- END)AS corporateName,
|
|
|
- (
|
|
|
- CASE WHEN b.userID = 0 THEN ''
|
|
|
- WHEN u.userIdentity = 2 THEN c.linkMan
|
|
|
- WHEN u.userIdentity = 3 THEN s.linkMan
|
|
|
- WHEN u.userIdentity = 4 THEN c.linkMan
|
|
|
- END)AS contacts,
|
|
|
- (CASE WHEN u.userIdentity = 2 THEN c.contractMobile
|
|
|
- WHEN u.userIdentity = 4 THEN c.contractMobile
|
|
|
- WHEN u.userIdentity = 3 THEN s.contractMobile
|
|
|
- END)AS phoneNumber,
|
|
|
- (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
|
|
|
- COUNT(b.IP) AS numbers,
|
|
|
- (SELECT consultName
|
|
|
- FROM cm_roos_information
|
|
|
- WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
|
|
|
- (SELECT consultMobile
|
|
|
- FROM cm_roos_information
|
|
|
- WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
|
|
|
- b.behaviorType,
|
|
|
- b.productID,
|
|
|
- b.accessTime,
|
|
|
- SUM(b.accessDuration) AS accessDuration,
|
|
|
- b.accessDate,
|
|
|
- b.accessClient,
|
|
|
- b.region AS region,
|
|
|
- b.delFlag
|
|
|
+ b.IP,
|
|
|
+ b.userID,
|
|
|
+ c.clubID,
|
|
|
+ MAX(b.accessTime) AS lastAccessTime,
|
|
|
+ (
|
|
|
+ CASE WHEN u.userIdentity = 2 THEN 2
|
|
|
+ WHEN u.userIdentity = 4 THEN 2
|
|
|
+ WHEN u.userIdentity = 3 THEN 3
|
|
|
+ WHEN b.userID = 0 THEN 1
|
|
|
+ END)AS companyType,
|
|
|
+ (
|
|
|
+ CASE WHEN b.userID = 0 THEN ''
|
|
|
+ WHEN u.userIdentity = 2 THEN c.name
|
|
|
+ when u.userIdentity = 3 then s.name
|
|
|
+ WHEN u.userIdentity = 4 THEN IF(c.name != u.userName,c.name,'')
|
|
|
+ END)AS corporateName,
|
|
|
+ (
|
|
|
+ CASE WHEN b.userID = 0 THEN ''
|
|
|
+ WHEN u.userIdentity = 2 THEN c.linkMan
|
|
|
+ WHEN u.userIdentity = 3 THEN s.linkMan
|
|
|
+ WHEN u.userIdentity = 4 THEN c.linkMan
|
|
|
+ END)AS contacts,
|
|
|
+ (CASE WHEN u.userIdentity = 2 THEN c.contractMobile
|
|
|
+ WHEN u.userIdentity = 4 THEN c.contractMobile
|
|
|
+ WHEN u.userIdentity = 3 THEN s.contractMobile
|
|
|
+ END)AS phoneNumber,
|
|
|
+ (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
|
|
|
+ COUNT(b.IP) AS numbers,
|
|
|
+ (SELECT consultName
|
|
|
+ FROM cm_roos_information
|
|
|
+ WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
|
|
|
+ (SELECT consultMobile
|
|
|
+ FROM cm_roos_information
|
|
|
+ WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
|
|
|
+ b.behaviorType,
|
|
|
+ b.productID,
|
|
|
+ b.accessTime,
|
|
|
+ SUM(b.accessDuration) AS accessDuration,
|
|
|
+ b.accessDate,
|
|
|
+ b.accessClient,
|
|
|
+ b.region AS region,
|
|
|
+ u.registerTime AS addTime,
|
|
|
+ b.delFlag
|
|
|
FROM cm_behavior_record b
|
|
|
- LEFT JOIN USER u ON b.userID = u.userID
|
|
|
- LEFT JOIN club c ON b.userID = c.userID
|
|
|
- LEFT JOIN shop s ON b.userID = s.userID
|
|
|
+ LEFT JOIN USER u ON b.userID = u.userID
|
|
|
+ LEFT JOIN club c ON b.userID = c.userID
|
|
|
+ LEFT JOIN shop s ON b.userID = s.userID
|
|
|
WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
|
|
|
GROUP BY b.IP, b.accessDate,b.userID, b.behaviorType ORDER BY b.accessTime DESC
|
|
|
</select>
|
|
|
+ <select id="insertYesterdayList">
|
|
|
+ INSERT INTO cm_behavior_record_index (
|
|
|
+ IP,
|
|
|
+ userID,
|
|
|
+ clubID,
|
|
|
+ lastAccessTime,
|
|
|
+ companyType,
|
|
|
+ corporateName,
|
|
|
+ contacts,
|
|
|
+ phoneNumber,
|
|
|
+ spName,
|
|
|
+ number,
|
|
|
+ consultName,
|
|
|
+ consultMobile,
|
|
|
+ accessTime,
|
|
|
+ accessDuration,
|
|
|
+ accessDate,
|
|
|
+ accessClient,
|
|
|
+ region,
|
|
|
+ relevanceShop,
|
|
|
+ label,
|
|
|
+ addTime,
|
|
|
+ delFlag
|
|
|
+ ) values (
|
|
|
+ #{IP},
|
|
|
+ #{userId},
|
|
|
+ #{clubId},
|
|
|
+ #{lastAccessTime},
|
|
|
+ #{companyType},
|
|
|
+ #{corporateName},
|
|
|
+ #{contacts},
|
|
|
+ #{phoneNumber},
|
|
|
+ #{spName},
|
|
|
+ #{number},
|
|
|
+ #{consultName},
|
|
|
+ #{consultMobile},
|
|
|
+ #{accessTime},
|
|
|
+ #{accessDuration},
|
|
|
+ #{accessDate},
|
|
|
+ #{accessClient},
|
|
|
+ #{region},
|
|
|
+ #{relevanceShop},
|
|
|
+ #{label},
|
|
|
+ #{addTime},
|
|
|
+ '0'
|
|
|
+ )
|
|
|
+ </select>
|
|
|
+ <select id="selTodayData" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
|
|
|
+ SELECT
|
|
|
+ b.IP,
|
|
|
+ b.userID,
|
|
|
+ c.clubID,
|
|
|
+ MAX(b.accessTime) AS lastAccessTime,
|
|
|
+ (
|
|
|
+ CASE WHEN u.userIdentity = 2 THEN 2
|
|
|
+ WHEN u.userIdentity = 4 THEN 2
|
|
|
+ WHEN u.userIdentity = 3 THEN 3
|
|
|
+ WHEN b.userID = 0 THEN 1
|
|
|
+ END)AS companyType,
|
|
|
+ (
|
|
|
+ CASE WHEN b.userID = 0 THEN ''
|
|
|
+ WHEN u.userIdentity = 2 THEN c.name
|
|
|
+ WHEN u.userIdentity = 3 THEN s.name
|
|
|
+ WHEN u.userIdentity = 4 THEN c.name -- IF(c.name != u.userName,c.name,'')
|
|
|
+ END)AS corporateName,
|
|
|
+ (
|
|
|
+ CASE WHEN b.userID = 0 THEN ''
|
|
|
+ WHEN u.userIdentity = 2 THEN c.linkMan
|
|
|
+ WHEN u.userIdentity = 3 THEN s.linkMan
|
|
|
+ WHEN u.userIdentity = 4 THEN c.linkMan
|
|
|
+ END)AS contacts,
|
|
|
+ (
|
|
|
+ CASE WHEN u.userIdentity = 2 THEN c.contractMobile
|
|
|
+ WHEN u.userIdentity = 4 THEN c.contractMobile
|
|
|
+ WHEN u.userIdentity = 3 THEN s.contractMobile
|
|
|
+ END)AS phoneNumber,
|
|
|
+ (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
|
|
|
+ COUNT(b.IP) AS number,
|
|
|
+ (SELECT consultName
|
|
|
+ FROM cm_roos_information
|
|
|
+ WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
|
|
|
+ (SELECT consultMobile
|
|
|
+ FROM cm_roos_information
|
|
|
+ WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
|
|
|
+ b.accessTime,
|
|
|
+ SUM(b.accessDuration) AS accessDuration,
|
|
|
+ b.accessDate,
|
|
|
+ b.accessClient,
|
|
|
+ b.region AS region,
|
|
|
+ u.registerTime AS addTime
|
|
|
+ FROM cm_behavior_record b
|
|
|
+ LEFT JOIN USER u ON b.userID = u.userID
|
|
|
+ LEFT JOIN club c ON b.userID = c.userID
|
|
|
+ LEFT JOIN shop s ON b.userID = s.userID
|
|
|
+ WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
|
|
|
+ GROUP BY b.IP, b.accessDate,b.userID ORDER BY b.accessTime DESC
|
|
|
+ </select>
|
|
|
+ <select id="selDataList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
|
|
|
+ SELECT s.name AS relevanceShop, cbs.userID, cbs.IP, cbs.pageLabel
|
|
|
+ FROM cm_behavior_record cbs
|
|
|
+ LEFT JOIN cm_behavior_shopid cbr ON cbs.recordID = cbr.recordID
|
|
|
+ LEFT JOIN shop s ON s.shopID = cbr.shopID
|
|
|
+ where cbs.accessDate = #{accessDate}
|
|
|
+ order by cbs.accessTime
|
|
|
+ </select>
|
|
|
+ <insert id="inBehaviorToday">
|
|
|
+ INSERT INTO cm_behavior_record_today (
|
|
|
+ id,
|
|
|
+ IP,
|
|
|
+ userId,
|
|
|
+ clubId,
|
|
|
+ lastAccessTime,
|
|
|
+ companyType,
|
|
|
+ corporateName,
|
|
|
+ contacts,
|
|
|
+ phoneNumber,
|
|
|
+ spName,
|
|
|
+ number,
|
|
|
+ consultName,
|
|
|
+ consultMobile,
|
|
|
+ accessTime,
|
|
|
+ accessDuration,
|
|
|
+ accessDate,
|
|
|
+ accessClient,
|
|
|
+ region,
|
|
|
+ relevanceShop,
|
|
|
+ label,
|
|
|
+ addTime
|
|
|
+ ) values (
|
|
|
+ #{recordID},
|
|
|
+ #{IP},
|
|
|
+ #{userId},
|
|
|
+ #{clubId},
|
|
|
+ #{lastAccessTime},
|
|
|
+ #{companyType},
|
|
|
+ #{corporateName},
|
|
|
+ #{contacts},
|
|
|
+ #{phoneNumber},
|
|
|
+ #{spName},
|
|
|
+ #{number},
|
|
|
+ #{consultName},
|
|
|
+ #{consultMobile},
|
|
|
+ #{accessTime},
|
|
|
+ #{accessDuration},
|
|
|
+ #{accessDate},
|
|
|
+ #{accessClient},
|
|
|
+ #{region},
|
|
|
+ #{relevanceShop},
|
|
|
+ #{label},
|
|
|
+ #{addTime}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <delete id="delTodayData">
|
|
|
+ TRUNCATE TABLE cm_behavior_record_today
|
|
|
+ </delete>
|
|
|
+ <select id="shopIds" resultType="java.lang.Integer">
|
|
|
+ SELECT DISTINCT csr.shopID FROM cm_shop_relevance csr
|
|
|
+ LEFT JOIN cm_shop_label csl ON csr.id = csl.relevanceId
|
|
|
+ LEFT JOIN cm_user_search_frequency cusf ON csl.keywordId = cusf.id
|
|
|
+ <where>
|
|
|
+ <if test="strList != null and strList.size > 0">
|
|
|
+ <foreach collection="strList" item="keyword" open="(" close=")" separator="or">
|
|
|
+ cusf.keyword like concat('%',#{keyword},'%')
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <insert id="insertShopId">
|
|
|
+ insert into cm_behavior_shopId (recordID, shopID) values (#{recordId}, #{shopId})
|
|
|
+ </insert>
|
|
|
</mapper>
|
|
|
|