...
|
...
|
@@ -12,6 +12,7 @@ import ( |
|
|
"opp/models"
|
|
|
"opp/protocol"
|
|
|
"opp/services/agg"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -403,6 +404,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//发送提交日志
|
|
|
if err = agg.SaveApproveLog(orm, 1, header.UserId, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
orm.Commit()
|
|
|
|
|
|
rsp = &protocol.ChanceSubmitResponse{}
|
...
|
...
|
@@ -449,10 +456,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
|
|
|
request.IsPublish = true
|
|
|
updateMap["DepartmentId"] = request.RelatedDepartment
|
|
|
//log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v",request.IsPublish,chance.ReviewStatus,chance.UserId==header.UserId))
|
|
|
} else {
|
|
|
log.Info(fmt.Sprintf("机会编辑 chance_id:%v chance.review_status:%v 无待处理 审核数据", request.Id, chance.ReviewStatus))
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
request.IsPublish = false
|
|
|
log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v", request.IsPublish, chance.ReviewStatus, chance.UserId == header.UserId))
|
|
|
}
|
|
|
//TODO:非本人 1.需要验证角色权限 2是否是审核人 3.是否是本人 (目前本人才可以审核)
|
|
|
if chance.UserId != header.UserId {
|
...
|
...
|
@@ -561,6 +571,12 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//发送提交日志
|
|
|
if err = agg.SaveApproveLog(orm, 1, chance.UserId, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
orm.Commit()
|
...
|
...
|
@@ -621,12 +637,43 @@ func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.Chanc |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err = saveApproveMsgChangePublic(orm, chance, request.PublicData); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
orm.Commit()
|
|
|
//TODO:添加log
|
|
|
rsp = &protocol.ChanceChangePublishResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//发送审核日志
|
|
|
func saveApproveMsgChangePublic(orm orm.Ormer, chance *models.Chance, approveData protocol.PublicData) (err error) {
|
|
|
var (
|
|
|
parames = make([]interface{}, 0)
|
|
|
code = 0
|
|
|
)
|
|
|
if approveData.PublishStatus == protocol.PublicToCompany {
|
|
|
code = 7
|
|
|
}
|
|
|
if approveData.PublishStatus == protocol.PublicToDepartment {
|
|
|
code = 8
|
|
|
var department []string
|
|
|
for i := range approveData.VisibleObjects {
|
|
|
v := approveData.VisibleObjects[i]
|
|
|
department = append(department, v.Name)
|
|
|
}
|
|
|
parames = append(parames, strings.Join(department, ","))
|
|
|
}
|
|
|
if err = agg.SaveApproveLog(orm, code, chance.UserId, chance.Id, parames...); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//修改评分
|
|
|
func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceChangeScoreRequest) (rsp *protocol.ChanceChangeScoreResponse, err error) {
|
|
|
var (
|
...
|
...
|
@@ -668,6 +715,17 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC |
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
//修改评分日志
|
|
|
if err = agg.SaveApproveLog(orm, 9, chance.UserId, chance.Id, request.Score.BasicScore, request.Score.ExtraScore, request.Score.ValueScore); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//if err = agg.SaveApproveLog(orm,9,chance.UserId,chance.Id,request.Score.BasicScore,request.Score.ExtraScore,request.Score.ValueScore);err!=nil{
|
|
|
// log.Error(err)
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
orm.Commit()
|
|
|
rsp = &protocol.ChanceChangeScoreResponse{
|
|
|
DiscoveryScore: result.DiscoveryScore,
|
...
|
...
|
@@ -844,11 +902,13 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
|
|
|
|
if company.AdminId == 0 {
|
|
|
err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
|
|
|
err = protocol.NewErrWithMessage(5207)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if admin, err = models.GetUserCompanyByUserId(company.AdminId, header.CompanyId); err != nil {
|
|
|
err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
|
|
|
err = protocol.NewErrWithMessage(5207)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -942,7 +1002,8 @@ func resolveActionType(t uint) string { |
|
|
//获取部门长用户列表
|
|
|
func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) {
|
|
|
var (
|
|
|
departments *models.Department
|
|
|
departments *models.Department
|
|
|
lastDepartmentId int
|
|
|
)
|
|
|
//if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil {
|
|
|
// log.Error(header.UserId,header.CompanyId,err)
|
...
|
...
|
@@ -952,6 +1013,7 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) |
|
|
log.Error(relatedDeparmentId, err)
|
|
|
return
|
|
|
}
|
|
|
//部门长
|
|
|
for {
|
|
|
if len(departments.Managers) > 0 {
|
|
|
var tmpIds []int64
|
...
|
...
|
@@ -966,7 +1028,9 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) |
|
|
//break
|
|
|
}
|
|
|
if departments.ParentId != 0 {
|
|
|
if departments, err = models.GetDepartmentById(int(relatedDeparmentId)); err != nil {
|
|
|
//relatedDeparmentId = int64departments.ParentId
|
|
|
lastDepartmentId = departments.ParentId
|
|
|
if departments, err = models.GetDepartmentById(int(departments.ParentId)); err != nil {
|
|
|
log.Error(relatedDeparmentId, err)
|
|
|
err = nil
|
|
|
break
|
...
|
...
|
@@ -979,7 +1043,7 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) |
|
|
if len(ids) == 0 {
|
|
|
ids = append(ids, 0)
|
|
|
}
|
|
|
log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v", relatedDeparmentId, departments.Managers, ids))
|
|
|
log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v last_department_id:%v", relatedDeparmentId, departments.Managers, ids, lastDepartmentId))
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1080,9 +1144,11 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh |
|
|
commItem := protocol.CommonListItem{}
|
|
|
{
|
|
|
item := protocol.ChanceItem{
|
|
|
Id: chance.Id,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
Id: chance.Id,
|
|
|
Provider: provider,
|
|
|
CreateTime: chance.CreateTime.Unix() * 1000,
|
|
|
UpdateTime: chance.UpdateTime.Unix() * 1000,
|
|
|
ApproveTime: chance.ApproveTime.Unix() * 1000,
|
|
|
}
|
|
|
jsonUnmarshal(chance.SourceContent, &item.FormList)
|
|
|
item.FormList = clearEmptyForm(item.FormList)
|
...
|
...
|
@@ -1638,15 +1704,26 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete |
|
|
err = protocol.NewErrWithMessage(5202)
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(chance, map[string]interface{}{
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
//发送提交日志
|
|
|
if err = agg.SaveApproveLog(orm, 2, chance.UserId, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm, chance, map[string]interface{}{
|
|
|
"EnableStatus": int8(0),
|
|
|
}); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if err = models.CloseAuditFlowProcess(chance.Id); err != nil {
|
|
|
if err = models.CloseAuditFlowProcess(orm, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
orm.Commit()
|
|
|
return
|
|
|
} |
...
|
...
|
|