...
|
...
|
@@ -344,7 +344,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
}
|
|
|
|
|
|
//生成提交记录
|
|
|
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
|
|
|
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
...
|
...
|
@@ -429,15 +429,25 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
err = protocol.NewErrWithMessage(5101)
|
|
|
return
|
|
|
}
|
|
|
//1.模板是否存在
|
|
|
if template, err = models.GetAuditTemplateById(int64(chance.AuditTemplateId)); err != nil {
|
|
|
log.Error("模板不存在:", chance.AuditTemplateId, err)
|
|
|
return
|
|
|
}
|
|
|
if chanceType, err = models.GetChanceTypeById(chance.ChanceTypeId); err != nil {
|
|
|
log.Error("一级分类不存在:", chance.ChanceTypeId, err)
|
|
|
return
|
|
|
}
|
|
|
//编辑重新发布 是否可以重新发布
|
|
|
if request.IsPublish && chance.ReviewStatus == protocol.ReviewStatusReturn && chance.UserId == header.UserId {
|
|
|
request.IsPublish = false
|
|
|
//当前没有被人审核过
|
|
|
if _, e := models.GetAuditFlowProcessApproved(request.Id, 1); e == orm.ErrNoRows && chance.AuditLevel == 1 {
|
|
|
//当前状态是退回-待处理
|
|
|
if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
|
|
|
request.IsPublish = true
|
|
|
}
|
|
|
//if _, e := models.GetAuditFlowProcessApproved(request.Id, 1); e == orm.ErrNoRows && chance.AuditLevel == 1 {
|
|
|
// //当前状态是退回-待处理
|
|
|
//
|
|
|
//}
|
|
|
if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
|
|
|
request.IsPublish = true
|
|
|
}
|
|
|
} else {
|
|
|
request.IsPublish = false
|
...
|
...
|
@@ -507,6 +517,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
|
|
|
{
|
|
|
if request.IsPublish {
|
|
|
|
|
|
//更新待处理->提交
|
|
|
if err = models.UpdatetAuditFlowProcessToSubmit(orm, request.Id, 0, protocol.ReviewStatusSubmit, header.UserId); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -737,18 +748,19 @@ func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePe |
|
|
}
|
|
|
|
|
|
//生成审批流-提交记录
|
|
|
func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64, reviewStatus int) (v *models.AuditFlowProcess) {
|
|
|
func GenAuditFlowProcess_Submit(userId, chanceId int64, templateId int64, reviewStatus int) (v *models.AuditFlowProcess) {
|
|
|
v = &models.AuditFlowProcess{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chanceId,
|
|
|
Uid: header.UserId,
|
|
|
Uid: userId,
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
ApproveTime: time.Now(),
|
|
|
EnableStatus: 1,
|
|
|
IsActive: 1,
|
|
|
ReviewStatus: int8(reviewStatus),
|
|
|
}
|
|
|
if approver, err := models.GetUsersById(header.Uid); err != nil {
|
|
|
if approver, err := models.GetUsersById(userId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
} else {
|
...
|
...
|
@@ -767,7 +779,8 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
company *models.Company
|
|
|
roleName string
|
|
|
approver *models.User
|
|
|
roleId []int
|
|
|
roleIds []int
|
|
|
roleId int
|
|
|
)
|
|
|
if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
...
|
...
|
@@ -849,11 +862,15 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
}
|
|
|
break
|
|
|
case protocol.AuditByRole:
|
|
|
if e := json.Unmarshal([]byte(config.ToRole), &roleId); e == nil {
|
|
|
if userIds, err = getRoleUsers(header, roleId[0]); err != nil {
|
|
|
if e := json.Unmarshal([]byte(config.ToRole), &roleIds); e == nil {
|
|
|
if userIds, err = getRoleUsers(header, roleIds[0]); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if role, e := models.GetRoleById(roleIds[0]); e == nil {
|
|
|
roleName = role.Name
|
|
|
roleId = role.Id
|
|
|
}
|
|
|
} else {
|
|
|
log.Error(config.ToRole, e)
|
|
|
}
|
...
|
...
|
@@ -890,6 +907,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
ActionType: int(config.ActionType),
|
|
|
RoleName: roleName,
|
|
|
UserName: approver.NickName,
|
|
|
RoleId: roleId,
|
|
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
|
|
TemplateId: int(templateId),
|
|
|
}
|
...
|
...
|
@@ -897,7 +915,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
item.IsActive = 1
|
|
|
item.EnableStatus = 1
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("生成机会审批流:chance_id:%v audit_id:%v audit_level:%v audit_user:%v action_type:%v", chanceId, item.Id, config.Level, uid, resolveActionType(config.ActionType)))
|
|
|
log.Info(fmt.Sprintf("生成机会审批流:chance_id:%v audit_id:%v audit_level:%v audit_user:%v action_type:%v is_active:%v", chanceId, item.Id, config.Level, uid, resolveActionType(config.ActionType), item.IsActive))
|
|
|
v = append(v, item)
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -905,10 +923,10 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
}
|
|
|
func resolveActionType(t uint) string {
|
|
|
if t == 1 {
|
|
|
return "or"
|
|
|
return "and"
|
|
|
}
|
|
|
if t == 2 {
|
|
|
return "and"
|
|
|
return "or"
|
|
|
}
|
|
|
return fmt.Sprintf("%v", t)
|
|
|
}
|
...
|
...
|
|