作者 yangfu

机会池排序修改

... ... @@ -111,12 +111,12 @@ func DeleteChance(id int64) (err error) {
func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,speechs,videos
from (
select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance
where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status=1 and enable_status=1
select id,user_id,create_at,update_at,update_at chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance
where user_id=? and company_id=? and review_status in (?) and (?=0 or unix_timestamp(update_at)<?) and status=1 and enable_status=1
) a left JOIN chance_data b on a.id =b.chance_id
order by update_at desc
limit ?
`
` //approve_time
//update_at
sqlCount := fmt.Sprintf(`select count(0) from (
select id,user_id,create_at,source_content from chance
... ... @@ -137,10 +137,11 @@ func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64,
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
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 (
select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time
from audit_flow_process where uid=? and review_status in (%v) and (?=0 or id<?)
from audit_flow_process where uid=? and review_status in (%v)
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
order by process_create_time desc
where (?=0 or unix_timestamp(a.update_at)<?)
order by a.update_at desc
LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //and enable_status =1 //就算已经删除了,列表上面还是要体现已经删除
sqlCount := fmt.Sprintf(`select count(0)
... ... @@ -160,10 +161,11 @@ func GetChanceMyApproveChanceEnable(uid, cid int64, reviewStatus []int8, lastId
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
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 (
select id,approve_time,approve_data,uid,chance_id,approve_message
from audit_flow_process where uid=? and review_status in (%v) and (?=0 or id<?) and enable_status =1
from audit_flow_process where uid=? and review_status in (%v) and enable_status =1
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
order by process_create_time desc
where (?=0 or unix_timestamp(a.update_at)<?)
order by a.update_at desc
LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) //,update_at process_create_time
sqlCount := fmt.Sprintf(`select count(0)
... ... @@ -477,12 +479,12 @@ limit %v
sqlCount := fmt.Sprintf(`
select count(0) from (
##公司公开的机会
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
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
where company_id = %v and publish_status = 2
UNION
##指定部门-机会公开的部门
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 (
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 (
select DISTINCT chance_id from chance_department where department_id in (%v)
)a inner join chance b on a.chance_id = b.id
UNION
... ... @@ -493,7 +495,7 @@ select count(0) from (
UNION
##我审核
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 (
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 (
select DISTINCT chance_id from audit_flow_process where uid =%v
) a inner join chance b on a.chance_id = b.id
... ...
... ... @@ -1302,7 +1302,15 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
myChances []protocol.ChanceItemOrm
total int
provider *protocol.BaseUserInfo
chance *models.Chance
)
if request.LastId > 0 {
if chance, err = models.GetChanceById(request.LastId); err != nil {
log.Error("机会不存在", request.LastId, err)
return
}
request.LastId = chance.UpdateAt.Unix()
}
if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -1432,7 +1440,15 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
myChances []protocol.ChanceApproveItemOrm
total int
provider *protocol.BaseUserInfo
chance *models.Chance
)
if request.LastId > 0 {
if chance, err = models.GetChanceById(request.LastId); err != nil {
log.Error("审批不存在", request.LastId, err)
return
}
request.LastId = chance.UpdateAt.Unix()
}
if request.ReviewStatus == protocol.ReviewStatusAuditging {
if total, err = models.GetChanceMyApproveChanceEnable(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
... ...