CmBehaviorRecordMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. <insert id="insertRecord">
  5. INSERT INTO cm_behavior_record (IP, userID, pagePath, pageType, pageLabel, behaviorType, productID, accessTime, accessDuration, accessDate,referer,accessSource,accessClient,isReckon,region,userAgent,delFlag)
  6. VALUES(#{IP},#{userId},#{pagePath},#{pageType},#{pageLabel},#{behaviorType},#{productId},#{accessTime},#{accessDuration},#{accessDate},#{referer},#{accessSource},#{accessClient},#{isReckon},#{region},#{userAgent},#{delFlag})
  7. </insert>
  8. <select id="toDateRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  9. SELECT IP, userID FROM cm_behavior_record WHERE accessDate = #{accessDate} GROUP BY IP, userID
  10. </select>
  11. <select id="toDateIPTimeRecode" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  12. SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND userID = #{userId} AND isReckon = 0
  13. AND accessTime BETWEEN #{startTime} and #{endTime}
  14. union
  15. SELECT recordID, IP, userID, accessTime FROM cm_behavior_record WHERE IP = #{IP} AND isReckon = 0 AND accessDate = #{accessDate} AND userID = #{userId}
  16. ORDER BY accessTime ASC
  17. </select>
  18. <update id="updateDuration">
  19. UPDATE cm_behavior_record
  20. SET accessDuration = #{accessDuration},
  21. isReckon = #{isReckon}
  22. WHERE recordID = #{recordID}
  23. </update>
  24. <select id="findList" resultType="com.caimei365.tools.model.po.CmUserPo">
  25. SELECT userID, registerIP FROM USER where userID between #{startId} and #{endId}
  26. </select>
  27. <update id="updateOldData">
  28. UPDATE USER
  29. SET ipAddress = #{ipAddress}
  30. WHERE userID = #{userID}
  31. </update>
  32. <select id="selSvipCoupon" resultType="com.caimei365.tools.model.po.CmVipCouponPo">
  33. SELECT id,
  34. useTime,
  35. updateTime,
  36. status,
  37. delFlag
  38. FROM cm_svip_coupon_month WHERE delFlag != 0 AND useTime BETWEEN #{startTime} AND #{endTime}
  39. </select>
  40. <update id="updateSvipCoupon">
  41. UPDATE cm_svip_coupon_month
  42. SET delFlag = 0
  43. WHERE id = #{id}
  44. </update>
  45. <insert id="insertVipCouponMonth">
  46. INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
  47. VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
  48. </insert>
  49. <select id="selCoupon" resultType="com.caimei365.tools.model.po.CmCouponPo">
  50. SELECT
  51. id,
  52. name,
  53. couponAmount,
  54. touchPrice,
  55. startDate,
  56. endDate,
  57. receivePeriod,
  58. useTimeFlag,
  59. receiveFlag,
  60. usePeriod,
  61. status,
  62. couponType,
  63. vipFlag,
  64. userId,
  65. shopId,
  66. productType,
  67. pcBanner,
  68. appletsBanner,
  69. categoryType,
  70. couponsMode,
  71. moneyCouponPrice,
  72. moneyCouponFlag,
  73. couponPayWay,
  74. moneyCouponType,
  75. createDate,
  76. delFlag
  77. FROM cm_coupon WHERE configure = 1
  78. </select>
  79. <update id="updateCoupon">
  80. UPDATE cm_coupon
  81. SET configure = #{configure}
  82. WHERE id = #{id}
  83. </update>
  84. <insert id="insertCoupon">
  85. INSERT INTO cm_coupon(
  86. name,
  87. couponPayWay,
  88. couponAmount,
  89. touchPrice,
  90. startDate,
  91. endDate,
  92. receivePeriod,
  93. receiveFlag,
  94. useTimeFlag,
  95. usePeriod,
  96. status,
  97. couponType,
  98. vipFlag,
  99. userId,
  100. shopId,
  101. productType,
  102. pcBanner,
  103. appletsBanner,
  104. categoryType,
  105. couponsMode,
  106. createDate,
  107. moneyCouponPrice,
  108. moneyCouponFlag,
  109. moneyCouponType,
  110. delFlag,
  111. configure
  112. ) VALUES (
  113. #{name},
  114. #{couponPayWay},
  115. #{couponAmount},
  116. #{touchPrice},
  117. #{startDate},
  118. #{endDate},
  119. #{receivePeriod},
  120. #{receiveFlag},
  121. #{useTimeFlag},
  122. #{usePeriod},
  123. #{status},
  124. #{couponType},
  125. #{vipFlag},
  126. #{userId},
  127. #{shopId},
  128. #{productType},
  129. #{pcBanner},
  130. #{appletsBanner},
  131. #{categoryType},
  132. #{couponsMode},
  133. #{createDate},
  134. #{moneyCouponPrice},
  135. #{moneyCouponFlag},
  136. #{moneyCouponType},
  137. #{delFlag},
  138. #{configure}
  139. )
  140. </insert>
  141. <select id="selById" resultType="integer">
  142. select max(id) as id from cm_coupon
  143. </select>
  144. <select id="selCouponPro" resultType="com.caimei365.tools.model.po.CmCouponAssociatePo">
  145. select * from cm_coupon_product where couponId = #{couponId}
  146. </select>
  147. <insert id="insertCouponAssociate">
  148. INSERT INTO `cm_coupon_product` (
  149. `couponId`, `productId`, `pcStatus`,
  150. `appletsStatus`,
  151. `sort`, `addTime`, `delFlag`
  152. )
  153. VALUES
  154. (
  155. #{couponId}, #{productId}, #{pcStatus},
  156. #{appletsStatus},
  157. #{sort}, #{addTime}, #{delFlag}
  158. )
  159. </insert>
  160. <select id="selSvipCouponById" resultType="integer">
  161. SELECT max(id) as id FROM cm_svip_coupon_month
  162. </select>
  163. <insert id="insertRelation">
  164. INSERT INTO cm_svip_coupon(couponId, montId, updateTime,delFlag)
  165. VALUES(#{couponId}, #{montId}, #{updateTime},#{delFlag})
  166. </insert>
  167. <select id="countNum" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  168. SELECT IP as IP, COUNT(DISTINCT userID) as count FROM cm_behavior_record
  169. where accessDate = #{accessDate}
  170. GROUP BY IP, accessDate ORDER BY accessDate DESC
  171. </select>
  172. <select id="userIdAcc" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  173. 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
  174. </select>
  175. <select id="selBehaviorList" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
  176. SELECT recordID as recordID, IP as IP, userID as userId FROM cm_behavior_record WHERE IP = #{IP} AND userID = 0 AND accessDate = #{accessDate}
  177. </select>
  178. <update id="updateBehavior">
  179. UPDATE cm_behavior_record
  180. SET IP = #{IP},
  181. userID = #{userId}
  182. WHERE recordID = #{recordID}
  183. </update>
  184. <select id="selYesterdayList">
  185. INSERT INTO cm_behavior_record_index (IP, userID, clubID, lastAccessTime, companyType, corporateName,
  186. contacts, phoneNumber, spName, number, consultName, consultMobile, behaviorType, productID, accessTime, accessDuration, accessDate, accessClient, region, delFlag)
  187. SELECT
  188. b.IP,
  189. b.userID,
  190. c.clubID,
  191. MAX(b.accessTime) AS lastAccessTime,
  192. (
  193. CASE WHEN u.userIdentity = 2 THEN 2
  194. WHEN u.userIdentity = 4 THEN 2
  195. WHEN u.userIdentity = 3 THEN 3
  196. WHEN b.userID = 0 THEN 1
  197. END)AS companyType,
  198. (
  199. CASE WHEN b.userID = 0 THEN ''
  200. WHEN u.userIdentity = 2 THEN c.name
  201. when u.userIdentity = 3 then s.name
  202. WHEN u.userIdentity = 4 THEN IF(c.name != u.userName,c.name,'')
  203. END)AS corporateName,
  204. (
  205. CASE WHEN b.userID = 0 THEN ''
  206. WHEN b.userID != 0 THEN u.userName
  207. END)AS contacts,
  208. (CASE WHEN u.userIdentity = 2 THEN c.contractMobile
  209. WHEN u.userIdentity = 4 THEN c.contractMobile
  210. WHEN u.userIdentity = 3 THEN s.contractMobile
  211. END)AS phoneNumber,
  212. (SELECT CASE STATUS WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE linkMan END FROM serviceprovider WHERE serviceProviderID = c.spID) AS spName,
  213. COUNT(b.IP) AS numbers,
  214. (SELECT consultName
  215. FROM cm_roos_information
  216. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultName,
  217. (SELECT consultMobile
  218. FROM cm_roos_information
  219. WHERE IP = b.IP AND createTime LIKE CONCAT('%',b.accessDate,'%') AND (consultName IS NOT NULL OR consultName = '') LIMIT 1) AS consultMobile,
  220. b.behaviorType,
  221. b.productID,
  222. b.accessTime,
  223. SUM(b.accessDuration) AS accessDuration,
  224. b.accessDate,
  225. b.accessClient,
  226. b.region AS region,
  227. b.delFlag
  228. FROM cm_behavior_record b
  229. LEFT JOIN USER u ON b.userID = u.userID
  230. LEFT JOIN club c ON b.userID = c.userID
  231. LEFT JOIN shop s ON b.userID = s.userID
  232. WHERE b.IP != '106.55.202.118' AND b.delFlag = 0 AND b.accessDate = #{accessDate}
  233. GROUP BY b.IP, b.accessDate,b.userID, b.behaviorType ORDER BY b.accessTime DESC
  234. </select>
  235. </mapper>