...
|
...
|
@@ -264,23 +264,23 @@ where user_id =?` |
|
|
}
|
|
|
|
|
|
//type4 查看所有机会
|
|
|
func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
|
|
|
sql := `select a.*,b.images,speechs,videos
|
|
|
func GetChancePoolAll(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
sql := fmt.Sprintf(`select a.*,b.images,speechs,videos
|
|
|
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 from chance
|
|
|
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1
|
|
|
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or unix_timestamp(approve_time)<?) and enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
order by create_at desc
|
|
|
limit ?
|
|
|
`
|
|
|
`, filterDepartment)
|
|
|
|
|
|
//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
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
|
|
|
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -293,8 +293,8 @@ where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and ena |
|
|
}
|
|
|
|
|
|
//type3 特定部门机会
|
|
|
func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
|
|
|
func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
...
|
...
|
@@ -318,11 +318,11 @@ select * from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
...
|
...
|
@@ -346,8 +346,8 @@ select count(0) from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 a.enable_status=1 and status=1
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -360,8 +360,8 @@ select count(0) from ( |
|
|
}
|
|
|
|
|
|
//type32 特定部门机会 - 多角色时包含levl2 部门公开
|
|
|
func GetChancePoolDepartment(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {
|
|
|
|
|
|
func GetChancePoolDepartment(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64, userDepartmetIds []int64) (total int, err error) {
|
|
|
var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
...
|
...
|
@@ -393,11 +393,11 @@ select * from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
...
|
...
|
@@ -429,8 +429,8 @@ select count(0) from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 a.enable_status=1 and status=1
|
|
|
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
|
|
|
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -443,7 +443,8 @@ select count(0) from ( |
|
|
}
|
|
|
|
|
|
//type2 对我所在部门公开的机会 公司公开的机会
|
|
|
func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
...
|
...
|
@@ -470,11 +471,11 @@ select * from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
...
|
...
|
@@ -501,8 +502,8 @@ select count(0) from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 a.enable_status=1 and status=1
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -513,9 +514,16 @@ select count(0) from ( |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
func getFilterSqlByDIds(dIds []int) string {
|
|
|
if len(dIds) == 0 {
|
|
|
return ""
|
|
|
}
|
|
|
return fmt.Sprintf(" and department_id in(%v) ", utils.JoinInts(dIds, ","))
|
|
|
}
|
|
|
|
|
|
//type1 禁止查看所有机会
|
|
|
func GetChancePoolMyself(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
func GetChancePoolMyself(uid, cid int64, chanceTypeId int, dIds []int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
var filterDepartment string = getFilterSqlByDIds(dIds)
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
...
|
...
|
@@ -529,11 +537,11 @@ select * from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or unix_timestamp(create_at)<%v) and a.enable_status=1 and status=1 %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, filterDepartment, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
...
|
...
|
@@ -547,8 +555,8 @@ select count(0) from ( |
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) 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 a.enable_status=1 and status=1
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId)
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1 %v
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId, filterDepartment)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -648,3 +656,14 @@ func ExitsChanceByAuditUser(chanceId int64, auditUserId int64) (v *Chance, err e |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//是否存在发布机会的部门编号查询
|
|
|
func GetChanceStatisticByDepartment(companyId int64, departmentIds []int, reviewStatus int) (v int, err error) {
|
|
|
sql := fmt.Sprintf(`select count(0) from chance where company_id=%v and review_status=%v and department_id in (%v)`,
|
|
|
companyId, reviewStatus, utils.JoinInts(departmentIds, ","))
|
|
|
o := orm.NewOrm()
|
|
|
if err = o.Raw(sql).QueryRow(&v); err != nil {
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|