SellerMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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.user.mapper.SellerMapper">
  4. <select id="getLoginSellerByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
  5. select u.userID as userId,
  6. u.clubID as clubId,
  7. u.shopID as shopId,
  8. u.userName as userName,
  9. u.name as name,
  10. u.mobile as mobile,
  11. u.bindMobile as bindMobile,
  12. u.email as email,
  13. u.guideFlag as guideFlag,
  14. u.userIdentity as userIdentity,
  15. u.serviceProviderID as serviceProviderId,
  16. u.serviceProviderStatus as serviceStatus,
  17. u.password as password
  18. from user u
  19. where u.mobile = #{mobile}
  20. and u.userIdentity = 1
  21. </select>
  22. <update id="updateServiceProviderByUserId">
  23. update serviceprovider
  24. set openid = #{openId},
  25. unionId = #{unionId}
  26. where userID = #{userId}
  27. </update>
  28. <update id="setSellerHome" parameterType="com.caimei365.user.model.po.ServiceProviderPo">
  29. update serviceprovider
  30. <trim prefix="SET" suffixOverrides=",">
  31. <if test="qrCode != null and qrCode != ''">qrCode = #{qrCode},</if>
  32. </trim>
  33. where userID = #{userId}
  34. </update>
  35. <update id="setSellerUserHome" >
  36. update user
  37. <trim prefix="SET" suffixOverrides=",">
  38. <if test="image != null and image != ''">image = #{image},</if>
  39. </trim>
  40. where userId = #{userId}
  41. </update>
  42. <select id="findClubTemporary" resultType="com.caimei365.user.model.vo.ClubTemporaryVo">
  43. SELECT
  44. `id`,
  45. `userId`,
  46. `name`,
  47. `shortName`,
  48. `bindMobile`,
  49. `contractEmail`,
  50. `linkMan`,
  51. `provinceId`,
  52. `cityId`,
  53. `townId`,
  54. `address`,
  55. `shopPhoto`,
  56. `businessLicense`,
  57. `socialCreditCode`,
  58. `firstClubType`,
  59. `secondClubType`,
  60. `department`,
  61. `medicalPracticeLicense`,
  62. `mainProduct`,
  63. `isAgreed`
  64. FROM
  65. club_temporary
  66. WHERE
  67. userId = #{userId}
  68. <if test="searchName != null and searchName != ''">
  69. AND (name LIKE CONCAT('%',#{searchName},'%') OR linkMan LIKE CONCAT('%',#{searchName},'%'))
  70. </if>
  71. ORDER BY
  72. id DESC
  73. </select>
  74. <update id="updateClubTemporary">
  75. UPDATE
  76. `club_temporary`
  77. SET `name` = #{name},
  78. `shortName` = #{shortName},
  79. `bindMobile` = #{bindMobile},
  80. `contractEmail` = #{contractEmail},
  81. `linkMan` = #{linkMan},
  82. `provinceId` = #{provinceId},
  83. `cityId` = #{cityId},
  84. `townId` = #{townId},
  85. `address` = #{address},
  86. `shopPhoto` = #{shopPhoto},
  87. `businessLicense` = #{businessLicense},
  88. `socialCreditCode` = #{socialCreditCode},
  89. `firstClubType` = #{firstClubType},
  90. `secondClubType` = #{secondClubType},
  91. `department` = #{department},
  92. `medicalPracticeLicense` = #{medicalPracticeLicense},
  93. `mainProduct` = #{mainProduct},
  94. `isAgreed` = #{isAgreed}
  95. WHERE `id` = #{id}
  96. </update>
  97. <delete id="deleteTemporaryClub">
  98. DELETE
  99. FROM `club_temporary`
  100. WHERE `id` = #{id}
  101. </delete>
  102. <select id="findOrderNum" resultType="integer">
  103. SELECT
  104. COUNT(*)
  105. FROM
  106. cm_order
  107. WHERE
  108. userID = #{userId}
  109. AND orderSubmitType IN (0, 1, 2)
  110. <if test="lastCheckOrderDate != null">
  111. AND orderTime > #{lastCheckOrderDate}
  112. </if>
  113. </select>
  114. <select id="findClubs" resultType="com.caimei365.user.model.vo.ClubVo">
  115. select c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
  116. c.contractEmail as contractEmail,
  117. c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
  118. c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
  119. c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
  120. c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
  121. c.lastCheckOrderDate,
  122. u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
  123. sp.name AS serviceName,
  124. coas.activeState AS activeState,
  125. covs.customerValue AS customerValue,
  126. cpr.createTime AS providerTime
  127. from club c
  128. left join user u on c.userID = u.userID
  129. LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
  130. LEFT JOIN (SELECT userId, activeStatus, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) coas ON coas.userId = c.userId
  131. LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON covs.userID = c.userID
  132. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
  133. LEFT JOIN cm_provider_record cpr ON cpr.spID = sp.serviceProviderID and cpr.clubId = c.clubId
  134. LEFT JOIN (SELECT DISTINCT clubID, checkTime FROM clubchangesprecord WHERE checkStatus = 1 GROUP BY clubID ORDER BY clubChangeSpRecordID DESC )ccs ON ccs.clubId = c.clubId
  135. where
  136. <if test="1 == type">
  137. c.spID = #{serviceProviderId}
  138. </if>
  139. <if test="2 == type">
  140. c.spID in
  141. <foreach collection="serviceIds" item="id" index="index" open="(" separator="," close=")">
  142. #{id}
  143. </foreach>
  144. </if>
  145. <if test="3 == type">
  146. r.clubId IS NOT NULL
  147. AND c.spId=1342
  148. </if>
  149. <if test="4 == type">
  150. c.spID = #{serviceProviderId}
  151. and coas.activeStatus = 0
  152. </if>
  153. <if test="5 == type">
  154. c.spID = #{serviceProviderId}
  155. and coas.activeStatus = 1
  156. </if>
  157. <if test="6 == type">
  158. c.spID = #{serviceProviderId}
  159. AND c.newDeal =1
  160. </if>
  161. <if test="name != null and name != ''">
  162. AND (c.name LIKE CONCAT('%',#{name},'%') OR c.linkMan LIKE CONCAT('%',#{name},'%') OR c.contractMobile LIKE CONCAT('%',#{name},'%'))
  163. </if>
  164. <if test="userIdentity != null">
  165. AND u.userIdentity = #{userIdentity}
  166. </if>
  167. <if test="startTime != null and startTime != ''">
  168. AND (ccs.checkTime <![CDATA[ >= ]]> #{startTime}
  169. OR cpr.createTime <![CDATA[ >= ]]> #{startTime})
  170. </if>
  171. <if test="endTime != null and endTime != ''">
  172. AND (ccs.checkTime <![CDATA[ <= ]]> #{endTime}
  173. OR cpr.createTime <![CDATA[ <= ]]> #{endTime})
  174. </if>
  175. <if test="activeState != null and activeState != ''">
  176. AND coas.activeState like concat('%', #{userIdentity}, '%')
  177. </if>
  178. <if test="customerValue != null and customerValue != ''">
  179. AND covs.customerValue like concat('%', #{customerValue}, '%')
  180. </if>
  181. <if test="status != null">
  182. <if test="90 == status and 4 == type and 5 == type">
  183. and c.status = 90 and u.userIdentity = 4
  184. </if>
  185. <if test="1 == status and 4 == type and 5 == type">
  186. and c.status = 1 and u.userIdentity = 4
  187. </if>
  188. <if test="92 == status and 4 == type and 5 == type">
  189. and c.status = 92 and u.userIdentity = 4
  190. </if>
  191. <if test="4 != type and 5 != type and 66 != status">
  192. AND c.status = #{status}
  193. </if>
  194. <if test="4 != type and 5 != type and 66 == status">
  195. AND c.status IN (1,90,92,93)
  196. </if>
  197. </if>
  198. group by c.clubID
  199. order by cpr.createTime desc
  200. </select>
  201. <select id="getIsRemarkClub" resultType="com.caimei365.user.model.vo.ClubVo">
  202. SELECT
  203. c.clubId,
  204. c.userId,
  205. c.name,
  206. c.sname AS shortName,
  207. c.contractMobile,
  208. u.userIdentity,
  209. sp.linkMan AS serviceName,
  210. coas.activeState AS activeState,
  211. covs.customerValue AS customerValue,
  212. b.num,
  213. (
  214. SELECT ADDTIME FROM
  215. (
  216. SELECT
  217. ADDTIME
  218. FROM cm_club_remarks
  219. WHERE clubId = c.clubId
  220. UNION
  221. SELECT
  222. ADDTIME
  223. FROM cm_visitor_remarks
  224. WHERE
  225. clubId IS NOT NULL AND clubId != ''
  226. AND clubId = c.clubId
  227. ) b ORDER BY ADDTIME DESC LIMIT 1
  228. ) AS ADDTIME
  229. FROM club c
  230. LEFT JOIN USER u ON c.userID = u.userID
  231. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
  232. LEFT JOIN (SELECT userId, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) coas ON coas.userId = c.userId
  233. LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON covs.userID = c.userID
  234. LEFT JOIN (SELECT clubId, COUNT(id) AS num FROM cm_club_remarks GROUP BY clubId
  235. UNION
  236. SELECT clubId, COUNT(id) AS num FROM cm_visitor_remarks WHERE clubId IS NOT NULL AND clubId != '' GROUP BY clubId ) AS b ON c.clubId = b.clubId
  237. where c.spId = #{spId}
  238. <if test="type != null">
  239. <if test="type == 1">
  240. and b.num > 0
  241. </if>
  242. <if test="type == 2">
  243. and b.num IS NULL OR b.num = 0
  244. </if>
  245. </if>
  246. </select>
  247. <select id="getClubAllRemark" resultType="com.caimei365.user.model.vo.RemarksVo">
  248. select * from
  249. (
  250. SELECT DISTINCT ccr.id AS remarksId,
  251. ccr.remarks,
  252. ccr.addTime,
  253. ccr.questionMan,
  254. ccr.serviceProviderId AS serviceProviderId,
  255. ccr.createServiceProviderId AS createServiceProviderId,
  256. csr.leaderId AS leaderId,
  257. IFNULL(ccr.consultType,'') AS consult,
  258. c.Name AS clubName,
  259. ccr.clubType AS clubType,
  260. ccr.pinceSensitve AS pinceSensitve,
  261. ccr.satisfied AS satisfied,
  262. ccr.followup AS followup,
  263. ccr.extra AS extra,
  264. ccr.communicationSituation,
  265. ccr.communicationMethods,
  266. ccr.customerSource,
  267. ccr.customerGender,
  268. ccr.groupAddition,
  269. ccr.customerAge,
  270. ifnull(ccr.trendsKeyword, "") as trendsKeyword,
  271. ifnull(ccr.stateKeyword, "") as stateKeyword,
  272. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  273. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.createServiceProviderId) AS recordName,
  274. cmc.status AS STATUS
  275. FROM cm_club_remarks ccr
  276. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  277. LEFT JOIN club c ON c.clubId=ccr.clubId
  278. LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
  279. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  280. LEFT JOIN cm_club_report cmc ON cmc.clubId = ccr.clubId
  281. <where>
  282. ccr.clubId = #{clubId}
  283. <if test="search != null and search != ''">
  284. and (
  285. ccr.remarks like concat('%',#{search},'%')
  286. or ccr.questionMan like concat('%',#{search},'%')
  287. or c.name like concat('%',#{search},'%')
  288. or c.contractMobile like concat('%',#{search},'%')
  289. )
  290. </if>
  291. </where>
  292. UNION
  293. SELECT DISTINCT ccr.id AS remarksId,
  294. ccr.remarks,
  295. ccr.addTime AS ADDDATE,
  296. ccr.questionMan,
  297. ccr.serviceProviderId,
  298. ccr.createServiceProviderId AS createServiceProviderId,
  299. csr.leaderId AS leaderId,
  300. IFNULL(ccr.consultType,'') AS consult,
  301. c.Name AS clubName,
  302. ccr.clubType AS clubType,
  303. ccr.pinceSensitve AS pinceSensitve,
  304. ccr.satisfied AS satisfied,
  305. ccr.followup AS followup,
  306. ccr.extra AS extra,
  307. ccr.communicationSituation,
  308. ccr.communicationMethods,
  309. ccr.customerSource,
  310. ccr.customerGender,
  311. ccr.groupAddition,
  312. ccr.customerAge,
  313. ifnull(ccr.trendsKeyword, "") as trendsKeyword,
  314. ifnull(ccr.stateKeyword, "") as stateKeyword,
  315. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName,
  316. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderId) AS recordName,
  317. cmc.status AS STATUS
  318. FROM cm_visitor_remarks ccr
  319. LEFT JOIN club c ON c.clubId=ccr.clubId
  320. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  321. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  322. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  323. LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
  324. <where>
  325. ccr.remarks IS NOT NULL
  326. AND ccr.clubId is NOT null AND ccr.clubId != '' AND ccr.clubId = #{clubId}
  327. <if test="search != null and search != ''">
  328. and (
  329. ccr.remarks like concat('%',#{search},'%')
  330. or ccr.questionMan like concat('%',#{search},'%')
  331. or c.name like concat('%',#{search},'%')
  332. or c.contractMobile like concat('%',#{search},'%')
  333. )
  334. </if>
  335. </where>
  336. ) b
  337. ORDER BY b.addTime DESC
  338. </select>
  339. <select id="findSpUserLoginSum" resultType="java.util.HashMap">
  340. SELECT
  341. (CASE coas.activeStatus
  342. WHEN 0 THEN 'active'
  343. WHEN 1 THEN 'unActive'
  344. END) AS activeStatus,
  345. COUNT(coas.activeStatus) AS number
  346. FROM cm_organ_active_system coas
  347. LEFT JOIN club c ON coas.userId = c.userId
  348. LEFT JOIN serviceprovider s ON s.serviceProviderId = c.spId
  349. WHERE s.serviceProviderId = #{spId} AND coas.stage = 0 AND delType = 1
  350. GROUP BY coas.activeStatus
  351. </select>
  352. <select id="getRemarkClub" resultType="java.util.Map">
  353. SELECT
  354. COUNT(clubId) AS isHaveClub,
  355. (SELECT COUNT(clubId) FROM club c LEFT JOIN serviceprovider s ON s.serviceProviderId = c.spId WHERE s.serviceProviderId = #{spId})AS allclub
  356. FROM
  357. (
  358. SELECT
  359. clubid AS clubID
  360. FROM cm_club_remarks
  361. WHERE createServiceProviderId = #{spId}
  362. GROUP BY clubId
  363. UNION
  364. SELECT
  365. clubId AS clubID
  366. FROM cm_visitor_remarks
  367. WHERE
  368. clubId IS NOT NULL AND clubId != ''
  369. AND createServiceProviderId = #{spId}
  370. GROUP BY clubId
  371. ) b
  372. </select>
  373. <select id="getAllClubList" resultType="com.caimei365.user.model.vo.ClubVo">
  374. SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
  375. c.contractEmail as contractEmail,
  376. c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
  377. c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
  378. c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
  379. c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
  380. c.lastCheckOrderDate,
  381. u.userIdentity
  382. FROM club c
  383. LEFT JOIN user u ON c.userID=u.userID
  384. WHERE u.userOrganizeID = 0 AND c.status = '90'
  385. <if test="searchWord != null and searchWord != ''">
  386. and (
  387. c.name LIKE CONCAT('%',#{searchWord},'%') or
  388. c.linkMan LIKE CONCAT('%',#{searchWord},'%') or
  389. c.contractMobile LIKE CONCAT('%',#{searchWord},'%')
  390. )
  391. </if>
  392. </select>
  393. <select id="getSellerByUserId" resultType="com.caimei365.user.model.po.ServiceProviderPo">
  394. select s.serviceProviderID AS serviceProviderId,
  395. s.status,
  396. s.userID AS userId,
  397. s.openid,
  398. s.unionId,
  399. s.name,
  400. s.contractMobile,
  401. s.linkMan,
  402. s.duty,
  403. s.contractEmail,
  404. s.addTime,
  405. s.qrCode,
  406. u.image
  407. from serviceprovider s
  408. LEFT JOIN USER u ON s.userId = u.userId
  409. where s.userID = #{userId}
  410. </select>
  411. <select id="findManager" resultType="java.lang.Integer">
  412. SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
  413. FROM cm_serviceteam_manager csm
  414. LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
  415. LEFT JOIN USER u ON s.userId = u.userId
  416. WHERE u.bindmobile = #{mobile}
  417. OR u.mobile = #{mobile}
  418. </select>
  419. <select id="findManagerByUser" resultType="java.lang.Integer">
  420. SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
  421. FROM cm_serviceteam_manager csm
  422. LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
  423. WHERE s.userID = #{userId}
  424. </select>
  425. <select id="findLeaderId" resultType="java.lang.Integer">
  426. SELECT csr.leaderId
  427. FROM cm_serviceteam_role csr
  428. LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
  429. WHERE s.userId = #{userId}
  430. </select>
  431. <select id="findLeaderIdByServiceId" resultType="java.lang.Integer">
  432. select leaderId
  433. FROM cm_serviceteam_role
  434. WHERE leaderId = #{serviceProviderId}
  435. </select>
  436. <select id="findmanagerIdByServiceId" resultType="java.lang.Integer">
  437. SELECT serviceProviderId
  438. FROM cm_serviceteam_manager
  439. where serviceProviderId = #{serviceProviderId}
  440. </select>
  441. <select id="findServiceIds" resultType="java.lang.Integer">
  442. SELECT csg.serviceId
  443. FROM cm_serviceteam_group csg
  444. LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
  445. WHERE csr.leaderId = #{serviceProviderId}
  446. AND csg.serviceId != #{serviceProviderId}
  447. </select>
  448. <select id="findAllServiceIds" resultType="java.lang.Integer">
  449. SELECT csg.serviceId
  450. FROM cm_serviceteam_group csg
  451. WHERE csg.serviceId != #{serviceProviderId}
  452. </select>
  453. <select id="findServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  454. SELECT csg.serviceId as serviceProviderId,s.linkMan as name
  455. FROM cm_serviceteam_group csg
  456. LEFT JOIN cm_serviceteam_role csr ON csr.id=csg.teamId
  457. left join serviceprovider s on csg.serviceId=s.serviceProviderID
  458. WHERE csr.leaderId = #{spId} and s.organizeID = 0
  459. <if test="status == 1">
  460. AND csg.serviceId != #{spId}
  461. </if>
  462. </select>
  463. <select id="findAllServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  464. SELECT csg.serviceId AS serviceProviderId,s.linkMan AS NAME
  465. FROM cm_serviceteam_group csg
  466. LEFT JOIN serviceprovider s ON csg.serviceId=s.serviceProviderID
  467. <where>
  468. s.organizeID = 0
  469. <if test="status == 1">
  470. and csg.serviceId != #{spId}
  471. </if>
  472. </where>
  473. </select>
  474. <select id="getBehaviorRecordYesterdayPageLabel" resultType="string">
  475. SELECT GROUP_CONCAT(a.pageLabel)
  476. FROM (SELECT b.pageLabel
  477. FROM cm_behavior_record b
  478. LEFT JOIN club c ON b.userID = c.userID
  479. WHERE b.userId !=0
  480. and c.spId=#{spId}
  481. <if test="clubId != null">
  482. AND c.clubId =#{clubId}
  483. </if>
  484. and b.pageType in(6,8,11)
  485. and DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
  486. GROUP BY b.pageLabel LIMIT 10) as a
  487. </select>
  488. <select id="getBehaviorRecordMinutePageLabel" resultType="string">
  489. SELECT GROUP_CONCAT(a.pageLabel)
  490. FROM (SELECT b.pageLabel
  491. FROM cm_behavior_record b
  492. LEFT JOIN club c ON b.userID = c.userID
  493. LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
  494. WHERE sp.status=90 and sp.serviceProviderID=#{spId}
  495. and b.pageType in (69,70,71)
  496. and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and #{accessTime}
  497. <if test="clubId != null">
  498. AND c.clubId =#{clubId}
  499. </if>
  500. GROUP BY b.pageLabel LIMIT 10) as a
  501. </select>
  502. <select id="getBehaviorRecordYesterdayClubFrom" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
  503. SELECT
  504. b.recordID,
  505. b.userID,
  506. b.pagePath,
  507. b.pageType,
  508. b.pageLabel,
  509. b.productID,
  510. b.accessTime,
  511. b.accessDuration,
  512. b.accessDate,
  513. b.referer,
  514. b.accessClient,
  515. b.isReckon,
  516. b.region,
  517. c.name,c.linkMan,c.contractMobile,c.clubId,u.image
  518. FROM cm_behavior_record b
  519. LEFT JOIN club c ON b.userID = c.userID
  520. LEFT JOIN user u ON u.userID = c.userID
  521. WHERE b.userId !=0
  522. and c.spId=#{spId}
  523. and c.clubId=#{clubId}
  524. and b.pageType in(6,11)
  525. and DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
  526. </select>
  527. <select id="getBehaviorRecordMinuteClubFrom" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
  528. SELECT
  529. b.recordID,
  530. b.userID,
  531. b.pagePath,
  532. b.pageType,
  533. b.pageLabel,
  534. b.productID,
  535. b.accessTime,
  536. b.accessDuration,
  537. b.accessDate,
  538. b.referer,
  539. b.accessClient,
  540. b.isReckon,
  541. b.region,
  542. (select cpaf.fileName from cm_product_archive_content cpac
  543. left join cm_product_archive_file cpaf on cpaf.archiveContentId=cpac.id
  544. where cpac.id=b.productArchiveId limit 1)as title,
  545. ifnull(c.name,b.IP),
  546. c.linkMan,c.contractMobile,c.clubId,u.image
  547. FROM cm_behavior_record b
  548. LEFT JOIN club c ON b.userID = c.userID
  549. LEFT JOIN user u ON u.userID = c.userID
  550. LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
  551. WHERE sp.status=90 and sp.serviceProviderID=#{spId}
  552. and b.pageType in (69,70,71)
  553. and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and #{accessTime}
  554. <if test="clubId != null">
  555. AND c.clubId =#{clubId}
  556. </if>
  557. </select>
  558. <select id="getBehaviorRecordYesterdayClub" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
  559. SELECT b.recordID,
  560. b.userID,
  561. b.pagePath,
  562. b.pageType,
  563. b.pageLabel,
  564. b.productID,
  565. b.accessTime,
  566. b.accessDuration,
  567. b.accessDate,
  568. b.referer,
  569. b.accessClient,
  570. b.isReckon,
  571. b.region,
  572. c.name,c.linkMan,c.contractMobile,c.clubId,u.image
  573. FROM cm_behavior_record b
  574. LEFT JOIN club c ON b.userID = c.userID
  575. LEFT JOIN user u ON u.userID = c.userID
  576. WHERE b.userId !=0
  577. and c.spId=#{spId}
  578. and b.pageType in(6,8,11)
  579. and DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
  580. GROUP BY c.clubId
  581. </select>
  582. <select id="getBehaviorRecordMinuteClub" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
  583. SELECT b.recordID,
  584. b.userID,
  585. b.pagePath,
  586. b.pageType,
  587. b.pageLabel,
  588. b.productID,
  589. b.accessTime,
  590. b.accessDuration,
  591. b.accessDate,
  592. b.referer,
  593. b.accessClient,
  594. b.isReckon,
  595. b.region,
  596. ifnull(c.name,b.region)
  597. ,c.linkMan,c.contractMobile,c.clubId,u.image
  598. FROM cm_behavior_record b
  599. LEFT JOIN club c ON b.userID = c.userID
  600. LEFT JOIN user u ON u.userID = c.userID
  601. LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
  602. WHERE sp.status=90 and sp.serviceProviderID=#{spId}
  603. and b.pageType in (69,70,71)
  604. and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and #{accessTime}
  605. GROUP BY b.region
  606. </select>
  607. <select id="getClubAccessDate" resultType="com.caimei365.user.model.vo.RetuenDataVo">
  608. select cbr.accessDate
  609. from cm_behavior_record cbr
  610. LEFT JOIN club c ON cbr.userID = c.userID
  611. where c.clubID = #{clubId} group by cbr.accessDate order by cbr.accessDate desc
  612. </select>
  613. <select id="getClubKeynoteRecord" resultType="com.caimei365.user.model.vo.BehaviorRecodeVo">
  614. SELECT
  615. b.recordID,
  616. b.userID,
  617. b.pagePath,
  618. pt.pageType,
  619. b.pageLabel,
  620. b.productID,
  621. b.accessTime,
  622. b.accessDuration,
  623. b.accessDate,
  624. b.referer,
  625. b.accessClient,
  626. b.isReckon,
  627. b.region,
  628. p.name AS productName,
  629. p.mainImage AS productImage
  630. FROM cm_behavior_record b
  631. LEFT JOIN club c ON b.userID = c.userID
  632. LEFT JOIN product p ON b.productID = p.productID
  633. LEFT JOIN cm_page_type pt ON b.pageType = pt.id
  634. WHERE c.clubID = #{clubId}
  635. and b.pageType IN (6,11)
  636. <if test="accessDateList.size()>0">
  637. and
  638. <foreach collection="accessDateList" item="accessDate" open="(" separator="or" close=")">
  639. b.accessTime like concat('%', #{accessDate}, '%')
  640. </foreach>
  641. </if>
  642. order by b.accessTime desc
  643. </select>
  644. <select id="getUnActiveClub" resultType="com.caimei365.user.model.vo.ClubVo">
  645. SELECT c.clubID as clubId,
  646. c.userID as userId,
  647. c.name,
  648. c.sname as shortName,
  649. c.contractMobile,
  650. c.contractEmail as contractEmail,
  651. c.contractPhone,
  652. c.linkMan,
  653. c.provinceID as proviceId,
  654. c.cityID as cityId,
  655. c.townID as townId,
  656. c.address,
  657. c.headpic as shopPhoto,
  658. c.businessLicenseImage as businessLicense,
  659. c.socialCreditCode,
  660. c.firstClubType,
  661. c.secondClubType,
  662. c.department,
  663. c.medicalPracticeLicenseImg as medicalPracticeLicense,
  664. c.mainpro as mainProduct,
  665. c.fax,
  666. c.info as profile,
  667. c.spID as serviceProviderId,
  668. c.addTime, c.status,
  669. c.lastCheckOrderDate,
  670. u.userIdentity,
  671. c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
  672. sp.name AS serviceName,
  673. coas.activeState AS activeState,
  674. covs.customerValue AS customerValue
  675. from club c
  676. left join user u on c.userID = u.userID
  677. LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
  678. LEFT JOIN (SELECT userId, activeState, activeStatus FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) AS coas ON coas.userId = c.userId
  679. LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) AS covs ON covs.userId = c.userId
  680. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
  681. WHERE coas.activeStatus = 1
  682. AND sp.serviceProviderID = #{serviceProviderId}
  683. GROUP BY covs.userID
  684. </select>
  685. </mapper>