|
@@ -344,7 +344,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -344,7 +344,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
344
|
}
|
344
|
}
|
345
|
|
345
|
|
346
|
//生成提交记录
|
346
|
//生成提交记录
|
347
|
- if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
|
347
|
+ if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
|
348
|
log.Error(err)
|
348
|
log.Error(err)
|
349
|
orm.Rollback()
|
349
|
orm.Rollback()
|
350
|
return
|
350
|
return
|
|
@@ -429,16 +429,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
@@ -429,16 +429,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
429
|
err = protocol.NewErrWithMessage(5101)
|
429
|
err = protocol.NewErrWithMessage(5101)
|
430
|
return
|
430
|
return
|
431
|
}
|
431
|
}
|
|
|
432
|
+ //1.模板是否存在
|
|
|
433
|
+ if template, err = models.GetAuditTemplateById(int64(chance.AuditTemplateId)); err != nil {
|
|
|
434
|
+ log.Error("模板不存在:", chance.AuditTemplateId, err)
|
|
|
435
|
+ return
|
|
|
436
|
+ }
|
|
|
437
|
+ if chanceType, err = models.GetChanceTypeById(chance.ChanceTypeId); err != nil {
|
|
|
438
|
+ log.Error("一级分类不存在:", chance.ChanceTypeId, err)
|
|
|
439
|
+ return
|
|
|
440
|
+ }
|
432
|
//编辑重新发布 是否可以重新发布
|
441
|
//编辑重新发布 是否可以重新发布
|
433
|
if request.IsPublish && chance.ReviewStatus == protocol.ReviewStatusReturn && chance.UserId == header.UserId {
|
442
|
if request.IsPublish && chance.ReviewStatus == protocol.ReviewStatusReturn && chance.UserId == header.UserId {
|
434
|
request.IsPublish = false
|
443
|
request.IsPublish = false
|
435
|
//当前没有被人审核过
|
444
|
//当前没有被人审核过
|
436
|
- if _, e := models.GetAuditFlowProcessApproved(request.Id, 1); e == orm.ErrNoRows && chance.AuditLevel == 1 {
|
|
|
437
|
- //当前状态是退回-待处理
|
445
|
+ //if _, e := models.GetAuditFlowProcessApproved(request.Id, 1); e == orm.ErrNoRows && chance.AuditLevel == 1 {
|
|
|
446
|
+ // //当前状态是退回-待处理
|
|
|
447
|
+ //
|
|
|
448
|
+ //}
|
438
|
if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
|
449
|
if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
|
439
|
request.IsPublish = true
|
450
|
request.IsPublish = true
|
440
|
}
|
451
|
}
|
441
|
- }
|
|
|
442
|
} else {
|
452
|
} else {
|
443
|
request.IsPublish = false
|
453
|
request.IsPublish = false
|
444
|
}
|
454
|
}
|
|
@@ -507,6 +517,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
@@ -507,6 +517,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
507
|
|
517
|
|
508
|
{
|
518
|
{
|
509
|
if request.IsPublish {
|
519
|
if request.IsPublish {
|
|
|
520
|
+
|
510
|
//更新待处理->提交
|
521
|
//更新待处理->提交
|
511
|
if err = models.UpdatetAuditFlowProcessToSubmit(orm, request.Id, 0, protocol.ReviewStatusSubmit, header.UserId); err != nil {
|
522
|
if err = models.UpdatetAuditFlowProcessToSubmit(orm, request.Id, 0, protocol.ReviewStatusSubmit, header.UserId); err != nil {
|
512
|
log.Error(err)
|
523
|
log.Error(err)
|
|
@@ -737,18 +748,19 @@ func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePe |
|
@@ -737,18 +748,19 @@ func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePe |
737
|
}
|
748
|
}
|
738
|
|
749
|
|
739
|
//生成审批流-提交记录
|
750
|
//生成审批流-提交记录
|
740
|
-func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64, reviewStatus int) (v *models.AuditFlowProcess) {
|
751
|
+func GenAuditFlowProcess_Submit(userId, chanceId int64, templateId int64, reviewStatus int) (v *models.AuditFlowProcess) {
|
741
|
v = &models.AuditFlowProcess{
|
752
|
v = &models.AuditFlowProcess{
|
742
|
Id: idgen.Next(),
|
753
|
Id: idgen.Next(),
|
743
|
ChanceId: chanceId,
|
754
|
ChanceId: chanceId,
|
744
|
- Uid: header.UserId,
|
755
|
+ Uid: userId,
|
745
|
CreateAt: time.Now(),
|
756
|
CreateAt: time.Now(),
|
746
|
UpdateAt: time.Now(),
|
757
|
UpdateAt: time.Now(),
|
747
|
ApproveTime: time.Now(),
|
758
|
ApproveTime: time.Now(),
|
748
|
EnableStatus: 1,
|
759
|
EnableStatus: 1,
|
|
|
760
|
+ IsActive: 1,
|
749
|
ReviewStatus: int8(reviewStatus),
|
761
|
ReviewStatus: int8(reviewStatus),
|
750
|
}
|
762
|
}
|
751
|
- if approver, err := models.GetUsersById(header.Uid); err != nil {
|
763
|
+ if approver, err := models.GetUsersById(userId); err != nil {
|
752
|
log.Error(err)
|
764
|
log.Error(err)
|
753
|
return
|
765
|
return
|
754
|
} else {
|
766
|
} else {
|
|
@@ -767,7 +779,8 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -767,7 +779,8 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
767
|
company *models.Company
|
779
|
company *models.Company
|
768
|
roleName string
|
780
|
roleName string
|
769
|
approver *models.User
|
781
|
approver *models.User
|
770
|
- roleId []int
|
782
|
+ roleIds []int
|
|
|
783
|
+ roleId int
|
771
|
)
|
784
|
)
|
772
|
if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
|
785
|
if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
|
773
|
if err == orm.ErrNoRows {
|
786
|
if err == orm.ErrNoRows {
|
|
@@ -849,11 +862,15 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -849,11 +862,15 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
849
|
}
|
862
|
}
|
850
|
break
|
863
|
break
|
851
|
case protocol.AuditByRole:
|
864
|
case protocol.AuditByRole:
|
852
|
- if e := json.Unmarshal([]byte(config.ToRole), &roleId); e == nil {
|
|
|
853
|
- if userIds, err = getRoleUsers(header, roleId[0]); err != nil {
|
865
|
+ if e := json.Unmarshal([]byte(config.ToRole), &roleIds); e == nil {
|
|
|
866
|
+ if userIds, err = getRoleUsers(header, roleIds[0]); err != nil {
|
854
|
log.Error(err)
|
867
|
log.Error(err)
|
855
|
return
|
868
|
return
|
856
|
}
|
869
|
}
|
|
|
870
|
+ if role, e := models.GetRoleById(roleIds[0]); e == nil {
|
|
|
871
|
+ roleName = role.Name
|
|
|
872
|
+ roleId = role.Id
|
|
|
873
|
+ }
|
857
|
} else {
|
874
|
} else {
|
858
|
log.Error(config.ToRole, e)
|
875
|
log.Error(config.ToRole, e)
|
859
|
}
|
876
|
}
|
|
@@ -890,6 +907,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -890,6 +907,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
890
|
ActionType: int(config.ActionType),
|
907
|
ActionType: int(config.ActionType),
|
891
|
RoleName: roleName,
|
908
|
RoleName: roleName,
|
892
|
UserName: approver.NickName,
|
909
|
UserName: approver.NickName,
|
|
|
910
|
+ RoleId: roleId,
|
893
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
911
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
894
|
TemplateId: int(templateId),
|
912
|
TemplateId: int(templateId),
|
895
|
}
|
913
|
}
|
|
@@ -897,7 +915,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -897,7 +915,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
897
|
item.IsActive = 1
|
915
|
item.IsActive = 1
|
898
|
item.EnableStatus = 1
|
916
|
item.EnableStatus = 1
|
899
|
}
|
917
|
}
|
900
|
- 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)))
|
918
|
+ 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))
|
901
|
v = append(v, item)
|
919
|
v = append(v, item)
|
902
|
}
|
920
|
}
|
903
|
}
|
921
|
}
|
|
@@ -905,10 +923,10 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -905,10 +923,10 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
905
|
}
|
923
|
}
|
906
|
func resolveActionType(t uint) string {
|
924
|
func resolveActionType(t uint) string {
|
907
|
if t == 1 {
|
925
|
if t == 1 {
|
908
|
- return "or"
|
926
|
+ return "and"
|
909
|
}
|
927
|
}
|
910
|
if t == 2 {
|
928
|
if t == 2 {
|
911
|
- return "and"
|
929
|
+ return "or"
|
912
|
}
|
930
|
}
|
913
|
return fmt.Sprintf("%v", t)
|
931
|
return fmt.Sprintf("%v", t)
|
914
|
}
|
932
|
}
|