作者 yangfu

机会池排序

... ... @@ -268,15 +268,16 @@ func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize i
from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1 and status=1
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
`
//if public==protocol.pu
sqlCount := fmt.Sprintf(`select count(0) from (
select id from chance
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1
order by create_at desc
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
return
... ... @@ -316,9 +317,9 @@ select * from (
) a inner join chance b on a.chance_id = b.id
) 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
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
) a left JOIN chance_data b on a.id =b.chance_id
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
sqlCount := fmt.Sprintf(`
... ... @@ -389,9 +390,9 @@ select * from (
) a inner join chance b on a.chance_id = b.id
) 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
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
) a left JOIN chance_data b on a.id =b.chance_id
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
sqlCount := fmt.Sprintf(`
... ... @@ -462,9 +463,9 @@ select * from (
) a inner join chance b on a.chance_id = b.id
) 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
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
) a left JOIN chance_data b on a.id =b.chance_id
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
sqlCount := fmt.Sprintf(`
... ... @@ -519,9 +520,9 @@ select * from (
) a inner join chance b on a.chance_id = b.id
) 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
) a left JOIN chance_data b on a.id =b.chance_id
order by create_at desc
limit %v
) a left JOIN chance_data b on a.id =b.chance_id
`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
sqlCount := fmt.Sprintf(`
... ...