|
@@ -434,27 +434,27 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
@@ -434,27 +434,27 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
434
|
"待更新的承接人": undertakerModelsToUpdate,
|
434
|
"待更新的承接人": undertakerModelsToUpdate,
|
435
|
})
|
435
|
})
|
436
|
for i, undertakerModelToUpdate := range undertakerModelsToUpdate {
|
436
|
for i, undertakerModelToUpdate := range undertakerModelsToUpdate {
|
437
|
- for j, undertaker := range cooperationContract.Undertakers {
|
437
|
+ for _, undertaker := range cooperationContract.Undertakers {
|
438
|
if undertaker.UndertakerId == undertakerModelToUpdate.CooperationContractUndertakerId {
|
438
|
if undertaker.UndertakerId == undertakerModelToUpdate.CooperationContractUndertakerId {
|
439
|
undertakerModelsToUpdate[i] = &models.CooperationContractUndertaker{
|
439
|
undertakerModelsToUpdate[i] = &models.CooperationContractUndertaker{
|
440
|
- CooperationContractUndertakerId: cooperationContract.Undertakers[j].UndertakerId,
|
|
|
441
|
- CooperationContractNumber: cooperationContract.Undertakers[j].CooperationContractNumber,
|
|
|
442
|
- UserId: cooperationContract.Undertakers[j].UserId,
|
|
|
443
|
- UserBaseId: cooperationContract.Undertakers[j].UserBaseId,
|
|
|
444
|
- Org: cooperationContract.Undertakers[j].Org,
|
|
|
445
|
- Orgs: cooperationContract.Undertakers[j].Orgs,
|
|
|
446
|
- Department: cooperationContract.Undertakers[j].Department,
|
|
|
447
|
- Roles: cooperationContract.Undertakers[j].Roles,
|
|
|
448
|
- UserInfo: cooperationContract.Undertakers[j].UserInfo,
|
|
|
449
|
- UserType: cooperationContract.Undertakers[j].UserType,
|
|
|
450
|
- Referrer: cooperationContract.Undertakers[j].Referrer,
|
|
|
451
|
- Salesman: cooperationContract.Undertakers[j].Salesman,
|
|
|
452
|
- Status: cooperationContract.Undertakers[j].Status,
|
|
|
453
|
- Company: cooperationContract.Undertakers[j].Company,
|
|
|
454
|
- ContractAttachment: cooperationContract.Undertakers[j].ContractAttachment,
|
|
|
455
|
- CreatedAt: undertakerModelsToUpdate[i].CreatedAt,
|
440
|
+ CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
441
|
+ CooperationContractNumber: undertaker.CooperationContractNumber,
|
|
|
442
|
+ UserId: undertaker.UserId,
|
|
|
443
|
+ UserBaseId: undertaker.UserBaseId,
|
|
|
444
|
+ Org: undertaker.Org,
|
|
|
445
|
+ Orgs: undertaker.Orgs,
|
|
|
446
|
+ Department: undertaker.Department,
|
|
|
447
|
+ Roles: undertaker.Roles,
|
|
|
448
|
+ UserInfo: undertaker.UserInfo,
|
|
|
449
|
+ UserType: undertaker.UserType,
|
|
|
450
|
+ Referrer: undertaker.Referrer,
|
|
|
451
|
+ Salesman: undertaker.Salesman,
|
|
|
452
|
+ Status: undertaker.Status,
|
|
|
453
|
+ Company: undertaker.Company,
|
|
|
454
|
+ ContractAttachment: undertaker.ContractAttachment,
|
|
|
455
|
+ CreatedAt: undertakerModelToUpdate.CreatedAt,
|
456
|
UpdatedAt: time.Now(),
|
456
|
UpdatedAt: time.Now(),
|
457
|
- DeletedAt: undertakerModelsToUpdate[i].DeletedAt,
|
457
|
+ DeletedAt: undertakerModelToUpdate.DeletedAt,
|
458
|
}
|
458
|
}
|
459
|
}
|
459
|
}
|
460
|
}
|
460
|
}
|
|
@@ -558,7 +558,30 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
@@ -558,7 +558,30 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
558
|
log.Logger.Info("待更新的分红激励规则", map[string]interface{}{
|
558
|
log.Logger.Info("待更新的分红激励规则", map[string]interface{}{
|
559
|
"dividendsRuleModelsToUpdate": dividendsRuleModelsToUpdate,
|
559
|
"dividendsRuleModelsToUpdate": dividendsRuleModelsToUpdate,
|
560
|
})
|
560
|
})
|
|
|
561
|
+
|
561
|
if len(dividendsRuleModelsToUpdate) > 0 {
|
562
|
if len(dividendsRuleModelsToUpdate) > 0 {
|
|
|
563
|
+ for i, dividendsRuleModelToUpdate := range dividendsRuleModelsToUpdate {
|
|
|
564
|
+ for _, dividendsRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
565
|
+ if dividendsRule.DividendsIncentivesRuleId == dividendsRuleModelToUpdate.DividendsIncentivesRuleId {
|
|
|
566
|
+ dividendsRuleModelsToUpdate[i] = &models.DividendsIncentivesRule{
|
|
|
567
|
+ DividendsIncentivesRuleId: dividendsRuleModelToUpdate.DividendsIncentivesRuleId,
|
|
|
568
|
+ CooperationContractNumber: dividendsRuleModelToUpdate.CooperationContractNumber,
|
|
|
569
|
+ ReferrerPercentage: dividendsRuleModelToUpdate.ReferrerPercentage,
|
|
|
570
|
+ SalesmanPercentage: dividendsRuleModelToUpdate.SalesmanPercentage,
|
|
|
571
|
+ DividendsIncentivesPercentage: dividendsRuleModelToUpdate.DividendsIncentivesPercentage,
|
|
|
572
|
+ DividendsIncentivesStage: dividendsRuleModelToUpdate.DividendsIncentivesStage,
|
|
|
573
|
+ DividendsIncentivesStageEnd: dividendsRuleModelToUpdate.DividendsIncentivesStageEnd,
|
|
|
574
|
+ DividendsIncentivesStageStart: dividendsRuleModelToUpdate.DividendsIncentivesStageStart,
|
|
|
575
|
+ Remarks: dividendsRuleModelToUpdate.Remarks,
|
|
|
576
|
+ Org: dividendsRuleModelToUpdate.Org,
|
|
|
577
|
+ Company: dividendsRuleModelToUpdate.Company,
|
|
|
578
|
+ UpdatedAt: time.Now(),
|
|
|
579
|
+ DeletedAt: dividendsRuleModelToUpdate.DeletedAt,
|
|
|
580
|
+ CreatedAt: dividendsRuleModelToUpdate.CreatedAt,
|
|
|
581
|
+ }
|
|
|
582
|
+ }
|
|
|
583
|
+ }
|
|
|
584
|
+ }
|
562
|
if _, err := tx.Model(÷ndsRuleModelsToUpdate).WherePK().Update(); err != nil {
|
585
|
if _, err := tx.Model(÷ndsRuleModelsToUpdate).WherePK().Update(); err != nil {
|
563
|
return nil, err
|
586
|
return nil, err
|
564
|
}
|
587
|
}
|
|
@@ -656,6 +679,29 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
@@ -656,6 +679,29 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
656
|
"moneyRuleModelsToUpdate": moneyRuleModelsToUpdate,
|
679
|
"moneyRuleModelsToUpdate": moneyRuleModelsToUpdate,
|
657
|
})
|
680
|
})
|
658
|
if len(moneyRuleModelsToUpdate) > 0 {
|
681
|
if len(moneyRuleModelsToUpdate) > 0 {
|
|
|
682
|
+ for i, moneyRuleModelToUpdate := range moneyRuleModelsToUpdate {
|
|
|
683
|
+ for _, moneyRule := range cooperationContract.MoneyIncentivesRules {
|
|
|
684
|
+ if moneyRule.MoneyIncentivesRuleId == moneyRuleModelToUpdate.MoneyIncentivesRuleId {
|
|
|
685
|
+ moneyRuleModelsToUpdate[i] = &models.MoneyIncentivesRule{
|
|
|
686
|
+ MoneyIncentivesRuleId: moneyRule.MoneyIncentivesRuleId,
|
|
|
687
|
+ CooperationContractNumber: moneyRule.CooperationContractNumber,
|
|
|
688
|
+ MoneyIncentivesAmount: moneyRule.MoneyIncentivesAmount,
|
|
|
689
|
+ MoneyIncentivesStage: moneyRule.MoneyIncentivesStage,
|
|
|
690
|
+ MoneyIncentivesStageEnd: moneyRule.MoneyIncentivesStageEnd,
|
|
|
691
|
+ MoneyIncentivesStageStart: moneyRule.MoneyIncentivesStageStart,
|
|
|
692
|
+ MoneyIncentivesTime: moneyRule.MoneyIncentivesTime,
|
|
|
693
|
+ ReferrerPercentage: moneyRule.MoneyIncentivesAmount,
|
|
|
694
|
+ SalesmanPercentage: moneyRule.MoneyIncentivesAmount,
|
|
|
695
|
+ Remarks: moneyRule.Remarks,
|
|
|
696
|
+ Org: moneyRule.Org,
|
|
|
697
|
+ Company: moneyRule.Company,
|
|
|
698
|
+ UpdatedAt: time.Now(),
|
|
|
699
|
+ DeletedAt: moneyRuleModelToUpdate.DeletedAt,
|
|
|
700
|
+ CreatedAt: moneyRuleModelToUpdate.CreatedAt,
|
|
|
701
|
+ }
|
|
|
702
|
+ }
|
|
|
703
|
+ }
|
|
|
704
|
+ }
|
659
|
if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil {
|
705
|
if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil {
|
660
|
return nil, err
|
706
|
return nil, err
|
661
|
}
|
707
|
}
|