...
|
...
|
@@ -1065,29 +1065,43 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
}
|
|
|
break
|
|
|
}
|
|
|
if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人
|
|
|
userIds = append(userIds, 0)
|
|
|
var tmpUserIds []int64
|
|
|
for z := range userIds {
|
|
|
uid := userIds[z]
|
|
|
if uid == header.UserId { //审核人自己 转交给管理员
|
|
|
continue
|
|
|
}
|
|
|
if uid == 0 {
|
|
|
continue
|
|
|
}
|
|
|
tmpUserIds = append(tmpUserIds, uid)
|
|
|
}
|
|
|
userIds = tmpUserIds
|
|
|
if len(userIds) == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //当前步骤没有用户 默认一个空审核人
|
|
|
//userIds = append(userIds, 0)
|
|
|
userIds = append(userIds, admin.Id)
|
|
|
log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v -> admin:%v", chanceId, config.Level, company.AdminId))
|
|
|
}
|
|
|
if len(userIds) == 0 && auditConfig.NoApprover == protocol.NoApproverPass {
|
|
|
log.Info(fmt.Sprintf("配置审核人为空 自动通过审批 chance_id:%v", chanceId))
|
|
|
return
|
|
|
}
|
|
|
userIds = append(userIds, admin.Id) //最后添加一个管理员,如果上面审核人都是空的那么使用最后的审核人
|
|
|
for j := 0; j < len(userIds); j++ {
|
|
|
uid := userIds[j]
|
|
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApproverPass {
|
|
|
log.Info(fmt.Sprintf("配置审核人为空 自动通过审批 chance_id:%v", chanceId))
|
|
|
var e error
|
|
|
if len(v) > 0 && j == (len(userIds)-1) { //如果列表有人了,就不使用最后添加进来的审批人
|
|
|
continue
|
|
|
}
|
|
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
|
|
|
uid = admin.Id
|
|
|
}
|
|
|
if uid == 0 {
|
|
|
uid = admin.Id
|
|
|
}
|
|
|
if uid == header.UserId { //审核人自己 转交给管理员
|
|
|
log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId))
|
|
|
uid = admin.Id
|
|
|
if j == (len(userIds)-1) && auditConfig.NoApprover == protocol.NoApproverPass {
|
|
|
log.Info(fmt.Sprintf("配置审核人已被删除:%v 自动通过审批 chance_id:%v", userIds, chanceId))
|
|
|
continue
|
|
|
}
|
|
|
if approver, err = models.GetUserByUcid(uid); err != nil {
|
|
|
log.Error(uid, err)
|
|
|
return
|
|
|
if approver, e = models.GetUserByUcidEnable(uid); e != nil {
|
|
|
log.Error(uid, e)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
item := &models.AuditFlowProcess{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chanceId,
|
...
|
...
|
|