作者 陈志颖

feat:共创合约模型调整,增加共创项目编号

@@ -15,7 +15,7 @@ logrus.log @@ -15,7 +15,7 @@ logrus.log
15 *.local 15 *.local
16 *.dev 16 *.dev
17 *.test 17 *.test
18 -.idea 18 +#.idea
19 .vscode 19 .vscode
20 .log 20 .log
21 *.tmp 21 *.tmp
  1 +# Default ignored files
  2 +/shelf/
  3 +/workspace.xml
  4 +# Datasource local storage ignored files
  5 +/dataSources/
  6 +/dataSources.local.xml
  7 +# Editor-based HTTP Client requests
  8 +/httpRequests/
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<module type="WEB_MODULE" version="4">
  3 + <component name="Go" enabled="true" />
  4 + <component name="NewModuleRootManager">
  5 + <content url="file://$MODULE_DIR$" />
  6 + <orderEntry type="inheritedJdk" />
  7 + <orderEntry type="sourceFolder" forTests="false" />
  8 + </component>
  9 +</module>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/.idea/allied-creation-cooperation.iml" filepath="$PROJECT_DIR$/.idea/allied-creation-cooperation.iml" />
  6 + </modules>
  7 + </component>
  8 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectTasksOptions">
  4 + <enabled-global>
  5 + <option value="go fmt" />
  6 + </enabled-global>
  7 + </component>
  8 +</project>
@@ -15,16 +15,22 @@ type UpdateCooperationContractCommand struct { @@ -15,16 +15,22 @@ type UpdateCooperationContractCommand struct {
15 CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` 15 CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"`
16 // 共创项目编号 16 // 共创项目编号
17 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` 17 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
18 - // 部门编码 18 + // 部门ID
19 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"` 19 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"`
20 // 共创合约承接对象,1员工,2共创用户,3公开 20 // 共创合约承接对象,1员工,2共创用户,3公开
21 CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"` 21 CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"`
22 // 共创合约名称 22 // 共创合约名称
23 CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"` 23 CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
24 - // 共创模式编码,手动输入,唯一确定  
25 - CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`  
26 // 共创合约发起人uid 24 // 共创合约发起人uid
27 SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"` 25 SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
  26 + // 业绩分红激励规则列表
  27 + DividendsIncentivesRules []*CreateDividendsIncentivesRulesCommand `cname:"业绩分红激励规则列表" json:"dividendsIncentivesRules,omitempty"`
  28 + // 金额激励规则列表
  29 + MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
  30 + // 承接方列表
  31 + Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers,omitempty"`
  32 + // 相关人UID列表
  33 + RelevantPeople []string `cname:"相关人列表" json:"relevantPeople,omitempty"`
28 // 公司ID,通过集成REST上下文获取 34 // 公司ID,通过集成REST上下文获取
29 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 35 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
30 // 组织机构ID 36 // 组织机构ID
@@ -251,6 +251,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -251,6 +251,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
251 CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription, 251 CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
252 CooperationContractName: createCooperationContractCommand.CooperationContractName, 252 CooperationContractName: createCooperationContractCommand.CooperationContractName,
253 CooperationContractNumber: contractNumber, 253 CooperationContractNumber: contractNumber,
  254 + CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber,
254 CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes, 255 CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes,
255 CooperationContractSponsor: sponsor, 256 CooperationContractSponsor: sponsor,
256 CooperationMode: cooperationMode, 257 CooperationMode: cooperationMode,
@@ -500,6 +501,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -500,6 +501,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
500 defer func() { 501 defer func() {
501 _ = transactionContext.RollbackTransaction() 502 _ = transactionContext.RollbackTransaction()
502 }() 503 }()
  504 +
503 var cooperationContractRepository domain.CooperationContractRepository 505 var cooperationContractRepository domain.CooperationContractRepository
504 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 506 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
505 "transactionContext": transactionContext, 507 "transactionContext": transactionContext,
@@ -515,6 +517,38 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -515,6 +517,38 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
515 if cooperationContract == nil { 517 if cooperationContract == nil {
516 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId))) 518 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
517 } 519 }
  520 + // 用户REST服务初始化
  521 + var userService service.UserService
  522 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  523 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  524 + } else {
  525 + userService = value
  526 + }
  527 + // 获取相关人
  528 + var relevantPeople []*domain.Relevant
  529 + for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
  530 + var relevantDomain *domain.Relevant
  531 + relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
  532 + if data, err := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err != nil {
  533 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  534 + } else {
  535 + relevantDomain = data
  536 + }
  537 + relevantPeople = append(relevantPeople, &domain.Relevant{
  538 + RelevantId: relevantDomain.RelevantId,
  539 + CooperationContractNumber: cooperationContract.CooperationContractNumber,
  540 + UserId: relevantDomain.UserId,
  541 + UserBaseId: relevantDomain.UserBaseId,
  542 + Org: relevantDomain.Org,
  543 + Orgs: relevantDomain.Orgs,
  544 + Department: relevantDomain.Department,
  545 + Roles: relevantDomain.Roles,
  546 + UserInfo: relevantDomain.UserInfo,
  547 + UserType: relevantDomain.UserType,
  548 + Status: relevantDomain.Status,
  549 + Company: relevantDomain.Company,
  550 + })
  551 + }
518 if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil { 552 if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil {
519 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 553 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
520 } 554 }
@@ -14,8 +14,10 @@ type CooperationContract struct { @@ -14,8 +14,10 @@ type CooperationContract struct {
14 CooperationContractName string `json:"cooperationContractName"` 14 CooperationContractName string `json:"cooperationContractName"`
15 // 共创合约编号 15 // 共创合约编号
16 CooperationContractNumber string `json:"cooperationContractNumber"` 16 CooperationContractNumber string `json:"cooperationContractNumber"`
  17 + // 共创项目编号
  18 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
17 // 共创合约承接对象,1员工,2共创用户,3公开 19 // 共创合约承接对象,1员工,2共创用户,3公开
18 - CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerType"` 20 + CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerTypes"`
19 // 共创合约发起人 21 // 共创合约发起人
20 CooperationContractSponsor *User `json:"cooperationContractSponsor"` 22 CooperationContractSponsor *User `json:"cooperationContractSponsor"`
21 // 共创模式或者合伙模式 23 // 共创模式或者合伙模式
@@ -70,8 +72,8 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -70,8 +72,8 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
70 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok { 72 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
71 cooperationContract.CooperationContractNumber = cooperationContractNumber.(string) 73 cooperationContract.CooperationContractNumber = cooperationContractNumber.(string)
72 } 74 }
73 - if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {  
74 - cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerType.([]int32) 75 + if cooperationContractUndertakerTypes, ok := data["cooperationContractUndertakerTypes"]; ok {
  76 + cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerTypes.([]int32)
75 } 77 }
76 if status, ok := data["status"]; ok { 78 if status, ok := data["status"]; ok {
77 cooperationContract.Status = status.(int32) 79 cooperationContract.Status = status.(int32)
@@ -15,6 +15,8 @@ type CooperationContract struct { @@ -15,6 +15,8 @@ type CooperationContract struct {
15 CooperationContractName string `comment:"共创合约名称"` 15 CooperationContractName string `comment:"共创合约名称"`
16 // 共创合约编号 16 // 共创合约编号
17 CooperationContractNumber string `comment:"共创合约编号"` 17 CooperationContractNumber string `comment:"共创合约编号"`
  18 + // 共创项目编号
  19 + CooperationProjectNumber string `comment:"共创项目编号"`
18 // 共创合约承接对象,1员工,2共创用户,3公开 20 // 共创合约承接对象,1员工,2共创用户,3公开
19 CooperationContractUndertakerTypes []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"` 21 CooperationContractUndertakerTypes []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"`
20 // 共创合约发起人 22 // 共创合约发起人
@@ -89,6 +89,7 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -89,6 +89,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
89 CooperationContractDescription: cooperationContractModel.CooperationContractDescription, 89 CooperationContractDescription: cooperationContractModel.CooperationContractDescription,
90 CooperationContractName: cooperationContractModel.CooperationContractName, 90 CooperationContractName: cooperationContractModel.CooperationContractName,
91 CooperationContractNumber: cooperationContractModel.CooperationContractNumber, 91 CooperationContractNumber: cooperationContractModel.CooperationContractNumber,
  92 + CooperationProjectNumber: cooperationContractModel.CooperationProjectNumber,
92 CooperationContractUndertakerTypes: cooperationContractModel.CooperationContractUndertakerTypes, 93 CooperationContractUndertakerTypes: cooperationContractModel.CooperationContractUndertakerTypes,
93 CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor, 94 CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor,
94 CooperationMode: &domain.CooperationMode{ 95 CooperationMode: &domain.CooperationMode{
@@ -32,6 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -32,6 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
32 "cooperation_contract_description", 32 "cooperation_contract_description",
33 "cooperation_contract_name", 33 "cooperation_contract_name",
34 "cooperation_contract_number", 34 "cooperation_contract_number",
  35 + "cooperation_project_number",
35 "cooperation_contract_undertaker_types", 36 "cooperation_contract_undertaker_types",
36 "cooperation_contract_sponsor", 37 "cooperation_contract_sponsor",
37 "cooperation_mode_number", 38 "cooperation_mode_number",
@@ -63,6 +64,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -63,6 +64,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
63 &cooperationContract.CooperationContractDescription, 64 &cooperationContract.CooperationContractDescription,
64 &cooperationContract.CooperationContractName, 65 &cooperationContract.CooperationContractName,
65 &cooperationContract.CooperationContractNumber, 66 &cooperationContract.CooperationContractNumber,
  67 + &cooperationContract.CooperationProjectNumber,
66 pg.Array(&cooperationContract.CooperationContractUndertakerTypes), 68 pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
67 &cooperationContract.CooperationContractSponsor, 69 &cooperationContract.CooperationContractSponsor,
68 &cooperationContract.CooperationMode.CooperationModeNumber, 70 &cooperationContract.CooperationMode.CooperationModeNumber,
@@ -80,6 +82,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -80,6 +82,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
80 cooperationContract.CooperationContractDescription, 82 cooperationContract.CooperationContractDescription,
81 cooperationContract.CooperationContractName, 83 cooperationContract.CooperationContractName,
82 cooperationContract.CooperationContractNumber, 84 cooperationContract.CooperationContractNumber,
  85 + cooperationContract.CooperationProjectNumber,
83 pg.Array(cooperationContract.CooperationContractUndertakerTypes), 86 pg.Array(cooperationContract.CooperationContractUndertakerTypes),
84 cooperationContract.CooperationContractSponsor, 87 cooperationContract.CooperationContractSponsor,
85 cooperationContract.CooperationMode.CooperationModeNumber, 88 cooperationContract.CooperationMode.CooperationModeNumber,
@@ -196,6 +199,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -196,6 +199,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
196 &cooperationContract.CooperationContractDescription, 199 &cooperationContract.CooperationContractDescription,
197 &cooperationContract.CooperationContractName, 200 &cooperationContract.CooperationContractName,
198 &cooperationContract.CooperationContractNumber, 201 &cooperationContract.CooperationContractNumber,
  202 + &cooperationContract.CooperationProjectNumber,
199 pg.Array(&cooperationContract.CooperationContractUndertakerTypes), 203 pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
200 &cooperationContract.CooperationContractSponsor, 204 &cooperationContract.CooperationContractSponsor,
201 &cooperationContract.CooperationMode.CooperationModeNumber, 205 &cooperationContract.CooperationMode.CooperationModeNumber,
@@ -213,6 +217,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -213,6 +217,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
213 cooperationContract.CooperationContractDescription, 217 cooperationContract.CooperationContractDescription,
214 cooperationContract.CooperationContractName, 218 cooperationContract.CooperationContractName,
215 cooperationContract.CooperationContractNumber, 219 cooperationContract.CooperationContractNumber,
  220 + cooperationContract.CooperationProjectNumber,
216 pg.Array(cooperationContract.CooperationContractUndertakerTypes), 221 pg.Array(cooperationContract.CooperationContractUndertakerTypes),
217 cooperationContract.CooperationContractSponsor, 222 cooperationContract.CooperationContractSponsor,
218 cooperationContract.CooperationMode.CooperationModeNumber, 223 cooperationContract.CooperationMode.CooperationModeNumber,