作者 yangfu

机会池排序修改

@@ -267,7 +267,7 @@ func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize i @@ -267,7 +267,7 @@ func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize i
267 sql := `select a.*,b.images,speechs,videos 267 sql := `select a.*,b.images,speechs,videos
268 from ( 268 from (
269 select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance 269 select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
270 -where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1 and status=1 270 +where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or approve_time<?) and enable_status=1 and status=1
271 ) a left JOIN chance_data b on a.id =b.chance_id 271 ) a left JOIN chance_data b on a.id =b.chance_id
272 order by create_at desc 272 order by create_at desc
273 limit ? 273 limit ?
@@ -316,7 +316,7 @@ select * from ( @@ -316,7 +316,7 @@ select * from (
316 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3 316 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3
317 ) a inner join chance b on a.chance_id = b.id 317 ) a inner join chance b on a.chance_id = b.id
318 318
319 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1 319 +) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or create_at<%v) and a.enable_status=1 and status=1
320 ) a left JOIN chance_data b on a.id =b.chance_id 320 ) a left JOIN chance_data b on a.id =b.chance_id
321 order by create_at desc 321 order by create_at desc
322 limit %v 322 limit %v
@@ -391,7 +391,7 @@ select * from ( @@ -391,7 +391,7 @@ select * from (
391 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3 391 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3
392 ) a inner join chance b on a.chance_id = b.id 392 ) a inner join chance b on a.chance_id = b.id
393 393
394 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1 394 +) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or create_at<%v) and a.enable_status=1 and status=1
395 ) a left JOIN chance_data b on a.id =b.chance_id 395 ) a left JOIN chance_data b on a.id =b.chance_id
396 order by create_at desc 396 order by create_at desc
397 limit %v 397 limit %v
@@ -468,7 +468,7 @@ select * from ( @@ -468,7 +468,7 @@ select * from (
468 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3 468 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3
469 ) a inner join chance b on a.chance_id = b.id 469 ) a inner join chance b on a.chance_id = b.id
470 470
471 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1 471 +) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or create_at<%v) and a.enable_status=1 and status=1
472 ) a left JOIN chance_data b on a.id =b.chance_id 472 ) a left JOIN chance_data b on a.id =b.chance_id
473 order by create_at desc 473 order by create_at desc
474 limit %v 474 limit %v
@@ -525,7 +525,7 @@ select * from ( @@ -525,7 +525,7 @@ select * from (
525 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3 525 select DISTINCT chance_id from audit_flow_process where uid =%v and review_status=3
526 ) a inner join chance b on a.chance_id = b.id 526 ) a inner join chance b on a.chance_id = b.id
527 527
528 -) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1 528 +) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or create_at<%v) and a.enable_status=1 and status=1
529 ) a left JOIN chance_data b on a.id =b.chance_id 529 ) a left JOIN chance_data b on a.id =b.chance_id
530 order by create_at desc 530 order by create_at desc
531 limit %v 531 limit %v
@@ -15,6 +15,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -15,6 +15,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
15 specialDIds []int64 15 specialDIds []int64
16 userDIds []int64 16 userDIds []int64
17 user *models.User 17 user *models.User
  18 + chance *models.Chance
18 ) 19 )
19 if user, err = models.GetUserByCompanyId(cid); err != nil { 20 if user, err = models.GetUserByCompanyId(cid); err != nil {
20 log.Error(err) 21 log.Error(err)
@@ -35,6 +36,13 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -35,6 +36,13 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
35 specialDIds = append(specialDIds, 0) 36 specialDIds = append(specialDIds, 0)
36 } 37 }
37 } 38 }
  39 + if lastId > 0 {
  40 + if chance, err = models.GetChanceById(lastId); err != nil {
  41 + log.Error("机会不存在", lastId, err)
  42 + return
  43 + }
  44 + lastId = chance.ApproveTime.Unix()
  45 + }
38 log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) 46 log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid))
39 switch check { 47 switch check {
40 case OpportunityCheckLv1: 48 case OpportunityCheckLv1: