...
|
...
|
@@ -84,6 +84,56 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan |
|
|
return
|
|
|
}
|
|
|
|
|
|
//发送被审核消息
|
|
|
func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int) (err error) {
|
|
|
var (
|
|
|
chanceType *models.ChanceType
|
|
|
format string
|
|
|
)
|
|
|
switch reviewStatus {
|
|
|
case protocol.ReviewStatusAuditging:
|
|
|
format = MessageApproving
|
|
|
break
|
|
|
case protocol.ReviewStatusReturn:
|
|
|
format = MessageApproveReject
|
|
|
break
|
|
|
case protocol.ReviewStatusPass:
|
|
|
format = MessageApproveSuccess
|
|
|
break
|
|
|
default:
|
|
|
format = MessageApproving
|
|
|
break
|
|
|
}
|
|
|
if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil {
|
|
|
return
|
|
|
}
|
|
|
format = fmt.Sprintf(format, chanceType.Name)
|
|
|
return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType)
|
|
|
}
|
|
|
|
|
|
//发送消息
|
|
|
func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int) (err error) {
|
|
|
var (
|
|
|
userMsg *models.UserMsg
|
|
|
)
|
|
|
userMsg = &models.UserMsg{
|
|
|
Id: idgen.Next(),
|
|
|
CompanyId: companyId,
|
|
|
ReceiveUserId: receiverId,
|
|
|
MsgType: msgType,
|
|
|
Message: message,
|
|
|
SourceId: sourceId,
|
|
|
SourceType: sourceType,
|
|
|
IsPublic: 0,
|
|
|
CreateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = models.AddUserMsg(userMsg); err != nil {
|
|
|
return
|
|
|
}
|
|
|
logMsg(userMsg, name)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//打印消息日志
|
|
|
func logMsg(msg *models.UserMsg, name string) {
|
|
|
log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v",
|
...
|
...
|
|