Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
27 个修改的文件
包含
871 行增加
和
84 行删除
@@ -11,7 +11,7 @@ import ( | @@ -11,7 +11,7 @@ import ( | ||
11 | 11 | ||
12 | type CreateContractUndertakerFeedbackCommand struct { | 12 | type CreateContractUndertakerFeedbackCommand struct { |
13 | // 合约承接方反馈内容附件 | 13 | // 合约承接方反馈内容附件 |
14 | - FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment"` | 14 | + FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment,omitempty"` |
15 | // 合约承接方反馈内容 | 15 | // 合约承接方反馈内容 |
16 | FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"` | 16 | FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"` |
17 | // 共创合约编号 | 17 | // 共创合约编号 |
@@ -86,7 +86,7 @@ type CreateCooperationContractCommand struct { | @@ -86,7 +86,7 @@ type CreateCooperationContractCommand struct { | ||
86 | // 共创合约名称 | 86 | // 共创合约名称 |
87 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"` | 87 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"` |
88 | // 共创模式编码 | 88 | // 共创模式编码 |
89 | - CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber,omitempty"` | 89 | + CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` |
90 | // 共创合约发起人uid | 90 | // 共创合约发起人uid |
91 | SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"` | 91 | SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"` |
92 | // 业绩分红激励规则列表 | 92 | // 业绩分红激励规则列表 |
@@ -108,7 +108,14 @@ type CreateCooperationContractCommand struct { | @@ -108,7 +108,14 @@ type CreateCooperationContractCommand struct { | ||
108 | } | 108 | } |
109 | 109 | ||
110 | func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) { | 110 | func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) { |
111 | - //validation.SetError("CustomValid", "未实现的自定义认证") | 111 | + // 激励规则自定义校验 |
112 | + if len(createCooperationContractCommand.DividendsIncentivesRules) == 0 && len(createCooperationContractCommand.MoneyIncentivesRules) == 0 { | ||
113 | + validation.Error("激励规则不能为空") | ||
114 | + } | ||
115 | + // 承接人列表校验 | ||
116 | + if len(createCooperationContractCommand.Undertakers) == 0 { | ||
117 | + validation.Error("承接人不能为空") | ||
118 | + } | ||
112 | } | 119 | } |
113 | 120 | ||
114 | func (createCooperationContractCommand *CreateCooperationContractCommand) ValidateCommand() error { | 121 | func (createCooperationContractCommand *CreateCooperationContractCommand) ValidateCommand() error { |
@@ -42,7 +42,31 @@ type UpdateCooperationContractCommand struct { | @@ -42,7 +42,31 @@ type UpdateCooperationContractCommand struct { | ||
42 | } | 42 | } |
43 | 43 | ||
44 | func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) { | 44 | func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) { |
45 | - //validation.SetError("CustomValid", "未实现的自定义认证") | 45 | + // 激励规则自定义校验 |
46 | + if len(updateCooperationContractCommand.DividendsIncentivesRules) <= 0 && len(updateCooperationContractCommand.MoneyIncentivesRules) <= 0 { | ||
47 | + validation.Error("激励规则不能为空") | ||
48 | + } else { | ||
49 | + for i, _ := range updateCooperationContractCommand.DividendsIncentivesRules { | ||
50 | + if updateCooperationContractCommand.DividendsIncentivesRules[i].DividendsIncentivesRuleId == "" { | ||
51 | + updateCooperationContractCommand.DividendsIncentivesRules[i].DividendsIncentivesRuleId = "0" | ||
52 | + } | ||
53 | + } | ||
54 | + for j, _ := range updateCooperationContractCommand.MoneyIncentivesRules { | ||
55 | + if updateCooperationContractCommand.MoneyIncentivesRules[j].MoneyIncentivesRuleId == "" { | ||
56 | + updateCooperationContractCommand.MoneyIncentivesRules[j].MoneyIncentivesRuleId = "0" | ||
57 | + } | ||
58 | + } | ||
59 | + } | ||
60 | + // 承接人列表校验 | ||
61 | + if len(updateCooperationContractCommand.Undertakers) <= 0 { | ||
62 | + validation.Error("承接人不能为空") | ||
63 | + } else { | ||
64 | + for i, _ := range updateCooperationContractCommand.Undertakers { | ||
65 | + if updateCooperationContractCommand.Undertakers[i].UndertakerId == "" { | ||
66 | + updateCooperationContractCommand.Undertakers[i].UndertakerId = "0" | ||
67 | + } | ||
68 | + } | ||
69 | + } | ||
46 | } | 70 | } |
47 | 71 | ||
48 | func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error { | 72 | func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error { |
@@ -166,7 +166,6 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -166,7 +166,6 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
166 | referrerDomain = data | 166 | referrerDomain = data |
167 | } | 167 | } |
168 | } | 168 | } |
169 | - | ||
170 | // 获取业务员 | 169 | // 获取业务员 |
171 | var salesmanDomain *domain.Salesman | 170 | var salesmanDomain *domain.Salesman |
172 | salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64) | 171 | salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64) |
@@ -179,6 +178,17 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -179,6 +178,17 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
179 | } | 178 | } |
180 | } | 179 | } |
181 | 180 | ||
181 | + // 解析附件 | ||
182 | + var attachments []*domain.Attachment | ||
183 | + for _, attachment := range undertaker.ContractAttachment { | ||
184 | + attachments = append(attachments, &domain.Attachment{ | ||
185 | + FileType: attachment.FileType, | ||
186 | + Name: attachment.Name, | ||
187 | + Url: attachment.Url, | ||
188 | + FileSize: attachment.FileSize, | ||
189 | + }) | ||
190 | + } | ||
191 | + | ||
182 | undertakers = append(undertakers, &domain.Undertaker{ | 192 | undertakers = append(undertakers, &domain.Undertaker{ |
183 | UndertakerId: 0, | 193 | UndertakerId: 0, |
184 | UserId: undertakerDomain.UserId, | 194 | UserId: undertakerDomain.UserId, |
@@ -192,9 +202,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -192,9 +202,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
192 | UserType: undertakerDomain.UserType, | 202 | UserType: undertakerDomain.UserType, |
193 | Referrer: referrerDomain, | 203 | Referrer: referrerDomain, |
194 | Salesman: salesmanDomain, | 204 | Salesman: salesmanDomain, |
195 | - Status: 0, | 205 | + Status: undertakerDomain.Status, |
196 | Company: company, | 206 | Company: company, |
197 | - ContractAttachment: nil, | 207 | + ContractAttachment: attachments, |
198 | }) | 208 | }) |
199 | } | 209 | } |
200 | 210 | ||
@@ -282,6 +292,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -282,6 +292,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
282 | if cooperationMode == nil { | 292 | if cooperationMode == nil { |
283 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationContractCommand.CooperationModeNumber)) | 293 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationContractCommand.CooperationModeNumber)) |
284 | } else { | 294 | } else { |
295 | + incentivesType := 0 | ||
296 | + if len(dividendsIncentivesRules) > 0 { | ||
297 | + incentivesType = domain.TYPE_DIVIDNEDS_INCENTIVES | ||
298 | + } else if len(moneyIncentivesRules) > 0 { | ||
299 | + incentivesType = domain.TYPE_MONEY_INCENTIVES | ||
300 | + } | ||
285 | newCooperationContract := &domain.CooperationContract{ | 301 | newCooperationContract := &domain.CooperationContract{ |
286 | CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription, | 302 | CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription, |
287 | CooperationContractName: createCooperationContractCommand.CooperationContractName, | 303 | CooperationContractName: createCooperationContractCommand.CooperationContractName, |
@@ -297,6 +313,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -297,6 +313,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
297 | Operator: operator, | 313 | Operator: operator, |
298 | DividendsIncentivesRules: dividendsIncentivesRules, | 314 | DividendsIncentivesRules: dividendsIncentivesRules, |
299 | MoneyIncentivesRules: moneyIncentivesRules, | 315 | MoneyIncentivesRules: moneyIncentivesRules, |
316 | + IncentivesType: int32(incentivesType), | ||
300 | Undertakers: undertakers, | 317 | Undertakers: undertakers, |
301 | RelevantPeople: relevantPeople, | 318 | RelevantPeople: relevantPeople, |
302 | OperateTime: time.Now(), | 319 | OperateTime: time.Now(), |
@@ -314,7 +331,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -314,7 +331,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
314 | } else { | 331 | } else { |
315 | cooperationContractRepository = value | 332 | cooperationContractRepository = value |
316 | } | 333 | } |
317 | - | 334 | + // 保存共创合约 |
318 | if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil { | 335 | if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil { |
319 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 336 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
320 | } else { | 337 | } else { |
@@ -795,6 +812,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -795,6 +812,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
795 | Company: relevantDomain.Company, | 812 | Company: relevantDomain.Company, |
796 | }) | 813 | }) |
797 | } | 814 | } |
815 | + | ||
798 | // 更新合约相关人 | 816 | // 更新合约相关人 |
799 | cooperationContract.RelevantPeople = relevantPeople | 817 | cooperationContract.RelevantPeople = relevantPeople |
800 | 818 |
@@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
10 | 10 | ||
11 | type UpdateCooperationContractChangeLogCommand struct { | 11 | type UpdateCooperationContractChangeLogCommand struct { |
12 | // 共创合约修改记录id | 12 | // 共创合约修改记录id |
13 | - CooperationContractChangeLogId string `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"` | 13 | + CooperationContractChangeLogId int64 `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"` |
14 | // 激励规则 | 14 | // 激励规则 |
15 | IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"` | 15 | IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"` |
16 | // 激励规则明细 | 16 | // 激励规则明细 |
@@ -225,10 +225,27 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) | @@ -225,10 +225,27 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) | ||
225 | defer func() { | 225 | defer func() { |
226 | _ = transactionContext.RollbackTransaction() | 226 | _ = transactionContext.RollbackTransaction() |
227 | }() | 227 | }() |
228 | + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository | ||
229 | + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ | ||
230 | + "transactionContext": transactionContext, | ||
231 | + }); err != nil { | ||
232 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
233 | + } else { | ||
234 | + cooperationContractChangeLogRepository = value | ||
235 | + } | ||
236 | + if count, cooperationContractChangeLogs, err := cooperationContractChangeLogRepository.Find(tool_funs.SimpleStructToMap(searchCooperationContractChangeLogQuery)); err != nil { | ||
237 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
238 | + } else { | ||
228 | if err := transactionContext.CommitTransaction(); err != nil { | 239 | if err := transactionContext.CommitTransaction(); err != nil { |
229 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 240 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
230 | } | 241 | } |
231 | - return nil, nil | 242 | + return map[string]interface{}{ |
243 | + "grid": map[string]interface{}{ | ||
244 | + "total": count, | ||
245 | + "list": cooperationContractChangeLogs, | ||
246 | + }, | ||
247 | + }, nil | ||
248 | + } | ||
232 | } | 249 | } |
233 | 250 | ||
234 | // UpdateCooperationContractChangeLog 更新共创合约变更日志 | 251 | // UpdateCooperationContractChangeLog 更新共创合约变更日志 |
@@ -259,7 +276,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) | @@ -259,7 +276,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) | ||
259 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 276 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
260 | } | 277 | } |
261 | if cooperationContractChangeLog == nil { | 278 | if cooperationContractChangeLog == nil { |
262 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId))) | 279 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10))) |
263 | } | 280 | } |
264 | if err := cooperationContractChangeLog.Update(tool_funs.SimpleStructToMap(updateCooperationContractChangeLogCommand)); err != nil { | 281 | if err := cooperationContractChangeLog.Update(tool_funs.SimpleStructToMap(updateCooperationContractChangeLogCommand)); err != nil { |
265 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 282 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
@@ -24,6 +24,8 @@ type ConfirmMoneyIncentivesEstimateCommand struct { | @@ -24,6 +24,8 @@ type ConfirmMoneyIncentivesEstimateCommand struct { | ||
24 | UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` | 24 | UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` |
25 | // 用户基础数据id | 25 | // 用户基础数据id |
26 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` | 26 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` |
27 | + // 动作,1预算,2确定预算 | ||
28 | + Action int32 `cname:"确定金额激励分红动作" json:"action" valid:"Required"` | ||
27 | } | 29 | } |
28 | 30 | ||
29 | func (estimateMoneyIncentivesCommand *ConfirmMoneyIncentivesEstimateCommand) Valid(validation *validation.Validation) { | 31 | func (estimateMoneyIncentivesCommand *ConfirmMoneyIncentivesEstimateCommand) Valid(validation *validation.Validation) { |
@@ -14,6 +14,7 @@ import ( | @@ -14,6 +14,7 @@ import ( | ||
14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" | 15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" |
16 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 16 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
17 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
17 | "strconv" | 18 | "strconv" |
18 | "time" | 19 | "time" |
19 | ) | 20 | ) |
@@ -373,15 +374,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -373,15 +374,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
373 | _ = transactionContext.RollbackTransaction() | 374 | _ = transactionContext.RollbackTransaction() |
374 | }() | 375 | }() |
375 | 376 | ||
376 | - orderGoodIds, _ := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds) | ||
377 | - | ||
378 | - // 用户REST服务初始化 | ||
379 | - //var userService service.UserService | ||
380 | - //if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil { | ||
381 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
382 | - //} else { | ||
383 | - // userService = value | ||
384 | - //} | 377 | + orderGoodIds, err := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds) |
378 | + if err != nil { | ||
379 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
380 | + } | ||
385 | 381 | ||
386 | // 公司REST服务初始化 | 382 | // 公司REST服务初始化 |
387 | var companyService service.CompanyService | 383 | var companyService service.CompanyService |
@@ -564,7 +560,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -564,7 +560,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
564 | Org: organization, | 560 | Org: organization, |
565 | Company: company, | 561 | Company: company, |
566 | Operator: nil, | 562 | Operator: nil, |
567 | - OperateTime: time.Now(), | 563 | + OperateTime: time.Time{}, |
568 | IsCanceled: false, | 564 | IsCanceled: false, |
569 | CreatedAt: time.Now(), | 565 | CreatedAt: time.Now(), |
570 | DeletedAt: time.Time{}, | 566 | DeletedAt: time.Time{}, |
@@ -575,13 +571,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -575,13 +571,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
575 | } | 571 | } |
576 | } | 572 | } |
577 | } | 573 | } |
578 | - var dividendsEstimatesSaved []*domain.DividendsEstimate | ||
579 | - for _, dividendsEstimate := range dividendsEstimates { | ||
580 | - if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil { | ||
581 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
582 | - } else { | ||
583 | - dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved) | ||
584 | - } | 574 | + log.Logger.Info("新增的分红预算单", map[string]interface{}{ |
575 | + "dividendsEstimates": dividendsEstimates, | ||
576 | + }) | ||
577 | + dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates) | ||
578 | + if err != nil { | ||
579 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
585 | } | 580 | } |
586 | if err := transactionContext.CommitTransaction(); err != nil { | 581 | if err := transactionContext.CommitTransaction(); err != nil { |
587 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 582 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -721,7 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -721,7 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
721 | Org: organization, | 716 | Org: organization, |
722 | Company: company, | 717 | Company: company, |
723 | Operator: nil, | 718 | Operator: nil, |
724 | - OperateTime: time.Now(), | 719 | + OperateTime: time.Time{}, |
725 | IsCanceled: false, | 720 | IsCanceled: false, |
726 | CreatedAt: time.Now(), | 721 | CreatedAt: time.Now(), |
727 | DeletedAt: time.Time{}, | 722 | DeletedAt: time.Time{}, |
@@ -729,19 +724,23 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -729,19 +724,23 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
729 | } | 724 | } |
730 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 725 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
731 | } | 726 | } |
732 | - var dividendsEstimatesSaved []*domain.DividendsEstimate | ||
733 | - for _, dividendsEstimate := range dividendsEstimates { | ||
734 | - if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil { | ||
735 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
736 | - } else { | ||
737 | - dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved) | 727 | + dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates) |
728 | + if err != nil { | ||
729 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
738 | } | 730 | } |
731 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
732 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
739 | } | 733 | } |
734 | + if confirmMoneyIncentivesEstimateCommand.Action == 1 { // 只预算,不入库 | ||
735 | + return dividendsEstimatesSaved, nil | ||
736 | + } else if confirmMoneyIncentivesEstimateCommand.Action == 2 { // 确定预算 | ||
740 | if err := transactionContext.CommitTransaction(); err != nil { | 737 | if err := transactionContext.CommitTransaction(); err != nil { |
741 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 738 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
742 | } | 739 | } |
743 | return dividendsEstimatesSaved, nil | 740 | return dividendsEstimatesSaved, nil |
744 | } | 741 | } |
742 | + return dividendsEstimatesSaved, nil | ||
743 | + } | ||
745 | } | 744 | } |
746 | 745 | ||
747 | // GetDividendsEstimate 返回分红预算单详情 | 746 | // GetDividendsEstimate 返回分红预算单详情 |
@@ -4,6 +4,11 @@ import ( | @@ -4,6 +4,11 @@ import ( | ||
4 | "time" | 4 | "time" |
5 | ) | 5 | ) |
6 | 6 | ||
7 | +const ( | ||
8 | + TYPE_DIVIDNEDS_INCENTIVES = iota + 1 | ||
9 | + TYPE_MONEY_INCENTIVES | ||
10 | +) | ||
11 | + | ||
7 | // CooperationContract 共创项目合约实体 | 12 | // CooperationContract 共创项目合约实体 |
8 | type CooperationContract struct { | 13 | type CooperationContract struct { |
9 | // 共创合约ID | 14 | // 共创合约ID |
@@ -65,6 +65,7 @@ type DividendsEstimate struct { | @@ -65,6 +65,7 @@ type DividendsEstimate struct { | ||
65 | 65 | ||
66 | type DividendsEstimateRepository interface { | 66 | type DividendsEstimateRepository interface { |
67 | Save(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) | 67 | Save(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) |
68 | + SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | ||
68 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | 69 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) |
69 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) | 70 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) |
70 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) | 71 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) |
@@ -89,7 +89,9 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -89,7 +89,9 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
89 | DividendsAmount: undertakerDividendsAmount, | 89 | DividendsAmount: undertakerDividendsAmount, |
90 | }) | 90 | }) |
91 | } | 91 | } |
92 | + | ||
92 | // 判断业务员在当前阶段是否已经分红 | 93 | // 判断业务员在当前阶段是否已经分红 |
94 | + if undertaker.Salesman.UserId != 0 { | ||
93 | salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ | 95 | salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ |
94 | "undertakerUid": undertaker.Salesman.UserId, | 96 | "undertakerUid": undertaker.Salesman.UserId, |
95 | "companyId": contract.Company.CompanyId, | 97 | "companyId": contract.Company.CompanyId, |
@@ -121,7 +123,11 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -121,7 +123,11 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
121 | DividendsAmount: undertakerDividendsAmount, | 123 | DividendsAmount: undertakerDividendsAmount, |
122 | }) | 124 | }) |
123 | } | 125 | } |
126 | + | ||
127 | + } | ||
128 | + | ||
124 | // 判断关联业务员在当前阶段是否已经分红 | 129 | // 判断关联业务员在当前阶段是否已经分红 |
130 | + if undertaker.Referrer.UserId != 0 { | ||
125 | referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ | 131 | referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ |
126 | "undertakerUid": undertaker.Referrer.UserId, | 132 | "undertakerUid": undertaker.Referrer.UserId, |
127 | "companyId": contract.Company.CompanyId, | 133 | "companyId": contract.Company.CompanyId, |
@@ -154,6 +160,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -154,6 +160,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
154 | }) | 160 | }) |
155 | } | 161 | } |
156 | } | 162 | } |
163 | + } | ||
157 | return dividendsEstimateDetails, nil | 164 | return dividendsEstimateDetails, nil |
158 | } | 165 | } |
159 | 166 |
@@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
8 | type CooperationContractRelevant struct { | 8 | type CooperationContractRelevant struct { |
9 | tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"` | 9 | tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"` |
10 | // 共创合约相关人id | 10 | // 共创合约相关人id |
11 | - CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:"pk:cooperation_contract_relevant_id"` | 11 | + CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk:cooperation_contract_relevant_id"` |
12 | // 共创合约编号 | 12 | // 共创合约编号 |
13 | CooperationContractNumber string `comment:"共创合约编号"` | 13 | CooperationContractNumber string `comment:"共创合约编号"` |
14 | // 合约人userId | 14 | // 合约人userId |
@@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
8 | type CooperationContractUndertaker struct { | 8 | type CooperationContractUndertaker struct { |
9 | tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"` | 9 | tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"` |
10 | // 共创合约承接人id | 10 | // 共创合约承接人id |
11 | - CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:"pk:cooperation_contract_undertaker_id"` | 11 | + CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk:cooperation_contract_undertaker_id"` |
12 | // 共创合约编号 | 12 | // 共创合约编号 |
13 | CooperationContractNumber string `comment:"共创合约编号"` | 13 | CooperationContractNumber string `comment:"共创合约编号"` |
14 | // 共创合约承接人uid | 14 | // 共创合约承接人uid |
@@ -60,6 +60,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -60,6 +60,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
60 | var relevantPeopleDomain []*domain.Relevant | 60 | var relevantPeopleDomain []*domain.Relevant |
61 | for _, relevant := range relevantPeople { | 61 | for _, relevant := range relevantPeople { |
62 | relevantPeopleDomain = append(relevantPeopleDomain, &domain.Relevant{ | 62 | relevantPeopleDomain = append(relevantPeopleDomain, &domain.Relevant{ |
63 | + RelevantId: relevant.CooperationContractRelevantId, | ||
64 | + CooperationContractNumber: relevant.CooperationContractNumber, | ||
63 | UserId: relevant.UserId, | 65 | UserId: relevant.UserId, |
64 | UserBaseId: relevant.UserBaseId, | 66 | UserBaseId: relevant.UserBaseId, |
65 | Org: relevant.Org, | 67 | Org: relevant.Org, |
@@ -76,6 +78,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -76,6 +78,8 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
76 | var undertakersDomain []*domain.Undertaker | 78 | var undertakersDomain []*domain.Undertaker |
77 | for _, undertaker := range undertakers { | 79 | for _, undertaker := range undertakers { |
78 | undertakersDomain = append(undertakersDomain, &domain.Undertaker{ | 80 | undertakersDomain = append(undertakersDomain, &domain.Undertaker{ |
81 | + UndertakerId: undertaker.CooperationContractUndertakerId, | ||
82 | + CooperationContractNumber: undertaker.CooperationContractNumber, | ||
79 | UserId: undertaker.UserId, | 83 | UserId: undertaker.UserId, |
80 | UserBaseId: undertaker.UserBaseId, | 84 | UserBaseId: undertaker.UserBaseId, |
81 | Org: undertaker.Org, | 85 | Org: undertaker.Org, |
@@ -24,6 +24,7 @@ func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64, | @@ -24,6 +24,7 @@ func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64, | ||
24 | id, err := IdWorker.NextId() | 24 | id, err := IdWorker.NextId() |
25 | return id, err | 25 | return id, err |
26 | } | 26 | } |
27 | + | ||
27 | func (repository *CooperationContractChangeLogRepository) Save(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) { | 28 | func (repository *CooperationContractChangeLogRepository) Save(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) { |
28 | sqlBuildFields := []string{ | 29 | sqlBuildFields := []string{ |
29 | "incentives_rule", | 30 | "incentives_rule", |
@@ -72,7 +73,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | @@ -72,7 +73,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | ||
72 | cooperationContractChangeLog.Company, | 73 | cooperationContractChangeLog.Company, |
73 | cooperationContractChangeLog.Operator, | 74 | cooperationContractChangeLog.Operator, |
74 | cooperationContractChangeLog.UpdatedAt, | 75 | cooperationContractChangeLog.UpdatedAt, |
75 | - cooperationContractChangeLog.DeletedAt, | 76 | + nil, |
76 | cooperationContractChangeLog.CreatedAt, | 77 | cooperationContractChangeLog.CreatedAt, |
77 | ); err != nil { | 78 | ); err != nil { |
78 | return cooperationContractChangeLog, err | 79 | return cooperationContractChangeLog, err |
@@ -100,7 +101,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | @@ -100,7 +101,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | ||
100 | cooperationContractChangeLog.Company, | 101 | cooperationContractChangeLog.Company, |
101 | cooperationContractChangeLog.Operator, | 102 | cooperationContractChangeLog.Operator, |
102 | cooperationContractChangeLog.UpdatedAt, | 103 | cooperationContractChangeLog.UpdatedAt, |
103 | - cooperationContractChangeLog.DeletedAt, | 104 | + nil, |
104 | cooperationContractChangeLog.CreatedAt, | 105 | cooperationContractChangeLog.CreatedAt, |
105 | cooperationContractChangeLog.Identify(), | 106 | cooperationContractChangeLog.Identify(), |
106 | ); err != nil { | 107 | ); err != nil { |
@@ -109,6 +110,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | @@ -109,6 +110,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra | ||
109 | } | 110 | } |
110 | return cooperationContractChangeLog, nil | 111 | return cooperationContractChangeLog, nil |
111 | } | 112 | } |
113 | + | ||
112 | func (repository *CooperationContractChangeLogRepository) Remove(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) { | 114 | func (repository *CooperationContractChangeLogRepository) Remove(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) { |
113 | tx := repository.transactionContext.PgTx | 115 | tx := repository.transactionContext.PgTx |
114 | cooperationContractChangeLogModel := new(models.CooperationContractChangeLog) | 116 | cooperationContractChangeLogModel := new(models.CooperationContractChangeLog) |
@@ -118,6 +120,7 @@ func (repository *CooperationContractChangeLogRepository) Remove(cooperationCont | @@ -118,6 +120,7 @@ func (repository *CooperationContractChangeLogRepository) Remove(cooperationCont | ||
118 | } | 120 | } |
119 | return cooperationContractChangeLog, nil | 121 | return cooperationContractChangeLog, nil |
120 | } | 122 | } |
123 | + | ||
121 | func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContractChangeLog, error) { | 124 | func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContractChangeLog, error) { |
122 | tx := repository.transactionContext.PgTx | 125 | tx := repository.transactionContext.PgTx |
123 | cooperationContractChangeLogModel := new(models.CooperationContractChangeLog) | 126 | cooperationContractChangeLogModel := new(models.CooperationContractChangeLog) |
@@ -136,11 +139,18 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m | @@ -136,11 +139,18 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m | ||
136 | return transform.TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel) | 139 | return transform.TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel) |
137 | } | 140 | } |
138 | } | 141 | } |
142 | + | ||
139 | func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContractChangeLog, error) { | 143 | func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContractChangeLog, error) { |
140 | tx := repository.transactionContext.PgTx | 144 | tx := repository.transactionContext.PgTx |
141 | var cooperationContractChangeLogModels []*models.CooperationContractChangeLog | 145 | var cooperationContractChangeLogModels []*models.CooperationContractChangeLog |
142 | cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0) | 146 | cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0) |
143 | query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions) | 147 | query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions) |
148 | + if operationType, ok := queryOptions["operationType"]; ok && operationType.(int32) != 0 { | ||
149 | + query.Where("operation_type = ?", operationType) | ||
150 | + } | ||
151 | + if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { | ||
152 | + query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) | ||
153 | + } | ||
144 | offsetLimitFlag := true | 154 | offsetLimitFlag := true |
145 | if offsetLimit, ok := queryOptions["offsetLimit"]; ok { | 155 | if offsetLimit, ok := queryOptions["offsetLimit"]; ok { |
146 | offsetLimitFlag = offsetLimit.(bool) | 156 | offsetLimitFlag = offsetLimit.(bool) |
@@ -162,6 +172,7 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[ | @@ -162,6 +172,7 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[ | ||
162 | return int64(count), cooperationContractChangeLogs, nil | 172 | return int64(count), cooperationContractChangeLogs, nil |
163 | } | 173 | } |
164 | } | 174 | } |
175 | + | ||
165 | func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationContractChangeLogRepository, error) { | 176 | func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationContractChangeLogRepository, error) { |
166 | if transactionContext == nil { | 177 | if transactionContext == nil { |
167 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 178 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
@@ -10,6 +10,7 @@ import ( | @@ -10,6 +10,7 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform" |
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
13 | "time" | 14 | "time" |
14 | ) | 15 | ) |
15 | 16 | ||
@@ -100,6 +101,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -100,6 +101,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
100 | ); err != nil { | 101 | ); err != nil { |
101 | return cooperationContract, err | 102 | return cooperationContract, err |
102 | } | 103 | } |
104 | + | ||
103 | // 新增相关人 | 105 | // 新增相关人 |
104 | var relevantPeopleModel []*models.CooperationContractRelevant | 106 | var relevantPeopleModel []*models.CooperationContractRelevant |
105 | for _, relevant := range cooperationContract.RelevantPeople { | 107 | for _, relevant := range cooperationContract.RelevantPeople { |
@@ -115,14 +117,18 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -115,14 +117,18 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
115 | UserType: relevant.UserType, | 117 | UserType: relevant.UserType, |
116 | Status: relevant.Status, | 118 | Status: relevant.Status, |
117 | Company: relevant.Company, | 119 | Company: relevant.Company, |
118 | - UpdatedAt: time.Now(), | 120 | + UpdatedAt: time.Time{}, |
119 | DeletedAt: time.Time{}, | 121 | DeletedAt: time.Time{}, |
120 | - CreatedAt: time.Time{}, | 122 | + CreatedAt: time.Now(), |
121 | }) | 123 | }) |
122 | } | 124 | } |
123 | if len(relevantPeopleModel) > 0 { | 125 | if len(relevantPeopleModel) > 0 { |
124 | - if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil { | 126 | + if result, err := tx.Model(&relevantPeopleModel).Insert(); err != nil { |
125 | return nil, err | 127 | return nil, err |
128 | + } else { | ||
129 | + log.Logger.Info("新增的相关人", map[string]interface{}{ | ||
130 | + "relevantPeopleModel": result, | ||
131 | + }) | ||
126 | } | 132 | } |
127 | } | 133 | } |
128 | 134 | ||
@@ -159,6 +165,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -159,6 +165,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
159 | var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule | 165 | var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule |
160 | for _, rule := range cooperationContract.DividendsIncentivesRules { | 166 | for _, rule := range cooperationContract.DividendsIncentivesRules { |
161 | dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{ | 167 | dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{ |
168 | + DividendsIncentivesRuleId: 0, | ||
162 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 169 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
163 | ReferrerPercentage: rule.ReferrerPercentage, | 170 | ReferrerPercentage: rule.ReferrerPercentage, |
164 | SalesmanPercentage: rule.SalesmanPercentage, | 171 | SalesmanPercentage: rule.SalesmanPercentage, |
@@ -183,6 +190,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -183,6 +190,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
183 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule | 190 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule |
184 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 191 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
185 | moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{ | 192 | moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{ |
193 | + MoneyIncentivesRuleId: 0, | ||
186 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 194 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
187 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, | 195 | MoneyIncentivesAmount: rule.MoneyIncentivesAmount, |
188 | MoneyIncentivesStage: rule.MoneyIncentivesStage, | 196 | MoneyIncentivesStage: rule.MoneyIncentivesStage, |
@@ -278,6 +286,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -278,6 +286,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
278 | var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant | 286 | var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant |
279 | for _, relevantDomain := range cooperationContractRelevantPeopleToAdd { | 287 | for _, relevantDomain := range cooperationContractRelevantPeopleToAdd { |
280 | cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{ | 288 | cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{ |
289 | + CooperationContractRelevantId: 0, | ||
281 | CooperationContractNumber: relevantDomain.CooperationContractNumber, | 290 | CooperationContractNumber: relevantDomain.CooperationContractNumber, |
282 | UserId: relevantDomain.UserId, | 291 | UserId: relevantDomain.UserId, |
283 | UserBaseId: relevantDomain.UserBaseId, | 292 | UserBaseId: relevantDomain.UserBaseId, |
@@ -333,9 +342,14 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -333,9 +342,14 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
333 | } | 342 | } |
334 | } | 343 | } |
335 | } | 344 | } |
345 | + log.Logger.Info("待删除的相关人", map[string]interface{}{ | ||
346 | + "待删除的相关人": relevantModelsToDelete, | ||
347 | + }) | ||
348 | + if len(relevantModelsToDelete) > 0 { | ||
336 | if _, err := tx.Model(&relevantModelsToDelete).Delete(); err != nil { | 349 | if _, err := tx.Model(&relevantModelsToDelete).Delete(); err != nil { |
337 | return nil, err | 350 | return nil, err |
338 | } | 351 | } |
352 | + } | ||
339 | 353 | ||
340 | /************************* 更新承接人 ****************************/ | 354 | /************************* 更新承接人 ****************************/ |
341 | // 获取承接人列表 | 355 | // 获取承接人列表 |
@@ -383,6 +397,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -383,6 +397,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
383 | CreatedAt: time.Now(), | 397 | CreatedAt: time.Now(), |
384 | }) | 398 | }) |
385 | } | 399 | } |
400 | + log.Logger.Info("待添加的承接人", map[string]interface{}{ | ||
401 | + "待添加的承接人": cooperationContractUndertakersToAddModels, | ||
402 | + }) | ||
386 | // 添加承接人 | 403 | // 添加承接人 |
387 | if len(cooperationContractUndertakersToAddModels) > 0 { | 404 | if len(cooperationContractUndertakersToAddModels) > 0 { |
388 | if _, err := tx.Model(&cooperationContractUndertakersToAddModels).Insert(); err != nil { | 405 | if _, err := tx.Model(&cooperationContractUndertakersToAddModels).Insert(); err != nil { |
@@ -406,6 +423,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -406,6 +423,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
406 | } | 423 | } |
407 | } | 424 | } |
408 | } | 425 | } |
426 | + log.Logger.Info("待更新的承接人", map[string]interface{}{ | ||
427 | + "待更新的承接人": undertakerModelsToUpdate, | ||
428 | + }) | ||
409 | if len(undertakerModelsToUpdate) > 0 { | 429 | if len(undertakerModelsToUpdate) > 0 { |
410 | if _, err := tx.Model(&undertakerModelsToUpdate).WherePK().Update(); err != nil { | 430 | if _, err := tx.Model(&undertakerModelsToUpdate).WherePK().Update(); err != nil { |
411 | return nil, err | 431 | return nil, err |
@@ -422,9 +442,14 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -422,9 +442,14 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
422 | } | 442 | } |
423 | } | 443 | } |
424 | } | 444 | } |
445 | + log.Logger.Info("待删除的承接人", map[string]interface{}{ | ||
446 | + "待删除的承接人": undertakerModelsToDelete, | ||
447 | + }) | ||
448 | + if len(undertakerModelsToDelete) > 0 { | ||
425 | if _, err := tx.Model(&undertakerModelsToDelete).Delete(); err != nil { | 449 | if _, err := tx.Model(&undertakerModelsToDelete).Delete(); err != nil { |
426 | return nil, err | 450 | return nil, err |
427 | } | 451 | } |
452 | + } | ||
428 | 453 | ||
429 | /************************ 更新分红激励规则 **************************/ | 454 | /************************ 更新分红激励规则 **************************/ |
430 | // 获取分红激励规则列表 | 455 | // 获取分红激励规则列表 |
@@ -471,6 +496,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -471,6 +496,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
471 | }) | 496 | }) |
472 | } | 497 | } |
473 | // 添加分红激励规则 | 498 | // 添加分红激励规则 |
499 | + log.Logger.Info("待添加的分红激励规则", map[string]interface{}{ | ||
500 | + "dividendsIncentivesRulesToAddModels": dividendsIncentivesRulesToAddModels, | ||
501 | + }) | ||
474 | if len(dividendsIncentivesRulesToAddModels) > 0 { | 502 | if len(dividendsIncentivesRulesToAddModels) > 0 { |
475 | if _, err := tx.Model(÷ndsIncentivesRulesToAddModels).Insert(); err != nil { | 503 | if _, err := tx.Model(÷ndsIncentivesRulesToAddModels).Insert(); err != nil { |
476 | return nil, err | 504 | return nil, err |
@@ -493,6 +521,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -493,6 +521,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
493 | } | 521 | } |
494 | } | 522 | } |
495 | } | 523 | } |
524 | + log.Logger.Info("待更新的分红激励规则", map[string]interface{}{ | ||
525 | + "dividendsRuleModelsToUpdate": dividendsRuleModelsToUpdate, | ||
526 | + }) | ||
496 | if len(dividendsRuleModelsToUpdate) > 0 { | 527 | if len(dividendsRuleModelsToUpdate) > 0 { |
497 | if _, err := tx.Model(÷ndsRuleModelsToUpdate).WherePK().Update(); err != nil { | 528 | if _, err := tx.Model(÷ndsRuleModelsToUpdate).WherePK().Update(); err != nil { |
498 | return nil, err | 529 | return nil, err |
@@ -509,9 +540,12 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -509,9 +540,12 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
509 | } | 540 | } |
510 | } | 541 | } |
511 | } | 542 | } |
512 | - if _, err := tx.Model(÷ndsIncentivesRuleModelsToDelete).Delete(); err != nil { | 543 | + log.Logger.Info("待删除的分红激励规则", map[string]interface{}{}) |
544 | + if len(dividendsIncentivesRuleModelsToDelete) > 0 { | ||
545 | + if _, err := tx.Model(÷ndsIncentivesRuleModelsToDelete).WherePK().Delete(); err != nil { | ||
513 | return nil, err | 546 | return nil, err |
514 | } | 547 | } |
548 | + } | ||
515 | 549 | ||
516 | /********************** 更新金额激励规则 **************************/ | 550 | /********************** 更新金额激励规则 **************************/ |
517 | var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule | 551 | var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule |
@@ -558,6 +592,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -558,6 +592,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
558 | }) | 592 | }) |
559 | } | 593 | } |
560 | // 添加金额激励规则 | 594 | // 添加金额激励规则 |
595 | + log.Logger.Info("待添加的金额激励规则", map[string]interface{}{ | ||
596 | + "moneyIncentivesRulesToAddModels": moneyIncentivesRulesToAddModels, | ||
597 | + }) | ||
561 | if len(moneyIncentivesRulesToAddModels) > 0 { | 598 | if len(moneyIncentivesRulesToAddModels) > 0 { |
562 | if _, err := tx.Model(&moneyIncentivesRulesToAddModels).Insert(); err != nil { | 599 | if _, err := tx.Model(&moneyIncentivesRulesToAddModels).Insert(); err != nil { |
563 | return nil, err | 600 | return nil, err |
@@ -580,6 +617,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -580,6 +617,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
580 | } | 617 | } |
581 | } | 618 | } |
582 | } | 619 | } |
620 | + log.Logger.Info("待更新的金额激励规则", map[string]interface{}{ | ||
621 | + "moneyRuleModelsToUpdate": moneyRuleModelsToUpdate, | ||
622 | + }) | ||
583 | if len(moneyRuleModelsToUpdate) > 0 { | 623 | if len(moneyRuleModelsToUpdate) > 0 { |
584 | if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil { | 624 | if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil { |
585 | return nil, err | 625 | return nil, err |
@@ -596,12 +636,23 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -596,12 +636,23 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
596 | } | 636 | } |
597 | } | 637 | } |
598 | } | 638 | } |
599 | - if _, err := tx.Model(&moneyIncentivesRuleModelsToDelete).Delete(); err != nil { | 639 | + log.Logger.Info("待删除的金额激励规则", map[string]interface{}{ |
640 | + "moneyIncentivesRuleModelsToDelete": moneyIncentivesRuleModelsToDelete, | ||
641 | + }) | ||
642 | + if len(moneyIncentivesRuleModelsToDelete) > 0 { | ||
643 | + if _, err := tx.Model(&moneyIncentivesRuleModelsToDelete).WherePK().Delete(); err != nil { | ||
600 | return nil, err | 644 | return nil, err |
601 | } | 645 | } |
602 | - | ||
603 | } | 646 | } |
604 | - return cooperationContract, nil | 647 | + } |
648 | + // 返回新增的合约 | ||
649 | + cooperationContractSaved, err := repository.FindOne(map[string]interface{}{ | ||
650 | + "cooperationContractId":cooperationContract.CooperationContractId, | ||
651 | + }) | ||
652 | + if err != nil { | ||
653 | + return nil, err | ||
654 | + } | ||
655 | + return cooperationContractSaved, nil | ||
605 | } | 656 | } |
606 | 657 | ||
607 | func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { | 658 | func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { |
@@ -693,7 +744,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | @@ -693,7 +744,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | ||
693 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 744 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
694 | return nil, err | 745 | return nil, err |
695 | } else { | 746 | } else { |
696 | - if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil { | 747 | + if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil { |
697 | return nil, err | 748 | return nil, err |
698 | } | 749 | } |
699 | } | 750 | } |
@@ -703,7 +754,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | @@ -703,7 +754,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom | ||
703 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 754 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
704 | return nil, err | 755 | return nil, err |
705 | } else { | 756 | } else { |
706 | - if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil { | 757 | + if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil { |
707 | return nil, err | 758 | return nil, err |
708 | } | 759 | } |
709 | } | 760 | } |
@@ -730,42 +781,50 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | @@ -730,42 +781,50 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract | ||
730 | if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 781 | if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
731 | return nil, err | 782 | return nil, err |
732 | } else { | 783 | } else { |
784 | + if len(dividendsIncentivesRuleModels) > 0 { | ||
733 | if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil { | 785 | if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil { |
734 | return nil, err | 786 | return nil, err |
735 | } | 787 | } |
736 | } | 788 | } |
789 | + } | ||
737 | // 获取金额激励规则列表 | 790 | // 获取金额激励规则列表 |
738 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule | 791 | var moneyIncentivesRuleModels []*models.MoneyIncentivesRule |
739 | moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels) | 792 | moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels) |
740 | if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 793 | if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
741 | return nil, err | 794 | return nil, err |
742 | } else { | 795 | } else { |
796 | + if len(moneyIncentivesRuleModels) > 0 { | ||
743 | if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil { | 797 | if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil { |
744 | return nil, err | 798 | return nil, err |
745 | } | 799 | } |
746 | } | 800 | } |
801 | + } | ||
747 | // 获取承接人列表 | 802 | // 获取承接人列表 |
748 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker | 803 | var cooperationContractUndertakerModels []*models.CooperationContractUndertaker |
749 | cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels) | 804 | cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels) |
750 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 805 | if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
751 | return nil, err | 806 | return nil, err |
752 | } else { | 807 | } else { |
753 | - if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil { | 808 | + if len(cooperationContractUndertakerModels) > 0 { |
809 | + if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil { | ||
754 | return nil, err | 810 | return nil, err |
755 | } | 811 | } |
756 | } | 812 | } |
813 | + } | ||
757 | // 获取相关人列表 | 814 | // 获取相关人列表 |
758 | var cooperationContractRelevantModels []*models.CooperationContractRelevant | 815 | var cooperationContractRelevantModels []*models.CooperationContractRelevant |
759 | cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels) | 816 | cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels) |
760 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { | 817 | if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil { |
761 | return nil, err | 818 | return nil, err |
762 | } else { | 819 | } else { |
763 | - if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil { | 820 | + if len(cooperationContractRelevantModels) > 0 { |
821 | + if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil { | ||
764 | return nil, err | 822 | return nil, err |
765 | } | 823 | } |
766 | } | 824 | } |
767 | } | 825 | } |
768 | } | 826 | } |
827 | + } | ||
769 | return cooperationContracts, nil | 828 | return cooperationContracts, nil |
770 | } | 829 | } |
771 | 830 |
@@ -162,6 +162,46 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -162,6 +162,46 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
162 | return dividendsEstimate, nil | 162 | return dividendsEstimate, nil |
163 | } | 163 | } |
164 | 164 | ||
165 | +func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { | ||
166 | + tx := repository.transactionContext.PgTx | ||
167 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
168 | + for _, dividendsEstimate := range dividendsEstimates { | ||
169 | + dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | ||
170 | + DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | ||
171 | + DividendsAmount: dividendsEstimate.DividendsAmount, | ||
172 | + DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | ||
173 | + DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime, | ||
174 | + DividendsParticipateType: dividendsEstimate.DividendsParticipateType, | ||
175 | + DividendsType: dividendsEstimate.DividendsType, | ||
176 | + DividendsTypeName: dividendsEstimate.DividendsTypeName, | ||
177 | + OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, | ||
178 | + CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | ||
179 | + DividendsUser: dividendsEstimate.DividendsUser, | ||
180 | + DividendsStage: dividendsEstimate.DividendsStage, | ||
181 | + Org: dividendsEstimate.Org, | ||
182 | + Company: dividendsEstimate.Company, | ||
183 | + Operator: dividendsEstimate.Operator, | ||
184 | + OperateTime: dividendsEstimate.OperateTime, | ||
185 | + IsCanceled: dividendsEstimate.IsCanceled, | ||
186 | + CreatedAt: dividendsEstimate.CreatedAt, | ||
187 | + DeletedAt: dividendsEstimate.DeletedAt, | ||
188 | + UpdatedAt: dividendsEstimate.UpdatedAt, | ||
189 | + }) | ||
190 | + } | ||
191 | + if _, err := tx.Model(÷ndsEstimateModels).Insert(); err != nil { | ||
192 | + return nil, err | ||
193 | + } | ||
194 | + dividendsEstimatesSaved := []*domain.DividendsEstimate{} | ||
195 | + for _, dividendsEstimateModel := range dividendsEstimateModels { | ||
196 | + if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil { | ||
197 | + return dividendsEstimates, err | ||
198 | + } else { | ||
199 | + dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate) | ||
200 | + } | ||
201 | + } | ||
202 | + return dividendsEstimatesSaved, nil | ||
203 | +} | ||
204 | + | ||
165 | func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { | 205 | func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { |
166 | tx := repository.transactionContext.PgTx | 206 | tx := repository.transactionContext.PgTx |
167 | var dividendsEstimateModels []*models.DividendsEstimate | 207 | var dividendsEstimateModels []*models.DividendsEstimate |
@@ -192,7 +232,15 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | @@ -192,7 +232,15 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | ||
192 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { | 232 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { |
193 | return nil, err | 233 | return nil, err |
194 | } | 234 | } |
195 | - return dividendsEstimates, nil | 235 | + dividendsEstimatesUpdated := []*domain.DividendsEstimate{} |
236 | + for _, dividendsEstimateModel := range dividendsEstimateModels { | ||
237 | + if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil { | ||
238 | + return dividendsEstimates, err | ||
239 | + } else { | ||
240 | + dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate) | ||
241 | + } | ||
242 | + } | ||
243 | + return dividendsEstimatesUpdated, nil | ||
196 | } | 244 | } |
197 | 245 | ||
198 | func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) { | 246 | func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) { |
@@ -118,94 +118,266 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) | @@ -118,94 +118,266 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) | ||
118 | } | 118 | } |
119 | 119 | ||
120 | func (translator *UserTranslator) ToReferrerFromRepresentation(user *UserDetail) (*domain.Referrer, error) { | 120 | func (translator *UserTranslator) ToReferrerFromRepresentation(user *UserDetail) (*domain.Referrer, error) { |
121 | + var orgs []*domain.Org | ||
122 | + for _, org := range user.UserOrg { | ||
123 | + orgs = append(orgs, &domain.Org{ | ||
124 | + OrgId: org.OrgID, | ||
125 | + OrgName: org.OrgName, | ||
126 | + Company: &domain.Company{ | ||
127 | + CompanyId: user.Company.CompanyId, | ||
128 | + CompanyLogo: "", | ||
129 | + CompanyName: user.Company.CompanyName, | ||
130 | + }, | ||
131 | + }) | ||
132 | + } | ||
133 | + var roles []*domain.Role | ||
134 | + for _, role := range user.UserRole { | ||
135 | + roles = append(roles, &domain.Role{ | ||
136 | + RoleId: int64(role.RoleID), | ||
137 | + RoleName: role.RoleName, | ||
138 | + }) | ||
139 | + } | ||
121 | return &domain.Referrer{ | 140 | return &domain.Referrer{ |
122 | UserId: user.UserId, | 141 | UserId: user.UserId, |
123 | UserBaseId: user.UserBaseId, | 142 | UserBaseId: user.UserBaseId, |
124 | - Roles: nil, | ||
125 | - Orgs: nil, | ||
126 | - Org: nil, | ||
127 | - Department: nil, | 143 | + Roles: roles, |
144 | + Orgs: orgs, | ||
145 | + Org: &domain.Org{ | ||
146 | + OrgId: user.Org.OrgId, | ||
147 | + OrgName: user.Org.OrgName, | ||
128 | Company: nil, | 148 | Company: nil, |
149 | + }, | ||
150 | + Department: &domain.Department{ | ||
151 | + DepartmentId: user.Department.DepartmentId, | ||
152 | + DepartmentName: user.Department.DepartmentName, | ||
153 | + DepartmentNumber: "", | ||
154 | + IsOrganization: false, | ||
155 | + }, | ||
156 | + Company: &domain.Company{ | ||
157 | + CompanyId: user.Company.CompanyId, | ||
158 | + CompanyLogo: "", | ||
159 | + CompanyName: user.Company.CompanyName, | ||
160 | + }, | ||
129 | UserInfo: nil, | 161 | UserInfo: nil, |
130 | - UserType: 0, | 162 | + UserType: user.UserType, |
131 | UserName: user.UserInfo.UserName, | 163 | UserName: user.UserInfo.UserName, |
132 | UserPhone: user.UserInfo.Phone, | 164 | UserPhone: user.UserInfo.Phone, |
133 | }, nil | 165 | }, nil |
134 | } | 166 | } |
135 | 167 | ||
136 | func (translator *UserTranslator) ToUndertakerFromRepresentation(user *UserDetail) (*domain.Undertaker, error) { | 168 | func (translator *UserTranslator) ToUndertakerFromRepresentation(user *UserDetail) (*domain.Undertaker, error) { |
169 | + var orgs []*domain.Org | ||
170 | + for _, org := range user.UserOrg { | ||
171 | + orgs = append(orgs, &domain.Org{ | ||
172 | + OrgId: org.OrgID, | ||
173 | + OrgName: org.OrgName, | ||
174 | + Company: &domain.Company{ | ||
175 | + CompanyId: user.Company.CompanyId, | ||
176 | + CompanyLogo: "", | ||
177 | + CompanyName: user.Company.CompanyName, | ||
178 | + }, | ||
179 | + }) | ||
180 | + } | ||
181 | + var roles []*domain.Role | ||
182 | + for _, role := range user.UserRole { | ||
183 | + roles = append(roles, &domain.Role{ | ||
184 | + RoleId: int64(role.RoleID), | ||
185 | + RoleName: role.RoleName, | ||
186 | + }) | ||
187 | + } | ||
137 | return &domain.Undertaker{ | 188 | return &domain.Undertaker{ |
138 | UserId: user.UserId, | 189 | UserId: user.UserId, |
139 | UserBaseId: user.UserBaseId, | 190 | UserBaseId: user.UserBaseId, |
140 | - Org: nil, | ||
141 | - Orgs: nil, | ||
142 | - Department: nil, | ||
143 | - Roles: nil, | ||
144 | - UserInfo: nil, | ||
145 | - UserType: 0, | 191 | + Org: &domain.Org{ |
192 | + OrgId: user.Org.OrgId, | ||
193 | + OrgName: user.Org.OrgName, | ||
194 | + Company: nil, | ||
195 | + }, | ||
196 | + Orgs: orgs, | ||
197 | + Department: &domain.Department{ | ||
198 | + DepartmentId: user.Department.DepartmentId, | ||
199 | + DepartmentName: user.Department.DepartmentName, | ||
200 | + DepartmentNumber: "", | ||
201 | + IsOrganization: false, | ||
202 | + }, | ||
203 | + Roles: roles, | ||
204 | + UserInfo: &domain.UserInfo{ | ||
205 | + UserAvatar: user.UserInfo.Avatar, | ||
206 | + UserEmail: user.UserInfo.Email, | ||
146 | UserName: user.UserInfo.UserName, | 207 | UserName: user.UserInfo.UserName, |
147 | UserPhone: user.UserInfo.Phone, | 208 | UserPhone: user.UserInfo.Phone, |
148 | - Status: 0, | ||
149 | - Company: nil, | 209 | + UserAccount: "", |
210 | + }, | ||
211 | + UserType: user.UserType, | ||
212 | + UserName: user.UserInfo.UserName, | ||
213 | + UserPhone: user.UserInfo.Phone, | ||
214 | + Status: user.EnableStatus, | ||
215 | + Company: &domain.Company{ | ||
216 | + CompanyId: user.Company.CompanyId, | ||
217 | + CompanyLogo: "", | ||
218 | + CompanyName: user.Company.CompanyName, | ||
219 | + }, | ||
150 | ContractAttachment: nil, | 220 | ContractAttachment: nil, |
151 | }, nil | 221 | }, nil |
152 | } | 222 | } |
153 | 223 | ||
154 | func (translator *UserTranslator) ToSalesmanFromRepresentation(user *UserDetail) (*domain.Salesman, error) { | 224 | func (translator *UserTranslator) ToSalesmanFromRepresentation(user *UserDetail) (*domain.Salesman, error) { |
225 | + var orgs []*domain.Org | ||
226 | + for _, org := range user.UserOrg { | ||
227 | + orgs = append(orgs, &domain.Org{ | ||
228 | + OrgId: org.OrgID, | ||
229 | + OrgName: org.OrgName, | ||
230 | + Company: &domain.Company{ | ||
231 | + CompanyId: user.Company.CompanyId, | ||
232 | + CompanyLogo: "", | ||
233 | + CompanyName: user.Company.CompanyName, | ||
234 | + }, | ||
235 | + }) | ||
236 | + } | ||
237 | + var roles []*domain.Role | ||
238 | + for _, role := range user.UserRole { | ||
239 | + roles = append(roles, &domain.Role{ | ||
240 | + RoleId: int64(role.RoleID), | ||
241 | + RoleName: role.RoleName, | ||
242 | + }) | ||
243 | + } | ||
155 | return &domain.Salesman{ | 244 | return &domain.Salesman{ |
156 | UserId: user.UserId, | 245 | UserId: user.UserId, |
157 | UserBaseId: user.UserBaseId, | 246 | UserBaseId: user.UserBaseId, |
158 | - Roles: nil, | ||
159 | - Orgs: nil, | ||
160 | - Org: nil, | ||
161 | - Department: nil, | 247 | + Roles: roles, |
248 | + Orgs: orgs, | ||
249 | + Org: &domain.Org{ | ||
250 | + OrgId: user.Org.OrgId, | ||
251 | + OrgName: user.Org.OrgName, | ||
162 | Company: nil, | 252 | Company: nil, |
163 | - UserInfo: nil, | ||
164 | - UserType: 0, | 253 | + }, |
254 | + Department: &domain.Department{ | ||
255 | + DepartmentId: user.Department.DepartmentId, | ||
256 | + DepartmentName: user.Department.DepartmentName, | ||
257 | + DepartmentNumber: "", | ||
258 | + IsOrganization: false, | ||
259 | + }, | ||
260 | + Company: &domain.Company{ | ||
261 | + CompanyId: user.Company.CompanyId, | ||
262 | + CompanyLogo: "", | ||
263 | + CompanyName: user.Company.CompanyName, | ||
264 | + }, | ||
265 | + UserInfo: &domain.UserInfo{ | ||
266 | + UserAvatar: user.UserInfo.Avatar, | ||
267 | + UserEmail: user.UserInfo.Email, | ||
268 | + UserName: user.UserInfo.UserName, | ||
269 | + UserPhone: user.UserInfo.Phone, | ||
270 | + UserAccount: "", | ||
271 | + }, | ||
272 | + UserType: user.UserType, | ||
165 | UserName: user.UserInfo.UserName, | 273 | UserName: user.UserInfo.UserName, |
166 | UserPhone: user.UserInfo.Phone, | 274 | UserPhone: user.UserInfo.Phone, |
167 | }, nil | 275 | }, nil |
168 | } | 276 | } |
169 | 277 | ||
170 | func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail) (*domain.User, error) { | 278 | func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail) (*domain.User, error) { |
279 | + var orgs []*domain.Org | ||
280 | + for _, org := range user.UserOrg { | ||
281 | + orgs = append(orgs, &domain.Org{ | ||
282 | + OrgId: org.OrgID, | ||
283 | + OrgName: org.OrgName, | ||
284 | + Company: &domain.Company{ | ||
285 | + CompanyId: user.Company.CompanyId, | ||
286 | + CompanyLogo: "", | ||
287 | + CompanyName: user.Company.CompanyName, | ||
288 | + }, | ||
289 | + }) | ||
290 | + } | ||
291 | + var roles []*domain.Role | ||
292 | + for _, role := range user.UserRole { | ||
293 | + roles = append(roles, &domain.Role{ | ||
294 | + RoleId: int64(role.RoleID), | ||
295 | + RoleName: role.RoleName, | ||
296 | + }) | ||
297 | + } | ||
171 | return &domain.User{ | 298 | return &domain.User{ |
172 | UserId: user.UserId, | 299 | UserId: user.UserId, |
173 | UserBaseId: user.UserBaseId, | 300 | UserBaseId: user.UserBaseId, |
174 | - Org: nil, | ||
175 | - Orgs: nil, | ||
176 | - Department: nil, | ||
177 | - Roles: nil, | 301 | + Org: &domain.Org{ |
302 | + OrgId: user.Org.OrgId, | ||
303 | + OrgName: user.Org.OrgName, | ||
304 | + Company: nil, | ||
305 | + }, | ||
306 | + Orgs: orgs, | ||
307 | + Department: &domain.Department{ | ||
308 | + DepartmentId: user.Department.DepartmentId, | ||
309 | + DepartmentName: user.Department.DepartmentName, | ||
310 | + DepartmentNumber: "", | ||
311 | + IsOrganization: false, | ||
312 | + }, | ||
313 | + Roles: roles, | ||
178 | UserInfo: &domain.UserInfo{ | 314 | UserInfo: &domain.UserInfo{ |
179 | UserName: user.UserInfo.UserName, | 315 | UserName: user.UserInfo.UserName, |
180 | UserPhone: user.UserInfo.Phone, | 316 | UserPhone: user.UserInfo.Phone, |
181 | UserAvatar: user.UserInfo.Avatar, | 317 | UserAvatar: user.UserInfo.Avatar, |
182 | }, | 318 | }, |
183 | - UserType: 0, | 319 | + UserType: user.UserType, |
184 | UserName: user.UserInfo.UserName, | 320 | UserName: user.UserInfo.UserName, |
185 | UserPhone: user.UserInfo.Phone, | 321 | UserPhone: user.UserInfo.Phone, |
186 | - Status: 0, | ||
187 | - Company: nil, | 322 | + Status: user.EnableStatus, |
323 | + Company: &domain.Company{ | ||
324 | + CompanyId: user.Company.CompanyId, | ||
325 | + CompanyLogo: "", | ||
326 | + CompanyName: user.Company.CompanyName, | ||
327 | + }, | ||
188 | }, nil | 328 | }, nil |
189 | } | 329 | } |
190 | 330 | ||
191 | func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*domain.User, error) { | 331 | func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*domain.User, error) { |
332 | + var orgs []*domain.Org | ||
333 | + for _, org := range user.UserOrg { | ||
334 | + orgs = append(orgs, &domain.Org{ | ||
335 | + OrgId: org.OrgID, | ||
336 | + OrgName: org.OrgName, | ||
337 | + Company: &domain.Company{ | ||
338 | + CompanyId: user.Company.CompanyId, | ||
339 | + CompanyLogo: "", | ||
340 | + CompanyName: user.Company.CompanyName, | ||
341 | + }, | ||
342 | + }) | ||
343 | + } | ||
344 | + var roles []*domain.Role | ||
345 | + for _, role := range user.UserRole { | ||
346 | + roles = append(roles, &domain.Role{ | ||
347 | + RoleId: int64(role.RoleID), | ||
348 | + RoleName: role.RoleName, | ||
349 | + }) | ||
350 | + } | ||
192 | return &domain.User{ | 351 | return &domain.User{ |
193 | UserId: user.UserId, | 352 | UserId: user.UserId, |
194 | UserBaseId: user.UserBaseId, | 353 | UserBaseId: user.UserBaseId, |
195 | - Org: nil, | ||
196 | - Orgs: nil, | ||
197 | - Department: nil, | ||
198 | - Roles: nil, | 354 | + Org: &domain.Org{ |
355 | + OrgId: user.Org.OrgId, | ||
356 | + OrgName: user.Org.OrgName, | ||
357 | + Company: nil, | ||
358 | + }, | ||
359 | + Orgs: orgs, | ||
360 | + Department: &domain.Department{ | ||
361 | + DepartmentId: user.Department.DepartmentId, | ||
362 | + DepartmentName: user.Department.DepartmentName, | ||
363 | + DepartmentNumber: "", | ||
364 | + IsOrganization: false, | ||
365 | + }, | ||
366 | + Roles: roles, | ||
199 | UserInfo: &domain.UserInfo{ | 367 | UserInfo: &domain.UserInfo{ |
200 | UserName: user.UserInfo.UserName, | 368 | UserName: user.UserInfo.UserName, |
201 | UserPhone: user.UserInfo.Phone, | 369 | UserPhone: user.UserInfo.Phone, |
202 | UserAvatar: user.UserInfo.Avatar, | 370 | UserAvatar: user.UserInfo.Avatar, |
203 | }, | 371 | }, |
204 | - UserType: 0, | 372 | + UserType: user.UserType, |
205 | UserName: user.UserInfo.UserName, | 373 | UserName: user.UserInfo.UserName, |
206 | UserPhone: user.UserInfo.Phone, | 374 | UserPhone: user.UserInfo.Phone, |
207 | - Status: 0, | ||
208 | - Company: nil, | 375 | + Status: user.EnableStatus, |
376 | + Company: &domain.Company{ | ||
377 | + CompanyId: user.Company.CompanyId, | ||
378 | + CompanyLogo: "", | ||
379 | + CompanyName: user.Company.CompanyName, | ||
380 | + }, | ||
209 | }, nil | 381 | }, nil |
210 | } | 382 | } |
211 | 383 |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/command" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/service" | ||
7 | +) | ||
8 | + | ||
9 | +type CooperationContractChangeLogController struct { | ||
10 | + BaseController | ||
11 | +} | ||
12 | + | ||
13 | +func (controller *CooperationContractChangeLogController) CreateCooperationContractChangeLog() { | ||
14 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
15 | + createCooperationContractChangeLogCommand := &command.CreateCooperationContractChangeLogCommand{} | ||
16 | + _ = controller.Unmarshal(createCooperationContractChangeLogCommand) | ||
17 | + header := controller.GetRequestHeader(controller.Ctx) | ||
18 | + createCooperationContractChangeLogCommand.CompanyId = header.CompanyId | ||
19 | + createCooperationContractChangeLogCommand.OrgId = header.OrgId | ||
20 | + createCooperationContractChangeLogCommand.UserId = header.UserId | ||
21 | + createCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId | ||
22 | + data, err := cooperationContractChangeLogService.CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand) | ||
23 | + controller.Response(data, err) | ||
24 | +} | ||
25 | + | ||
26 | +func (controller *CooperationContractChangeLogController) UpdateCooperationContractChangeLog() { | ||
27 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
28 | + updateCooperationContractChangeLogCommand := &command.UpdateCooperationContractChangeLogCommand{} | ||
29 | + _ = controller.Unmarshal(updateCooperationContractChangeLogCommand) | ||
30 | + header := controller.GetRequestHeader(controller.Ctx) | ||
31 | + updateCooperationContractChangeLogCommand.CompanyId = header.CompanyId | ||
32 | + updateCooperationContractChangeLogCommand.OrgId = header.OrgId | ||
33 | + updateCooperationContractChangeLogCommand.UserId = header.UserId | ||
34 | + updateCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId | ||
35 | + cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId") | ||
36 | + updateCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId | ||
37 | + data, err := cooperationContractChangeLogService.UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand) | ||
38 | + controller.Response(data, err) | ||
39 | +} | ||
40 | + | ||
41 | +func (controller *CooperationContractChangeLogController) GetCooperationContractChangeLog() { | ||
42 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
43 | + getCooperationContractChangeLogQuery := &query.GetCooperationContractChangeLogQuery{} | ||
44 | + header := controller.GetRequestHeader(controller.Ctx) | ||
45 | + getCooperationContractChangeLogQuery.CompanyId = header.CompanyId | ||
46 | + getCooperationContractChangeLogQuery.OrgId = header.OrgId | ||
47 | + getCooperationContractChangeLogQuery.UserId = header.UserId | ||
48 | + getCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId | ||
49 | + cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId") | ||
50 | + getCooperationContractChangeLogQuery.CooperationContractChangeLogId = cooperationContractChangeLogId | ||
51 | + data, err := cooperationContractChangeLogService.GetCooperationContractChangeLog(getCooperationContractChangeLogQuery) | ||
52 | + controller.Response(data, err) | ||
53 | +} | ||
54 | + | ||
55 | +func (controller *CooperationContractChangeLogController) RemoveCooperationContractChangeLog() { | ||
56 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
57 | + removeCooperationContractChangeLogCommand := &command.RemoveCooperationContractChangeLogCommand{} | ||
58 | + _ = controller.Unmarshal(removeCooperationContractChangeLogCommand) | ||
59 | + header := controller.GetRequestHeader(controller.Ctx) | ||
60 | + removeCooperationContractChangeLogCommand.CompanyId = header.CompanyId | ||
61 | + removeCooperationContractChangeLogCommand.OrgId = header.OrgId | ||
62 | + removeCooperationContractChangeLogCommand.UserId = header.UserId | ||
63 | + removeCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId | ||
64 | + cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId") | ||
65 | + removeCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId | ||
66 | + data, err := cooperationContractChangeLogService.RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand) | ||
67 | + controller.Response(data, err) | ||
68 | +} | ||
69 | + | ||
70 | +func (controller *CooperationContractChangeLogController) ListCooperationContractChangeLog() { | ||
71 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
72 | + listCooperationContractChangeLogQuery := &query.ListCooperationContractChangeLogQuery{} | ||
73 | + header := controller.GetRequestHeader(controller.Ctx) | ||
74 | + listCooperationContractChangeLogQuery.CompanyId = header.CompanyId | ||
75 | + listCooperationContractChangeLogQuery.OrgId = header.OrgId | ||
76 | + listCooperationContractChangeLogQuery.UserId = header.UserId | ||
77 | + listCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId | ||
78 | + pageSize, _ := controller.GetInt64("pageSize") | ||
79 | + listCooperationContractChangeLogQuery.PageSize = pageSize | ||
80 | + pageNumber, _ := controller.GetInt64("pageNumber") | ||
81 | + listCooperationContractChangeLogQuery.PageNumber = pageNumber | ||
82 | + data, err := cooperationContractChangeLogService.ListCooperationContractChangeLog(listCooperationContractChangeLogQuery) | ||
83 | + controller.Response(data, err) | ||
84 | +} | ||
85 | + | ||
86 | +func (controller *CooperationContractChangeLogController) SearchCooperationContractChangeLog() { | ||
87 | + cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil) | ||
88 | + searchCooperationContractChangeLogQuery := &query.SearchCooperationContractChangeLogQuery{} | ||
89 | + _ = controller.Unmarshal(searchCooperationContractChangeLogQuery) | ||
90 | + header := controller.GetRequestHeader(controller.Ctx) | ||
91 | + searchCooperationContractChangeLogQuery.CompanyId = header.CompanyId | ||
92 | + searchCooperationContractChangeLogQuery.OrgId = header.OrgId | ||
93 | + searchCooperationContractChangeLogQuery.UserId = header.UserId | ||
94 | + searchCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId | ||
95 | + data, err := cooperationContractChangeLogService.SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery) | ||
96 | + controller.Response(data, err) | ||
97 | +} |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego/controllers" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Post:CreateCooperationContractChangeLog") // 新增共创合约变更记录(预留) | ||
10 | + web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Put:UpdateCooperationContractChangeLog") // 编辑共创合约变更记录(预留) | ||
11 | + web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Get:GetCooperationContractChangeLog") // 获取共创合约变更记录详情(预留) | ||
12 | + web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Delete:RemoveCooperationContractChangeLog") // 移除共创合约变更记录(预留) | ||
13 | + web.Router("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Get:ListCooperationContractChangeLog") // 返回共创合约变更记录列表 | ||
14 | + web.Router("/cooperation-contract-change-logs/search", &controllers.CooperationContractChangeLogController{}, "Post:SearchCooperationContractChangeLog") // 查询共创合约变更记录 | ||
15 | +} |
test/integration/beego/cooperation_contract_change_log/cooperation_contract_change_log_suite_test.go
0 → 100644
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + "net/http/httptest" | ||
6 | + "testing" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/server/web" | ||
9 | + . "github.com/onsi/ginkgo" | ||
10 | + . "github.com/onsi/gomega" | ||
11 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application" | ||
12 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
13 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego" | ||
14 | +) | ||
15 | + | ||
16 | +func TestCooperationContractChangeLog(t *testing.T) { | ||
17 | + RegisterFailHandler(Fail) | ||
18 | + RunSpecs(t, "Beego Port CooperationContractChangeLog Correlations Test Case Suite") | ||
19 | +} | ||
20 | + | ||
21 | +var handler http.Handler | ||
22 | +var server *httptest.Server | ||
23 | + | ||
24 | +var _ = BeforeSuite(func() { | ||
25 | + handler = web.BeeApp.Handlers | ||
26 | + server = httptest.NewServer(handler) | ||
27 | +}) | ||
28 | + | ||
29 | +var _ = AfterSuite(func() { | ||
30 | + server.Close() | ||
31 | +}) |
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("创建共创合约变更日志", func() { | ||
13 | + Describe("提交数据创建共创合约变更日志", func() { | ||
14 | + Context("提交正确的新共创合约变更日志数据", func() { | ||
15 | + It("返回共创合约变更日志数据", func() { | ||
16 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
17 | + body := map[string]interface{}{ | ||
18 | + "incentivesRule": "string", | ||
19 | + "incentivesRuleDetail": "string", | ||
20 | + "operationType": "int32", | ||
21 | + "undertakers": "string", | ||
22 | + "cooperationContractNumber": "string", | ||
23 | + "companyId": "int64", | ||
24 | + "orgId": "int64", | ||
25 | + "userId": "int64", | ||
26 | + } | ||
27 | + httpExpect.POST("/cooperation-contract-change-logs/"). | ||
28 | + WithJSON(body). | ||
29 | + Expect(). | ||
30 | + Status(http.StatusOK). | ||
31 | + JSON(). | ||
32 | + Object(). | ||
33 | + ContainsKey("code").ValueEqual("code", 0). | ||
34 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
35 | + ContainsKey("data").Value("data").Object(). | ||
36 | + ContainsKey("cooperationContractChangeLogId").ValueNotEqual("cooperationContractChangeLogId", BeZero()) | ||
37 | + }) | ||
38 | + }) | ||
39 | + }) | ||
40 | + AfterEach(func() { | ||
41 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
42 | + Expect(err).NotTo(HaveOccurred()) | ||
43 | + }) | ||
44 | +}) |
test/integration/beego/cooperation_contract_change_log/get_cooperation_contract_change_log_test.go
0 → 100644
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("返回共创合约变更日志", func() { | ||
13 | + var cooperationContractChangeLogId int64 | ||
14 | + BeforeEach(func() { | ||
15 | + _, err := pG.DB.QueryOne( | ||
16 | + pg.Scan(&cooperationContractChangeLogId), | ||
17 | + "INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id", | ||
18 | + "testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt") | ||
19 | + Expect(err).NotTo(HaveOccurred()) | ||
20 | + }) | ||
21 | + Describe("根据cooperationContractChangeLogId参数返回共创合约变更日志", func() { | ||
22 | + Context("传入有效的cooperationContractChangeLogId", func() { | ||
23 | + It("返回共创合约变更日志数据", func() { | ||
24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
25 | + httpExpect.GET("/cooperation-contract-change-logs/{cooperationContractChangeLogId}"). | ||
26 | + Expect(). | ||
27 | + Status(http.StatusOK). | ||
28 | + JSON(). | ||
29 | + Object(). | ||
30 | + ContainsKey("code").ValueEqual("code", 0). | ||
31 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
32 | + ContainsKey("data").Value("data").Object() | ||
33 | + }) | ||
34 | + }) | ||
35 | + }) | ||
36 | + AfterEach(func() { | ||
37 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
38 | + Expect(err).NotTo(HaveOccurred()) | ||
39 | + }) | ||
40 | +}) |
test/integration/beego/cooperation_contract_change_log/list_cooperation_contract_change_log_test.go
0 → 100644
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("返回共创合约变更日志列表", func() { | ||
13 | + var cooperationContractChangeLogId int64 | ||
14 | + BeforeEach(func() { | ||
15 | + _, err := pG.DB.QueryOne( | ||
16 | + pg.Scan(&cooperationContractChangeLogId), | ||
17 | + "INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id", | ||
18 | + "testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt") | ||
19 | + Expect(err).NotTo(HaveOccurred()) | ||
20 | + }) | ||
21 | + Describe("根据参数返回共创合约变更日志列表", func() { | ||
22 | + Context("传入有效的参数", func() { | ||
23 | + It("返回共创合约变更日志数据列表", func() { | ||
24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
25 | + httpExpect.GET("/cooperation-contract-change-logs/"). | ||
26 | + WithQuery("offset", "int"). | ||
27 | + WithQuery("limit", "int"). | ||
28 | + Expect(). | ||
29 | + Status(http.StatusOK). | ||
30 | + JSON(). | ||
31 | + Object(). | ||
32 | + ContainsKey("code").ValueEqual("code", 0). | ||
33 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
34 | + ContainsKey("data").Value("data").Object(). | ||
35 | + ContainsKey("count").ValueEqual("count", 1). | ||
36 | + ContainsKey("cooperationContractChangeLogs").Value("cooperationContractChangeLogs").Array() | ||
37 | + }) | ||
38 | + }) | ||
39 | + }) | ||
40 | + AfterEach(func() { | ||
41 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
42 | + Expect(err).NotTo(HaveOccurred()) | ||
43 | + }) | ||
44 | +}) |
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("移除共创合约变更日志", func() { | ||
13 | + var cooperationContractChangeLogId int64 | ||
14 | + BeforeEach(func() { | ||
15 | + _, err := pG.DB.QueryOne( | ||
16 | + pg.Scan(&cooperationContractChangeLogId), | ||
17 | + "INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id", | ||
18 | + "testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt") | ||
19 | + Expect(err).NotTo(HaveOccurred()) | ||
20 | + }) | ||
21 | + Describe("根据参数移除共创合约变更日志", func() { | ||
22 | + Context("传入有效的cooperationContractChangeLogId", func() { | ||
23 | + It("返回被移除共创合约变更日志的数据", func() { | ||
24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
25 | + httpExpect.DELETE("/cooperation-contract-change-logs/{cooperationContractChangeLogId}"). | ||
26 | + Expect(). | ||
27 | + Status(http.StatusOK). | ||
28 | + JSON(). | ||
29 | + Object(). | ||
30 | + ContainsKey("code").ValueEqual("code", 0). | ||
31 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
32 | + ContainsKey("data").Value("data").Object() | ||
33 | + }) | ||
34 | + }) | ||
35 | + }) | ||
36 | + AfterEach(func() { | ||
37 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
38 | + Expect(err).NotTo(HaveOccurred()) | ||
39 | + }) | ||
40 | +}) |
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("共创合约变更记录搜索", func() { | ||
13 | + var cooperationContractChangeLogId int64 | ||
14 | + BeforeEach(func() { | ||
15 | + _, err := pG.DB.QueryOne( | ||
16 | + pg.Scan(&cooperationContractChangeLogId), | ||
17 | + "INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id", | ||
18 | + "testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt") | ||
19 | + Expect(err).NotTo(HaveOccurred()) | ||
20 | + }) | ||
21 | + Describe("共创合约变更记录搜索", func() { | ||
22 | + Context("", func() { | ||
23 | + It("", func() { | ||
24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
25 | + body := map[string]interface{}{ | ||
26 | + "operationType": "int32", | ||
27 | + "cooperationContractNumber": "string", | ||
28 | + "pageSize": "int32", | ||
29 | + "pageNumber": "int32", | ||
30 | + "companyId": "int64", | ||
31 | + "orgId": "int64", | ||
32 | + "userId": "int64", | ||
33 | + } | ||
34 | + httpExpect.POST("/cooperation-contract-change-logs/search"). | ||
35 | + WithJSON(body). | ||
36 | + Expect(). | ||
37 | + Status(http.StatusOK). | ||
38 | + JSON(). | ||
39 | + Object(). | ||
40 | + ContainsKey("code").ValueEqual("code", 0). | ||
41 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
42 | + ContainsKey("data").Value("data").Object() | ||
43 | + }) | ||
44 | + }) | ||
45 | + }) | ||
46 | + AfterEach(func() { | ||
47 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
48 | + Expect(err).NotTo(HaveOccurred()) | ||
49 | + }) | ||
50 | +}) |
1 | +package cooperation_contract_change_log | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/gavv/httpexpect" | ||
7 | + . "github.com/onsi/ginkgo" | ||
8 | + . "github.com/onsi/gomega" | ||
9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" | ||
10 | +) | ||
11 | + | ||
12 | +var _ = Describe("更新共创合约变更日志", func() { | ||
13 | + var cooperationContractChangeLogId int64 | ||
14 | + BeforeEach(func() { | ||
15 | + _, err := pG.DB.QueryOne( | ||
16 | + pg.Scan(&cooperationContractChangeLogId), | ||
17 | + "INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id", | ||
18 | + "testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt") | ||
19 | + Expect(err).NotTo(HaveOccurred()) | ||
20 | + }) | ||
21 | + Describe("提交数据更新共创合约变更日志", func() { | ||
22 | + Context("提交正确的共创合约变更日志数据", func() { | ||
23 | + It("返回更新后的共创合约变更日志数据", func() { | ||
24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
25 | + body := map[string]interface{}{ | ||
26 | + "incentivesRule": "string", | ||
27 | + "incentivesRuleDetail": "string", | ||
28 | + "operationType": "int32", | ||
29 | + "undertakers": "string", | ||
30 | + "cooperationContractNumber": "string", | ||
31 | + "companyId": "int64", | ||
32 | + "orgId": "int64", | ||
33 | + "userId": "int64", | ||
34 | + } | ||
35 | + httpExpect.PUT("/cooperation-contract-change-logs/{cooperationContractChangeLogId}"). | ||
36 | + WithJSON(body). | ||
37 | + Expect(). | ||
38 | + Status(http.StatusOK). | ||
39 | + JSON(). | ||
40 | + Object(). | ||
41 | + ContainsKey("code").ValueEqual("code", 0). | ||
42 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
43 | + ContainsKey("data").Value("data").Object(). | ||
44 | + ContainsKey("cooperationContractChangeLogId").ValueEqual("cooperationContractChangeLogId", cooperationContractChangeLogId) | ||
45 | + }) | ||
46 | + }) | ||
47 | + }) | ||
48 | + AfterEach(func() { | ||
49 | + _, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true") | ||
50 | + Expect(err).NotTo(HaveOccurred()) | ||
51 | + }) | ||
52 | +}) |
-
请 注册 或 登录 后发表评论