|
@@ -135,7 +135,7 @@
|
|
|
from club c
|
|
|
left join user u on c.userID = u.userID
|
|
|
LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
|
|
|
- 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, 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
|
|
@@ -155,58 +155,10 @@
|
|
|
AND c.spId=1342
|
|
|
</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))
|
|
|
+ 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 )
|
|
|
+ coas.activeStatus = 1
|
|
|
</if>
|
|
|
<if test="6 == type">
|
|
|
c.spID = #{serviceProviderId}
|
|
@@ -234,13 +186,13 @@
|
|
|
</if>
|
|
|
<if test="status != null">
|
|
|
<if test="status == 90">
|
|
|
- and c.status = 90 and c.userIdentity = 4
|
|
|
+ and c.status = 90 and u.userIdentity = 4
|
|
|
</if>
|
|
|
<if test="status == 1">
|
|
|
- and c.status = 1 and c.userIdentity = 4
|
|
|
+ and c.status = 1 and u.userIdentity = 4
|
|
|
</if>
|
|
|
<if test="status == 92">
|
|
|
- and c.status = 92 and c.userIdentity = 4
|
|
|
+ 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}
|
|
@@ -264,21 +216,22 @@
|
|
|
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
|
|
|
+ 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 c.userID = u.userID
|
|
@@ -286,15 +239,15 @@
|
|
|
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
|
|
|
+ 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">
|
|
|
- having b.num > 0
|
|
|
+ and b.num > 0
|
|
|
</if>
|
|
|
<if test="type == 2">
|
|
|
- having b.num IS NULL OR b.num = 0
|
|
|
+ and b.num IS NULL OR b.num = 0
|
|
|
</if>
|
|
|
</if>
|
|
|
</select>
|
|
@@ -333,7 +286,17 @@
|
|
|
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}
|
|
|
+ <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,
|
|
@@ -366,15 +329,24 @@
|
|
|
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
|
|
|
+ <where>
|
|
|
ccr.remarks IS NOT NULL
|
|
|
- AND ccr.clubId is NOT null AND ccr.clubId != '' AND ccr.clubId = #{clubId}
|
|
|
+ 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" parameterType="string">
|
|
|
+ <select id="findSpUserLoginSum" resultType="java.util.HashMap">
|
|
|
SELECT
|
|
|
(CASE coas.activeStatus
|
|
|
WHEN 0 THEN 'active'
|