...
|
...
|
@@ -95,6 +95,7 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve |
|
|
var (
|
|
|
items []protocol.CommAchievementItemOrm
|
|
|
participants []*models.AchievementProvider
|
|
|
chances []protocol.SourceChanceItemOrm
|
|
|
)
|
|
|
if err = models.GetCommAchievementItemOrmId(request.Id, &items); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -145,7 +146,50 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve |
|
|
//查看数量
|
|
|
utils.ExecuteSqlByRoll(true, agg.GetIncrementSql((&models.Achievement{}).TableName(), "view_total", 1, request.Id))
|
|
|
|
|
|
if err = models.GetAchievementChances(request.Id, &chances); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
for i := range chances {
|
|
|
chance := chances[i]
|
|
|
commItem := &protocol.CommonListItem{}
|
|
|
commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, chance.CommChanceItemOrm)
|
|
|
//commItem.ChanceTemplate = getTemplate(chance.TemplateId)
|
|
|
//commItem.ChanceType = getChanceType(chance.ChanceTypeId)
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
rsp.SourceChance = append(rsp.SourceChance, commItem)
|
|
|
}
|
|
|
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.SourceChance)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//func GetSourceChance(header ) |
|
|
//设置机会详情
|
|
|
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
|
|
|
} |
...
|
...
|
|