正在显示
6 个修改的文件
包含
51 行增加
和
11 行删除
@@ -22,6 +22,7 @@ type UserMsg struct { | @@ -22,6 +22,7 @@ type UserMsg struct { | ||
22 | CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"` | 22 | CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"` |
23 | ChanceId int64 `orm:"column(chance_id)" description:"机会编号"` | 23 | ChanceId int64 `orm:"column(chance_id)" description:"机会编号"` |
24 | SenderUserId int64 `orm:"column(sender_user_id)" description:"发送人用户id"` | 24 | SenderUserId int64 `orm:"column(sender_user_id)" description:"发送人用户id"` |
25 | + Data string `orm:"column(data)" description:"扩展数据"` | ||
25 | } | 26 | } |
26 | 27 | ||
27 | const ( | 28 | const ( |
@@ -182,7 +183,7 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag | @@ -182,7 +183,7 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag | ||
182 | func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) { | 183 | func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) { |
183 | sql := `select a.*,b.images,b.speechs,b.videos from ( | 184 | sql := `select a.*,b.images,b.speechs,b.videos from ( |
184 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( | 185 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( |
185 | -select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time | 186 | +select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time,data |
186 | from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=? | 187 | from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=? |
187 | )a left outer join chance b on a.source_id = b.id | 188 | )a left outer join chance b on a.source_id = b.id |
188 | )a left outer join chance_data b on a.source_id =b.chance_id | 189 | )a left outer join chance_data b on a.source_id =b.chance_id |
@@ -276,6 +276,7 @@ type MsgChanceApproveItemOrm struct { | @@ -276,6 +276,7 @@ type MsgChanceApproveItemOrm struct { | ||
276 | IsRead int64 `orm:"column(is_read)"` | 276 | IsRead int64 `orm:"column(is_read)"` |
277 | ChanceId int64 `orm:"column(chance_id)"` // 机会id | 277 | ChanceId int64 `orm:"column(chance_id)"` // 机会id |
278 | //EnableStatus int `orm:"column(enable_status)"` | 278 | //EnableStatus int `orm:"column(enable_status)"` |
279 | + Data string `orm:"column(data)"` | ||
279 | } | 280 | } |
280 | 281 | ||
281 | /*Announcement H5公告详情*/ | 282 | /*Announcement H5公告详情*/ |
@@ -313,3 +314,8 @@ type Answer struct { | @@ -313,3 +314,8 @@ type Answer struct { | ||
313 | VoteResults []int `json:"voteResults"` | 314 | VoteResults []int `json:"voteResults"` |
314 | EditContent string `json:"editContent"` | 315 | EditContent string `json:"editContent"` |
315 | } | 316 | } |
317 | + | ||
318 | +//扩展消息附加数据 | ||
319 | +type MsgData struct { | ||
320 | + Score *Score `json:"score,omitempty"` | ||
321 | +} |
@@ -3,6 +3,7 @@ package agg | @@ -3,6 +3,7 @@ package agg | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/astaxie/beego/orm" | 5 | "github.com/astaxie/beego/orm" |
6 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" |
7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 8 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
8 | "opp/internal/utils" | 9 | "opp/internal/utils" |
@@ -19,7 +20,7 @@ var ( | @@ -19,7 +20,7 @@ var ( | ||
19 | ) | 20 | ) |
20 | 21 | ||
21 | //发送审批消息 | 22 | //发送审批消息 |
22 | -func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int) (err error) { | 23 | +func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, data protocol.MsgData) (err error) { |
23 | var ( | 24 | var ( |
24 | userMsg *models.UserMsg | 25 | userMsg *models.UserMsg |
25 | chanceType *models.ChanceType | 26 | chanceType *models.ChanceType |
@@ -56,6 +57,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int | @@ -56,6 +57,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int | ||
56 | IsPublic: 0, | 57 | IsPublic: 0, |
57 | CreateAt: time.Now(), | 58 | CreateAt: time.Now(), |
58 | ChanceId: chanceId, | 59 | ChanceId: chanceId, |
60 | + Data: common.AssertJson(data), | ||
59 | } | 61 | } |
60 | if _, err = models.AddUserMsg(userMsg); err != nil { | 62 | if _, err = models.AddUserMsg(userMsg); err != nil { |
61 | return | 63 | return |
@@ -65,7 +67,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int | @@ -65,7 +67,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int | ||
65 | } | 67 | } |
66 | 68 | ||
67 | //发送审批消息 | 69 | //发送审批消息 |
68 | -func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string) (err error) { | 70 | +func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string, data protocol.MsgData) (err error) { |
69 | var ( | 71 | var ( |
70 | userMsg *models.UserMsg | 72 | userMsg *models.UserMsg |
71 | chanceType *models.ChanceType | 73 | chanceType *models.ChanceType |
@@ -83,6 +85,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | @@ -83,6 +85,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | ||
83 | SourceType: protocol.SourceTypeChance, | 85 | SourceType: protocol.SourceTypeChance, |
84 | IsPublic: 0, | 86 | IsPublic: 0, |
85 | CreateAt: time.Now(), | 87 | CreateAt: time.Now(), |
88 | + Data: common.AssertJson(data), | ||
86 | } | 89 | } |
87 | if _, err = models.AddUserMsg(userMsg); err != nil { | 90 | if _, err = models.AddUserMsg(userMsg); err != nil { |
88 | return | 91 | return |
@@ -92,7 +95,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | @@ -92,7 +95,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | ||
92 | } | 95 | } |
93 | 96 | ||
94 | //发送被审核消息 | 97 | //发送被审核消息 |
95 | -func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int) (err error) { | 98 | +func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int, msgData protocol.MsgData) (err error) { |
96 | var ( | 99 | var ( |
97 | chanceType *models.ChanceType | 100 | chanceType *models.ChanceType |
98 | format string | 101 | format string |
@@ -115,7 +118,7 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in | @@ -115,7 +118,7 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in | ||
115 | return | 118 | return |
116 | } | 119 | } |
117 | format = fmt.Sprintf(format, chanceType.Name) | 120 | format = fmt.Sprintf(format, chanceType.Name) |
118 | - return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId) | 121 | + return SendMsgWithData(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId, msgData) |
119 | } | 122 | } |
120 | 123 | ||
121 | //发送消息 | 124 | //发送消息 |
@@ -143,6 +146,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou | @@ -143,6 +146,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou | ||
143 | } | 146 | } |
144 | 147 | ||
145 | //发送消息 | 148 | //发送消息 |
149 | +func SendMsgWithData(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int, chanceId int64, msgData protocol.MsgData) (err error) { | ||
150 | + var ( | ||
151 | + userMsg *models.UserMsg | ||
152 | + ) | ||
153 | + userMsg = &models.UserMsg{ | ||
154 | + Id: idgen.Next(), | ||
155 | + CompanyId: companyId, | ||
156 | + ReceiveUserId: receiverId, | ||
157 | + MsgType: msgType, | ||
158 | + Message: message, | ||
159 | + SourceId: sourceId, | ||
160 | + SourceType: sourceType, | ||
161 | + IsPublic: 0, | ||
162 | + CreateAt: time.Now(), | ||
163 | + ChanceId: chanceId, | ||
164 | + Data: common.AssertJson(msgData), | ||
165 | + } | ||
166 | + if _, err = models.AddUserMsg(userMsg); err != nil { | ||
167 | + return | ||
168 | + } | ||
169 | + logMsg(userMsg, name) | ||
170 | + return | ||
171 | +} | ||
172 | + | ||
173 | +//发送消息 | ||
146 | func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name string, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) { | 174 | func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name string, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) { |
147 | var ( | 175 | var ( |
148 | userMsg *models.UserMsg | 176 | userMsg *models.UserMsg |
@@ -365,7 +365,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -365,7 +365,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
365 | //更新下一批次的审核人 | 365 | //更新下一批次的审核人 |
366 | var nextApprovers []int64 | 366 | var nextApprovers []int64 |
367 | if err = agg.SendApprovedMsg(chance.UserId, "", | 367 | if err = agg.SendApprovedMsg(chance.UserId, "", |
368 | - header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil { | 368 | + header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score}); err != nil { |
369 | log.Error(err) | 369 | log.Error(err) |
370 | orm.Rollback() | 370 | orm.Rollback() |
371 | return | 371 | return |
@@ -391,7 +391,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -391,7 +391,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
391 | message := approveItemResponse.MessageData.ApproveMessage[i] | 391 | message := approveItemResponse.MessageData.ApproveMessage[i] |
392 | nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid) | 392 | nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid) |
393 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, | 393 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, |
394 | - header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil { | 394 | + header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil { |
395 | log.Error(err) | 395 | log.Error(err) |
396 | orm.Rollback() | 396 | orm.Rollback() |
397 | return | 397 | return |
@@ -414,7 +414,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -414,7 +414,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
414 | for i := range m.MessageData { | 414 | for i := range m.MessageData { |
415 | message := m.MessageData[i] | 415 | message := m.MessageData[i] |
416 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, | 416 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, |
417 | - header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil { | 417 | + header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil { |
418 | log.Error(err) | 418 | log.Error(err) |
419 | orm.Rollback() | 419 | orm.Rollback() |
420 | return | 420 | return |
@@ -473,9 +473,9 @@ func setChanceAutoPass(header *protocol.RequestHeader, chance *models.Chance, or | @@ -473,9 +473,9 @@ func setChanceAutoPass(header *protocol.RequestHeader, chance *models.Chance, or | ||
473 | chance.ApproveData = common.AssertJson(approveData) | 473 | chance.ApproveData = common.AssertJson(approveData) |
474 | chance.ApproveTime = time.Now() | 474 | chance.ApproveTime = time.Now() |
475 | chance.ReviewStatus = protocol.ReviewStatusPass | 475 | chance.ReviewStatus = protocol.ReviewStatusPass |
476 | - | 476 | + msgData := protocol.MsgData{Score: &approveData.Score} |
477 | if err = agg.SendApproveMsgByFormat(chance.UserId, "", | 477 | if err = agg.SendApproveMsgByFormat(chance.UserId, "", |
478 | - header.CompanyId, chance.Id, chance.ChanceTypeId, fmt.Sprintf(agg.MessageApproveAutoPass, chanceType.Name)); err != nil { | 478 | + header.CompanyId, chance.Id, chance.ChanceTypeId, fmt.Sprintf(agg.MessageApproveAutoPass, chanceType.Name), msgData); err != nil { |
479 | log.Error(err) | 479 | log.Error(err) |
480 | return | 480 | return |
481 | } | 481 | } |
@@ -619,7 +619,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -619,7 +619,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
619 | for i := range m.MessageData { | 619 | for i := range m.MessageData { |
620 | message := m.MessageData[i] | 620 | message := m.MessageData[i] |
621 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, | 621 | if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName, |
622 | - header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil { | 622 | + header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil { |
623 | log.Error(err) | 623 | log.Error(err) |
624 | orm.Rollback() | 624 | orm.Rollback() |
625 | return | 625 | return |
@@ -354,6 +354,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | @@ -354,6 +354,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | ||
354 | commItem.Score = approveData.Score | 354 | commItem.Score = approveData.Score |
355 | } | 355 | } |
356 | } | 356 | } |
357 | + if len(chance.Data) > 0 { //获取评分 | ||
358 | + var msgData *protocol.MsgData | ||
359 | + utils.JsonUnmarshal(chance.ApproveData, &msgData) | ||
360 | + commItem.Score = msgData.Score | ||
361 | + } | ||
357 | commItem.IsRead = chance.IsRead == 1 | 362 | commItem.IsRead = chance.IsRead == 1 |
358 | //审核完有审核数据 | 363 | //审核完有审核数据 |
359 | commItem.Message = chance.Message | 364 | commItem.Message = chance.Message |
-
请 注册 或 登录 后发表评论