|
@@ -52,7 +52,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
|
@@ -52,7 +52,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces |
52
|
Approver: userCompany.NickName,
|
52
|
Approver: userCompany.NickName,
|
53
|
Uid: userCompany.Id,
|
53
|
Uid: userCompany.Id,
|
54
|
Sign: ApproveSign,
|
54
|
Sign: ApproveSign,
|
55
|
- Type: 1,
|
55
|
+ Type: 2,
|
56
|
}
|
56
|
}
|
57
|
for i := range process {
|
57
|
for i := range process {
|
58
|
var (
|
58
|
var (
|
|
@@ -343,29 +343,42 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
@@ -343,29 +343,42 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
343
|
return
|
343
|
return
|
344
|
}
|
344
|
}
|
345
|
log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
|
345
|
log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
|
|
|
346
|
+ orm := orm.NewOrm()
|
|
|
347
|
+ orm.Begin()
|
|
|
348
|
+ if request.ReviewStatus == protocol.ReviewStatusReturn {
|
|
|
349
|
+ mapChance["ReviewStatus"] = int8(request.ReviewStatus) //退回也要更新审核状态
|
|
|
350
|
+ //增加一条待处理记录到审核列表
|
|
|
351
|
+ //生成提交记录
|
|
|
352
|
+ if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, chance.AuditTemplateId, protocol.ReviewStatusWait)); err != nil {
|
|
|
353
|
+ log.Error(err)
|
|
|
354
|
+ orm.Rollback()
|
|
|
355
|
+ return
|
|
|
356
|
+ }
|
|
|
357
|
+ }
|
346
|
{
|
358
|
{
|
347
|
//更新下一批次的审核人
|
359
|
//更新下一批次的审核人
|
348
|
var nextApprovers []int64
|
360
|
var nextApprovers []int64
|
|
|
361
|
+ if err = agg.SendApprovedMsg(chance.UserId, "",
|
|
|
362
|
+ header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
363
|
+ log.Error(err)
|
|
|
364
|
+ orm.Rollback()
|
|
|
365
|
+ return
|
|
|
366
|
+ }
|
349
|
if approveItemResponse.IsOver == 1 {
|
367
|
if approveItemResponse.IsOver == 1 {
|
350
|
//结束审批
|
368
|
//结束审批
|
351
|
{
|
369
|
{
|
352
|
mapChance["ReviewStatus"] = int8(request.ReviewStatus)
|
370
|
mapChance["ReviewStatus"] = int8(request.ReviewStatus)
|
353
|
}
|
371
|
}
|
354
|
//发送审核结果消息给提交人
|
372
|
//发送审核结果消息给提交人
|
355
|
- for i := range approveItemResponse.MessageData.ApplyUserMessage {
|
|
|
356
|
- message := approveItemResponse.MessageData.ApplyUserMessage[i]
|
|
|
357
|
- nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
358
|
- if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
359
|
- header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
360
|
- log.Error(err)
|
|
|
361
|
- return
|
|
|
362
|
- }
|
|
|
363
|
- }
|
|
|
364
|
- //更新同批次的为审核的状态置为无效
|
|
|
365
|
- if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
366
|
- log.Error(err)
|
|
|
367
|
- return
|
|
|
368
|
- }
|
373
|
+ //for i := range approveItemResponse.MessageData.ApplyUserMessage {
|
|
|
374
|
+ // message := approveItemResponse.MessageData.ApplyUserMessage[i]
|
|
|
375
|
+ // nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
|
|
|
376
|
+ // if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
|
|
377
|
+ // header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
|
|
|
378
|
+ // log.Error(err)
|
|
|
379
|
+ // return
|
|
|
380
|
+ // }
|
|
|
381
|
+ //}
|
369
|
} else {
|
382
|
} else {
|
370
|
//发送下一个消息给下一流程的审核人
|
383
|
//发送下一个消息给下一流程的审核人
|
371
|
for i := range approveItemResponse.MessageData.ApproveMessage {
|
384
|
for i := range approveItemResponse.MessageData.ApproveMessage {
|
|
@@ -374,26 +387,27 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
@@ -374,26 +387,27 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
374
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
387
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
375
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
388
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
376
|
log.Error(err)
|
389
|
log.Error(err)
|
|
|
390
|
+ orm.Rollback()
|
377
|
return
|
391
|
return
|
378
|
}
|
392
|
}
|
379
|
}
|
393
|
}
|
380
|
//更新下一批次的审核人 同批次的为审核的状态置为无效
|
394
|
//更新下一批次的审核人 同批次的为审核的状态置为无效
|
381
|
if len(nextApprovers) != 0 {
|
395
|
if len(nextApprovers) != 0 {
|
382
|
- if err = models.UpdatetAuditFlowProcessToNext(chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
|
396
|
+ if err = models.UpdatetAuditFlowProcessToNext(orm, chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
|
383
|
log.Error(err)
|
397
|
log.Error(err)
|
|
|
398
|
+ orm.Rollback()
|
384
|
log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
399
|
log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
385
|
return
|
400
|
return
|
386
|
}
|
401
|
}
|
387
|
log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
402
|
log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
|
388
|
- if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
403
|
+ if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
389
|
log.Error(err)
|
404
|
log.Error(err)
|
|
|
405
|
+ orm.Rollback()
|
390
|
return
|
406
|
return
|
391
|
}
|
407
|
}
|
392
|
}
|
408
|
}
|
393
|
}
|
409
|
}
|
394
|
}
|
410
|
}
|
395
|
- orm := orm.NewOrm()
|
|
|
396
|
- orm.Begin()
|
|
|
397
|
if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil {
|
411
|
if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil {
|
398
|
log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err)
|
412
|
log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err)
|
399
|
orm.Rollback()
|
413
|
orm.Rollback()
|
|
@@ -404,6 +418,14 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
|
@@ -404,6 +418,14 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro |
404
|
log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
|
418
|
log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
|
405
|
return
|
419
|
return
|
406
|
}
|
420
|
}
|
|
|
421
|
+ if request.ReviewStatus == protocol.ReviewStatusReturn || approveItemResponse.IsOver == 1 {
|
|
|
422
|
+ //更新同批次的为审核的状态置为无效
|
|
|
423
|
+ if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
|
|
|
424
|
+ log.Error(err)
|
|
|
425
|
+ orm.Rollback()
|
|
|
426
|
+ return
|
|
|
427
|
+ }
|
|
|
428
|
+ }
|
407
|
if request.ApproveData.PublicData.PublishStatus == protocol.PublicToDepartment {
|
429
|
if request.ApproveData.PublicData.PublishStatus == protocol.PublicToDepartment {
|
408
|
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil {
|
430
|
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil {
|
409
|
log.Error(err)
|
431
|
log.Error(err)
|