正在显示
11 个修改的文件
包含
377 行增加
和
70 行删除
| @@ -242,3 +242,24 @@ func (this *MessageController) MsgChanceThumbUp() { | @@ -242,3 +242,24 @@ func (this *MessageController) MsgChanceThumbUp() { | ||
| 242 | header := controllers.GetRequestHeader(this.Ctx) | 242 | header := controllers.GetRequestHeader(this.Ctx) |
| 243 | msg = protocol.NewReturnResponse(message.MsgChanceThumbUp(header, request)) | 243 | msg = protocol.NewReturnResponse(message.MsgChanceThumbUp(header, request)) |
| 244 | } | 244 | } |
| 245 | + | ||
| 246 | +//MsgChanceRevise 消息中心-机会补充 | ||
| 247 | +//@router /msgChanceRevise [post] | ||
| 248 | +func (this *MessageController) MsgChanceRevise() { | ||
| 249 | + var msg *protocol.ResponseMessage | ||
| 250 | + defer func() { | ||
| 251 | + this.Resp(msg) | ||
| 252 | + }() | ||
| 253 | + var request *protocol.MsgChanceReviseRequest | ||
| 254 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
| 255 | + log.Error(err) | ||
| 256 | + msg = protocol.BadRequestParam(1) | ||
| 257 | + return | ||
| 258 | + } | ||
| 259 | + if b, m := this.Valid(request); !b { | ||
| 260 | + msg = m | ||
| 261 | + return | ||
| 262 | + } | ||
| 263 | + header := controllers.GetRequestHeader(this.Ctx) | ||
| 264 | + msg = protocol.NewReturnResponse(message.MsgChanceRevise(header, request)) | ||
| 265 | +} |
models/chance_revise_log.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "github.com/astaxie/beego/orm" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +type ChanceReviseLog struct { | ||
| 10 | + Id int64 `orm:"column(id);pk" description:"id 主键"` | ||
| 11 | + ChanceId int64 `orm:"column(chance_id)" description:"机会编号"` | ||
| 12 | + UserCompanyId int64 `orm:"column(user_company_id);null" description:"用户编号 编辑机会的人"` | ||
| 13 | + Data string `orm:"column(data);null" description:"机会数据"` | ||
| 14 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (t *ChanceReviseLog) TableName() string { | ||
| 18 | + return "chance_revise_log" | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func init() { | ||
| 22 | + orm.RegisterModel(new(ChanceReviseLog)) | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +// AddChanceReviseLog insert a new ChanceReviseLog into database and returns | ||
| 26 | +// last inserted Id on success. | ||
| 27 | +func AddChanceReviseLog(m *ChanceReviseLog) (id int64, err error) { | ||
| 28 | + o := orm.NewOrm() | ||
| 29 | + id, err = o.Insert(m) | ||
| 30 | + return | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +// GetChanceReviseLogById retrieves ChanceReviseLog by Id. Returns error if | ||
| 34 | +// Id doesn't exist | ||
| 35 | +func GetChanceReviseLogById(id int64) (v *ChanceReviseLog, err error) { | ||
| 36 | + o := orm.NewOrm() | ||
| 37 | + v = &ChanceReviseLog{Id: id} | ||
| 38 | + if err = o.Read(v); err == nil { | ||
| 39 | + return v, nil | ||
| 40 | + } | ||
| 41 | + return nil, err | ||
| 42 | +} |
| @@ -9,13 +9,18 @@ const ( | @@ -9,13 +9,18 @@ const ( | ||
| 9 | 9 | ||
| 10 | //成果项 | 10 | //成果项 |
| 11 | type AchievementItem struct { | 11 | type AchievementItem struct { |
| 12 | - Id int64 `json:"id"` | ||
| 13 | - CreateTime int64 `json:"createTime"` | ||
| 14 | - Provider *BaseUserInfo `json:"provider"` | ||
| 15 | - Content string `json:"content"` | ||
| 16 | - Pictures []Picture `json:"pictures"` | ||
| 17 | - GraspScore float64 `json:"graspScore"` //把握分 | ||
| 18 | - GraspScorePercent float64 `json:"graspScorePercent"` //把握分百分比 | 12 | + Id int64 `json:"id"` |
| 13 | + CreateTime int64 `json:"createTime"` | ||
| 14 | + Provider *BaseUserInfo `json:"provider"` | ||
| 15 | + Content string `json:"content"` | ||
| 16 | + Pictures []Picture `json:"pictures"` | ||
| 17 | + //GraspScore float64 `json:"graspScore"` //把握分 | ||
| 18 | + //GraspScorePercent float64 `json:"graspScorePercent"` //把握分百分比 | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +type GraspScore struct { | ||
| 22 | + GraspScore float64 `json:"graspScore"` //把握分 | ||
| 23 | + GraspScorePercent float64 `json:"graspScorePercent"` //把握分百分比 | ||
| 19 | } | 24 | } |
| 20 | 25 | ||
| 21 | //机会列表 通用项 | 26 | //机会列表 通用项 |
| @@ -23,7 +28,8 @@ type AchievementCommonListItem struct { | @@ -23,7 +28,8 @@ type AchievementCommonListItem struct { | ||
| 23 | Achievement AchievementItem `json:"achievement,omitempty"` //成果详情 | 28 | Achievement AchievementItem `json:"achievement,omitempty"` //成果详情 |
| 24 | StatisticData interface{} `json:"statisticData,omitempty"` //统计数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData | 29 | StatisticData interface{} `json:"statisticData,omitempty"` //统计数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData |
| 25 | //我审核的-通过 | 30 | //我审核的-通过 |
| 26 | - Score interface{} `json:"score,omitempty"` | 31 | + Score interface{} `json:"score,omitempty"` |
| 32 | + GraspScore interface{} `json:"graspScore,omitempty"` //把握分 | ||
| 27 | //模板 | 33 | //模板 |
| 28 | ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 | 34 | ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 |
| 29 | ChanceTemplate interface{} `json:"template,omitempty"` //机会模板 | 35 | ChanceTemplate interface{} `json:"template,omitempty"` //机会模板 |
| @@ -96,6 +102,7 @@ type AchievementDetailRequest struct { | @@ -96,6 +102,7 @@ type AchievementDetailRequest struct { | ||
| 96 | } | 102 | } |
| 97 | type AchievementDetailResponse struct { | 103 | type AchievementDetailResponse struct { |
| 98 | Achievement AchievementItem `json:"achievement,omitempty"` //成果详情 | 104 | Achievement AchievementItem `json:"achievement,omitempty"` //成果详情 |
| 105 | + GraspScore interface{} `json:"graspScore,omitempty"` //把握分 | ||
| 99 | StatisticData interface{} `json:"statisticData,omitempty"` //统计数据(是否收藏/点赞 浏览数 点赞总数 评论数 | 106 | StatisticData interface{} `json:"statisticData,omitempty"` //统计数据(是否收藏/点赞 浏览数 点赞总数 评论数 |
| 100 | //模板 | 107 | //模板 |
| 101 | ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 | 108 | ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 |
| @@ -106,10 +113,10 @@ type AchievementDetailResponse struct { | @@ -106,10 +113,10 @@ type AchievementDetailResponse struct { | ||
| 106 | } | 113 | } |
| 107 | 114 | ||
| 108 | type UserGraspInfo struct { | 115 | type UserGraspInfo struct { |
| 109 | - Provider *BaseUserInfo `json:"provider"` | ||
| 110 | - GraspScore float64 `json:"graspScore"` //把握分 | ||
| 111 | - GraspScorePercent float64 `json:"graspScorePercent"` //把握分百分比 | ||
| 112 | - Type int `json:"type"` //1:把握人 2:提供者 | 116 | + Provider *BaseUserInfo `json:"provider"` |
| 117 | + GraspScore GraspScore `json:"graspScore"` //把握分 | ||
| 118 | + //GraspScorePercent float64 `json:"graspScorePercent"` //把握分百分比 | ||
| 119 | + Type int `json:"type"` //1:把握人 2:提供者 | ||
| 113 | } | 120 | } |
| 114 | 121 | ||
| 115 | type SourceChanceItemOrm struct { | 122 | type SourceChanceItemOrm struct { |
| @@ -332,6 +332,24 @@ type ChanceCommentItemOrm struct { | @@ -332,6 +332,24 @@ type ChanceCommentItemOrm struct { | ||
| 332 | SenderUserId int64 `orm:"column(sender_user_id)"` | 332 | SenderUserId int64 `orm:"column(sender_user_id)"` |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | +//我的评论 | ||
| 336 | +type ChanceReviseItemOrm struct { | ||
| 337 | + CommChanceItemOrm | ||
| 338 | + MsgItemOrm | ||
| 339 | +} | ||
| 340 | + | ||
| 341 | +//消息 | ||
| 342 | +type MsgItemOrm struct { | ||
| 343 | + MsgId int64 `orm:"column(msg_id)"` | ||
| 344 | + MsgTime time.Time `orm:"column(msg_time)"` //收藏时间 | ||
| 345 | + //评论对象类型 | ||
| 346 | + SourceType int `orm:"column(source_type)"` | ||
| 347 | + SourceId int64 `orm:"column(source_id)"` | ||
| 348 | + IsRead int64 `orm:"column(is_read)"` | ||
| 349 | + ReceiveUserId int64 `orm:"column(receive_user_id)"` | ||
| 350 | + SenderUserId int64 `orm:"column(sender_user_id)"` | ||
| 351 | +} | ||
| 352 | + | ||
| 335 | //通用 机会orm对象 | 353 | //通用 机会orm对象 |
| 336 | type CommChanceItemOrm struct { | 354 | type CommChanceItemOrm struct { |
| 337 | ChanceId int64 `orm:"column(chance_id)"` | 355 | ChanceId int64 `orm:"column(chance_id)"` |
| @@ -543,12 +561,17 @@ type MsgCommonListItem struct { | @@ -543,12 +561,17 @@ type MsgCommonListItem struct { | ||
| 543 | //我评论的 评论数据 | 561 | //我评论的 评论数据 |
| 544 | CommentedData interface{} `json:"commentedData,omitempty"` | 562 | CommentedData interface{} `json:"commentedData,omitempty"` |
| 545 | 563 | ||
| 546 | - SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论 | ||
| 547 | - ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭 | ||
| 548 | - ReviewStatus int `json:"reviewStatus"` //审核状态 | 564 | + SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论 |
| 565 | + SourceId int64 `json:"sourceId,omitempty"` //类型 1:机会 2:评论 | ||
| 566 | + ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭 | ||
| 567 | + ReviewStatus int `json:"reviewStatus"` //审核状态 | ||
| 549 | 568 | ||
| 550 | - IsRead bool `json:"isRead"` | ||
| 551 | - ChanceId int64 `json:"chanceId"` //机会编号 | 569 | + IsRead bool `json:"isRead"` |
| 570 | + ChanceId int64 `json:"chanceId"` //机会编号 | ||
| 571 | + ChanceReviseLogId int64 `json:"chanceReviseLogId,omitempty"` //机会补充编号 | ||
| 572 | +} | ||
| 573 | + | ||
| 574 | +type MsgItem struct { | ||
| 552 | } | 575 | } |
| 553 | type ChanceItem struct { | 576 | type ChanceItem struct { |
| 554 | Id int64 `json:"id"` | 577 | Id int64 `json:"id"` |
| @@ -3,9 +3,10 @@ package protocol | @@ -3,9 +3,10 @@ package protocol | ||
| 3 | const ( | 3 | const ( |
| 4 | SourceTypeChance = 1 //机会 | 4 | SourceTypeChance = 1 //机会 |
| 5 | SourceTypeComment = 2 //机会评论 | 5 | SourceTypeComment = 2 //机会评论 |
| 6 | - SourceTypeBulletin = 3 | 6 | + SourceTypeBulletin = 3 //公告 |
| 7 | SourceTypeAchievement = 4 //成果 | 7 | SourceTypeAchievement = 4 //成果 |
| 8 | SourceTypeAchievementComment = 5 //成果评论 | 8 | SourceTypeAchievementComment = 5 //成果评论 |
| 9 | + SourceTypeChanceReviseLog = 6 //机会变更 | ||
| 9 | ) | 10 | ) |
| 10 | 11 | ||
| 11 | /*IComment */ | 12 | /*IComment */ |
| @@ -65,13 +65,14 @@ var errmessge ErrorMap = map[int]string{ | @@ -65,13 +65,14 @@ var errmessge ErrorMap = map[int]string{ | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | const ( | 67 | const ( |
| 68 | - MsgTypeBulletin = 1 //公告 | ||
| 69 | - MsgTypeCommend = 2 //表彰 | ||
| 70 | - MsgTypeInteraction = 4 //互动消息 | ||
| 71 | - MsgTypeAudit = 8 //机会审核 | ||
| 72 | - MsgTypeAuditBy = 16 //机会被审核消息-我提交的 | ||
| 73 | - MsgTypeComment = 32 //评论 | ||
| 74 | - MsgTypeThumbUp = 64 //点赞 | 68 | + MsgTypeBulletin = 1 //公告 |
| 69 | + MsgTypeCommend = 2 //表彰 | ||
| 70 | + MsgTypeInteraction = 4 //互动消息 | ||
| 71 | + MsgTypeAudit = 8 //机会审核 | ||
| 72 | + MsgTypeAuditBy = 16 //机会被审核消息-我提交的 | ||
| 73 | + MsgTypeComment = 32 //评论 | ||
| 74 | + MsgTypeThumbUp = 64 //点赞 | ||
| 75 | + MsgTypeChanceRevise = 128 //补充机会 | ||
| 75 | ) | 76 | ) |
| 76 | 77 | ||
| 77 | var ( | 78 | var ( |
| @@ -79,8 +80,9 @@ var ( | @@ -79,8 +80,9 @@ var ( | ||
| 79 | MessageApproveSuccess = "审核通过您提交的%v机会" | 80 | MessageApproveSuccess = "审核通过您提交的%v机会" |
| 80 | MessageApproveReject = "退回了您提交的%v机会" | 81 | MessageApproveReject = "退回了您提交的%v机会" |
| 81 | 82 | ||
| 82 | - MessageZanChance = "点赞了您发布的机会" | ||
| 83 | - MessageZanComment = "点赞了您发布的评论" | 83 | + MessageZanChance = "点赞了您发布的机会" |
| 84 | + MessageZanComment = "点赞了您发布的评论" | ||
| 85 | + MessageChanceRevise = "补充了您发布的%v机会信息" | ||
| 84 | ) | 86 | ) |
| 85 | 87 | ||
| 86 | /*MessageCenter */ | 88 | /*MessageCenter */ |
| @@ -258,6 +260,16 @@ type MsgChanceThumbUpResponse struct { | @@ -258,6 +260,16 @@ type MsgChanceThumbUpResponse struct { | ||
| 258 | Total int `json:"total"` | 260 | Total int `json:"total"` |
| 259 | } | 261 | } |
| 260 | 262 | ||
| 263 | +/*MsgChanceRevise 消息中心-机会补充*/ | ||
| 264 | +type MsgChanceReviseRequest struct { | ||
| 265 | + LastId int64 `json:"lastId"` | ||
| 266 | + PageSize int `json:"pageSize" valid:"Required"` | ||
| 267 | +} | ||
| 268 | +type MsgChanceReviseResponse struct { | ||
| 269 | + List []MsgCommonListItem `json:"list"` | ||
| 270 | + Total int `json:"total"` | ||
| 271 | +} | ||
| 272 | + | ||
| 261 | //我的审核机会列表 | 273 | //我的审核机会列表 |
| 262 | type MsgChanceApproveItemOrm struct { | 274 | type MsgChanceApproveItemOrm struct { |
| 263 | ChanceUserId int64 `orm:"column(chance_user_id)"` | 275 | ChanceUserId int64 `orm:"column(chance_user_id)"` |
| @@ -393,6 +393,14 @@ func init() { | @@ -393,6 +393,14 @@ func init() { | ||
| 393 | 393 | ||
| 394 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | 394 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], |
| 395 | beego.ControllerComments{ | 395 | beego.ControllerComments{ |
| 396 | + Method: "MsgChanceRevise", | ||
| 397 | + Router: `/msgChanceRevise`, | ||
| 398 | + AllowHTTPMethods: []string{"post"}, | ||
| 399 | + MethodParams: param.Make(), | ||
| 400 | + Params: nil}) | ||
| 401 | + | ||
| 402 | + beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | ||
| 403 | + beego.ControllerComments{ | ||
| 396 | Method: "MsgChanceSubmit", | 404 | Method: "MsgChanceSubmit", |
| 397 | Router: `/msgChanceSubmit`, | 405 | Router: `/msgChanceSubmit`, |
| 398 | AllowHTTPMethods: []string{"post"}, | 406 | AllowHTTPMethods: []string{"post"}, |
| @@ -3,6 +3,7 @@ package agg | @@ -3,6 +3,7 @@ package agg | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | + "opp/internal/utils" | ||
| 6 | "opp/models" | 7 | "opp/models" |
| 7 | "opp/protocol" | 8 | "opp/protocol" |
| 8 | ) | 9 | ) |
| @@ -197,3 +198,41 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | @@ -197,3 +198,41 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | ||
| 197 | } | 198 | } |
| 198 | return | 199 | return |
| 199 | } | 200 | } |
| 201 | + | ||
| 202 | +//设置机会详情 | ||
| 203 | +func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceItemOrm) (item protocol.ChanceItem, chanceStatus int) { | ||
| 204 | + var provider *protocol.BaseUserInfo | ||
| 205 | + var err error | ||
| 206 | + if provider, err = GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | ||
| 207 | + chanceStatus = protocol.ChanceStatusDelete | ||
| 208 | + log.Error(err) | ||
| 209 | + return | ||
| 210 | + } | ||
| 211 | + if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除 | ||
| 212 | + chanceStatus = protocol.ChanceStatusDelete | ||
| 213 | + } | ||
| 214 | + if chance.Status == models.ChanceStatusClose { //机会关闭 | ||
| 215 | + chanceStatus = protocol.ChanceStatusClose | ||
| 216 | + return | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + item = protocol.ChanceItem{ | ||
| 220 | + Id: chance.ChanceId, | ||
| 221 | + Provider: provider, | ||
| 222 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
| 223 | + //PublicStatus: chance.PublishStatus, | ||
| 224 | + } | ||
| 225 | + utils.JsonUnmarshal(chance.SourceContent, &item.FormList) | ||
| 226 | + item.FormList = ClearEmptyForm(item.FormList) | ||
| 227 | + utils.JsonUnmarshal(chance.Images, &item.Pictures) | ||
| 228 | + utils.JsonUnmarshal(chance.Voices, &item.Speechs) | ||
| 229 | + utils.JsonUnmarshal(chance.Videos, &item.Videos) | ||
| 230 | + return item, chanceStatus | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commItem *protocol.MsgCommonListItem) { | ||
| 234 | + commItem.MsgId = msg.MsgId | ||
| 235 | + commItem.MsgTime = msg.MsgTime.Unix() * 1000 | ||
| 236 | + commItem.IsRead = msg.IsRead == 1 | ||
| 237 | + commItem.SourceId = msg.SourceId | ||
| 238 | +} |
| @@ -43,7 +43,11 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme | @@ -43,7 +43,11 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme | ||
| 43 | for i := range ormItems { | 43 | for i := range ormItems { |
| 44 | item := ormItems[i] | 44 | item := ormItems[i] |
| 45 | rspItem := &protocol.AchievementCommonListItem{ | 45 | rspItem := &protocol.AchievementCommonListItem{ |
| 46 | - Achievement: GetAchievementItem(header, item), | 46 | + Achievement: GetAchievementItem(header, item), |
| 47 | + GraspScore: protocol.GraspScore{ | ||
| 48 | + GraspScore: item.GraspScore, | ||
| 49 | + GraspScorePercent: item.GraspScore, | ||
| 50 | + }, | ||
| 47 | StatisticData: GetStatisticData(header, item.StaticDataOrm, item.AchievementId), | 51 | StatisticData: GetStatisticData(header, item.StaticDataOrm, item.AchievementId), |
| 48 | ChanceTemplate: getTemplate(item.TemplateId), | 52 | ChanceTemplate: getTemplate(item.TemplateId), |
| 49 | ChanceType: getChanceType(item.ChanceTypeId), | 53 | ChanceType: getChanceType(item.ChanceTypeId), |
| @@ -65,12 +69,12 @@ func GetAchievementItem(header *protocol.RequestHeader, from protocol.CommAchiev | @@ -65,12 +69,12 @@ func GetAchievementItem(header *protocol.RequestHeader, from protocol.CommAchiev | ||
| 65 | return | 69 | return |
| 66 | } else { | 70 | } else { |
| 67 | item = protocol.AchievementItem{ | 71 | item = protocol.AchievementItem{ |
| 68 | - Id: from.AchievementId, | ||
| 69 | - Provider: provider, | ||
| 70 | - CreateTime: from.CreateTime.Unix() * 1000, | ||
| 71 | - Content: from.SourceContent, | ||
| 72 | - GraspScore: from.GraspScore, | ||
| 73 | - GraspScorePercent: from.GraspScore, | 72 | + Id: from.AchievementId, |
| 73 | + Provider: provider, | ||
| 74 | + CreateTime: from.CreateTime.Unix() * 1000, | ||
| 75 | + Content: from.SourceContent, | ||
| 76 | + //GraspScore: from.GraspScore, | ||
| 77 | + //GraspScorePercent: from.GraspScore, | ||
| 74 | } | 78 | } |
| 75 | jsonUnmarshal(from.Images, &item.Pictures) | 79 | jsonUnmarshal(from.Images, &item.Pictures) |
| 76 | } | 80 | } |
| @@ -127,6 +131,10 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | @@ -127,6 +131,10 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | ||
| 127 | rsp = &protocol.AchievementDetailResponse{} | 131 | rsp = &protocol.AchievementDetailResponse{} |
| 128 | { | 132 | { |
| 129 | rsp.Achievement = GetAchievementItem(header, item) | 133 | rsp.Achievement = GetAchievementItem(header, item) |
| 134 | + rsp.GraspScore = protocol.GraspScore{ | ||
| 135 | + GraspScore: item.GraspScore, | ||
| 136 | + GraspScorePercent: item.GraspScore, | ||
| 137 | + } | ||
| 130 | rsp.StatisticData = GetStatisticData(header, item.StaticDataOrm, item.AchievementId) | 138 | rsp.StatisticData = GetStatisticData(header, item.StaticDataOrm, item.AchievementId) |
| 131 | rsp.ChanceTemplate = getTemplate(item.TemplateId) | 139 | rsp.ChanceTemplate = getTemplate(item.TemplateId) |
| 132 | rsp.ChanceType = getChanceType(item.ChanceTypeId) | 140 | rsp.ChanceType = getChanceType(item.ChanceTypeId) |
| @@ -138,10 +146,12 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | @@ -138,10 +146,12 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | ||
| 138 | } | 146 | } |
| 139 | newParticipant := func(user *protocol.BaseUserInfo, score float64, t int) protocol.UserGraspInfo { | 147 | newParticipant := func(user *protocol.BaseUserInfo, score float64, t int) protocol.UserGraspInfo { |
| 140 | return protocol.UserGraspInfo{ | 148 | return protocol.UserGraspInfo{ |
| 141 | - Provider: user, | ||
| 142 | - GraspScore: score, | ||
| 143 | - GraspScorePercent: score, | ||
| 144 | - Type: t, | 149 | + Provider: user, |
| 150 | + GraspScore: protocol.GraspScore{ | ||
| 151 | + GraspScore: score, | ||
| 152 | + GraspScorePercent: score, | ||
| 153 | + }, | ||
| 154 | + Type: t, | ||
| 145 | } | 155 | } |
| 146 | } | 156 | } |
| 147 | addParticipants := func(item protocol.UserGraspInfo) { | 157 | addParticipants := func(item protocol.UserGraspInfo) { |
| @@ -168,43 +178,16 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | @@ -168,43 +178,16 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve | ||
| 168 | for i := range chances { | 178 | for i := range chances { |
| 169 | chance := chances[i] | 179 | chance := chances[i] |
| 170 | commItem := &protocol.CommonListItem{} | 180 | commItem := &protocol.CommonListItem{} |
| 171 | - commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, chance.CommChanceItemOrm) | 181 | + commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, chance.CommChanceItemOrm) |
| 172 | //commItem.ChanceTemplate = getTemplate(chance.TemplateId) | 182 | //commItem.ChanceTemplate = getTemplate(chance.TemplateId) |
| 173 | //commItem.ChanceType = getChanceType(chance.ChanceTypeId) | 183 | //commItem.ChanceType = getChanceType(chance.ChanceTypeId) |
| 184 | + //commItem.Score=protocol.GraspScore{ | ||
| 185 | + // GraspScore:chance., | ||
| 186 | + // GraspScorePercent:chance.GraspScore, | ||
| 187 | + //} | ||
| 174 | commItem.ChanceId = chance.ChanceId | 188 | commItem.ChanceId = chance.ChanceId |
| 175 | rsp.SourceChance = append(rsp.SourceChance, commItem) | 189 | rsp.SourceChance = append(rsp.SourceChance, commItem) |
| 176 | } | 190 | } |
| 177 | agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.SourceChance) | 191 | agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.SourceChance) |
| 178 | return | 192 | return |
| 179 | } | 193 | } |
| 180 | - | ||
| 181 | -//设置机会详情 | ||
| 182 | -func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceItemOrm) (item protocol.ChanceItem, chanceStatus int) { | ||
| 183 | - var provider *protocol.BaseUserInfo | ||
| 184 | - var err error | ||
| 185 | - if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | ||
| 186 | - chanceStatus = protocol.ChanceStatusDelete | ||
| 187 | - log.Error(err) | ||
| 188 | - return | ||
| 189 | - } | ||
| 190 | - if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除 | ||
| 191 | - chanceStatus = protocol.ChanceStatusDelete | ||
| 192 | - } | ||
| 193 | - if chance.Status == models.ChanceStatusClose { //机会关闭 | ||
| 194 | - chanceStatus = protocol.ChanceStatusClose | ||
| 195 | - return | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - item = protocol.ChanceItem{ | ||
| 199 | - Id: chance.ChanceId, | ||
| 200 | - Provider: provider, | ||
| 201 | - CreateTime: chance.CreateTime.Unix() * 1000, | ||
| 202 | - //PublicStatus: chance.PublishStatus, | ||
| 203 | - } | ||
| 204 | - jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
| 205 | - item.FormList = clearEmptyForm(item.FormList) | ||
| 206 | - jsonUnmarshal(chance.Images, &item.Pictures) | ||
| 207 | - jsonUnmarshal(chance.Voices, &item.Speechs) | ||
| 208 | - jsonUnmarshal(chance.Videos, &item.Videos) | ||
| 209 | - return item, chanceStatus | ||
| 210 | -} |
| @@ -12,6 +12,7 @@ import ( | @@ -12,6 +12,7 @@ import ( | ||
| 12 | "opp/models" | 12 | "opp/models" |
| 13 | "opp/protocol" | 13 | "opp/protocol" |
| 14 | "opp/services/agg" | 14 | "opp/services/agg" |
| 15 | + "reflect" | ||
| 15 | "strings" | 16 | "strings" |
| 16 | "time" | 17 | "time" |
| 17 | ) | 18 | ) |
| @@ -576,6 +577,9 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -576,6 +577,9 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
| 576 | return | 577 | return |
| 577 | } | 578 | } |
| 578 | auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} | 579 | auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} |
| 580 | + | ||
| 581 | + go CheckChanceUpdate(header, chance, request) | ||
| 582 | + | ||
| 579 | orm := orm.NewOrm() | 583 | orm := orm.NewOrm() |
| 580 | orm.Begin() | 584 | orm.Begin() |
| 581 | //6.更新文件 | 585 | //6.更新文件 |
| @@ -707,6 +711,142 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -707,6 +711,142 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
| 707 | return | 711 | return |
| 708 | } | 712 | } |
| 709 | 713 | ||
| 714 | +//检查机会更新 | ||
| 715 | +func CheckChanceUpdate(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) { | ||
| 716 | + var ( | ||
| 717 | + //chanceData *models.ChanceData | ||
| 718 | + isSaveLog bool = false | ||
| 719 | + chanceReviseLog *models.ChanceReviseLog | ||
| 720 | + message string | ||
| 721 | + ) | ||
| 722 | + defer func() { | ||
| 723 | + if p := recover(); p != nil { | ||
| 724 | + log.Error(p) | ||
| 725 | + } else { | ||
| 726 | + log.Debug("") | ||
| 727 | + } | ||
| 728 | + }() | ||
| 729 | + if header.UserId == chance.UserId { | ||
| 730 | + return | ||
| 731 | + } | ||
| 732 | + type ChanceModifyLog struct { | ||
| 733 | + DiffContents interface{} `json:"diffContents"` | ||
| 734 | + Speechs []protocol.Speech `json:"speechs"` | ||
| 735 | + Pictures []protocol.Picture `json:"pictures"` | ||
| 736 | + Videos []protocol.Video `json:"videos"` | ||
| 737 | + } | ||
| 738 | + var modifyLog = ChanceModifyLog{} | ||
| 739 | + diffFormList := func(source string, dis []*protocol.Form) { | ||
| 740 | + type DiffContent struct { | ||
| 741 | + Content string `json:"content"` | ||
| 742 | + } | ||
| 743 | + var ( | ||
| 744 | + src []*protocol.Form | ||
| 745 | + mapForm map[string]*protocol.Form = make(map[string]*protocol.Form) | ||
| 746 | + diffStructs = []DiffContent{} | ||
| 747 | + ) | ||
| 748 | + jsonUnmarshal(source, &src) | ||
| 749 | + for i := range src { | ||
| 750 | + mapForm[src[i].Label] = src[i] | ||
| 751 | + } | ||
| 752 | + for i := range dis { | ||
| 753 | + isDiff := false | ||
| 754 | + srcValue := "" | ||
| 755 | + if v, ok := mapForm[dis[i].Label]; ok { | ||
| 756 | + srcValue = v.Value | ||
| 757 | + if dis[i].Value != v.Value { | ||
| 758 | + isDiff = true | ||
| 759 | + } | ||
| 760 | + } else { | ||
| 761 | + isDiff = true | ||
| 762 | + } | ||
| 763 | + if isDiff { | ||
| 764 | + diffStructs = append(diffStructs, DiffContent{ | ||
| 765 | + Content: fmt.Sprintf("将“%v”由“%v”改为 “%v“", dis[i].Label, srcValue, dis[i].Value)}) | ||
| 766 | + if !isSaveLog { | ||
| 767 | + isSaveLog = true | ||
| 768 | + } | ||
| 769 | + } | ||
| 770 | + } | ||
| 771 | + modifyLog.DiffContents = diffStructs | ||
| 772 | + } | ||
| 773 | + | ||
| 774 | + diffChanceData := func() { | ||
| 775 | + var ( | ||
| 776 | + speechs []protocol.Speech | ||
| 777 | + pictures []protocol.Picture | ||
| 778 | + videos []protocol.Video | ||
| 779 | + ) | ||
| 780 | + if chanceData, e := models.GetChanceDataByChanceId(chance.Id); e == nil { | ||
| 781 | + jsonUnmarshal(chanceData.Speechs, &speechs) | ||
| 782 | + jsonUnmarshal(chanceData.Images, &pictures) | ||
| 783 | + jsonUnmarshal(chanceData.Videos, &videos) | ||
| 784 | + if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) { | ||
| 785 | + if !isSaveLog { | ||
| 786 | + isSaveLog = true | ||
| 787 | + } | ||
| 788 | + modifyLog.Videos = request.Videos | ||
| 789 | + } | ||
| 790 | + if !reflect.DeepEqual(request.Pictures, pictures) { | ||
| 791 | + if !isSaveLog { | ||
| 792 | + isSaveLog = true | ||
| 793 | + } | ||
| 794 | + modifyLog.Pictures = request.Pictures | ||
| 795 | + } | ||
| 796 | + if !reflect.DeepEqual(request.Speechs, speechs) { | ||
| 797 | + if !isSaveLog { | ||
| 798 | + isSaveLog = true | ||
| 799 | + } | ||
| 800 | + modifyLog.Speechs = request.Speechs | ||
| 801 | + } | ||
| 802 | + } else { | ||
| 803 | + if !isSaveLog { | ||
| 804 | + isSaveLog = true | ||
| 805 | + } | ||
| 806 | + modifyLog.Speechs = request.Speechs | ||
| 807 | + modifyLog.Videos = request.Videos | ||
| 808 | + modifyLog.Speechs = request.Speechs | ||
| 809 | + } | ||
| 810 | + } | ||
| 811 | + | ||
| 812 | + diffFormList(chance.SourceContent, request.FormList) | ||
| 813 | + diffChanceData() | ||
| 814 | + | ||
| 815 | + if isSaveLog { | ||
| 816 | + orm := orm.NewOrm() | ||
| 817 | + orm.Begin() | ||
| 818 | + //保存修改详情 | ||
| 819 | + chanceReviseLog = &models.ChanceReviseLog{ | ||
| 820 | + Id: idgen.Next(), | ||
| 821 | + ChanceId: chance.Id, | ||
| 822 | + UserCompanyId: header.UserId, | ||
| 823 | + Data: common.AssertJson(modifyLog), | ||
| 824 | + CreateAt: time.Now(), | ||
| 825 | + } | ||
| 826 | + if _, e := orm.Insert(chanceReviseLog); e != nil { | ||
| 827 | + log.Error(e) | ||
| 828 | + orm.Rollback() | ||
| 829 | + return | ||
| 830 | + } | ||
| 831 | + if chanceType, err := models.GetChanceTypeById(chance.ChanceTypeId); err != nil { | ||
| 832 | + log.Error(err) | ||
| 833 | + orm.Rollback() | ||
| 834 | + return | ||
| 835 | + } else { | ||
| 836 | + message = fmt.Sprintf(protocol.MessageChanceRevise, chanceType.Name) | ||
| 837 | + } | ||
| 838 | + //发送修改机会消息 | ||
| 839 | + if err := agg.SendMsgWithHeader(header, chance.UserId, "", chanceReviseLog.Id, protocol.SourceTypeChanceReviseLog, message, protocol.MsgTypeChanceRevise, chance.Id); err != nil { | ||
| 840 | + log.Error(err) | ||
| 841 | + orm.Rollback() | ||
| 842 | + return | ||
| 843 | + } | ||
| 844 | + | ||
| 845 | + //TODO:保存变更日志 | ||
| 846 | + orm.Commit() | ||
| 847 | + } | ||
| 848 | +} | ||
| 849 | + | ||
| 710 | //修改公开状态 | 850 | //修改公开状态 |
| 711 | func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.ChanceChangePublishRequest) (rsp *protocol.ChanceChangePublishResponse, err error) { | 851 | func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.ChanceChangePublishRequest) (rsp *protocol.ChanceChangePublishResponse, err error) { |
| 712 | var ( | 852 | var ( |
| @@ -586,6 +586,37 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc | @@ -586,6 +586,37 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc | ||
| 586 | return | 586 | return |
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | +//消息中心-机会补充 | ||
| 590 | +func MsgChanceRevise(header *protocol.RequestHeader, request *protocol.MsgChanceReviseRequest) (rsp *protocol.MsgChanceReviseResponse, err error) { | ||
| 591 | + var ( | ||
| 592 | + myChances []protocol.ChanceReviseItemOrm | ||
| 593 | + total int | ||
| 594 | + ) | ||
| 595 | + | ||
| 596 | + if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeThumbUp, &myChances); err != nil { | ||
| 597 | + if err == orm.ErrNoRows { | ||
| 598 | + err = nil | ||
| 599 | + return | ||
| 600 | + } | ||
| 601 | + log.Error(err) | ||
| 602 | + return | ||
| 603 | + } | ||
| 604 | + rsp = &protocol.MsgChanceReviseResponse{Total: total} | ||
| 605 | + rsp.List = make([]protocol.MsgCommonListItem, 0) | ||
| 606 | + for i := 0; i < len(myChances); i++ { | ||
| 607 | + chance := myChances[i] | ||
| 608 | + commItem := protocol.MsgCommonListItem{} | ||
| 609 | + commItem.Chance, commItem.ChanceStatus = agg.SetChanceItem(header, chance.CommChanceItemOrm) | ||
| 610 | + agg.SetMsgItem(header, chance.MsgItemOrm, &commItem) | ||
| 611 | + | ||
| 612 | + commItem.ChanceId = chance.ChanceId | ||
| 613 | + commItem.ReviewStatus = chance.ReviewStatus | ||
| 614 | + //commItem.ChanceReviseLogId = chance.SourceId | ||
| 615 | + rsp.List = append(rsp.List, commItem) | ||
| 616 | + } | ||
| 617 | + return | ||
| 618 | +} | ||
| 619 | + | ||
| 589 | //H5公告详情 | 620 | //H5公告详情 |
| 590 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { | 621 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { |
| 591 | var ( | 622 | var ( |
-
请 注册 或 登录 后发表评论