...
|
...
|
@@ -43,7 +43,11 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme |
|
|
for i := range ormItems {
|
|
|
item := ormItems[i]
|
|
|
rspItem := &protocol.AchievementCommonListItem{
|
|
|
Achievement: GetAchievementItem(header, item),
|
|
|
Achievement: GetAchievementItem(header, item),
|
|
|
GraspScore: protocol.GraspScore{
|
|
|
GraspScore: item.GraspScore,
|
|
|
GraspScorePercent: item.GraspScore,
|
|
|
},
|
|
|
StatisticData: GetStatisticData(header, item.StaticDataOrm, item.AchievementId),
|
|
|
ChanceTemplate: getTemplate(item.TemplateId),
|
|
|
ChanceType: getChanceType(item.ChanceTypeId),
|
...
|
...
|
@@ -65,12 +69,12 @@ func GetAchievementItem(header *protocol.RequestHeader, from protocol.CommAchiev |
|
|
return
|
|
|
} else {
|
|
|
item = protocol.AchievementItem{
|
|
|
Id: from.AchievementId,
|
|
|
Provider: provider,
|
|
|
CreateTime: from.CreateTime.Unix() * 1000,
|
|
|
Content: from.SourceContent,
|
|
|
GraspScore: from.GraspScore,
|
|
|
GraspScorePercent: from.GraspScore,
|
|
|
Id: from.AchievementId,
|
|
|
Provider: provider,
|
|
|
CreateTime: from.CreateTime.Unix() * 1000,
|
|
|
Content: from.SourceContent,
|
|
|
//GraspScore: from.GraspScore,
|
|
|
//GraspScorePercent: from.GraspScore,
|
|
|
}
|
|
|
jsonUnmarshal(from.Images, &item.Pictures)
|
|
|
}
|
...
|
...
|
@@ -127,6 +131,10 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve |
|
|
rsp = &protocol.AchievementDetailResponse{}
|
|
|
{
|
|
|
rsp.Achievement = GetAchievementItem(header, item)
|
|
|
rsp.GraspScore = protocol.GraspScore{
|
|
|
GraspScore: item.GraspScore,
|
|
|
GraspScorePercent: item.GraspScore,
|
|
|
}
|
|
|
rsp.StatisticData = GetStatisticData(header, item.StaticDataOrm, item.AchievementId)
|
|
|
rsp.ChanceTemplate = getTemplate(item.TemplateId)
|
|
|
rsp.ChanceType = getChanceType(item.ChanceTypeId)
|
...
|
...
|
@@ -138,10 +146,12 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve |
|
|
}
|
|
|
newParticipant := func(user *protocol.BaseUserInfo, score float64, t int) protocol.UserGraspInfo {
|
|
|
return protocol.UserGraspInfo{
|
|
|
Provider: user,
|
|
|
GraspScore: score,
|
|
|
GraspScorePercent: score,
|
|
|
Type: t,
|
|
|
Provider: user,
|
|
|
GraspScore: protocol.GraspScore{
|
|
|
GraspScore: score,
|
|
|
GraspScorePercent: score,
|
|
|
},
|
|
|
Type: t,
|
|
|
}
|
|
|
}
|
|
|
addParticipants := func(item protocol.UserGraspInfo) {
|
...
|
...
|
@@ -168,43 +178,16 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve |
|
|
for i := range chances {
|
|
|
chance := chances[i]
|
|
|
commItem := &protocol.CommonListItem{}
|
|
|
commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, chance.CommChanceItemOrm)
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, chance.CommChanceItemOrm)
|
|
|
//commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
//commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
//commItem.Score=protocol.GraspScore{
|
|
|
// GraspScore:chance.,
|
|
|
// GraspScorePercent:chance.GraspScore,
|
|
|
//}
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
rsp.SourceChance = append(rsp.SourceChance, commItem)
|
|
|
}
|
|
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.SourceChance)
|
|
|
return
|
|
|
} |
|
|
|
|
|
//设置机会详情
|
|
|
func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceItemOrm) (item protocol.ChanceItem, chanceStatus int) {
|
|
|
var provider *protocol.BaseUserInfo
|
|
|
var err error
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
chanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除
|
|
|
chanceStatus = protocol.ChanceStatusDelete
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose { //机会关闭
|
|
|
chanceStatus = protocol.ChanceStatusClose
|
|
|
return
|
|
|
}
|
|
|
|
|
|
item = protocol.ChanceItem{
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
//PublicStatus: chance.PublishStatus,
|
|
|
}
|
|
|
jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = clearEmptyForm(item.FormList)
|
|
|
jsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
jsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
jsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
return item, chanceStatus
|
|
|
} |
...
|
...
|
|