...
|
...
|
@@ -167,7 +167,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule
|
|
|
for _, rule := range cooperationContract.DividendsIncentivesRules {
|
|
|
dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{
|
|
|
DividendsIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: cooperationContract.CooperationContractNumber,
|
|
|
ReferrerPercentage: rule.ReferrerPercentage,
|
|
|
SalesmanPercentage: rule.SalesmanPercentage,
|
...
|
...
|
@@ -193,7 +192,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
var moneyIncentivesRulesModel []*models.MoneyIncentivesRule
|
|
|
for _, rule := range cooperationContract.MoneyIncentivesRules {
|
|
|
moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{
|
|
|
MoneyIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: cooperationContract.CooperationContractNumber,
|
|
|
MoneyIncentivesAmount: rule.MoneyIncentivesAmount,
|
|
|
MoneyIncentivesStage: rule.MoneyIncentivesStage,
|
...
|
...
|
@@ -292,7 +290,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant
|
|
|
for _, relevantDomain := range cooperationContractRelevantPeopleToAdd {
|
|
|
cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{
|
|
|
CooperationContractRelevantId: 0,
|
|
|
CooperationContractNumber: relevantDomain.CooperationContractNumber,
|
|
|
UserId: relevantDomain.UserId,
|
|
|
UserBaseId: relevantDomain.UserBaseId,
|
...
|
...
|
@@ -437,27 +434,27 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
"待更新的承接人": undertakerModelsToUpdate,
|
|
|
})
|
|
|
for i, undertakerModelToUpdate := range undertakerModelsToUpdate {
|
|
|
for j, undertaker := range cooperationContract.Undertakers {
|
|
|
for _, undertaker := range cooperationContract.Undertakers {
|
|
|
if undertaker.UndertakerId == undertakerModelToUpdate.CooperationContractUndertakerId {
|
|
|
undertakerModelsToUpdate[i] = &models.CooperationContractUndertaker{
|
|
|
CooperationContractUndertakerId: cooperationContract.Undertakers[j].UndertakerId,
|
|
|
CooperationContractNumber: cooperationContract.Undertakers[j].CooperationContractNumber,
|
|
|
UserId: cooperationContract.Undertakers[j].UserId,
|
|
|
UserBaseId: cooperationContract.Undertakers[j].UserBaseId,
|
|
|
Org: cooperationContract.Undertakers[j].Org,
|
|
|
Orgs: cooperationContract.Undertakers[j].Orgs,
|
|
|
Department: cooperationContract.Undertakers[j].Department,
|
|
|
Roles: cooperationContract.Undertakers[j].Roles,
|
|
|
UserInfo: cooperationContract.Undertakers[j].UserInfo,
|
|
|
UserType: cooperationContract.Undertakers[j].UserType,
|
|
|
Referrer: cooperationContract.Undertakers[j].Referrer,
|
|
|
Salesman: cooperationContract.Undertakers[j].Salesman,
|
|
|
Status: cooperationContract.Undertakers[j].Status,
|
|
|
Company: cooperationContract.Undertakers[j].Company,
|
|
|
ContractAttachment: cooperationContract.Undertakers[j].ContractAttachment,
|
|
|
CreatedAt: undertakerModelsToUpdate[i].CreatedAt,
|
|
|
CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
CooperationContractNumber: undertaker.CooperationContractNumber,
|
|
|
UserId: undertaker.UserId,
|
|
|
UserBaseId: undertaker.UserBaseId,
|
|
|
Org: undertaker.Org,
|
|
|
Orgs: undertaker.Orgs,
|
|
|
Department: undertaker.Department,
|
|
|
Roles: undertaker.Roles,
|
|
|
UserInfo: undertaker.UserInfo,
|
|
|
UserType: undertaker.UserType,
|
|
|
Referrer: undertaker.Referrer,
|
|
|
Salesman: undertaker.Salesman,
|
|
|
Status: undertaker.Status,
|
|
|
Company: undertaker.Company,
|
|
|
ContractAttachment: undertaker.ContractAttachment,
|
|
|
CreatedAt: undertakerModelToUpdate.CreatedAt,
|
|
|
UpdatedAt: time.Now(),
|
|
|
DeletedAt: undertakerModelsToUpdate[i].DeletedAt,
|
|
|
DeletedAt: undertakerModelToUpdate.DeletedAt,
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -561,7 +558,30 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
log.Logger.Info("待更新的分红激励规则", map[string]interface{}{
|
|
|
"dividendsRuleModelsToUpdate": dividendsRuleModelsToUpdate,
|
|
|
})
|
|
|
|
|
|
if len(dividendsRuleModelsToUpdate) > 0 {
|
|
|
for i, dividendsRuleModelToUpdate := range dividendsRuleModelsToUpdate {
|
|
|
for _, dividendsRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
if dividendsRule.DividendsIncentivesRuleId == dividendsRuleModelToUpdate.DividendsIncentivesRuleId {
|
|
|
dividendsRuleModelsToUpdate[i] = &models.DividendsIncentivesRule{
|
|
|
DividendsIncentivesRuleId: dividendsRuleModelToUpdate.DividendsIncentivesRuleId,
|
|
|
CooperationContractNumber: dividendsRuleModelToUpdate.CooperationContractNumber,
|
|
|
ReferrerPercentage: dividendsRuleModelToUpdate.ReferrerPercentage,
|
|
|
SalesmanPercentage: dividendsRuleModelToUpdate.SalesmanPercentage,
|
|
|
DividendsIncentivesPercentage: dividendsRuleModelToUpdate.DividendsIncentivesPercentage,
|
|
|
DividendsIncentivesStage: dividendsRuleModelToUpdate.DividendsIncentivesStage,
|
|
|
DividendsIncentivesStageEnd: dividendsRuleModelToUpdate.DividendsIncentivesStageEnd,
|
|
|
DividendsIncentivesStageStart: dividendsRuleModelToUpdate.DividendsIncentivesStageStart,
|
|
|
Remarks: dividendsRuleModelToUpdate.Remarks,
|
|
|
Org: dividendsRuleModelToUpdate.Org,
|
|
|
Company: dividendsRuleModelToUpdate.Company,
|
|
|
UpdatedAt: time.Now(),
|
|
|
DeletedAt: dividendsRuleModelToUpdate.DeletedAt,
|
|
|
CreatedAt: dividendsRuleModelToUpdate.CreatedAt,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if _, err := tx.Model(÷ndsRuleModelsToUpdate).WherePK().Update(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -659,6 +679,29 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
"moneyRuleModelsToUpdate": moneyRuleModelsToUpdate,
|
|
|
})
|
|
|
if len(moneyRuleModelsToUpdate) > 0 {
|
|
|
for i, moneyRuleModelToUpdate := range moneyRuleModelsToUpdate {
|
|
|
for _, moneyRule := range cooperationContract.MoneyIncentivesRules {
|
|
|
if moneyRule.MoneyIncentivesRuleId == moneyRuleModelToUpdate.MoneyIncentivesRuleId {
|
|
|
moneyRuleModelsToUpdate[i] = &models.MoneyIncentivesRule{
|
|
|
MoneyIncentivesRuleId: moneyRule.MoneyIncentivesRuleId,
|
|
|
CooperationContractNumber: moneyRule.CooperationContractNumber,
|
|
|
MoneyIncentivesAmount: moneyRule.MoneyIncentivesAmount,
|
|
|
MoneyIncentivesStage: moneyRule.MoneyIncentivesStage,
|
|
|
MoneyIncentivesStageEnd: moneyRule.MoneyIncentivesStageEnd,
|
|
|
MoneyIncentivesStageStart: moneyRule.MoneyIncentivesStageStart,
|
|
|
MoneyIncentivesTime: moneyRule.MoneyIncentivesTime,
|
|
|
ReferrerPercentage: moneyRule.MoneyIncentivesAmount,
|
|
|
SalesmanPercentage: moneyRule.MoneyIncentivesAmount,
|
|
|
Remarks: moneyRule.Remarks,
|
|
|
Org: moneyRule.Org,
|
|
|
Company: moneyRule.Company,
|
|
|
UpdatedAt: time.Now(),
|
|
|
DeletedAt: moneyRuleModelToUpdate.DeletedAt,
|
|
|
CreatedAt: moneyRuleModelToUpdate.CreatedAt,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -952,7 +995,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in |
|
|
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
|
|
|
query.Where("org->>'orgId' = '?'", orgId)
|
|
|
}
|
|
|
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
|
|
|
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]string)) > 0 {
|
|
|
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
|
|
|
}
|
|
|
if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
|
...
|
...
|
|