CmBehaviorRecordMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei365.tools.mapper.CmBehaviorRecordMapper">
  4. <select id="getShopName" resultType="java.lang.String">
  5. select name from shop where shopId = #{shopId}
  6. </select>
  7. <select id="getPageLabel" resultType="java.lang.String">
  8. select pageType from cm_page_type where id = #{type}
  9. </select>
  10. <select id="getProductPageLabel" resultType="java.lang.String">
  11. SELECT relatedLabels FROM product WHERE productId = #{productId}
  12. </select>
  13. <select id="getInfoPageLabel" resultType="java.lang.String">
  14. SELECT relatedLabels FROM info WHERE id = #{Id}
  15. </select>
  16. <select id="getBaiKePageLabel" resultType="java.lang.String">
  17. SELECT relatedLabels FROM cm_baike_product WHERE id = #{Id}
  18. </select>
  19. <insert id="insertRecord" parameterType="com.caimei365.tools.model.po.CmBehaviorRecordPo" useGeneratedKeys="true" keyProperty="recordID">
  20. INSERT INTO cm_behavior_record (IP, userID, touristId, pagePath, pageType, pageLabel, behaviorType, productID, accessTime,
  21. accessDuration, accessDate, referer, accessSource, accessClient, isReckon, region, userAgent, openId, delFlag)
  22. VALUES(#{IP}, #{userId}, #{touristId}, #{pagePath}, #{pageType}, #{pageLabel}, #{behaviorType}, #{productId}, #{accessTime},
  23. #{accessDuration}, #{accessDate}, #{referer}, #{accessSource}, #{accessClient}, #{isReckon}, #{region}, #{userAgent}, #{openId}, #{delFlag})
  24. </insert>
  25. <select id="toDateRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  26. SELECT IP, userID FROM cm_behavior_record WHERE accessDate = #{accessDate} GROUP BY IP, userID
  27. </select>
  28. <select id="toDateIPTimeRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  29. SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND userID = #{userId} AND isReckon = 0
  30. AND accessTime BETWEEN #{startTime} and #{endTime}
  31. union
  32. SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND isReckon = 0 AND accessDate = #{accessDate} AND userID = #{userId}
  33. ORDER BY accessTime ASC
  34. </select>
  35. <update id="updateDuration">
  36. UPDATE cm_behavior_record
  37. SET accessDuration = #{accessDuration},
  38. isReckon = #{isReckon}
  39. WHERE recordID = #{recordID}
  40. </update>
  41. <select id="findList" resultType="com.caimei365.tools.model.po.CmUserPo">
  42. SELECT userID, registerIP FROM USER where userID between #{startId} and #{endId}
  43. </select>
  44. <select id="skuList" resultType="com.caimei365.tools.model.po.CmSkuPo">
  45. select
  46. skuId,
  47. productId,
  48. organizeId,
  49. normalPrice,
  50. price,
  51. ladderPriceFlag,
  52. costCheckFlag,
  53. ifnull(costPrice,0) as costPrice,
  54. shopPercent,
  55. organizePercent,
  56. cmPercent,
  57. stock,
  58. unit,
  59. minBuyNumber
  60. from cm_sku
  61. WHERE costCheckFlag = 1
  62. </select>
  63. <update id="updateSku">
  64. update cm_sku
  65. set shopPercent = #{shopPercent},
  66. organizePercent = #{organizePercent},
  67. cmPercent = #{cmPercent},
  68. costCheckFlag = #{costCheckFlag}
  69. where skuId = #{skuId}
  70. </update>
  71. <update id="updateOldData">
  72. UPDATE USER
  73. SET ipAddress = #{ipAddress}
  74. WHERE userID = #{userID}
  75. </update>
  76. <select id="selSvipCoupon" resultType="com.caimei365.tools.model.po.CmVipCouponPo">
  77. SELECT id,
  78. useTime,
  79. updateTime,
  80. status,
  81. delFlag
  82. FROM cm_svip_coupon_month WHERE delFlag != 0 AND useTime BETWEEN #{startTime} AND #{endTime}
  83. </select>
  84. <update id="updateSvipCoupon">
  85. UPDATE cm_svip_coupon_month
  86. SET delFlag = 0
  87. WHERE id = #{id}
  88. </update>
  89. <insert id="insertVipCouponMonth" parameterType="com.caimei365.tools.model.po.CmVipCouponPo" keyProperty="id" useGeneratedKeys="true" >
  90. INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
  91. VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
  92. </insert>
  93. <select id="selCoupon" resultType="com.caimei365.tools.model.po.CmCouponPo">
  94. SELECT
  95. id,
  96. name,
  97. couponAmount,
  98. touchPrice,
  99. startDate,
  100. endDate,
  101. receivePeriod,
  102. useTimeFlag,
  103. receiveFlag,
  104. usePeriod,
  105. status,
  106. couponType,
  107. vipFlag,
  108. userId,
  109. shopId,
  110. productType,
  111. pcBanner,
  112. appletsBanner,
  113. categoryType,
  114. couponsMode,
  115. moneyCouponPrice,
  116. moneyCouponFlag,
  117. couponPayWay,
  118. moneyCouponType,
  119. createDate,
  120. delFlag
  121. FROM cm_coupon WHERE delFlag = 0 AND configure = 1
  122. </select>
  123. <update id="updateCoupon">
  124. UPDATE cm_coupon
  125. SET configure = #{configure}
  126. WHERE id = #{id}
  127. </update>
  128. <insert id="insertCoupon" parameterType="com.caimei365.tools.model.po.CmCouponPo" keyProperty="id" useGeneratedKeys="true">
  129. INSERT INTO cm_coupon(
  130. name,
  131. couponPayWay,
  132. couponAmount,
  133. touchPrice,
  134. startDate,
  135. endDate,
  136. receivePeriod,
  137. receiveFlag,
  138. useTimeFlag,
  139. usePeriod,
  140. status,
  141. couponType,
  142. vipFlag,
  143. userId,
  144. shopId,
  145. productType,
  146. pcBanner,
  147. appletsBanner,
  148. categoryType,
  149. couponsMode,
  150. createDate,
  151. moneyCouponPrice,
  152. moneyCouponFlag,
  153. moneyCouponType,
  154. delFlag,
  155. configure
  156. ) VALUES (
  157. #{name},
  158. #{couponPayWay},
  159. #{couponAmount},
  160. #{touchPrice},
  161. #{startDate},
  162. #{endDate},
  163. #{receivePeriod},
  164. #{receiveFlag},
  165. #{useTimeFlag},
  166. #{usePeriod},
  167. #{status},
  168. #{couponType},
  169. #{vipFlag},
  170. #{userId},
  171. #{shopId},
  172. #{productType},
  173. #{pcBanner},
  174. #{appletsBanner},
  175. #{categoryType},
  176. #{couponsMode},
  177. #{createDate},
  178. #{moneyCouponPrice},
  179. #{moneyCouponFlag},
  180. #{moneyCouponType},
  181. #{delFlag},
  182. #{configure}
  183. )
  184. </insert>
  185. <select id="selCouponPro" resultType="com.caimei365.tools.model.po.CmCouponAssociatePo">
  186. select * from cm_coupon_product where delFlag = 0 and couponId = #{couponId}
  187. </select>
  188. <insert id="insertCouponAssociate">
  189. INSERT INTO `cm_coupon_product` (
  190. `couponId`, `productId`, `pcStatus`,
  191. `appletsStatus`,
  192. `sort`, `addTime`, `delFlag`
  193. )
  194. VALUES
  195. (
  196. #{couponId}, #{productId}, #{pcStatus},
  197. #{appletsStatus},
  198. #{sort}, #{addTime}, #{delFlag}
  199. )
  200. </insert>
  201. <select id="selSvipCouponById" resultType="integer">
  202. SELECT max(id) as id FROM cm_svip_coupon_month
  203. </select>
  204. <insert id="insertRelation">
  205. INSERT INTO cm_svip_coupon(couponId, montId, updateTime,delFlag)
  206. VALUES(#{couponId}, #{montId}, #{updateTime},#{delFlag})
  207. </insert>
  208. <select id="getRecodeOpenId" resultType="java.lang.String">
  209. SELECT openId as count FROM cm_behavior_record where accessDate = #{accessDate} and accessClient = 1 GROUP BY openId
  210. </select>
  211. <select id="getCuxOpen" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  212. SELECT openId, COUNT(DISTINCT userId) as count FROM cm_behavior_record WHERE accessDate = #{accessDate} AND accessClient = 1 AND (openId IS NOT NULL AND openId != '') GROUP BY openId
  213. </select>
  214. <select id="getRecordOpenIdInfo" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  215. SELECT ip as IP, userID as userId, openId FROM cm_behavior_record
  216. <where>
  217. userId is not null and userId != '' and userId = 0 and accessDate = #{accessDate}
  218. <if test="openIdList.size()>0">
  219. and openId in
  220. <foreach collection="openIdList" item="openId" open="(" separator="," close=")">
  221. #{openId}
  222. </foreach>
  223. </if>
  224. </where>
  225. group by userId
  226. </select>
  227. <select id="getRecodeTouristId" resultType="java.lang.String">
  228. SELECT touristId FROM cm_behavior_record WHERE accessDate = #{accessDate} and accessClient = 0 GROUP BY touristId
  229. </select>
  230. <select id="getCuxTourist" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  231. SELECT touristId, COUNT(DISTINCT userId) as count FROM cm_behavior_record WHERE accessDate = #{accessDate} AND accessClient = 0 GROUP BY touristId
  232. </select>
  233. <select id="getTouristInfo" resultType="com.caimei365.tools.model.po.CmBehaviorTouristInfoPo">
  234. select userId, touristId, addTime from cm_behavior_tourist_info
  235. <where>
  236. userId is not null and userId != '' and addTime like concat('%',#{accessDate},'%')
  237. <if test="touristIds.size() > 0">
  238. and touristId in
  239. <foreach collection="touristIds" item="touristId" open="(" separator="," close=")">
  240. #{touristId}
  241. </foreach>
  242. </if>
  243. </where>
  244. group by userId
  245. </select>
  246. <select id="getTouristIdByIp" resultType="java.lang.String">
  247. SELECT ip FROM cm_behavior_record WHERE accessDate = #{accessDate} and touristId = #{touristId}
  248. </select>
  249. <select id="getUserIdAttribute" resultType="java.lang.Integer">
  250. SELECT userId FROM cm_behavior_record
  251. <where>
  252. accessDate = #{accessDate}
  253. <if test="openId != null and openId != ''">
  254. AND openId = #{openId}
  255. </if>
  256. <if test="touristId != null and touristId != ''">
  257. AND touristId = #{touristId}
  258. </if>
  259. </where>
  260. GROUP BY userId
  261. </select>
  262. <update id="updateBehavior">
  263. UPDATE cm_behavior_record
  264. SET IP = #{IP},
  265. userID = #{userId}
  266. WHERE openId = #{openId} and accessDate = #{accessDate}
  267. </update>
  268. <update id="updateBehaviorByTouristId">
  269. update cm_behavior_record
  270. SET userID = #{userId},
  271. IP = #{IP}
  272. WHERE touristId = #{touristId} and accessDate = #{accessDate}
  273. </update>
  274. <select id="getUserAndBehavior" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  275. SELECT u.userId,
  276. u.registerTime,
  277. cbr.recordID as recordID,
  278. cbr.ip,
  279. cbr.userId,
  280. cbr.accessDate
  281. FROM USER u
  282. LEFT JOIN cm_behavior_record cbr ON u.registerIP = cbr.IP
  283. WHERE cbr.accessdate = #{accessDate}
  284. AND u.registerTime LIKE concat('%',#{accessDate},'%')
  285. AND cbr.userId = 0
  286. </select>
  287. <update id="updateBehaviorTourist">
  288. update cm_behavior_record
  289. set userId = #{userId}
  290. where recordID = #{recordId}
  291. </update>
  292. <select id="selYesterdayList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  293. SELECT
  294. b.IP,
  295. b.userID,
  296. c.clubID,
  297. MAX(b.accessTime) AS lastAccessTime,
  298. (
  299. CASE WHEN u.userIdentity = 2 THEN 2
  300. WHEN u.userIdentity = 4 THEN 2
  301. WHEN u.userIdentity = 3 THEN 3
  302. WHEN b.userID = 0 THEN 1
  303. END)AS companyType,
  304. (
  305. CASE WHEN b.userID = 0 THEN ''
  306. WHEN u.userIdentity = 2 THEN c.name
  307. when u.userIdentity = 3 then s.name
  308. WHEN u.userIdentity = 4 THEN IF(c.name != u.userName,c.name,'')
  309. END)AS corporateName,
  310. (
  311. CASE WHEN b.userID = 0 THEN ''
  312. WHEN u.userIdentity = 2 THEN c.linkMan
  313. WHEN u.userIdentity = 3 THEN s.linkMan
  314. WHEN u.userIdentity = 4 THEN c.linkMan
  315. END)AS contacts,
  316. (CASE WHEN u.userIdentity = 2 THEN c.contractMobile
  317. WHEN u.userIdentity = 4 THEN c.contractMobile
  318. WHEN u.userIdentity = 3 THEN s.contractMobile
  319. END)AS phoneNumber,
  320. (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
  321. COUNT(b.IP) AS number,
  322. (SELECT consultName
  323. FROM cm_roos_information
  324. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
  325. (SELECT consultMobile
  326. FROM cm_roos_information
  327. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
  328. b.behaviorType,
  329. b.productID,
  330. b.accessTime,
  331. SUM(b.accessDuration) AS accessDuration,
  332. b.accessDate,
  333. b.accessClient,
  334. b.region AS region,
  335. u.registerTime AS addTime,
  336. (SELECT touristId FROM cm_behavior_record WHERE accessDate = #{accessDate} and IP = b.IP ORDER BY accessTime DESC LIMIT 1) AS touristId,
  337. b.delFlag
  338. FROM cm_behavior_record b
  339. LEFT JOIN USER u ON b.userID = u.userID
  340. LEFT JOIN club c ON b.userID = c.userID
  341. LEFT JOIN shop s ON b.userID = s.userID
  342. WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
  343. AND b.region NOT LIKE '%美国Microsoft公司%' AND b.region NOT LIKE '%亚马逊(Amazon)公司%'
  344. GROUP BY b.IP, b.accessDate,b.userID ORDER BY b.accessTime DESC
  345. </select>
  346. <select id="insertYesterdayList">
  347. INSERT INTO cm_behavior_record_index (
  348. IP,
  349. userID,
  350. clubID,
  351. lastAccessTime,
  352. companyType,
  353. corporateName,
  354. contacts,
  355. phoneNumber,
  356. spName,
  357. number,
  358. consultName,
  359. consultMobile,
  360. accessTime,
  361. accessDuration,
  362. accessDate,
  363. accessClient,
  364. region,
  365. relevanceShop,
  366. label,
  367. pageLabels,
  368. pageTypes,
  369. addTime,
  370. touristId,
  371. delFlag
  372. ) values (
  373. #{IP},
  374. #{userId},
  375. #{clubId},
  376. #{lastAccessTime},
  377. #{companyType},
  378. #{corporateName},
  379. #{contacts},
  380. #{phoneNumber},
  381. #{spName},
  382. #{number},
  383. #{consultName},
  384. #{consultMobile},
  385. #{accessTime},
  386. #{accessDuration},
  387. #{accessDate},
  388. #{accessClient},
  389. #{region},
  390. #{relevanceShop},
  391. #{label},
  392. #{pageLabels},
  393. #{pageTypes},
  394. #{addTime},
  395. #{touristId},
  396. '0'
  397. )
  398. </select>
  399. <select id="selTodayData" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  400. SELECT
  401. b.IP,
  402. b.userID,
  403. c.clubID,
  404. MAX(b.accessTime) AS lastAccessTime,
  405. (
  406. CASE WHEN u.userIdentity = 2 THEN 2
  407. WHEN u.userIdentity = 4 THEN 2
  408. WHEN u.userIdentity = 3 THEN 3
  409. WHEN b.userID = 0 THEN 1
  410. END)AS companyType,
  411. (
  412. CASE WHEN b.userID = 0 THEN ''
  413. WHEN u.userIdentity = 2 THEN c.name
  414. WHEN u.userIdentity = 3 THEN s.name
  415. WHEN u.userIdentity = 4 THEN c.name -- IF(c.name != u.userName,c.name,'')
  416. END)AS corporateName,
  417. (
  418. CASE WHEN b.userID = 0 THEN ''
  419. WHEN u.userIdentity = 2 THEN c.linkMan
  420. WHEN u.userIdentity = 3 THEN s.linkMan
  421. WHEN u.userIdentity = 4 THEN c.linkMan
  422. END)AS contacts,
  423. (
  424. CASE WHEN u.userIdentity = 2 THEN c.contractMobile
  425. WHEN u.userIdentity = 4 THEN c.contractMobile
  426. WHEN u.userIdentity = 3 THEN s.contractMobile
  427. END)AS phoneNumber,
  428. (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
  429. COUNT(b.IP) AS number,
  430. (SELECT consultName
  431. FROM cm_roos_information
  432. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
  433. (SELECT consultMobile
  434. FROM cm_roos_information
  435. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
  436. b.accessTime,
  437. SUM(b.accessDuration) AS accessDuration,
  438. b.accessDate,
  439. b.accessClient,
  440. b.region AS region,
  441. u.registerTime AS addTime
  442. FROM cm_behavior_record b
  443. LEFT JOIN USER u ON b.userID = u.userID
  444. LEFT JOIN club c ON b.userID = c.userID
  445. LEFT JOIN shop s ON b.userID = s.userID
  446. WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
  447. AND b.region NOT LIKE '%美国Microsoft公司%' AND b.region NOT LIKE '%亚马逊(Amazon)公司%'
  448. GROUP BY b.IP, b.accessDate,b.userID ORDER BY b.accessTime DESC
  449. </select>
  450. <select id="selDataList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  451. SELECT s.name AS relevanceShop, cbs.userID, cbs.IP, cbs.pageLabel
  452. FROM cm_behavior_record cbs
  453. LEFT JOIN cm_behavior_shopid cbr ON cbs.recordID = cbr.recordID
  454. LEFT JOIN shop s ON s.shopID = cbr.shopID
  455. where cbs.accessDate = #{accessDate}
  456. order by cbs.accessTime
  457. </select>
  458. <select id="getBehaviorPageLabel" resultType="java.lang.String">
  459. select pageLabel
  460. from cm_behavior_record
  461. where ip = #{ip} and accessDate = #{accessDate} and userId = #{userId}
  462. </select>
  463. <select id="getBehaviorPageType" resultType="java.lang.Integer">
  464. select pageType
  465. from cm_behavior_record
  466. where ip = #{ip} and accessDate = #{accessDate} and userId = #{userId}
  467. </select>
  468. <insert id="inBehaviorToday">
  469. INSERT INTO cm_behavior_record_today (
  470. id,
  471. IP,
  472. userId,
  473. clubId,
  474. lastAccessTime,
  475. companyType,
  476. corporateName,
  477. contacts,
  478. phoneNumber,
  479. spName,
  480. number,
  481. consultName,
  482. consultMobile,
  483. accessTime,
  484. accessDuration,
  485. accessDate,
  486. accessClient,
  487. region,
  488. relevanceShop,
  489. label,
  490. pageLabels,
  491. pageTypes,
  492. addTime
  493. ) values (
  494. #{recordID},
  495. #{IP},
  496. #{userId},
  497. #{clubId},
  498. #{lastAccessTime},
  499. #{companyType},
  500. #{corporateName},
  501. #{contacts},
  502. #{phoneNumber},
  503. #{spName},
  504. #{number},
  505. #{consultName},
  506. #{consultMobile},
  507. #{accessTime},
  508. #{accessDuration},
  509. #{accessDate},
  510. #{accessClient},
  511. #{region},
  512. #{relevanceShop},
  513. #{label},
  514. #{pageLabels},
  515. #{pageTypes},
  516. #{addTime}
  517. )
  518. </insert>
  519. <delete id="delTodayData">
  520. TRUNCATE TABLE cm_behavior_record_today
  521. </delete>
  522. <select id="shopKeyword" resultType="java.lang.String">
  523. SELECT cusf.keyword FROM cm_shop_relevance csr
  524. LEFT JOIN cm_shop_label csl ON csr.id = csl.relevanceId
  525. LEFT JOIN cm_user_search_frequency cusf ON csl.keywordId = cusf.id
  526. WHERE csr.delFlag = 0 AND
  527. csl.delFlag = 0
  528. </select>
  529. <select id="shopIds" resultType="java.lang.Integer">
  530. SELECT DISTINCT csr.shopID FROM cm_shop_relevance csr
  531. LEFT JOIN cm_shop_label csl ON csr.id = csl.relevanceId
  532. LEFT JOIN cm_user_search_frequency cusf ON csl.keywordId = cusf.id
  533. <where>
  534. csr.delFlag = 0 and
  535. csl.delFlag = 0 and
  536. <if test="strList != null and strList.size > 0">
  537. <foreach collection="strList" item="keyword" open="(" close=")" separator="or">
  538. cusf.keyword = #{keyword}
  539. </foreach>
  540. </if>
  541. </where>
  542. </select>
  543. <select id="selShopId" resultType="java.lang.Integer">
  544. select id from cm_shop_relevance where delFlag = 0 and shopID = #{shopId}
  545. </select>
  546. <insert id="insertShopId">
  547. insert into cm_behavior_shopId (recordID, shopID) values (#{recordId}, #{shopId})
  548. </insert>
  549. <select id="selRegisterIP" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  550. SELECT u.userID as userId, u.registerIP as registerIp, c.clubID as clubId, c.provinceID as provinceId , c.cityID as cityId
  551. FROM USER u
  552. LEFT JOIN club c ON c.userID = u.userID
  553. WHERE u.userIdentity = 4 and c.clubID between #{startId} and #{endId}
  554. </select>
  555. <select id="selProvince" resultType="java.lang.Integer">
  556. SELECT provinceID as provinceId FROM province WHERE NAME LIKE concat('%', #{regionPro} ,'%') limit 1
  557. </select>
  558. <select id="selCity" resultType="com.caimei365.tools.model.po.AddressPo">
  559. SELECT cityID as cityId, provinceID as provinceId FROM city WHERE NAME LIKE concat('%', #{regionCity} ,'%') AND validFlag = 1 limit 1
  560. </select>
  561. <update id="upClubAddress">
  562. update club
  563. <set>
  564. <if test="provinceId != null and provinceId != ''">
  565. provinceID = #{provinceId},
  566. </if>
  567. <if test="cityId != null and cityId != ''">
  568. cityID = #{cityId}
  569. </if>
  570. </set>
  571. where clubID = #{clubId}
  572. </update>
  573. <select id="getShopId" resultType="java.lang.Integer">
  574. select shopId from cm_shop_statistics where delFlag= 0 and status = 0
  575. </select>
  576. <select id="getProductId" resultType="java.lang.Integer">
  577. SELECT productId FROM product WHERE shopId = #{shopId}
  578. </select>
  579. <select id="getShopInfoId" resultType="java.lang.Integer">
  580. select infoId from cm_shop_info where shopId = #{shopId} and delFlag = 0 and status = 0
  581. </select>
  582. <select id="getShopKeywordId" resultType="com.caimei365.tools.model.po.SearchFrequencyVo">
  583. SELECT ifnull(cusf.keyword, '') as keyword, ifnull(csk.searchId, 0) as id
  584. FROM cm_shop_keyword csk
  585. LEFT JOIN cm_user_search_frequency cusf ON cusf.id = csk.searchId
  586. WHERE csk.shopId = #{shopId} AND csk.delFlag = 0 AND csk.status = 0
  587. </select>
  588. <select id="getBehaviorList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  589. SELECT ifnull((select pagePath from cm_behavior_record where pagePath like concat('%',#{pagePath},'%') order by accessDate desc LIMIT 1), '') as pagePath,
  590. count(recordID) as number,
  591. ifnull(sum(accessDuration), 0) as accessDuration
  592. from cm_behavior_record
  593. <where>
  594. delFlag = 0 and accessDate = #{accessDate}
  595. <if test="pageType != null">
  596. and pageType = #{pageType}
  597. </if>
  598. <if test="pageType != 8">
  599. <if test="pagePath != null and pagePath != ''">
  600. and pagePath like concat('%',#{pagePath},'%')
  601. </if>
  602. </if>
  603. <if test="pageType == 8">
  604. and pageLabel like concat('%',#{pagePath},'%')
  605. </if>
  606. </where>
  607. </select>
  608. <insert id="insertPageShop">
  609. INSERT INTO cm_page_shop (shopId, shopLink, accessNumber, accessDuration, accessDate)
  610. VALUES (#{shopId}, #{shopLink}, #{accessNumber}, #{accessDuration}, #{accessDate})
  611. </insert>
  612. <insert id="insertPageProduct">
  613. insert into cm_page_shop_product (shopId, productId, link, accessNumber, accessDuration, accessDate)
  614. values (#{shopId}, #{productId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
  615. </insert>
  616. <insert id="insertPageInfo">
  617. insert into cm_page_shop_info (shopId, infoId, link, accessNumber, accessDuration, accessDate)
  618. values (#{shopId}, #{infoId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
  619. </insert>
  620. <insert id="insertPageKeyword">
  621. insert into cm_page_shop_keyword (shopId, searchId, link, accessNumber, accessDuration, accessDate)
  622. values (#{shopId}, #{searchId}, #{link}, #{accessNumber}, #{accessDuration}, #{accessDate})
  623. </insert>
  624. <select id="getClubId" resultType="java.lang.Integer">
  625. select clubId from club
  626. </select>
  627. <select id="getClubLabel" resultType="com.caimei365.tools.model.po.CmClubLabelPo">
  628. SELECT trendsKeyword, stateKeyword FROM cm_club_remarks
  629. where clubId = #{clubId} AND trendsKeyword IS NOT NULL AND stateKeyword IS NOT NULL
  630. <if test="startTime != null and startTime != ''">
  631. and addTime > #{startTime}
  632. </if>
  633. <if test="endTime != null and endTime != ''">
  634. and addTime <![CDATA[ <= ]]> #{endTime}
  635. </if>
  636. UNION
  637. SELECT trendsKeyword, stateKeyword FROM cm_visitor_remarks
  638. where clubId = #{clubId} AND trendsKeyword IS NOT NULL AND stateKeyword IS NOT NULL
  639. <if test="startTime != null and startTime != ''">
  640. and addTime > #{startTime}
  641. </if>
  642. <if test="endTime != null and endTime != ''">
  643. and addTime <![CDATA[ <= ]]> #{endTime}
  644. </if>
  645. </select>
  646. <select id="getClubBehavior" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  647. SELECT cbr.pageLabel, cbr.pageType , COUNT(cbr.pageLabel) number
  648. FROM cm_behavior_record cbr
  649. LEFT JOIN club c ON c.userID = cbr.userId
  650. where cbr.pageType IN (6, 8, 9, 11, 14)
  651. AND c.clubId = #{clubId}
  652. <if test="startTime != null and startTime != ''">
  653. and cbr.accessDate > #{startTime}
  654. </if>
  655. <if test="endTime != null and endTime != ''">
  656. and cbr.accessDate <![CDATA[ <= ]]> #{endTime}
  657. </if>
  658. GROUP BY cbr.pageLabel ORDER BY COUNT(cbr.pageLabel) DESC
  659. </select>
  660. <select id="getTrendsKeyword" resultType="java.lang.String">
  661. SELECT keyword FROM cm_keyword_info WHERE dynamicStatus = 0
  662. </select>
  663. <select id="getStateKeyword" resultType="java.lang.String">
  664. SELECT keyword FROM cm_keyword_info WHERE dynamicStatus = 1
  665. </select>
  666. <select id="getClubTrendsKeyword" resultType="com.caimei365.tools.model.po.CmClubLabelPo">
  667. SELECT id, clubId, label, appearNumber FROM cm_club_label WHERE dynamicStatus = 0
  668. </select>
  669. <select id="getClubStateKeyword" resultType="com.caimei365.tools.model.po.CmClubLabelPo">
  670. SELECT id, clubId, label, appearNumber FROM cm_club_label WHERE dynamicStatus = 1
  671. </select>
  672. <insert id="insertClubLabel" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
  673. INSERT INTO cm_club_label (clubId, label, pageType, dynamicStatus, appearNumber, addTime, delFlag)
  674. values(#{clubId}, #{label}, #{pageType}, #{dynamicStatus}, #{appearNumber}, now(), 0)
  675. </insert>
  676. <update id="updateClubLabel">
  677. update cm_club_label
  678. set appearNumber = #{appearNumber}
  679. where id = #{id}
  680. </update>
  681. </mapper>