...
|
...
|
@@ -840,7 +840,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
// 获取公司信息
|
|
|
var company *domain.Company
|
|
|
if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司信息失败")
|
|
|
} else {
|
|
|
company = data
|
|
|
}
|
...
|
...
|
@@ -856,7 +856,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
// 获取组织机构信息
|
|
|
var organization *domain.Org
|
|
|
if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取组织机构失败")
|
|
|
} else {
|
|
|
organization = data
|
|
|
}
|
...
|
...
|
@@ -907,9 +907,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
|
|
|
// 获取发起人
|
|
|
var sponsor *domain.User
|
|
|
sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
|
|
sponsorUid, err := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "发起人UID类型错误")
|
|
|
}
|
|
|
if data, err11 := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err11 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err11.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发起人失败")
|
|
|
} else {
|
|
|
sponsor = data
|
|
|
}
|
...
|
...
|
@@ -917,7 +920,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
// 获取操作人
|
|
|
var operator *domain.User
|
|
|
if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败")
|
|
|
} else {
|
|
|
operator = data
|
|
|
}
|
...
|
...
|
@@ -927,11 +930,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
|
|
|
// 获取相关人
|
|
|
var relevantPeople []*domain.Relevant
|
|
|
for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
|
|
|
for _, relevantPersonUid := range updateCooperationContractCommand.RelevantIds {
|
|
|
var relevantDomain *domain.Relevant
|
|
|
relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
|
|
|
relevantUid, err := strconv.ParseInt(relevantPersonUid, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "相关人UID类型错误")
|
|
|
}
|
|
|
if data, err12 := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err12 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err12.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人失败")
|
|
|
} else {
|
|
|
relevantDomain = data
|
|
|
}
|
...
|
...
|
@@ -958,7 +964,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
var undertakers []*domain.Undertaker
|
|
|
for _, undertaker := range updateCooperationContractCommand.Undertakers {
|
|
|
var undertakerDomain *domain.Undertaker
|
|
|
undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
|
|
|
undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID类型错误")
|
|
|
}
|
|
|
if data, err13 := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err13 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
|
|
|
} else {
|
...
|
...
|
@@ -967,33 +976,42 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
|
|
|
// 获取推荐人
|
|
|
var referrerDomain *domain.Referrer
|
|
|
referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
|
|
if undertaker.ReferrerId != "" {
|
|
|
referrerUid, err := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "推荐人UID类型错误")
|
|
|
}
|
|
|
if referrerUid > 0 {
|
|
|
if data, err14 := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err14 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err14.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取推荐人失败")
|
|
|
} else {
|
|
|
referrerDomain = data
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取业务员
|
|
|
var salesmanDomain *domain.Salesman
|
|
|
if undertaker.SalesmanId != "" {
|
|
|
salesmanUid, err22 := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
|
|
|
if err22 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err22.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "业务员UID类型错误")
|
|
|
}
|
|
|
if salesmanUid > 0 {
|
|
|
if data, err15 := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err15 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err15.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取业务员失败")
|
|
|
} else {
|
|
|
salesmanDomain = data
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 承接人ID类型转换
|
|
|
undertakerId, err16 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
|
|
|
if err16 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
|
|
|
}
|
|
|
|
|
|
undertakers = append(undertakers, &domain.Undertaker{
|
|
|
UndertakerId: undertakerId,
|
|
|
UserId: undertakerDomain.UserId,
|
...
|
...
|
@@ -1038,6 +1056,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
CreatedAt: time.Now(),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 更新分红规则列表
|
|
|
cooperationContract.DividendsIncentivesRules = dividendsIncentivesRules
|
|
|
|
...
|
...
|
@@ -1065,6 +1084,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
CreatedAt: time.Now(),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 更新金额激励规则列表
|
|
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
|
|
|
...
|
...
|
@@ -1218,9 +1238,40 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
// 原承接人
|
|
|
var undertakersOriginal string
|
|
|
for i, undertaker := range cooperationContractFound.Undertakers {
|
|
|
if undertaker.Referrer == nil {
|
|
|
undertaker.Referrer = &domain.Referrer{
|
|
|
UserId: 0,
|
|
|
UserBaseId: 0,
|
|
|
Roles: nil,
|
|
|
Orgs: nil,
|
|
|
Org: nil,
|
|
|
Department: nil,
|
|
|
Company: nil,
|
|
|
UserInfo: nil,
|
|
|
UserType: 0,
|
|
|
UserName: "",
|
|
|
UserPhone: "",
|
|
|
}
|
|
|
}
|
|
|
if undertaker.Salesman == nil {
|
|
|
undertaker.Salesman = &domain.Salesman{
|
|
|
UserId: 0,
|
|
|
UserBaseId: 0,
|
|
|
Roles: nil,
|
|
|
Orgs: nil,
|
|
|
Org: nil,
|
|
|
Department: nil,
|
|
|
Company: nil,
|
|
|
UserInfo: nil,
|
|
|
UserType: 0,
|
|
|
UserName: "",
|
|
|
UserPhone: "",
|
|
|
}
|
|
|
}
|
|
|
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
|
|
|
}
|
|
|
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
|
|
|
|
|
|
// 变更承接人
|
|
|
var undertakersChanged string
|
|
|
for i, undertaker := range cooperationContractSaved.Undertakers {
|
...
|
...
|
|