...
|
...
|
@@ -52,7 +52,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
|
Approver: userCompany.NickName,
|
|
|
Uid: userCompany.Id,
|
|
|
Sign: ApproveSign,
|
|
|
Type: 1,
|
|
|
Type: 2,
|
|
|
}
|
|
|
for i := range process {
|
|
|
var (
|
...
|
...
|
@@ -343,29 +343,42 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
if request.ReviewStatus == protocol.ReviewStatusReturn {
|
|
|
mapChance["ReviewStatus"] = int8(request.ReviewStatus) //退回也要更新审核状态
|
|
|
//增加一条待处理记录到审核列表
|
|
|
//生成提交记录
|
|
|
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, chance.AuditTemplateId, protocol.ReviewStatusWait)); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
//更新下一批次的审核人
|
|
|
var nextApprovers []int64
|
|
|
if err = agg.SendApprovedMsg(chance.UserId, "",
|
|
|
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if approveItemResponse.IsOver == 1 {
|
|
|
//结束审批
|
|
|
{
|
|
|
mapChance["ReviewStatus"] = int8(request.ReviewStatus)
|
|
|
}
|
|
|
//发送审核结果消息给提交人
|
|
|
for i := range approveItemResponse.MessageData.ApplyUserMessage {
|
|
|
message := approveItemResponse.MessageData.ApplyUserMessage[i]
|
|
|
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//更新同批次的为审核的状态置为无效
|
|
|
if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
//for i := range approveItemResponse.MessageData.ApplyUserMessage {
|
|
|
// message := approveItemResponse.MessageData.ApplyUserMessage[i]
|
|
|
// nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
// if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
// header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
// log.Error(err)
|
|
|
// return
|
|
|
// }
|
|
|
//}
|
|
|
} else {
|
|
|
//发送下一个消息给下一流程的审核人
|
|
|
for i := range approveItemResponse.MessageData.ApproveMessage {
|
...
|
...
|
@@ -374,26 +387,27 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//更新下一批次的审核人 同批次的为审核的状态置为无效
|
|
|
if len(nextApprovers) != 0 {
|
|
|
if err = models.UpdatetAuditFlowProcessToNext(chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
|
|
|
if err = models.UpdatetAuditFlowProcessToNext(orm, chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
|
|
return
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
|
|
if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil {
|
|
|
log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err)
|
|
|
orm.Rollback()
|
...
|
...
|
@@ -404,6 +418,14 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
|
log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
|
|
|
return
|
|
|
}
|
|
|
if request.ReviewStatus == protocol.ReviewStatusReturn || approveItemResponse.IsOver == 1 {
|
|
|
//更新同批次的为审核的状态置为无效
|
|
|
if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if request.ApproveData.PublicData.PublishStatus == protocol.PublicToDepartment {
|
|
|
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
|