123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- <?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" 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>
- <select id="toDateRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT IP, userID FROM cm_behavior_record WHERE accessDate = #{accessDate} GROUP BY IP, userID
- </select>
- <select id="toDateIPTimeRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND userID = #{userId} AND isReckon = 0
- AND accessTime BETWEEN #{startTime} and #{endTime}
- union
- SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND isReckon = 0 AND accessDate = #{accessDate} AND userID = #{userId}
- ORDER BY accessTime ASC
- </select>
- <update id="updateDuration">
- UPDATE cm_behavior_record
- SET accessDuration = #{accessDuration},
- isReckon = #{isReckon}
- WHERE recordID = #{recordID}
- </update>
- <select id="findList" resultType="com.caimei365.tools.model.po.CmUserPo">
- SELECT userID, registerIP FROM USER where userID between #{startId} and #{endId}
- </select>
- <select id="skuList" resultType="com.caimei365.tools.model.po.CmSkuPo">
- select
- skuId,
- productId,
- organizeId,
- normalPrice,
- price,
- ladderPriceFlag,
- costCheckFlag,
- ifnull(costPrice,0) as costPrice,
- shopPercent,
- organizePercent,
- cmPercent,
- stock,
- unit,
- minBuyNumber
- from cm_sku
- WHERE costCheckFlag = 1
- </select>
- <update id="updateSku">
- update cm_sku
- set shopPercent = #{shopPercent},
- organizePercent = #{organizePercent},
- cmPercent = #{cmPercent},
- costCheckFlag = #{costCheckFlag}
- where skuId = #{skuId}
- </update>
- <update id="updateOldData">
- UPDATE USER
- SET ipAddress = #{ipAddress}
- WHERE userID = #{userID}
- </update>
- <select id="selSvipCoupon" resultType="com.caimei365.tools.model.po.CmVipCouponPo">
- SELECT id,
- useTime,
- updateTime,
- status,
- delFlag
- FROM cm_svip_coupon_month WHERE delFlag != 0 AND useTime BETWEEN #{startTime} AND #{endTime}
- </select>
- <update id="updateSvipCoupon">
- UPDATE cm_svip_coupon_month
- SET delFlag = 0
- WHERE id = #{id}
- </update>
- <insert id="insertVipCouponMonth" parameterType="com.caimei365.tools.model.po.CmVipCouponPo" keyProperty="id" useGeneratedKeys="true" >
- INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
- VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
- </insert>
- <select id="selCoupon" resultType="com.caimei365.tools.model.po.CmCouponPo">
- SELECT
- id,
- name,
- couponAmount,
- touchPrice,
- startDate,
- endDate,
- receivePeriod,
- useTimeFlag,
- receiveFlag,
- usePeriod,
- status,
- couponType,
- vipFlag,
- userId,
- shopId,
- productType,
- pcBanner,
- appletsBanner,
- categoryType,
- couponsMode,
- moneyCouponPrice,
- moneyCouponFlag,
- couponPayWay,
- moneyCouponType,
- createDate,
- delFlag
- FROM cm_coupon WHERE delFlag = 0 AND configure = 1
- </select>
- <update id="updateCoupon">
- UPDATE cm_coupon
- SET configure = #{configure}
- WHERE id = #{id}
- </update>
- <insert id="insertCoupon" parameterType="com.caimei365.tools.model.po.CmCouponPo" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_coupon(
- name,
- couponPayWay,
- couponAmount,
- touchPrice,
- startDate,
- endDate,
- receivePeriod,
- receiveFlag,
- useTimeFlag,
- usePeriod,
- status,
- couponType,
- vipFlag,
- userId,
- shopId,
- productType,
- pcBanner,
- appletsBanner,
- categoryType,
- couponsMode,
- createDate,
- moneyCouponPrice,
- moneyCouponFlag,
- moneyCouponType,
- delFlag,
- configure
- ) VALUES (
- #{name},
- #{couponPayWay},
- #{couponAmount},
- #{touchPrice},
- #{startDate},
- #{endDate},
- #{receivePeriod},
- #{receiveFlag},
- #{useTimeFlag},
- #{usePeriod},
- #{status},
- #{couponType},
- #{vipFlag},
- #{userId},
- #{shopId},
- #{productType},
- #{pcBanner},
- #{appletsBanner},
- #{categoryType},
- #{couponsMode},
- #{createDate},
- #{moneyCouponPrice},
- #{moneyCouponFlag},
- #{moneyCouponType},
- #{delFlag},
- #{configure}
- )
- </insert>
- <select id="selCouponPro" resultType="com.caimei365.tools.model.po.CmCouponAssociatePo">
- select * from cm_coupon_product where delFlag = 0 and couponId = #{couponId}
- </select>
- <insert id="insertCouponAssociate">
- INSERT INTO `cm_coupon_product` (
- `couponId`, `productId`, `pcStatus`,
- `appletsStatus`,
- `sort`, `addTime`, `delFlag`
- )
- VALUES
- (
- #{couponId}, #{productId}, #{pcStatus},
- #{appletsStatus},
- #{sort}, #{addTime}, #{delFlag}
- )
- </insert>
- <select id="selSvipCouponById" resultType="integer">
- SELECT max(id) as id FROM cm_svip_coupon_month
- </select>
- <insert id="insertRelation">
- INSERT INTO cm_svip_coupon(couponId, montId, updateTime,delFlag)
- VALUES(#{couponId}, #{montId}, #{updateTime},#{delFlag})
- </insert>
- <select id="countNum" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT IP as IP, COUNT(DISTINCT userID) as count FROM cm_behavior_record
- where accessDate = #{accessDate}
- GROUP BY IP, accessDate ORDER BY accessDate DESC
- </select>
- <select id="userIdAcc" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT IP as IP, userID as userId FROM cm_behavior_record WHERE IP = #{IP} AND accessDate = #{accessDate} GROUP BY IP ,userID ORDER BY userID DESC LIMIT 1
- </select>
- <select id="selBehaviorList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT recordID as recordID, IP as IP, userID as userId FROM cm_behavior_record WHERE IP = #{IP} AND userID = 0 AND accessDate = #{accessDate}
- </select>
- <update id="updateBehavior">
- UPDATE cm_behavior_record
- SET IP = #{IP},
- userID = #{userId}
- WHERE recordID = #{recordID}
- </update>
- <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 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.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
- WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
- AND b.region NOT LIKE '%美国Microsoft公司%' AND b.region NOT LIKE '%亚马逊(Amazon)公司%'
- GROUP BY b.IP, b.accessDate,b.userID 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}
- AND b.region NOT LIKE '%美国Microsoft公司%' AND b.region NOT LIKE '%亚马逊(Amazon)公司%'
- 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="shopKeyword" resultType="java.lang.String">
- SELECT cusf.keyword 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 csr.delFlag = 0 AND
- csl.delFlag = 0
- </select>
- <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>
- csr.delFlag = 0 and
- csl.delFlag = 0 and
- <if test="strList != null and strList.size > 0">
- <foreach collection="strList" item="keyword" open="(" close=")" separator="or">
- cusf.keyword = #{keyword}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selShopId" resultType="java.lang.Integer">
- select id from cm_shop_relevance where delFlag = 0 and shopID = #{shopId}
- </select>
- <insert id="insertShopId">
- insert into cm_behavior_shopId (recordID, shopID) values (#{recordId}, #{shopId})
- </insert>
- <select id="selRegisterIP" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT u.userID as userId, u.registerIP as registerIp, c.clubID as clubId, c.provinceID as provinceId , c.cityID as cityId
- FROM USER u
- LEFT JOIN club c ON c.userID = u.userID
- WHERE u.userIdentity = 4 and c.clubID between #{startId} and #{endId}
- </select>
- <select id="selProvince" resultType="java.lang.Integer">
- SELECT provinceID as provinceId FROM province WHERE NAME LIKE concat('%', #{regionPro} ,'%') limit 1
- </select>
- <select id="selCity" resultType="com.caimei365.tools.model.po.AddressPo">
- SELECT cityID as cityId, provinceID as provinceId FROM city WHERE NAME LIKE concat('%', #{regionCity} ,'%') AND validFlag = 1 limit 1
- </select>
- <update id="upClubAddress">
- update club
- <set>
- <if test="provinceId != null and provinceId != ''">
- provinceID = #{provinceId},
- </if>
- <if test="cityId != null and cityId != ''">
- cityID = #{cityId}
- </if>
- </set>
- where clubID = #{clubId}
- </update>
- <select id="getShopId" resultType="java.lang.Integer">
- select shopId from cm_shop_statistics where delFlag= 0 and status = 0
- </select>
- <select id="getProductId" resultType="java.lang.Integer">
- SELECT productId FROM product WHERE shopId = #{shopId}
- </select>
- <select id="getShopInfoId" resultType="java.lang.Integer">
- select infoId from cm_shop_info where shopId = #{shopId} and delFlag = 0 and status = 0
- </select>
- <select id="getShopKeywordId" resultType="com.caimei365.tools.model.po.SearchFrequencyVo">
- SELECT ifnull(cusf.keyword, '') as keyword, ifnull(csk.searchId, 0) as id
- FROM cm_shop_keyword csk
- LEFT JOIN cm_user_search_frequency cusf ON cusf.id = csk.searchId
- WHERE csk.shopId = #{shopId} AND csk.delFlag = 0 AND csk.status = 0
- </select>
- <select id="getBehaviorList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
- SELECT ifnull((select pagePath from cm_behavior_record where pagePath like concat('%',#{pagePath},'%') order by accessDate desc LIMIT 1), '') as pagePath,
- count(recordID) as number,
- ifnull(sum(accessDuration), 0) as accessDuration
- from cm_behavior_record
- <where>
- delFlag = 0 and accessDate = #{accessDate}
- <if test="pageType != null">
- and pageType = #{pageType}
- </if>
- <if test="pageType != 8">
- <if test="pagePath != null and pagePath != ''">
- and pagePath like concat('%',#{pagePath},'%')
- </if>
- </if>
- <if test="pageType == 8">
- and pageLabel like concat('%',#{pagePath},'%')
- </if>
- </where>
- </select>
- <insert id="insertPageShop">
- INSERT INTO cm_page_shop (shopId, shopLink, accessNumber, accessDuration, accessDate)
- VALUES (#{shopId}, #{shopLink}, #{accessNumber}, #{accessDuration}, #{accessDate})
- </insert>
- <insert id="insertPageProduct">
- insert into cm_page_shop_product (shopId, productId, link, accessNumber, accessDuration, accessDate)
- values (#{shopId}, #{productId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
- </insert>
- <insert id="insertPageInfo">
- insert into cm_page_shop_info (shopId, infoId, link, accessNumber, accessDuration, accessDate)
- values (#{shopId}, #{infoId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
- </insert>
- <insert id="insertPageKeyword">
- insert into cm_page_shop_keyword (shopId, searchId, link, accessNumber, accessDuration, accessDate)
- values (#{shopId}, #{searchId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
- </insert>
- </mapper>
|