作者 yangfu

排行榜修改

@@ -86,7 +86,7 @@ func GetRanksByUser(companyId int64, rankTypeId, rankRangeId, rankPeriodId int, @@ -86,7 +86,7 @@ func GetRanksByUser(companyId int64, rankTypeId, rankRangeId, rankPeriodId int,
86 ( 86 (
87 select score,relation_id,user_id from( 87 select score,relation_id,user_id from(
88 select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id 88 select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id
89 -where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v 89 +where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
90 order by a.%v desc,c.create_at asc 90 order by a.%v desc,c.create_at asc
91 ) a,(select @rowno:=%v) b 91 ) a,(select @rowno:=%v) b
92 limit %v,%v 92 limit %v,%v
@@ -117,7 +117,7 @@ select a.*,b.nick_name name from @@ -117,7 +117,7 @@ select a.*,b.nick_name name from
117 ( 117 (
118 select score,relation_id,user_id,(@rowno:=@rowno+1) as ranking from( 118 select score,relation_id,user_id,(@rowno:=@rowno+1) as ranking from(
119 select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id 119 select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id
120 -where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v 120 +where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
121 order by a.%v desc,c.create_at asc 121 order by a.%v desc,c.create_at asc
122 ) a,(select @rowno:=0 ) b 122 ) a,(select @rowno:=0 ) b
123 )a inner join user b on a.user_id = b.id 123 )a inner join user b on a.user_id = b.id
@@ -145,7 +145,7 @@ select a.*,(@rowno:=@rowno+1) as ranking from @@ -145,7 +145,7 @@ select a.*,(@rowno:=@rowno+1) as ranking from
145 ( 145 (
146 select a.%v score,a.relation_id,c.name 146 select a.%v score,a.relation_id,c.name
147 from rank a inner join department c on a.relation_id=c.id 147 from rank a inner join department c on a.relation_id=c.id
148 -where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v 148 +where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
149 order by a.%v desc,c.create_at asc 149 order by a.%v desc,c.create_at asc
150 )a,(select (@rowno:=%v)) b 150 )a,(select (@rowno:=%v)) b
151 limit %v,%v 151 limit %v,%v
@@ -174,7 +174,7 @@ func GetRanksByDepartmentSelf(companyId int64, rankTypeId, rankRangeId, rankPeri @@ -174,7 +174,7 @@ func GetRanksByDepartmentSelf(companyId int64, rankTypeId, rankRangeId, rankPeri
174 sql := fmt.Sprintf(`select * from ( 174 sql := fmt.Sprintf(`select * from (
175 select a.*,(@rowno:=@rowno+1) as ranking from ( 175 select a.*,(@rowno:=@rowno+1) as ranking from (
176 select a.%v score,a.relation_id,c.name from rank a inner join department c on a.relation_id=c.id 176 select a.%v score,a.relation_id,c.name from rank a inner join department c on a.relation_id=c.id
177 -where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v 177 +where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
178 order by a.%v desc,c.create_at asc 178 order by a.%v desc,c.create_at asc
179 ) a,(select (@rowno:=0)) b 179 ) a,(select (@rowno:=0)) b
180 )a 180 )a
@@ -184,6 +184,9 @@ where a.relation_id=%v @@ -184,6 +184,9 @@ where a.relation_id=%v
184 184
185 if v != nil { 185 if v != nil {
186 if err = utils.ExecuteQueryOne(v, sql); err != nil { 186 if err = utils.ExecuteQueryOne(v, sql); err != nil {
  187 + if err == orm.ErrNoRows {
  188 + err = nil
  189 + }
187 return 190 return
188 } 191 }
189 } 192 }
@@ -219,10 +219,10 @@ func updateRank(o RankOption) { @@ -219,10 +219,10 @@ func updateRank(o RankOption) {
219 Type: int8(o.Type), 219 Type: int8(o.Type),
220 } 220 }
221 } else { 221 } else {
  222 + rankTmp = *rank
222 if rank.EnableStatus == protocol.InValid { 223 if rank.EnableStatus == protocol.InValid {
223 rank.EnableStatus = protocol.Valid 224 rank.EnableStatus = protocol.Valid
224 } 225 }
225 - rankTmp = *rank  
226 } 226 }
227 o.Rank = rank 227 o.Rank = rank
228 for i := range rankList { 228 for i := range rankList {
@@ -269,6 +269,9 @@ func checkScoreChange(old, new models.Rank) string { @@ -269,6 +269,9 @@ func checkScoreChange(old, new models.Rank) string {
269 if old.CommentTotal != new.CommentTotal { 269 if old.CommentTotal != new.CommentTotal {
270 changeLog.WriteString(logScoreChanceLog("评论总数", float64(old.CommentTotal), float64(new.CommentTotal))) 270 changeLog.WriteString(logScoreChanceLog("评论总数", float64(old.CommentTotal), float64(new.CommentTotal)))
271 } 271 }
  272 + if old.EnableStatus != new.EnableStatus {
  273 + changeLog.WriteString(logScoreChanceLog("状态", float64(old.EnableStatus), float64(new.EnableStatus)))
  274 + }
272 return changeLog.String() 275 return changeLog.String()
273 } 276 }
274 277