CmBehaciorRecordDao.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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.manager.dao.user.CmBehaviorRecordDao">
  4. <sql id="behaviorRecord">
  5. b.recordID,
  6. b.IP as ip,
  7. b.userID as userId,
  8. b.pagePath,
  9. b.pageType,
  10. b.pageLabel,
  11. b.productID as productId,
  12. b.accessTime,
  13. b.accessDate
  14. </sql>
  15. <select id="getkeyword" resultType="com.caimei365.manager.entity.caimei.RetuenEntity">
  16. select
  17. id,
  18. keyword as value
  19. from cm_keyword_info
  20. where parentLabel = 1
  21. and delFlag = 1
  22. <if test="keyword != null and keyword != ''">
  23. and keyword like concat('%',#{keyword},'%')
  24. </if>
  25. </select>
  26. <select id="getPageType" resultType="com.caimei365.manager.entity.caimei.CmPageType">
  27. select
  28. id,
  29. pageType
  30. from cm_page_type
  31. <where>
  32. <if test="pageLabels != null and pageLabels != ''">
  33. pageType like concat('%',#{pageLabels},'%')
  34. </if>
  35. </where>
  36. </select>
  37. <select id="findList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
  38. SELECT
  39. IP as ip,
  40. userID as userId,
  41. clubID as clubId,
  42. lastAccessTime,
  43. companyType,
  44. corporateName,
  45. contacts,
  46. phoneNumber,
  47. spName,
  48. number as numbers,
  49. consultName,
  50. consultMobile,
  51. productID,
  52. accessTime,
  53. accessDuration,
  54. accessDate,
  55. accessClient,
  56. region,
  57. label,
  58. relevanceShop,
  59. addTime
  60. FROM cm_behavior_record_index
  61. <where>
  62. delFlag = 0
  63. <if test="clubId != null">
  64. AND clubId = #{clubId}
  65. </if>
  66. <if test="ip != null and ip != ''">
  67. AND IP = #{ip}
  68. </if>
  69. <if test="corporateName != null and corporateName != ''">
  70. AND (corporateName like concat('%',#{corporateName},'%') or contacts like concat('%',#{corporateName},'%'))
  71. </if>
  72. <if test="companyType != null and companyType != ''">
  73. AND companyType = #{companyType}
  74. </if>
  75. <if test="accessClient != null and accessClient != ''">
  76. AND accessClient =#{accessClient}
  77. </if>
  78. <if test="contacts != null and contacts != ''">
  79. AND (corporateName like concat('%',#{contacts},'%') or contacts like concat('%',#{contacts},'%'))
  80. </if>
  81. <if test="phoneNumber != null and phoneNumber != ''">
  82. AND phoneNumber = #{phoneNumber}
  83. </if>
  84. <if test="spName != null and spName != ''">
  85. AND spName = #{spName}
  86. </if>
  87. <if test="relevanceShop != null and relevanceShop != ''">
  88. AND (relevanceShop like concat('%',#{relevanceShop},'%')
  89. <if test="behaviorType == 2">
  90. or behaviorType = #{behaviorType}
  91. </if>
  92. )
  93. </if>
  94. <if test="labels != null and labels.size > 0">
  95. AND
  96. <foreach collection="labels" open="(" close=")" separator="or" item="label">
  97. label like concat('%',#{label},'%')
  98. </foreach>
  99. </if>
  100. <if test="pageLabels != null and pageLabels != ''">
  101. AND pageLabels like concat('%', #{pageLabels}, '%')
  102. </if>
  103. <if test="pageTypes != null and pageTypes != ''">
  104. AND pageTypes like concat('%', #{pageTypes}, '%')
  105. </if>
  106. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  107. AND accessDate between #{startTime} and #{endTime}
  108. </if>
  109. </where>
  110. ORDER BY accessTime DESC
  111. <if test="exportType == 1">
  112. limit 5000
  113. </if>
  114. </select>
  115. <select id="findListToday" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
  116. SELECT
  117. IP as ip,
  118. userID as userId,
  119. clubID as clubId,
  120. lastAccessTime,
  121. companyType,
  122. corporateName,
  123. contacts,
  124. phoneNumber,
  125. spName,
  126. number as numbers,
  127. consultName,
  128. consultMobile,
  129. accessTime,
  130. accessDuration,
  131. accessDate,
  132. accessClient,
  133. region,
  134. label,
  135. relevanceShop,
  136. addTime
  137. FROM cm_behavior_record_today
  138. <where>
  139. <if test="cluId != null">
  140. AND clubId = #{clubId}
  141. </if>
  142. <if test="ip != null and ip != ''">
  143. AND IP = #{ip}
  144. </if>
  145. <if test="corporateName != null and corporateName != ''">
  146. AND (corporateName like concat('%',#{corporateName},'%') or contacts like concat('%',#{corporateName},'%'))
  147. </if>
  148. <if test="companyType != null and companyType != ''">
  149. AND companyType = #{companyType}
  150. </if>
  151. <if test="accessClient != null and accessClient != ''">
  152. AND accessClient =#{accessClient}
  153. </if>
  154. <if test="contacts != null and contacts != ''">
  155. AND (corporateName like concat('%',#{contacts},'%') or contacts like concat('%',#{contacts},'%'))
  156. </if>
  157. <if test="phoneNumber != null and phoneNumber != ''">
  158. AND phoneNumber = #{phoneNumber}
  159. </if>
  160. <if test="spName != null and spName != ''">
  161. AND spName = #{spName}
  162. </if>
  163. <if test="relevanceShop != null and relevanceShop != ''">
  164. AND relevanceShop like concat('%',#{relevanceShop},'%')
  165. </if>
  166. <if test="labels != null and labels.size > 0">
  167. AND
  168. <foreach collection="labels" open="(" close=")" separator="or" item="label">
  169. label like concat('%',#{label},'%')
  170. </foreach>
  171. </if>
  172. <if test="pageLabels != null and pageLabels != ''">
  173. AND pageLabels like concat('%', #{pageLabels}, '%')
  174. </if>
  175. <if test="pageTypes != null and pageTypes != ''">
  176. AND pageTypes like concat('%', #{pageTypes}, '%')
  177. </if>
  178. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  179. AND accessDate between #{startTime} and #{endTime}
  180. </if>
  181. </where>
  182. ORDER BY accessTime DESC
  183. </select>
  184. <select id="selRegion" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
  185. SELECT * FROM cm_behavior_record_ref where accessTime like concat('%',#{accessDate},'%')
  186. </select>
  187. <select id="recordList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
  188. SELECT
  189. <include refid="behaviorRecord"/>
  190. ,b.accessDuration,
  191. b.accessSource,
  192. b.accessClient,
  193. u.userIdentity,
  194. c.name,
  195. c.clubId,
  196. c.linkMan,
  197. c.contractMobile,
  198. s.name AS sname,
  199. s.linkMan AS slinkMan,
  200. s.contractMobile AS sncontractMobile,
  201. p.name AS productName,
  202. p.mainImage AS productImage,
  203. pt.pagetype AS pageTypes
  204. FROM cm_behavior_record b
  205. LEFT JOIN USER u ON b.userID = u.userID
  206. LEFT JOIN club c ON b.userID = c.userID
  207. LEFT JOIN shop s ON b.userID = s.userID
  208. LEFT JOIN product p ON b.productID = p.productID
  209. LEFT JOIN cm_page_type pt ON b.pageType = pt.id
  210. <where>
  211. b.accessDate = #{accessDate} AND b.IP != '106.55.202.118' AND b.delFlag = 0
  212. <if test="userId != null">
  213. AND b.userID = #{userId} AND b.IP = #{ip}
  214. </if>
  215. </where>
  216. ORDER BY accessTime DESC
  217. </select>
  218. <select id="searchList" resultType="com.caimei365.manager.entity.caimei.RetuenEntity">
  219. SELECT cusf.id , cusf.keyword AS VALUE
  220. FROM cm_user_search_frequency cusf
  221. LEFT JOIN cm_shop_label csl ON csl.keywordId = cusf.id
  222. LEFT JOIN cm_shop_relevance csr ON csr.id = csl.relevanceId
  223. WHERE cusf.trueStatus = 1
  224. AND csl.delFlag = 0
  225. AND csr.delFlag = 0
  226. </select>
  227. <select id="behaviorShopNameList" resultType="com.caimei365.manager.entity.caimei.CmBehaviorRecord">
  228. SELECT cbs.recordID, cbs.shopID, s.name FROM cm_behavior_shopId cbs LEFT JOIN shop s ON cbs.shopID = s.shopID
  229. </select>
  230. </mapper>