作者 陈志颖

refactor:共创合约优化

... ... @@ -1056,6 +1056,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
Remarks: dividendsIncentivesRule.Remarks,
})
}
... ... @@ -1084,6 +1085,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
Remarks: moneyIncentivesRule.Remarks,
})
}
... ...
... ... @@ -434,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,
}
}
}
... ... @@ -558,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(&dividendsRuleModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
}
... ... @@ -656,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
}
... ...
... ... @@ -243,30 +243,31 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
log.Logger.Info("待更新的分红订单产品", map[string]interface{}{
"orderGoodModelsToUpdate": orderGoodModelsToUpdate,
})
for i, orderGoodModelToUpdate := range orderGoodModelsToUpdate {
for j, orderGood := range dividendsOrder.Goods {
if orderGood.OrderGoodId == orderGoodModelToUpdate.OrderGoodId {
orderGoodModelsToUpdate[i] = &models.OrderGood{
OrderGoodId: dividendsOrder.Goods[j].OrderGoodId,
OrderGoodAmount: dividendsOrder.Goods[j].OrderGoodAmount,
OrderGoodName: dividendsOrder.Goods[j].OrderGoodName,
OrderGoodPrice: dividendsOrder.Goods[j].OrderGoodPrice,
OrderGoodQuantity: dividendsOrder.Goods[j].OrderGoodQuantity,
DividendsOrderNumber: dividendsOrder.Goods[j].DividendsOrderNumber,
DividendsReturnedOrderNumber: dividendsOrder.Goods[j].DividendsReturnedOrderNumber,
CooperationContractNumber: dividendsOrder.Goods[j].CooperationContractNumber,
OrgId: dividendsOrder.Goods[j].OrgId,
CompanyId: dividendsOrder.Goods[j].CompanyId,
OrderGoodExpense: dividendsOrder.Goods[j].OrderGoodExpense,
OrderGoodDividendsStatus: dividendsOrder.Goods[j].OrderGoodDividendsStatus,
CreatedAt: orderGoodModelsToUpdate[i].CreatedAt,
DeletedAt: orderGoodModelsToUpdate[i].DeletedAt,
UpdatedAt: time.Now(),
if len(orderGoodModelsToUpdate) > 0 {
for i, orderGoodModelToUpdate := range orderGoodModelsToUpdate {
for _, orderGood := range dividendsOrder.Goods {
if orderGood.OrderGoodId == orderGoodModelToUpdate.OrderGoodId {
orderGoodModelsToUpdate[i] = &models.OrderGood{
OrderGoodId: orderGoodModelToUpdate.OrderGoodId,
OrderGoodAmount: orderGoodModelToUpdate.OrderGoodAmount,
OrderGoodName: orderGoodModelToUpdate.OrderGoodName,
OrderGoodPrice: orderGoodModelToUpdate.OrderGoodPrice,
OrderGoodQuantity: orderGoodModelToUpdate.OrderGoodQuantity,
DividendsOrderNumber: orderGoodModelToUpdate.DividendsOrderNumber,
DividendsReturnedOrderNumber: orderGoodModelToUpdate.DividendsReturnedOrderNumber,
CooperationContractNumber: orderGoodModelToUpdate.CooperationContractNumber,
OrgId: orderGoodModelToUpdate.OrgId,
CompanyId: orderGoodModelToUpdate.CompanyId,
OrderGoodExpense: orderGoodModelToUpdate.OrderGoodExpense,
OrderGoodDividendsStatus: orderGoodModelToUpdate.OrderGoodDividendsStatus,
CreatedAt: orderGoodModelToUpdate.CreatedAt,
DeletedAt: orderGoodModelToUpdate.DeletedAt,
UpdatedAt: time.Now(),
}
}
}
}
}
if len(orderGoodModelsToUpdate) > 0 {
if _, err := tx.Model(&orderGoodModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
}
... ...