|
@@ -840,7 +840,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -840,7 +840,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
840
|
// 获取公司信息
|
840
|
// 获取公司信息
|
841
|
var company *domain.Company
|
841
|
var company *domain.Company
|
842
|
if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
|
842
|
if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
|
843
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
843
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司信息失败")
|
844
|
} else {
|
844
|
} else {
|
845
|
company = data
|
845
|
company = data
|
846
|
}
|
846
|
}
|
|
@@ -856,7 +856,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -856,7 +856,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
856
|
// 获取组织机构信息
|
856
|
// 获取组织机构信息
|
857
|
var organization *domain.Org
|
857
|
var organization *domain.Org
|
858
|
if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
|
858
|
if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
|
859
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
|
859
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取组织机构失败")
|
860
|
} else {
|
860
|
} else {
|
861
|
organization = data
|
861
|
organization = data
|
862
|
}
|
862
|
}
|
|
@@ -907,9 +907,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -907,9 +907,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
907
|
|
907
|
|
908
|
// 获取发起人
|
908
|
// 获取发起人
|
909
|
var sponsor *domain.User
|
909
|
var sponsor *domain.User
|
910
|
- sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
910
|
+ sponsorUid, err := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
|
|
911
|
+ if err != nil {
|
|
|
912
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "发起人UID类型错误")
|
|
|
913
|
+ }
|
911
|
if data, err11 := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err11 != nil {
|
914
|
if data, err11 := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err11 != nil {
|
912
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err11.Error())
|
915
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发起人失败")
|
913
|
} else {
|
916
|
} else {
|
914
|
sponsor = data
|
917
|
sponsor = data
|
915
|
}
|
918
|
}
|
|
@@ -917,7 +920,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -917,7 +920,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
917
|
// 获取操作人
|
920
|
// 获取操作人
|
918
|
var operator *domain.User
|
921
|
var operator *domain.User
|
919
|
if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
|
922
|
if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
|
920
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
923
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败")
|
921
|
} else {
|
924
|
} else {
|
922
|
operator = data
|
925
|
operator = data
|
923
|
}
|
926
|
}
|
|
@@ -927,11 +930,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -927,11 +930,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
927
|
|
930
|
|
928
|
// 获取相关人
|
931
|
// 获取相关人
|
929
|
var relevantPeople []*domain.Relevant
|
932
|
var relevantPeople []*domain.Relevant
|
930
|
- for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
|
933
|
+ for _, relevantPersonUid := range updateCooperationContractCommand.RelevantIds {
|
931
|
var relevantDomain *domain.Relevant
|
934
|
var relevantDomain *domain.Relevant
|
932
|
- relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
|
935
|
+ relevantUid, err := strconv.ParseInt(relevantPersonUid, 10, 64)
|
|
|
936
|
+ if err != nil {
|
|
|
937
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "相关人UID类型错误")
|
|
|
938
|
+ }
|
933
|
if data, err12 := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err12 != nil {
|
939
|
if data, err12 := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err12 != nil {
|
934
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err12.Error())
|
940
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取相关人失败")
|
935
|
} else {
|
941
|
} else {
|
936
|
relevantDomain = data
|
942
|
relevantDomain = data
|
937
|
}
|
943
|
}
|
|
@@ -958,7 +964,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -958,7 +964,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
958
|
var undertakers []*domain.Undertaker
|
964
|
var undertakers []*domain.Undertaker
|
959
|
for _, undertaker := range updateCooperationContractCommand.Undertakers {
|
965
|
for _, undertaker := range updateCooperationContractCommand.Undertakers {
|
960
|
var undertakerDomain *domain.Undertaker
|
966
|
var undertakerDomain *domain.Undertaker
|
961
|
- undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
|
967
|
+ undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64)
|
|
|
968
|
+ if err != nil {
|
|
|
969
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID类型错误")
|
|
|
970
|
+ }
|
962
|
if data, err13 := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err13 != nil {
|
971
|
if data, err13 := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err13 != nil {
|
963
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
|
972
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
|
964
|
} else {
|
973
|
} else {
|
|
@@ -967,33 +976,42 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -967,33 +976,42 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
967
|
|
976
|
|
968
|
// 获取推荐人
|
977
|
// 获取推荐人
|
969
|
var referrerDomain *domain.Referrer
|
978
|
var referrerDomain *domain.Referrer
|
970
|
- referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
|
|
971
|
- if referrerUid > 0 {
|
|
|
972
|
- if data, err14 := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err14 != nil {
|
|
|
973
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err14.Error())
|
|
|
974
|
- } else {
|
|
|
975
|
- referrerDomain = data
|
979
|
+ if undertaker.ReferrerId != "" {
|
|
|
980
|
+ referrerUid, err := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
|
|
981
|
+ if err != nil {
|
|
|
982
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "推荐人UID类型错误")
|
|
|
983
|
+ }
|
|
|
984
|
+ if referrerUid > 0 {
|
|
|
985
|
+ if data, err14 := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err14 != nil {
|
|
|
986
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取推荐人失败")
|
|
|
987
|
+ } else {
|
|
|
988
|
+ referrerDomain = data
|
|
|
989
|
+ }
|
976
|
}
|
990
|
}
|
977
|
}
|
991
|
}
|
978
|
|
992
|
|
979
|
// 获取业务员
|
993
|
// 获取业务员
|
980
|
var salesmanDomain *domain.Salesman
|
994
|
var salesmanDomain *domain.Salesman
|
981
|
- salesmanUid, err22 := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
|
|
|
982
|
- if err22 != nil {
|
|
|
983
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err22.Error())
|
|
|
984
|
- }
|
|
|
985
|
- if salesmanUid > 0 {
|
|
|
986
|
- if data, err15 := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err15 != nil {
|
|
|
987
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err15.Error())
|
|
|
988
|
- } else {
|
|
|
989
|
- salesmanDomain = data
|
995
|
+ if undertaker.SalesmanId != "" {
|
|
|
996
|
+ salesmanUid, err22 := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
|
|
|
997
|
+ if err22 != nil {
|
|
|
998
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "业务员UID类型错误")
|
|
|
999
|
+ }
|
|
|
1000
|
+ if salesmanUid > 0 {
|
|
|
1001
|
+ if data, err15 := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err15 != nil {
|
|
|
1002
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取业务员失败")
|
|
|
1003
|
+ } else {
|
|
|
1004
|
+ salesmanDomain = data
|
|
|
1005
|
+ }
|
990
|
}
|
1006
|
}
|
991
|
}
|
1007
|
}
|
992
|
|
1008
|
|
|
|
1009
|
+ // 承接人ID类型转换
|
993
|
undertakerId, err16 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
|
1010
|
undertakerId, err16 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
|
994
|
if err16 != nil {
|
1011
|
if err16 != nil {
|
995
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
|
1012
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
|
996
|
}
|
1013
|
}
|
|
|
1014
|
+
|
997
|
undertakers = append(undertakers, &domain.Undertaker{
|
1015
|
undertakers = append(undertakers, &domain.Undertaker{
|
998
|
UndertakerId: undertakerId,
|
1016
|
UndertakerId: undertakerId,
|
999
|
UserId: undertakerDomain.UserId,
|
1017
|
UserId: undertakerDomain.UserId,
|
|
@@ -1038,6 +1056,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -1038,6 +1056,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
1038
|
CreatedAt: time.Now(),
|
1056
|
CreatedAt: time.Now(),
|
1039
|
})
|
1057
|
})
|
1040
|
}
|
1058
|
}
|
|
|
1059
|
+
|
1041
|
// 更新分红规则列表
|
1060
|
// 更新分红规则列表
|
1042
|
cooperationContract.DividendsIncentivesRules = dividendsIncentivesRules
|
1061
|
cooperationContract.DividendsIncentivesRules = dividendsIncentivesRules
|
1043
|
|
1062
|
|
|
@@ -1065,6 +1084,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -1065,6 +1084,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
1065
|
CreatedAt: time.Now(),
|
1084
|
CreatedAt: time.Now(),
|
1066
|
})
|
1085
|
})
|
1067
|
}
|
1086
|
}
|
|
|
1087
|
+
|
1068
|
// 更新金额激励规则列表
|
1088
|
// 更新金额激励规则列表
|
1069
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
1089
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
1070
|
|
1090
|
|
|
@@ -1218,9 +1238,40 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -1218,9 +1238,40 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
1218
|
// 原承接人
|
1238
|
// 原承接人
|
1219
|
var undertakersOriginal string
|
1239
|
var undertakersOriginal string
|
1220
|
for i, undertaker := range cooperationContractFound.Undertakers {
|
1240
|
for i, undertaker := range cooperationContractFound.Undertakers {
|
|
|
1241
|
+ if undertaker.Referrer == nil {
|
|
|
1242
|
+ undertaker.Referrer = &domain.Referrer{
|
|
|
1243
|
+ UserId: 0,
|
|
|
1244
|
+ UserBaseId: 0,
|
|
|
1245
|
+ Roles: nil,
|
|
|
1246
|
+ Orgs: nil,
|
|
|
1247
|
+ Org: nil,
|
|
|
1248
|
+ Department: nil,
|
|
|
1249
|
+ Company: nil,
|
|
|
1250
|
+ UserInfo: nil,
|
|
|
1251
|
+ UserType: 0,
|
|
|
1252
|
+ UserName: "",
|
|
|
1253
|
+ UserPhone: "",
|
|
|
1254
|
+ }
|
|
|
1255
|
+ }
|
|
|
1256
|
+ if undertaker.Salesman == nil {
|
|
|
1257
|
+ undertaker.Salesman = &domain.Salesman{
|
|
|
1258
|
+ UserId: 0,
|
|
|
1259
|
+ UserBaseId: 0,
|
|
|
1260
|
+ Roles: nil,
|
|
|
1261
|
+ Orgs: nil,
|
|
|
1262
|
+ Org: nil,
|
|
|
1263
|
+ Department: nil,
|
|
|
1264
|
+ Company: nil,
|
|
|
1265
|
+ UserInfo: nil,
|
|
|
1266
|
+ UserType: 0,
|
|
|
1267
|
+ UserName: "",
|
|
|
1268
|
+ UserPhone: "",
|
|
|
1269
|
+ }
|
|
|
1270
|
+ }
|
1221
|
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
|
1271
|
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
|
1222
|
}
|
1272
|
}
|
1223
|
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
|
1273
|
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
|
|
|
1274
|
+
|
1224
|
// 变更承接人
|
1275
|
// 变更承接人
|
1225
|
var undertakersChanged string
|
1276
|
var undertakersChanged string
|
1226
|
for i, undertaker := range cooperationContractSaved.Undertakers {
|
1277
|
for i, undertaker := range cooperationContractSaved.Undertakers {
|