作者 陈志颖

feat:共创合约、分红退货单、分红订单删除仓储修改

@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "strconv"
11 ) 12 )
12 13
13 // CooperationContractService 共创合约服务 14 // CooperationContractService 共创合约服务
@@ -43,8 +44,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -43,8 +44,8 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
43 CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber, 44 CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
44 //CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber, 45 //CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber,
45 //DepartmentNumber: createCooperationContractCommand.DepartmentNumber, 46 //DepartmentNumber: createCooperationContractCommand.DepartmentNumber,
46 - CooperationContractUndertakerType: createCooperationContractCommand.CooperationContractUndertakerType,  
47 - CooperationContractName: createCooperationContractCommand.CooperationContractName, 47 + CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerType,
  48 + CooperationContractName: createCooperationContractCommand.CooperationContractName,
48 //CooperationModeNumber: createCooperationContractCommand.CooperationModeNumber, 49 //CooperationModeNumber: createCooperationContractCommand.CooperationModeNumber,
49 //SponsorUid: createCooperationContractCommand.SponsorUid, 50 //SponsorUid: createCooperationContractCommand.SponsorUid,
50 //DividendsIncentivesRules: createCooperationContractCommand.DividendsIncentivesRules, 51 //DividendsIncentivesRules: createCooperationContractCommand.DividendsIncentivesRules,
@@ -130,7 +131,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont @@ -130,7 +131,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
130 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 131 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
131 } 132 }
132 defer func() { 133 defer func() {
133 - transactionContext.RollbackTransaction() 134 + _ = transactionContext.RollbackTransaction()
134 }() 135 }()
135 var cooperationContractRepository domain.CooperationContractRepository 136 var cooperationContractRepository domain.CooperationContractRepository
136 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 137 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
@@ -145,7 +146,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont @@ -145,7 +146,7 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
145 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 146 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
146 } 147 }
147 if cooperationContract == nil { 148 if cooperationContract == nil {
148 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationContractQuery.CooperationContractId))) 149 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10)))
149 } else { 150 } else {
150 if err := transactionContext.CommitTransaction(); err != nil { 151 if err := transactionContext.CommitTransaction(); err != nil {
151 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 152 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -167,7 +168,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -167,7 +168,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
167 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 168 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
168 } 169 }
169 defer func() { 170 defer func() {
170 - transactionContext.RollbackTransaction() 171 + _ = transactionContext.RollbackTransaction()
171 }() 172 }()
172 var cooperationContractRepository domain.CooperationContractRepository 173 var cooperationContractRepository domain.CooperationContractRepository
173 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 174 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
@@ -205,7 +206,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC @@ -205,7 +206,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC
205 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 206 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
206 } 207 }
207 defer func() { 208 defer func() {
208 - transactionContext.RollbackTransaction() 209 + _ = transactionContext.RollbackTransaction()
209 }() 210 }()
210 var cooperationContractRepository domain.CooperationContractRepository 211 var cooperationContractRepository domain.CooperationContractRepository
211 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 212 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
@@ -220,7 +221,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC @@ -220,7 +221,7 @@ func (cooperationContractService *CooperationContractService) RemoveCooperationC
220 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 221 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
221 } 222 }
222 if cooperationContract == nil { 223 if cooperationContract == nil {
223 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationContractCommand.CooperationContractId))) 224 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationContractCommand.CooperationContractId, 10)))
224 } 225 }
225 if cooperationContract, err := cooperationContractRepository.Remove(cooperationContract); err != nil { 226 if cooperationContract, err := cooperationContractRepository.Remove(cooperationContract); err != nil {
226 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 227 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -245,7 +246,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -245,7 +246,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
245 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 246 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
246 } 247 }
247 defer func() { 248 defer func() {
248 - transactionContext.RollbackTransaction() 249 + _ = transactionContext.RollbackTransaction()
249 }() 250 }()
250 if err := transactionContext.CommitTransaction(); err != nil { 251 if err := transactionContext.CommitTransaction(); err != nil {
251 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 252 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -266,7 +267,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -266,7 +267,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
266 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 267 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
267 } 268 }
268 defer func() { 269 defer func() {
269 - transactionContext.RollbackTransaction() 270 + _ = transactionContext.RollbackTransaction()
270 }() 271 }()
271 if err := transactionContext.CommitTransaction(); err != nil { 272 if err := transactionContext.CommitTransaction(); err != nil {
272 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 273 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -287,7 +288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -287,7 +288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
287 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 288 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
288 } 289 }
289 defer func() { 290 defer func() {
290 - transactionContext.RollbackTransaction() 291 + _ = transactionContext.RollbackTransaction()
291 }() 292 }()
292 var cooperationContractRepository domain.CooperationContractRepository 293 var cooperationContractRepository domain.CooperationContractRepository
293 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 294 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
@@ -2,7 +2,6 @@ package command @@ -2,7 +2,6 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"  
6 "reflect" 5 "reflect"
7 "strings" 6 "strings"
8 7
@@ -20,42 +19,12 @@ type ReleaseCooperationProjectCommand struct { @@ -20,42 +19,12 @@ type ReleaseCooperationProjectCommand struct {
20 UserBaseId int64 `cname:"用户基本id" json:"userBaseId,string" valid:"Required"` 19 UserBaseId int64 `cname:"用户基本id" json:"userBaseId,string" valid:"Required"`
21 // 组织机构ID 20 // 组织机构ID
22 OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` 21 OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
23 - // 组织名称  
24 - OrgName string `cname:"组织名称" json:"orgName" valid:"Required"`  
25 // 公司ID,通过集成REST上下文获取 22 // 公司ID,通过集成REST上下文获取
26 CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` 23 CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
27 - // 公司logo  
28 - CompanyLogo string `cname:"公司logo" json:"companyLogo" valid:"Required"`  
29 - // 公司名称  
30 - CompanyName string `cname:"公司名称" json:"companyName" valid:"Required"`  
31 - // 用户关联的组织机构  
32 - Orgs []*domain.Org `cname:"用户关联的组织机构" json:"orgs" valid:"Required"` 24 + // 共创项目发起人id
  25 + CooperationProjectSponsorId string `cname:"共创项目发起人id" json:"cooperationProjectSponsorId" valid:"Required"`
33 // 部门ID,通过REST集成上下文获取 26 // 部门ID,通过REST集成上下文获取
34 - DepartmentId int64 `cname:"部门ID,通过REST集成上下文获取" json:"departmentId,string" valid:"Required"`  
35 - // 部门名称  
36 - DepartmentName string `cname:"部门名称" json:"departmentName" valid:"Required"`  
37 - // 部门编码  
38 - DepartmentNumber string `cname:"部门编码" json:"departmentNumber" valid:"Required"`  
39 - // 是否组织机构标识,1为是,2为否,默认为否  
40 - IsOrganization bool `cname:"是否组织机构标识,1为是,2为否,默认为否" json:"isOrganization" valid:"Required"`  
41 - // 角色ID  
42 - RoleId int64 `cname:"角色ID" json:"roleId,string" valid:"Required"`  
43 - // 角色名称  
44 - RoleName string `cname:"角色名称" json:"roleName" valid:"Required"`  
45 - // 用户头像  
46 - UserAvatar string `cname:"用户头像" json:"userAvatar" valid:"Required"`  
47 - // 用户邮箱  
48 - UserEmail string `cname:"用户邮箱" json:"userEmail" valid:"Required"`  
49 - // 共创人员姓名  
50 - UserName string `cname:"共创人员姓名" json:"userName" valid:"Required"`  
51 - // 用户手机号  
52 - UserPhone string `cname:"用户手机号" json:"userPhone" valid:"Required"`  
53 - // 用户账号,区别于手机号,冗余字段  
54 - UserAccount string `cname:"用户账号,区别于手机号,冗余字段" json:"userAccount" valid:"Required"`  
55 - // 用户类型  
56 - UserType int32 `cname:"用户类型" json:"userType" valid:"Required"`  
57 - // 状态  
58 - Status int32 `cname:"状态" json:"status" valid:"Required"` 27 + DepartmentId int64 `cname:"部门ID" json:"departmentId,string" valid:"Required"`
59 // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 28 // 共创项目承接对象,1员工,2共创用户,3公开,可以多选
60 CooperationProjectUndertakerType []int32 `cname:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"` 29 CooperationProjectUndertakerType []int32 `cname:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
61 // 共创项目描述 30 // 共创项目描述
@@ -19,7 +19,7 @@ type CooperationContract struct { @@ -19,7 +19,7 @@ type CooperationContract struct {
19 // 共创合约业务员 19 // 共创合约业务员
20 CooperationContractSalesman *User `json:"cooperationContractSalesman"` 20 CooperationContractSalesman *User `json:"cooperationContractSalesman"`
21 // 共创合约承接对象,1员工,2共创用户,3公开 21 // 共创合约承接对象,1员工,2共创用户,3公开
22 - CooperationContractUndertakerType []int32 `json:"cooperationContractUndertakerType"` 22 + CooperationContractUndertakerTypes []int32 `json:"cooperationContractUndertakerType"`
23 // 共创合约发起人 23 // 共创合约发起人
24 CooperationContractSponsor *User `json:"cooperationContractSponsor"` 24 CooperationContractSponsor *User `json:"cooperationContractSponsor"`
25 // 共创模式或者合伙模式 25 // 共创模式或者合伙模式
@@ -87,7 +87,7 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -87,7 +87,7 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
87 cooperationContract.CooperationContractReferrer.Status = status.(int32) 87 cooperationContract.CooperationContractReferrer.Status = status.(int32)
88 } 88 }
89 if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok { 89 if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {
90 - cooperationContract.CooperationContractUndertakerType = cooperationContractUndertakerType.([]int32) 90 + cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerType.([]int32)
91 } 91 }
92 if status, ok := data["status"]; ok { 92 if status, ok := data["status"]; ok {
93 cooperationContract.Status = status.(int32) 93 cooperationContract.Status = status.(int32)
1 package service 1 package service
2 2
3 type ApplyForCooperationService interface { 3 type ApplyForCooperationService interface {
4 - ApplyFor() 4 + ApplyForCooperation()
5 } 5 }
  1 +package service
  2 +
  3 +type ReleaseCooperationProjectService interface {
  4 + Release()
  5 +}
@@ -20,7 +20,7 @@ type CooperationContract struct { @@ -20,7 +20,7 @@ type CooperationContract struct {
20 // 共创合约业务员 20 // 共创合约业务员
21 CooperationContractSalesman *domain.User `comment:"共创合约业务员"` 21 CooperationContractSalesman *domain.User `comment:"共创合约业务员"`
22 // 共创合约承接对象,1员工,2共创用户,3公开 22 // 共创合约承接对象,1员工,2共创用户,3公开
23 - CooperationContractUndertakerType []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"` 23 + CooperationContractUndertakerTypes []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"`
24 // 共创合约发起人 24 // 共创合约发起人
25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"` 25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
26 // 共创模式编号 26 // 共创模式编号
@@ -85,14 +85,14 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -85,14 +85,14 @@ func TransformToCooperationContractDomainModelFromPgModels(
85 }) 85 })
86 } 86 }
87 return &domain.CooperationContract{ 87 return &domain.CooperationContract{
88 - CooperationContractId: cooperationContractModel.CooperationContractId,  
89 - CooperationContractDescription: cooperationContractModel.CooperationContractDescription,  
90 - CooperationContractName: cooperationContractModel.CooperationContractName,  
91 - CooperationContractNumber: cooperationContractModel.CooperationContractNumber,  
92 - CooperationContractReferrer: cooperationContractModel.CooperationContractReferrer,  
93 - CooperationContractSalesman: cooperationContractModel.CooperationContractSalesman,  
94 - CooperationContractUndertakerType: cooperationContractModel.CooperationContractUndertakerType,  
95 - CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor, 88 + CooperationContractId: cooperationContractModel.CooperationContractId,
  89 + CooperationContractDescription: cooperationContractModel.CooperationContractDescription,
  90 + CooperationContractName: cooperationContractModel.CooperationContractName,
  91 + CooperationContractNumber: cooperationContractModel.CooperationContractNumber,
  92 + CooperationContractReferrer: cooperationContractModel.CooperationContractReferrer,
  93 + CooperationContractSalesman: cooperationContractModel.CooperationContractSalesman,
  94 + CooperationContractUndertakerTypes: cooperationContractModel.CooperationContractUndertakerTypes,
  95 + CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor,
96 CooperationMode: &domain.CooperationMode{ 96 CooperationMode: &domain.CooperationMode{
97 CooperationModeId: cooperationMode.CooperationModeId, 97 CooperationModeId: cooperationMode.CooperationModeId,
98 CooperationModeNumber: cooperationMode.CooperationModeNumber, 98 CooperationModeNumber: cooperationMode.CooperationModeNumber,
@@ -32,7 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -32,7 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
32 "cooperation_contract_number", 32 "cooperation_contract_number",
33 "cooperation_contract_referrer", 33 "cooperation_contract_referrer",
34 "cooperation_contract_salesman", 34 "cooperation_contract_salesman",
35 - "cooperation_contract_undertaker_type", 35 + "cooperation_contract_undertaker_types",
36 "cooperation_contract_sponsor", 36 "cooperation_contract_sponsor",
37 "cooperation_mode_number", 37 "cooperation_mode_number",
38 "status", 38 "status",
@@ -65,7 +65,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -65,7 +65,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
65 &cooperationContract.CooperationContractNumber, 65 &cooperationContract.CooperationContractNumber,
66 &cooperationContract.CooperationContractReferrer, 66 &cooperationContract.CooperationContractReferrer,
67 &cooperationContract.CooperationContractSalesman, 67 &cooperationContract.CooperationContractSalesman,
68 - pg.Array(&cooperationContract.CooperationContractUndertakerType), 68 + pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
69 &cooperationContract.CooperationContractSponsor, 69 &cooperationContract.CooperationContractSponsor,
70 &cooperationContract.CooperationMode.CooperationModeNumber, 70 &cooperationContract.CooperationMode.CooperationModeNumber,
71 &cooperationContract.Status, 71 &cooperationContract.Status,
@@ -84,7 +84,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -84,7 +84,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
84 cooperationContract.CooperationContractNumber, 84 cooperationContract.CooperationContractNumber,
85 cooperationContract.CooperationContractReferrer, 85 cooperationContract.CooperationContractReferrer,
86 cooperationContract.CooperationContractSalesman, 86 cooperationContract.CooperationContractSalesman,
87 - pg.Array(cooperationContract.CooperationContractUndertakerType), 87 + pg.Array(cooperationContract.CooperationContractUndertakerTypes),
88 cooperationContract.CooperationContractSponsor, 88 cooperationContract.CooperationContractSponsor,
89 cooperationContract.CooperationMode.CooperationModeNumber, 89 cooperationContract.CooperationMode.CooperationModeNumber,
90 cooperationContract.Status, 90 cooperationContract.Status,
@@ -189,7 +189,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -189,7 +189,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
189 &cooperationContract.CooperationContractNumber, 189 &cooperationContract.CooperationContractNumber,
190 &cooperationContract.CooperationContractReferrer, 190 &cooperationContract.CooperationContractReferrer,
191 &cooperationContract.CooperationContractSalesman, 191 &cooperationContract.CooperationContractSalesman,
192 - pg.Array(&cooperationContract.CooperationContractUndertakerType), 192 + pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
193 &cooperationContract.CooperationContractSponsor, 193 &cooperationContract.CooperationContractSponsor,
194 &cooperationContract.CooperationMode.CooperationModeNumber, 194 &cooperationContract.CooperationMode.CooperationModeNumber,
195 &cooperationContract.Status, 195 &cooperationContract.Status,
@@ -208,7 +208,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -208,7 +208,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
208 cooperationContract.CooperationContractNumber, 208 cooperationContract.CooperationContractNumber,
209 cooperationContract.CooperationContractReferrer, 209 cooperationContract.CooperationContractReferrer,
210 cooperationContract.CooperationContractSalesman, 210 cooperationContract.CooperationContractSalesman,
211 - pg.Array(cooperationContract.CooperationContractUndertakerType), 211 + pg.Array(cooperationContract.CooperationContractUndertakerTypes),
212 cooperationContract.CooperationContractSponsor, 212 cooperationContract.CooperationContractSponsor,
213 cooperationContract.CooperationMode.CooperationModeNumber, 213 cooperationContract.CooperationMode.CooperationModeNumber,
214 cooperationContract.Status, 214 cooperationContract.Status,
@@ -224,6 +224,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -224,6 +224,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
224 return cooperationContract, err 224 return cooperationContract, err
225 } 225 }
226 226
  227 + // TODO 更新相关人
227 // 查找相关人列表 228 // 查找相关人列表
228 var cooperationContractRelevantFetched []*models.CooperationContractRelevant 229 var cooperationContractRelevantFetched []*models.CooperationContractRelevant
229 cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched) 230 cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched)
@@ -233,8 +234,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -233,8 +234,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
233 234
234 // 待更新相关人 235 // 待更新相关人
235 var cooperationContractRelevantPeopleToUpdate []*domain.Relevant 236 var cooperationContractRelevantPeopleToUpdate []*domain.Relevant
  237 +
236 // 待添加相关人 238 // 待添加相关人
237 var cooperationContractRelevantPeopleToAdd []*domain.Relevant 239 var cooperationContractRelevantPeopleToAdd []*domain.Relevant
  240 +
238 for _, relevant := range cooperationContract.RelevantPeople { 241 for _, relevant := range cooperationContract.RelevantPeople {
239 if relevant.RelevantId != 0 { 242 if relevant.RelevantId != 0 {
240 cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant) 243 cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant)
@@ -285,30 +288,26 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -285,30 +288,26 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
285 }) 288 })
286 } 289 }
287 290
288 - // 待删除的相关人  
289 -  
290 - // 待新增的相关人  
291 -  
292 //TODO 更新承接人 291 //TODO 更新承接人
293 // 获取承接人列表 292 // 获取承接人列表
294 - var cooperationContractUndertakerModels []*models.CooperationContractUndertaker  
295 - cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels) 293 + var cooperationContractUndertakersFetched []*models.CooperationContractUndertaker
  294 + cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakersFetched)
296 if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { 295 if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
297 return nil, err 296 return nil, err
298 } 297 }
299 298
300 //TODO 更新分红激励规则 299 //TODO 更新分红激励规则
301 // 获取分红激励规则列表 300 // 获取分红激励规则列表
302 - var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule  
303 - dividendsIncentivesRuleQuery := tx.Model(&dividendsIncentivesRuleModels) 301 + var dividendsIncentivesRulesFetched []*models.DividendsIncentivesRule
  302 + dividendsIncentivesRuleQuery := tx.Model(&dividendsIncentivesRulesFetched)
304 if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { 303 if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
305 return nil, err 304 return nil, err
306 } 305 }
307 306
308 //TODO 更新金额激励规则 307 //TODO 更新金额激励规则
309 // 获取金额激励规则列表 308 // 获取金额激励规则列表
310 - var moneyIncentivesRuleModels []*models.MoneyIncentivesRule  
311 - moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels) 309 + var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule
  310 + moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRulesFetched)
312 if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { 311 if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
313 return nil, err 312 return nil, err
314 } 313 }
@@ -322,7 +321,46 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom @@ -322,7 +321,46 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom
322 if _, err := tx.Model(cooperationContractModel).WherePK().Delete(); err != nil { 321 if _, err := tx.Model(cooperationContractModel).WherePK().Delete(); err != nil {
323 return cooperationContract, err 322 return cooperationContract, err
324 } else { 323 } else {
325 - //TODO 删除关联数据 324 + // 获取分红激励规则列表
  325 + var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
  326 + dividendsIncentivesRuleQuery := tx.Model(&dividendsIncentivesRuleModels)
  327 + if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
  328 + return nil, err
  329 + } else {
  330 + if _, err := tx.Model(&dividendsIncentivesRuleModels).WherePK().Delete(); err != nil {
  331 + return nil, err
  332 + }
  333 + }
  334 + // 获取金额激励规则列表
  335 + var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
  336 + moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
  337 + if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
  338 + return nil, err
  339 + } else {
  340 + if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
  341 + return nil, err
  342 + }
  343 + }
  344 + // 获取承接人列表
  345 + var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
  346 + cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
  347 + if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
  348 + return nil, err
  349 + } else {
  350 + if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
  351 + return nil, err
  352 + }
  353 + }
  354 + // 获取相关人列表
  355 + var cooperationContractRelevantModels []*models.CooperationContractRelevant
  356 + cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
  357 + if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
  358 + return nil, err
  359 + } else {
  360 + if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
  361 + return nil, err
  362 + }
  363 + }
326 } 364 }
327 return cooperationContract, nil 365 return cooperationContract, nil
328 } 366 }
@@ -173,6 +173,17 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide @@ -173,6 +173,17 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide
173 dividendsOrderModel.DividendsOrderId = dividendsOrder.Identify().(int64) 173 dividendsOrderModel.DividendsOrderId = dividendsOrder.Identify().(int64)
174 if _, err := tx.Model(dividendsOrderModel).WherePK().Delete(); err != nil { 174 if _, err := tx.Model(dividendsOrderModel).WherePK().Delete(); err != nil {
175 return dividendsOrder, err 175 return dividendsOrder, err
  176 + } else {
  177 + // 获取订单产品
  178 + var orderGoodModels []*models.OrderGood
  179 + orderGoodModelQuery := tx.Model(&orderGoodModels)
  180 + if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
  181 + return nil, err
  182 + }
  183 + // 批量删除订单产品
  184 + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
  185 + return nil, err
  186 + }
176 } 187 }
177 return dividendsOrder, nil 188 return dividendsOrder, nil
178 } 189 }
@@ -178,6 +178,17 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde @@ -178,6 +178,17 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde
178 dividendsReturnedOrderModel.DividendsReturnedOrderId = dividendsReturnedOrder.Identify().(int64) 178 dividendsReturnedOrderModel.DividendsReturnedOrderId = dividendsReturnedOrder.Identify().(int64)
179 if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil { 179 if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil {
180 return dividendsReturnedOrder, err 180 return dividendsReturnedOrder, err
  181 + } else {
  182 + // 获取退货单产品
  183 + var orderGoodModels []*models.OrderGood
  184 + orderGoodModelQuery := tx.Model(&orderGoodModels)
  185 + if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
  186 + return nil, err
  187 + }
  188 + // 批量删除退货单产品
  189 + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
  190 + return nil, err
  191 + }
181 } 192 }
182 return dividendsReturnedOrder, nil 193 return dividendsReturnedOrder, nil
183 } 194 }