...
|
...
|
@@ -303,11 +303,10 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa |
|
|
//消息中心-机会审核消息
|
|
|
func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanceApproveRequest) (rsp *protocol.MsgChanceApproveResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.MsgChanceApproveItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.MsgChanceApproveItemOrm
|
|
|
total int
|
|
|
)
|
|
|
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -317,49 +316,18 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc |
|
|
}
|
|
|
rsp = &protocol.MsgChanceApproveResponse{Total: total}
|
|
|
rsp.List = make([]protocol.MsgCommonListItem, 0)
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := protocol.MsgCommonListItem{}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
continue
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
}
|
|
|
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = agg.ClearEmptyForm(item.FormList)
|
|
|
utils.JsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
utils.JsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
commItem.Chance = item
|
|
|
}
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
|
|
|
//if chance.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
// var approveData *protocol.ApproveData
|
|
|
// utils.JsonUnmarshal(chance.ApproveData, &approveData)
|
|
|
// if approveData != nil {
|
|
|
// commItem.Score = approveData.Score
|
|
|
// }
|
|
|
//}
|
|
|
commItem.MsgId = chance.Id
|
|
|
commItem.MsgTime = chance.MsgTime.Unix() * 1000
|
|
|
commItem.MsgId = ormItem.Id
|
|
|
commItem.MsgTime = ormItem.MsgTime.Unix() * 1000
|
|
|
//审核完有审核数据
|
|
|
commItem.Message = chance.Message
|
|
|
commItem.IsRead = chance.IsRead == 1
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
commItem.Message = ormItem.Message
|
|
|
commItem.IsRead = ormItem.IsRead == 1
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -368,11 +336,10 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc |
|
|
// 消息中心-我提交的
|
|
|
func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChanceSubmitRequest) (rsp *protocol.MsgChanceSubmitResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.MsgChanceApproveItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.MsgChanceApproveItemOrm
|
|
|
)
|
|
|
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAuditBy, &myChances); err != nil {
|
|
|
rsp = &protocol.MsgChanceSubmitResponse{List: make([]protocol.MsgCommonListItem, 0)}
|
|
|
if rsp.Total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAuditBy, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -380,62 +347,33 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.MsgChanceSubmitResponse{Total: total}
|
|
|
rsp.List = make([]protocol.MsgCommonListItem, 0)
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := protocol.MsgCommonListItem{}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
approveUserId := chance.ChanceUserId
|
|
|
if chance.SenderUserId != 0 {
|
|
|
approveUserId = chance.SenderUserId
|
|
|
}
|
|
|
if provider, err = agg.GetUserBaseInfo(approveUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
continue
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.ChanceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
}
|
|
|
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = agg.ClearEmptyForm(item.FormList)
|
|
|
utils.JsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
utils.JsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
commItem.Chance = item
|
|
|
|
|
|
//注:此处是审核人的用户信息
|
|
|
if ormItem.SenderUserId != 0 {
|
|
|
ormItem.CommChanceItemOrm.ChanceUserId = ormItem.SenderUserId
|
|
|
}
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
|
|
|
//if chance.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
// var approveData *protocol.ApproveData
|
|
|
// utils.JsonUnmarshal(chance.ApproveData, &approveData)
|
|
|
// if approveData != nil {
|
|
|
// commItem.Score = approveData.Score
|
|
|
// }
|
|
|
//}
|
|
|
if len(chance.Data) > 0 && chance.ReviewStatus != protocol.ReviewStatusReturn { //获取评分 && chance.ReviewStatus == protocol.ReviewStatusPass
|
|
|
//审核数据
|
|
|
if len(ormItem.Data) > 0 && ormItem.ReviewStatus != protocol.ReviewStatusReturn { //获取评分 && chance.ReviewStatus == protocol.ReviewStatusPass
|
|
|
var msgData *protocol.MsgData
|
|
|
utils.JsonUnmarshal(chance.Data, &msgData)
|
|
|
utils.JsonUnmarshal(ormItem.Data, &msgData)
|
|
|
commItem.Score = msgData.Score
|
|
|
}
|
|
|
commItem.IsRead = chance.IsRead == 1
|
|
|
//审核完有审核数据
|
|
|
commItem.Message = chance.Message
|
|
|
commItem.MsgId = chance.Id
|
|
|
commItem.MsgTime = chance.MsgTime.Unix() * 1000
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
if commItem.ChanceId == 0 && chance.SourceId > 0 {
|
|
|
commItem.ChanceId = chance.SourceId
|
|
|
|
|
|
//消息基础数据
|
|
|
commItem.IsRead = ormItem.IsRead == 1
|
|
|
commItem.Message = ormItem.Message
|
|
|
commItem.MsgId = ormItem.Id
|
|
|
commItem.MsgTime = ormItem.MsgTime.Unix() * 1000
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
if commItem.ChanceId == 0 && ormItem.SourceId > 0 {
|
|
|
commItem.ChanceId = ormItem.SourceId
|
|
|
}
|
|
|
rsp.List = append(rsp.List, commItem) //非指针 append对象完 再修改数据也是无效
|
|
|
}
|
...
|
...
|
@@ -445,11 +383,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance |
|
|
// 消息中心-互动消息.评论
|
|
|
func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanceCommentRequest) (rsp *protocol.MsgChanceCommentResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceCommentItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.ChanceCommentItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeComment, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeComment, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -459,66 +397,46 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc |
|
|
}
|
|
|
rsp = &protocol.MsgChanceCommentResponse{Total: total}
|
|
|
rsp.List = make([]protocol.MsgCommonListItem, 0)
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := protocol.MsgCommonListItem{}
|
|
|
if chance.SourceType == protocol.SourceTypeChance {
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if chance.ChanceUserId > 0 {
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
//return
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.SourceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
}
|
|
|
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = protocol.ClearEmptyForm(item.FormList)
|
|
|
utils.JsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
utils.JsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
commItem.Chance = item
|
|
|
}
|
|
|
}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if ormItem.SourceType == protocol.SourceTypeChance {
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
}
|
|
|
if chance.SourceType == protocol.SourceTypeComment {
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.CommentedUserId, header.CompanyId); err != nil {
|
|
|
|
|
|
//被评论内容
|
|
|
if ormItem.SourceType == protocol.SourceTypeComment {
|
|
|
if provider, err = agg.GetUserBaseInfo(ormItem.CommentedUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
//return
|
|
|
}
|
|
|
commItem.CommentedData = protocol.CommentData{
|
|
|
Id: chance.SourceId,
|
|
|
Content: chance.CommentedContent,
|
|
|
CommentTime: chance.CommentedTime.Unix() * 1000,
|
|
|
Id: ormItem.SourceId,
|
|
|
Content: ormItem.CommentedContent,
|
|
|
CommentTime: ormItem.CommentedTime.Unix() * 1000,
|
|
|
Provider: provider,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//评论内容
|
|
|
comment := protocol.CommentData{
|
|
|
Id: chance.CommentId,
|
|
|
CommentTime: chance.CommentTime.Unix() * 1000,
|
|
|
Content: chance.CommentContent,
|
|
|
Id: ormItem.CommentId,
|
|
|
CommentTime: ormItem.CommentTime.Unix() * 1000,
|
|
|
Content: ormItem.CommentContent,
|
|
|
//Provider: provider,
|
|
|
}
|
|
|
comment.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
|
|
|
comment.Provider, _ = agg.GetUserBaseInfo(ormItem.SenderUserId, header.CompanyId)
|
|
|
commItem.CommentData = comment
|
|
|
commItem.IsRead = chance.IsRead == 1
|
|
|
commItem.SourceType = chance.SourceType
|
|
|
commItem.MsgId = chance.CommentId
|
|
|
commItem.MsgTime = chance.CommentTime.Unix() * 1000
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
|
|
|
//消息基础内容
|
|
|
commItem.IsRead = ormItem.IsRead == 1
|
|
|
commItem.SourceType = ormItem.SourceType
|
|
|
commItem.MsgId = ormItem.CommentId
|
|
|
commItem.MsgTime = ormItem.CommentTime.Unix() * 1000
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -527,11 +445,11 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc |
|
|
//消息中心-互动消息.点赞
|
|
|
func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanceThumbUpRequest) (rsp *protocol.MsgChanceThumbUpResponse, err error) {
|
|
|
var (
|
|
|
myChances []protocol.ChanceCommentItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
ormItems []protocol.ChanceCommentItemOrm
|
|
|
total int
|
|
|
provider *protocol.BaseUserInfo
|
|
|
)
|
|
|
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeThumbUp, &myChances); err != nil {
|
|
|
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeThumbUp, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -541,65 +459,44 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc |
|
|
}
|
|
|
rsp = &protocol.MsgChanceThumbUpResponse{Total: total}
|
|
|
rsp.List = make([]protocol.MsgCommonListItem, 0)
|
|
|
for i := 0; i < len(myChances); i++ {
|
|
|
chance := myChances[i]
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := protocol.MsgCommonListItem{}
|
|
|
if chance.SourceType == protocol.SourceTypeChance {
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if len(chance.SourceContent) == 0 { //机会删除
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
} else if chance.ChanceEnableStatus == 0 { //机会关闭
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusClose
|
|
|
}
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
//return
|
|
|
} else {
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.SourceId,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
}
|
|
|
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = protocol.ClearEmptyForm(item.FormList)
|
|
|
utils.JsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
utils.JsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
commItem.Chance = item
|
|
|
}
|
|
|
commItem.ReviewStatus = chance.ReviewStatus
|
|
|
if ormItem.SourceType == protocol.SourceTypeChance {
|
|
|
commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.ReviewStatus = ormItem.ReviewStatus
|
|
|
}
|
|
|
if chance.SourceType == protocol.SourceTypeComment {
|
|
|
if provider, err = agg.GetUserBaseInfo(chance.CommentedUserId, header.CompanyId); err != nil {
|
|
|
|
|
|
//点赞评论的内容
|
|
|
if ormItem.SourceType == protocol.SourceTypeComment {
|
|
|
if provider, err = agg.GetUserBaseInfo(ormItem.CommentedUserId, header.CompanyId); err != nil {
|
|
|
commItem.ChanceStatus = protocol.ChanceStatusDelete
|
|
|
log.Error(err)
|
|
|
//return
|
|
|
}
|
|
|
commItem.CommentedData = protocol.CommentData{
|
|
|
Id: chance.SourceId,
|
|
|
Content: chance.CommentedContent,
|
|
|
CommentTime: chance.CommentedTime.Unix() * 1000,
|
|
|
Id: ormItem.SourceId,
|
|
|
Content: ormItem.CommentedContent,
|
|
|
CommentTime: ormItem.CommentedTime.Unix() * 1000,
|
|
|
Provider: provider,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//点赞数据
|
|
|
thumb := protocol.ThumbUpData{
|
|
|
Id: chance.CommentId,
|
|
|
ThumbUpTime: chance.CommentTime.Unix() * 1000,
|
|
|
Content: chance.CommentContent,
|
|
|
Id: ormItem.CommentId,
|
|
|
ThumbUpTime: ormItem.CommentTime.Unix() * 1000,
|
|
|
Content: ormItem.CommentContent,
|
|
|
//Provider: provider,
|
|
|
}
|
|
|
thumb.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
|
|
|
thumb.Provider, _ = agg.GetUserBaseInfo(ormItem.SenderUserId, header.CompanyId)
|
|
|
commItem.ThumbUpData = thumb
|
|
|
commItem.IsRead = chance.IsRead == 1
|
|
|
commItem.SourceType = chance.SourceType
|
|
|
commItem.MsgId = chance.CommentId
|
|
|
commItem.MsgTime = chance.CommentTime.Unix() * 1000
|
|
|
commItem.ChanceId = chance.ChanceId
|
|
|
|
|
|
//消息基础数据
|
|
|
commItem.IsRead = ormItem.IsRead == 1
|
|
|
commItem.SourceType = ormItem.SourceType
|
|
|
commItem.MsgId = ormItem.CommentId
|
|
|
commItem.MsgTime = ormItem.CommentTime.Unix() * 1000
|
|
|
commItem.ChanceId = ormItem.ChanceId
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
...
|
...
|
|