作者 yangfu

机会池统计修改

... ... @@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
sql := `select a.*,b.images,speechs,videos
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 user_id=? and company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
... ... @@ -160,14 +160,14 @@ limit ?
sqlCount := fmt.Sprintf(`select count(0) from (
select id from chance
where user_id=? and company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_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, uid, cid); err != nil {
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
return
}
}
... ...
... ... @@ -766,6 +766,8 @@ func getParentDepartmentors(pid int) (ids []int64) {
func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceStatisticsRequest) (rsp *protocol.ChanceStatisticsResponse, err error) {
var (
chanceType []*models.ChanceType
total int
sum int
)
if chanceType, err = models.GetChanceTypeAll(header.CompanyId); err != nil {
log.Error(err)
... ... @@ -774,12 +776,18 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt
rsp = &protocol.ChanceStatisticsResponse{}
for i := range chanceType {
item := chanceType[i]
if total, err = models.GetChancePool(header.UserId, header.CompanyId, item.Id, 0, 0, nil); err != nil {
log.Error(err)
return
}
sum += total
rsp.List = append(rsp.List, protocol.ChanceTotalItem{
Id: item.Id,
Name: item.Name,
Total: i * 2,
Total: total,
})
}
rsp.ChanceTotal = sum
return
}
... ...