...
|
...
|
@@ -67,11 +67,34 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int |
|
|
}
|
|
|
|
|
|
//发送审批消息
|
|
|
func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string, data protocol.MsgData) (err error) {
|
|
|
func SendApproveMsgWithHeader(header *protocol.RequestHeader, receiverId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int, data protocol.MsgData) (err error) {
|
|
|
return sendApproveMsg(header, receiverId, "", header.CompanyId, chanceId, chanceTypeId, reviewStatus, msgType, data)
|
|
|
}
|
|
|
|
|
|
//发送审批消息
|
|
|
func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int, data protocol.MsgData) (err error) {
|
|
|
var (
|
|
|
userMsg *models.UserMsg
|
|
|
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
|
|
|
case protocol.ReviewStatusAutoPass:
|
|
|
format = MessageApproveAutoPass
|
|
|
break
|
|
|
default:
|
|
|
format = MessageApproving
|
|
|
break
|
|
|
}
|
|
|
if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -79,18 +102,51 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan |
|
|
Id: idgen.Next(),
|
|
|
CompanyId: companyId,
|
|
|
ReceiveUserId: receiverId,
|
|
|
MsgType: protocol.MsgTypeAuditBy,
|
|
|
MsgType: msgType,
|
|
|
Message: fmt.Sprintf(format, chanceType.Name),
|
|
|
SourceId: chanceId,
|
|
|
SourceType: protocol.SourceTypeChance,
|
|
|
IsPublic: 0,
|
|
|
CreateAt: time.Now(),
|
|
|
ChanceId: chanceId,
|
|
|
Data: common.AssertJson(data),
|
|
|
}
|
|
|
if header != nil {
|
|
|
userMsg.SenderUserId = header.UserId
|
|
|
}
|
|
|
if _, err = models.AddUserMsg(userMsg); err != nil {
|
|
|
return
|
|
|
}
|
|
|
logMsgWithHeaer(header, userMsg, name)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//发送审批消息
|
|
|
func SendApproveMsgByFormat(header *protocol.RequestHeader, receiverId int64, chanceId int64, message string, data protocol.MsgData) (err error) {
|
|
|
var (
|
|
|
userMsg *models.UserMsg
|
|
|
//chanceType *models.ChanceType
|
|
|
)
|
|
|
//if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil {
|
|
|
// return
|
|
|
//}
|
|
|
userMsg = &models.UserMsg{
|
|
|
Id: idgen.Next(),
|
|
|
CompanyId: header.CompanyId,
|
|
|
ReceiveUserId: receiverId,
|
|
|
MsgType: protocol.MsgTypeAuditBy,
|
|
|
Message: message, //fmt.Sprintf(message, chanceType.Name),
|
|
|
SourceId: chanceId,
|
|
|
SourceType: protocol.SourceTypeChance,
|
|
|
IsPublic: 0,
|
|
|
CreateAt: time.Now(),
|
|
|
Data: common.AssertJson(data),
|
|
|
SenderUserId: header.UserId,
|
|
|
}
|
|
|
if _, err = models.AddUserMsg(userMsg); err != nil {
|
|
|
return
|
|
|
}
|
|
|
logMsg(userMsg, name)
|
|
|
logMsg(userMsg, "")
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -211,6 +267,11 @@ func logMsg(msg *models.UserMsg, name string) { |
|
|
msg.MsgType, msg.ReceiveUserId, name, msg.Message, msg.SourceId, msg.SourceType))
|
|
|
}
|
|
|
|
|
|
func logMsgWithHeaer(header *protocol.RequestHeader, msg *models.UserMsg, name string) {
|
|
|
log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v 发送人:%v",
|
|
|
msg.MsgType, msg.ReceiveUserId, name, msg.Message, msg.SourceId, msg.SourceType, header.UserId))
|
|
|
}
|
|
|
|
|
|
//保查审核日志
|
|
|
func SaveApproveLog(orm orm.Ormer, code int, userId int64, chanceId int64, param ...interface{}) (err error) {
|
|
|
var (
|
...
|
...
|
|