|
@@ -127,13 +127,14 @@
|
|
|
c.lastCheckOrderDate,
|
|
|
u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
|
|
|
sp.name AS serviceName,
|
|
|
- covs.activeState AS activeState,
|
|
|
+ coas.activeState AS activeState,
|
|
|
covs.customerValue AS customerValue,
|
|
|
cpr.createTime AS providerTime
|
|
|
from club c
|
|
|
left join user u on c.userID = u.userID
|
|
|
LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
|
|
|
- LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
|
|
|
+ LEFT JOIN (SELECT userId, activeStatus, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) coas ON coas.userId = c.userId
|
|
|
+ LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON covs.userID = c.userID
|
|
|
LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
|
|
|
LEFT JOIN cm_provider_record cpr ON cpr.spID = sp.serviceProviderID and cpr.clubId = c.clubId
|
|
|
LEFT JOIN (SELECT DISTINCT clubID, checkTime FROM clubchangesprecord WHERE checkStatus = 1 GROUP BY clubID ORDER BY clubChangeSpRecordID DESC )ccs ON ccs.clubId = c.clubId
|
|
@@ -153,68 +154,16 @@
|
|
|
</if>
|
|
|
<if test="4 == type">
|
|
|
c.spID = #{serviceProviderId}
|
|
|
- AND sp.status = 90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
|
|
|
- AND (u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) OR c.clubId in (select a.clubId
|
|
|
- FROM ((
|
|
|
- select
|
|
|
- c.clubId,ccr.addTime AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90
|
|
|
- and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )UNION(
|
|
|
- select c.clubId,cr.orderTime AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_order cr ON cr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90
|
|
|
- and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )) a where a.time is not null
|
|
|
- and a.spID=#{serviceProviderId}
|
|
|
- GROUP BY a.clubId))
|
|
|
+ and coas.activeStatus = 0
|
|
|
</if>
|
|
|
<if test="5 == type">
|
|
|
c.spID = #{serviceProviderId}
|
|
|
- AND sp.status = 90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
|
|
|
- AND (u.loginTime <![CDATA[ < ]]> DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) or u.loginTime is null)and c.clubId not in (select a.clubId
|
|
|
- FROM ((
|
|
|
- select
|
|
|
- c.clubId,ccr.addTime AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90
|
|
|
- and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )UNION(
|
|
|
- select c.clubId,cr.orderTime AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_order cr ON cr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90
|
|
|
- and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )) a where a.time is not null
|
|
|
- and a.spID=#{serviceProviderId}
|
|
|
- GROUP BY a.clubId )
|
|
|
+ and coas.activeStatus = 1
|
|
|
</if>
|
|
|
<if test="6 == type">
|
|
|
c.spID = #{serviceProviderId}
|
|
|
AND c.newDeal =1
|
|
|
</if>
|
|
|
- <if test="status != null and status != 66">
|
|
|
- AND c.status = #{status}
|
|
|
- </if>
|
|
|
- <if test="status == 66">
|
|
|
- AND c.status IN (1,90,92,93)
|
|
|
- </if>
|
|
|
<if test="name != null and name != ''">
|
|
|
AND (c.name LIKE CONCAT('%',#{name},'%') OR c.linkMan LIKE CONCAT('%',#{name},'%') OR c.contractMobile LIKE CONCAT('%',#{name},'%'))
|
|
|
</if>
|
|
@@ -229,55 +178,208 @@
|
|
|
AND (ccs.checkTime <![CDATA[ <= ]]> #{endTime}
|
|
|
OR cpr.createTime <![CDATA[ <= ]]> #{endTime})
|
|
|
</if>
|
|
|
- AND covs.stage = 0 AND covs.delType = 1
|
|
|
+ <if test="activeState != null and activeState != ''">
|
|
|
+ AND coas.activeState like concat('%', #{userIdentity}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="customerValue != null and customerValue != ''">
|
|
|
+ AND covs.customerValue like concat('%', #{customerValue}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ <if test="status == 90">
|
|
|
+ and c.status = 90 and u.userIdentity = 4
|
|
|
+ </if>
|
|
|
+ <if test="status == 1">
|
|
|
+ and c.status = 1 and u.userIdentity = 4
|
|
|
+ </if>
|
|
|
+ <if test="status == 92">
|
|
|
+ and c.status = 92 and u.userIdentity = 4
|
|
|
+ </if>
|
|
|
+ <if test="status != 90 and status != 1 and status != 92 and status != 66">
|
|
|
+ AND c.status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="status == 66">
|
|
|
+ AND c.status IN (1,90,92,93)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
group by c.clubID
|
|
|
order by cpr.createTime desc
|
|
|
</select>
|
|
|
|
|
|
- <select id="findSpUserLoginSum" resultType="java.util.HashMap" parameterType="string">
|
|
|
- select
|
|
|
- COUNT( CASE WHEN a.time=1 THEN 1 END) AS loginSum,
|
|
|
- ((SELECT count(1) from club
|
|
|
- WHERE status=90
|
|
|
- <if test="spID != null">
|
|
|
- and spID=#{spID}
|
|
|
- </if>
|
|
|
- )-COUNT( CASE WHEN a.time=1 THEN 1 END)) AS not_loginSum
|
|
|
- FROM (select a.*
|
|
|
- FROM ((
|
|
|
- select
|
|
|
- c.clubId,1 AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
|
|
|
- and u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )UNION(
|
|
|
- select
|
|
|
- c.clubId,1 AS time,c.spID
|
|
|
- FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
|
|
|
- and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )UNION(
|
|
|
- select c.clubId,1 AS time,c.spID
|
|
|
+ <select id="getIsRemarkClub" resultType="com.caimei365.user.model.vo.ClubVo">
|
|
|
+ SELECT
|
|
|
+ c.clubId,
|
|
|
+ c.userId,
|
|
|
+ c.name,
|
|
|
+ c.sname AS shortName,
|
|
|
+ c.contractMobile,
|
|
|
+ u.userIdentity,
|
|
|
+ sp.linkMan AS serviceName,
|
|
|
+ coas.activeState AS activeState,
|
|
|
+ covs.customerValue AS customerValue,
|
|
|
+ b.num,
|
|
|
+ (
|
|
|
+ SELECT ADDTIME FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ADDTIME
|
|
|
+ FROM cm_club_remarks
|
|
|
+ WHERE clubId = c.clubId
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ ADDTIME
|
|
|
+ FROM cm_visitor_remarks
|
|
|
+ WHERE
|
|
|
+ clubId IS NOT NULL AND clubId != ''
|
|
|
+ AND clubId = c.clubId
|
|
|
+ ) b ORDER BY ADDTIME DESC LIMIT 1
|
|
|
+ ) AS ADDTIME
|
|
|
FROM club c
|
|
|
- LEFT JOIN user u ON u.userID = c.userID
|
|
|
- LEFT JOIN cm_order cr ON cr.clubId = c.clubId
|
|
|
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
|
|
|
- where c.status=90 and sp.status=90 and (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4
|
|
|
- and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
|
|
|
- GROUP BY c.clubId
|
|
|
- )
|
|
|
- ) a where 1=1
|
|
|
- <if test="spID != null">
|
|
|
- and a.spID=#{spID}
|
|
|
+ LEFT JOIN USER u ON c.userID = u.userID
|
|
|
+ LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
|
|
|
+ LEFT JOIN (SELECT userId, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) coas ON coas.userId = c.userId
|
|
|
+ LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON covs.userID = c.userID
|
|
|
+ LEFT JOIN (SELECT clubId, COUNT(id) AS num FROM cm_club_remarks GROUP BY clubId
|
|
|
+ UNION
|
|
|
+ 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
|
|
|
+ where c.spId = #{spId}
|
|
|
+ <if test="type != null">
|
|
|
+ <if test="type == 1">
|
|
|
+ and b.num > 0
|
|
|
+ </if>
|
|
|
+ <if test="type == 2">
|
|
|
+ and b.num IS NULL OR b.num = 0
|
|
|
+ </if>
|
|
|
</if>
|
|
|
- GROUP BY a.clubId ) a
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getClubAllRemark" resultType="com.caimei365.user.model.vo.RemarksVo">
|
|
|
+ select * from
|
|
|
+ (
|
|
|
+ SELECT DISTINCT ccr.id AS remarksId,
|
|
|
+ ccr.remarks,
|
|
|
+ ccr.addTime,
|
|
|
+ ccr.questionMan,
|
|
|
+ ccr.serviceProviderId AS serviceProviderId,
|
|
|
+ ccr.createServiceProviderId AS createServiceProviderId,
|
|
|
+ csr.leaderId AS leaderId,
|
|
|
+ IFNULL(ccr.consultType,'') AS consult,
|
|
|
+ c.Name AS clubName,
|
|
|
+ ccr.clubType AS clubType,
|
|
|
+ ccr.pinceSensitve AS pinceSensitve,
|
|
|
+ ccr.satisfied AS satisfied,
|
|
|
+ ccr.followup AS followup,
|
|
|
+ ccr.extra AS extra,
|
|
|
+ ccr.communicationSituation,
|
|
|
+ ccr.communicationMethods,
|
|
|
+ ccr.customerSource,
|
|
|
+ ccr.customerGender,
|
|
|
+ ccr.groupAddition,
|
|
|
+ ccr.customerAge,
|
|
|
+ ccr.trendsKeyword,
|
|
|
+ ccr.stateKeyword,
|
|
|
+ (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
|
|
|
+ (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.createServiceProviderId) AS recordName,
|
|
|
+ cmc.status AS STATUS
|
|
|
+ FROM cm_club_remarks ccr
|
|
|
+ LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
|
|
|
+ LEFT JOIN club c ON c.clubId=ccr.clubId
|
|
|
+ LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
|
|
|
+ LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
|
|
|
+ LEFT JOIN cm_club_report cmc ON cmc.clubId = ccr.clubId
|
|
|
+ <where>
|
|
|
+ ccr.clubId = #{clubId}
|
|
|
+ <if test="search != null and search != ''">
|
|
|
+ and (
|
|
|
+ ccr.remarks like concat('%',#{search},'%')
|
|
|
+ or ccr.questionMan like concat('%',#{search},'%')
|
|
|
+ or c.name like concat('%',#{search},'%')
|
|
|
+ or c.contractMobile like concat('%',#{search},'%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ UNION
|
|
|
+ SELECT DISTINCT ccr.id AS remarksId,
|
|
|
+ ccr.remarks,
|
|
|
+ ccr.addTime AS ADDDATE,
|
|
|
+ ccr.questionMan,
|
|
|
+ ccr.serviceProviderId,
|
|
|
+ ccr.createServiceProviderId AS createServiceProviderId,
|
|
|
+ csr.leaderId AS leaderId,
|
|
|
+ IFNULL(ccr.consultType,'') AS consult,
|
|
|
+ c.Name AS clubName,
|
|
|
+ ccr.clubType AS clubType,
|
|
|
+ ccr.pinceSensitve AS pinceSensitve,
|
|
|
+ ccr.satisfied AS satisfied,
|
|
|
+ ccr.followup AS followup,
|
|
|
+ ccr.extra AS extra,
|
|
|
+ ccr.communicationSituation,
|
|
|
+ ccr.communicationMethods,
|
|
|
+ ccr.customerSource,
|
|
|
+ ccr.customerGender,
|
|
|
+ ccr.groupAddition,
|
|
|
+ ccr.customerAge,
|
|
|
+ ccr.trendsKeyword,
|
|
|
+ ccr.stateKeyword,
|
|
|
+ (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName,
|
|
|
+ (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderId) AS recordName,
|
|
|
+ cmc.status AS STATUS
|
|
|
+ FROM cm_visitor_remarks ccr
|
|
|
+ LEFT JOIN club c ON c.clubId=ccr.clubId
|
|
|
+ LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
|
|
|
+ LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
|
|
|
+ LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
|
|
|
+ LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
|
|
|
+ <where>
|
|
|
+ ccr.remarks IS NOT NULL
|
|
|
+ AND ccr.clubId is NOT null AND ccr.clubId != '' AND ccr.clubId = #{clubId}
|
|
|
+ <if test="search != null and search != ''">
|
|
|
+ and (
|
|
|
+ ccr.remarks like concat('%',#{search},'%')
|
|
|
+ or ccr.questionMan like concat('%',#{search},'%')
|
|
|
+ or c.name like concat('%',#{search},'%')
|
|
|
+ or c.contractMobile like concat('%',#{search},'%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ) b
|
|
|
+ ORDER BY b.addTime DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="findSpUserLoginSum" resultType="java.util.HashMap">
|
|
|
+ SELECT
|
|
|
+ (CASE coas.activeStatus
|
|
|
+ WHEN 0 THEN 'active'
|
|
|
+ WHEN 1 THEN 'unActive'
|
|
|
+ END) AS activeStatus,
|
|
|
+ COUNT(coas.activeStatus) AS number
|
|
|
+ FROM cm_organ_active_system coas
|
|
|
+ LEFT JOIN club c ON coas.userId = c.userId
|
|
|
+ LEFT JOIN serviceprovider s ON s.serviceProviderId = c.spId
|
|
|
+ WHERE s.serviceProviderId = #{spId} AND coas.stage = 0 AND delType = 1
|
|
|
+ GROUP BY coas.activeStatus
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getRemarkClub" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ COUNT(clubId) AS isHaveClub,
|
|
|
+ (SELECT COUNT(clubId) FROM club c LEFT JOIN serviceprovider s ON s.serviceProviderId = c.spId WHERE s.serviceProviderId = #{spId})AS allclub
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ clubid AS clubID
|
|
|
+ FROM cm_club_remarks
|
|
|
+ WHERE createServiceProviderId = #{spId}
|
|
|
+ GROUP BY clubId
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ clubId AS clubID
|
|
|
+ FROM cm_visitor_remarks
|
|
|
+ WHERE
|
|
|
+ clubId IS NOT NULL AND clubId != ''
|
|
|
+ AND createServiceProviderId = #{spId}
|
|
|
+ GROUP BY clubId
|
|
|
+ ) b
|
|
|
</select>
|
|
|
<select id="getAllClubList" resultType="com.caimei365.user.model.vo.ClubVo">
|
|
|
SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
|
|
@@ -516,14 +618,15 @@
|
|
|
u.userIdentity,
|
|
|
c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
|
|
|
sp.name AS serviceName,
|
|
|
- covs.activeState AS activeState,
|
|
|
+ coas.activeState AS activeState,
|
|
|
covs.customerValue AS customerValue
|
|
|
from club c
|
|
|
left join user u on c.userID = u.userID
|
|
|
LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
|
|
|
- LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
|
|
|
+ LEFT JOIN (SELECT userId, activeState, activeStatus FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) AS coas ON coas.userId = c.userId
|
|
|
+ LEFT JOIN (SELECT userId, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) AS covs ON covs.userId = c.userId
|
|
|
LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
|
|
|
- WHERE covs.delType = 1 AND covs.stage = 0 AND covs.activeStatus = 1
|
|
|
+ WHERE coas.activeStatus = 1
|
|
|
AND sp.serviceProviderID = #{serviceProviderId}
|
|
|
GROUP BY covs.userID
|
|
|
</select>
|