作者 yangfu

机会池排序修改

@@ -111,12 +111,12 @@ func DeleteChance(id int64) (err error) { @@ -111,12 +111,12 @@ func DeleteChance(id int64) (err error) {
111 func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 111 func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
112 sql := `select a.*,b.images,speechs,videos 112 sql := `select a.*,b.images,speechs,videos
113 from ( 113 from (
114 -select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance  
115 -where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status=1 and enable_status=1 114 +select id,user_id,create_at,update_at,update_at chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance
  115 +where user_id=? and company_id=? and review_status in (?) and (?=0 or unix_timestamp(update_at)<?) and status=1 and enable_status=1
116 ) a left JOIN chance_data b on a.id =b.chance_id 116 ) a left JOIN chance_data b on a.id =b.chance_id
117 order by update_at desc 117 order by update_at desc
118 limit ? 118 limit ?
119 -` 119 +` //approve_time
120 //update_at 120 //update_at
121 sqlCount := fmt.Sprintf(`select count(0) from ( 121 sqlCount := fmt.Sprintf(`select count(0) from (
122 select id,user_id,create_at,source_content from chance 122 select id,user_id,create_at,source_content from chance
@@ -137,10 +137,11 @@ func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, @@ -137,10 +137,11 @@ func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64,
137 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 137 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
138 select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status from ( 138 select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status from (
139 select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time 139 select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time
140 -from audit_flow_process where uid=? and review_status in (%v) and (?=0 or id<?) 140 +from audit_flow_process where uid=? and review_status in (%v)
141 )a left outer join chance b on a.chance_id = b.id 141 )a left outer join chance b on a.chance_id = b.id
142 )a left outer join chance_data b on a.chance_id =b.chance_id 142 )a left outer join chance_data b on a.chance_id =b.chance_id
143 -order by process_create_time desc 143 +where (?=0 or unix_timestamp(a.update_at)<?)
  144 +order by a.update_at desc
144 LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除 145 LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除
145 146
146 sqlCount := fmt.Sprintf(`select count(0) 147 sqlCount := fmt.Sprintf(`select count(0)
@@ -160,10 +161,11 @@ func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId @@ -160,10 +161,11 @@ func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId
160 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 161 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
161 select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status,b.update_at process_create_time from ( 162 select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status,b.update_at process_create_time from (
162 select id,approve_time,approve_data,uid,chance_id,approve_message 163 select id,approve_time,approve_data,uid,chance_id,approve_message
163 -from audit_flow_process where uid=? and review_status in (%v) and (?=0 or id<?) and enable_status =1 164 +from audit_flow_process where uid=? and review_status in (%v) and enable_status =1
164 )a left outer join chance b on a.chance_id = b.id 165 )a left outer join chance b on a.chance_id = b.id
165 )a left outer join chance_data b on a.chance_id =b.chance_id 166 )a left outer join chance_data b on a.chance_id =b.chance_id
166 -order by process_create_time desc 167 +where (?=0 or unix_timestamp(a.update_at)<?)
  168 +order by a.update_at desc
167 LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time 169 LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time
168 170
169 sqlCount := fmt.Sprintf(`select count(0) 171 sqlCount := fmt.Sprintf(`select count(0)
@@ -477,12 +479,12 @@ limit %v @@ -477,12 +479,12 @@ limit %v
477 sqlCount := fmt.Sprintf(` 479 sqlCount := fmt.Sprintf(`
478 select count(0) from ( 480 select count(0) from (
479 ##公司公开的机会 481 ##公司公开的机会
480 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance 482 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from chance
481 where company_id = %v and publish_status = 2 483 where company_id = %v and publish_status = 2
482 484
483 UNION 485 UNION
484 ##指定部门-机会公开的部门 486 ##指定部门-机会公开的部门
485 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 487 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
486 select DISTINCT chance_id from chance_department where department_id in (%v) 488 select DISTINCT chance_id from chance_department where department_id in (%v)
487 )a inner join chance b on a.chance_id = b.id 489 )a inner join chance b on a.chance_id = b.id
488 UNION 490 UNION
@@ -493,7 +495,7 @@ select count(0) from ( @@ -493,7 +495,7 @@ select count(0) from (
493 UNION 495 UNION
494 496
495 ##我审核 497 ##我审核
496 - select id,user_id,approve_time create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from ( 498 + select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id,status from (
497 select DISTINCT chance_id from audit_flow_process where uid =%v 499 select DISTINCT chance_id from audit_flow_process where uid =%v
498 ) a inner join chance b on a.chance_id = b.id 500 ) a inner join chance b on a.chance_id = b.id
499 501
@@ -1302,7 +1302,15 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh @@ -1302,7 +1302,15 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
1302 myChances []protocol.ChanceItemOrm 1302 myChances []protocol.ChanceItemOrm
1303 total int 1303 total int
1304 provider *protocol.BaseUserInfo 1304 provider *protocol.BaseUserInfo
  1305 + chance *models.Chance
1305 ) 1306 )
  1307 + if request.LastId > 0 {
  1308 + if chance, err = models.GetChanceById(request.LastId); err != nil {
  1309 + log.Error("机会不存在", request.LastId, err)
  1310 + return
  1311 + }
  1312 + request.LastId = chance.UpdateAt.Unix()
  1313 + }
1306 if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { 1314 if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
1307 if err == orm.ErrNoRows { 1315 if err == orm.ErrNoRows {
1308 err = nil 1316 err = nil
@@ -1432,7 +1440,15 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -1432,7 +1440,15 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
1432 myChances []protocol.ChanceApproveItemOrm 1440 myChances []protocol.ChanceApproveItemOrm
1433 total int 1441 total int
1434 provider *protocol.BaseUserInfo 1442 provider *protocol.BaseUserInfo
  1443 + chance *models.Chance
1435 ) 1444 )
  1445 + if request.LastId > 0 {
  1446 + if chance, err = models.GetChanceById(request.LastId); err != nil {
  1447 + log.Error("审批不存在", request.LastId, err)
  1448 + return
  1449 + }
  1450 + request.LastId = chance.UpdateAt.Unix()
  1451 + }
1436 if request.ReviewStatus == protocol.ReviewStatusAuditging { 1452 if request.ReviewStatus == protocol.ReviewStatusAuditging {
1437 if total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { 1453 if total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
1438 if err == orm.ErrNoRows { 1454 if err == orm.ErrNoRows {