|
@@ -263,23 +263,30 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -263,23 +263,30 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
263
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
263
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
264
|
DepartmentId: request.RelatedDepartment,
|
264
|
DepartmentId: request.RelatedDepartment,
|
265
|
}
|
265
|
}
|
266
|
- if _, err = orm.Insert(chance); err != nil {
|
266
|
+ logAndRollBack := func(err error) {
|
267
|
log.Error(err)
|
267
|
log.Error(err)
|
268
|
orm.Rollback()
|
268
|
orm.Rollback()
|
269
|
return
|
269
|
return
|
270
|
}
|
270
|
}
|
|
|
271
|
+ if _, err = orm.Insert(chance); err != nil {
|
|
|
272
|
+ logAndRollBack(err)
|
|
|
273
|
+ return
|
|
|
274
|
+ }
|
271
|
|
275
|
|
|
|
276
|
+ //生成提交记录
|
|
|
277
|
+ if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id)); err != nil {
|
|
|
278
|
+ logAndRollBack(err)
|
|
|
279
|
+ return
|
|
|
280
|
+ }
|
272
|
//4.查询审核配置
|
281
|
//4.查询审核配置
|
273
|
//5.生成审核流
|
282
|
//5.生成审核流
|
274
|
if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
283
|
if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
275
|
- log.Error(err)
|
|
|
276
|
- orm.Rollback()
|
284
|
+ logAndRollBack(err)
|
277
|
return
|
285
|
return
|
278
|
}
|
286
|
}
|
279
|
for i := 0; i < len(auditFlows); i++ {
|
287
|
for i := 0; i < len(auditFlows); i++ {
|
280
|
if _, err = orm.Insert(auditFlows[i]); err != nil {
|
288
|
if _, err = orm.Insert(auditFlows[i]); err != nil {
|
281
|
- log.Error(err)
|
|
|
282
|
- orm.Rollback()
|
289
|
+ logAndRollBack(err)
|
283
|
return
|
290
|
return
|
284
|
}
|
291
|
}
|
285
|
}
|
292
|
}
|
|
@@ -296,8 +303,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -296,8 +303,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
296
|
message := m.MessageData[i]
|
303
|
message := m.MessageData[i]
|
297
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
304
|
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
|
298
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
305
|
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
|
299
|
- log.Error(err)
|
|
|
300
|
- orm.Rollback()
|
306
|
+ logAndRollBack(err)
|
301
|
return
|
307
|
return
|
302
|
}
|
308
|
}
|
303
|
}
|
309
|
}
|
|
@@ -316,8 +322,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -316,8 +322,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
316
|
UpdateAt: time.Now(),
|
322
|
UpdateAt: time.Now(),
|
317
|
}
|
323
|
}
|
318
|
if _, err = orm.Insert(data); err != nil {
|
324
|
if _, err = orm.Insert(data); err != nil {
|
319
|
- log.Error(err)
|
|
|
320
|
- orm.Rollback()
|
325
|
+ logAndRollBack(err)
|
321
|
return
|
326
|
return
|
322
|
}
|
327
|
}
|
323
|
}
|
328
|
}
|
|
@@ -406,6 +411,21 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -406,6 +411,21 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
406
|
return
|
411
|
return
|
407
|
}
|
412
|
}
|
408
|
|
413
|
|
|
|
414
|
+//生成审批流-提交记录
|
|
|
415
|
+func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) {
|
|
|
416
|
+ v = &models.AuditFlowProcess{
|
|
|
417
|
+ Id: idgen.Next(),
|
|
|
418
|
+ ChanceId: chanceId,
|
|
|
419
|
+ Uid: header.UserId,
|
|
|
420
|
+ CreateAt: time.Now(),
|
|
|
421
|
+ UpdateAt: time.Now(),
|
|
|
422
|
+ ApproveTime: time.Now(),
|
|
|
423
|
+ EnableStatus: 1,
|
|
|
424
|
+ ReviewStatus: protocol.ReviewStatusSubmit,
|
|
|
425
|
+ }
|
|
|
426
|
+ return
|
|
|
427
|
+}
|
|
|
428
|
+
|
409
|
//生成审批流
|
429
|
//生成审批流
|
410
|
func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) {
|
430
|
func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) {
|
411
|
var (
|
431
|
var (
|
|
@@ -475,7 +495,6 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
|
@@ -475,7 +495,6 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat |
475
|
err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
|
495
|
err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
|
476
|
return
|
496
|
return
|
477
|
}
|
497
|
}
|
478
|
-
|
|
|
479
|
//3.生成审核列表
|
498
|
//3.生成审核列表
|
480
|
for i := range configs {
|
499
|
for i := range configs {
|
481
|
config := configs[i]
|
500
|
config := configs[i]
|