SellerMapper.xml 27 KB

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