作者 yangfu

机会审核

... ... @@ -38,6 +38,7 @@ const (
ReviewStatusAuditging = 1 //待审核
ReviewStatusReturn = 2 //退回
ReviewStatusPass = 3 //通过
ReviewStatusSubmit = 4 //提交
)
//公开状态
... ...
... ... @@ -263,23 +263,30 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
ReviewStatus: protocol.ReviewStatusAuditging,
DepartmentId: request.RelatedDepartment,
}
if _, err = orm.Insert(chance); err != nil {
logAndRollBack := func(err error) {
log.Error(err)
orm.Rollback()
return
}
if _, err = orm.Insert(chance); err != nil {
logAndRollBack(err)
return
}
//生成提交记录
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id)); err != nil {
logAndRollBack(err)
return
}
//4.查询审核配置
//5.生成审核流
if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
log.Error(err)
orm.Rollback()
logAndRollBack(err)
return
}
for i := 0; i < len(auditFlows); i++ {
if _, err = orm.Insert(auditFlows[i]); err != nil {
log.Error(err)
orm.Rollback()
logAndRollBack(err)
return
}
}
... ... @@ -296,8 +303,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
message := m.MessageData[i]
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()
logAndRollBack(err)
return
}
}
... ... @@ -316,8 +322,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
UpdateAt: time.Now(),
}
if _, err = orm.Insert(data); err != nil {
log.Error(err)
orm.Rollback()
logAndRollBack(err)
return
}
}
... ... @@ -406,6 +411,21 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
return
}
//生成审批流-提交记录
func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) {
v = &models.AuditFlowProcess{
Id: idgen.Next(),
ChanceId: chanceId,
Uid: header.UserId,
CreateAt: time.Now(),
UpdateAt: time.Now(),
ApproveTime: time.Now(),
EnableStatus: 1,
ReviewStatus: protocol.ReviewStatusSubmit,
}
return
}
//生成审批流
func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) {
var (
... ... @@ -475,7 +495,6 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
return
}
//3.生成审核列表
for i := range configs {
config := configs[i]
... ...