正在显示
6 个修改的文件
包含
94 行增加
和
23 行删除
@@ -188,6 +188,22 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | @@ -188,6 +188,22 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | ||
188 | cancelDividendsEstimateService = value | 188 | cancelDividendsEstimateService = value |
189 | } | 189 | } |
190 | 190 | ||
191 | + // 用户REST服务初始化 | ||
192 | + var userService service.UserService | ||
193 | + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil { | ||
194 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
195 | + } else { | ||
196 | + userService = value | ||
197 | + } | ||
198 | + | ||
199 | + // 获取操作人 | ||
200 | + var operator *domain.User | ||
201 | + if data, err := userService.OperatorFrom(cancelDividendsEstimateCommand.CompanyId, cancelDividendsEstimateCommand.OrgId, cancelDividendsEstimateCommand.UserId); err != nil { | ||
202 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败") | ||
203 | + } else { | ||
204 | + operator = data | ||
205 | + } | ||
206 | + | ||
191 | // 分红预算仓储初始化 | 207 | // 分红预算仓储初始化 |
192 | var dividendsEstimateRepository domain.DividendsEstimateRepository | 208 | var dividendsEstimateRepository domain.DividendsEstimateRepository |
193 | if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | 209 | if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ |
@@ -235,7 +251,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | @@ -235,7 +251,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | ||
235 | } | 251 | } |
236 | 252 | ||
237 | // 取消分红预算 | 253 | // 取消分红预算 |
238 | - if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate([]int64{cancelDividendsEstimateCommand.DividendsEstimateId}, cancelDividendsEstimateCommand.UserId); err != nil { | 254 | + if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate([]int64{cancelDividendsEstimateCommand.DividendsEstimateId}, operator); err != nil { |
239 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 255 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
240 | } else { | 256 | } else { |
241 | if err := transactionContext.CommitTransaction(); err != nil { | 257 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -271,6 +287,22 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -271,6 +287,22 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
271 | cancelDividendsEstimateService = value | 287 | cancelDividendsEstimateService = value |
272 | } | 288 | } |
273 | 289 | ||
290 | + // 用户REST服务初始化 | ||
291 | + var userService service.UserService | ||
292 | + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil { | ||
293 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
294 | + } else { | ||
295 | + userService = value | ||
296 | + } | ||
297 | + | ||
298 | + // 获取操作人 | ||
299 | + var operator *domain.User | ||
300 | + if data, err := userService.OperatorFrom(batchCancelEstimateCommand.CompanyId, batchCancelEstimateCommand.OrgId, batchCancelEstimateCommand.UserId); err != nil { | ||
301 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败") | ||
302 | + } else { | ||
303 | + operator = data | ||
304 | + } | ||
305 | + | ||
274 | // 分红预算仓储初始化 | 306 | // 分红预算仓储初始化 |
275 | var dividendsEstimateRepository domain.DividendsEstimateRepository | 307 | var dividendsEstimateRepository domain.DividendsEstimateRepository |
276 | if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | 308 | if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ |
@@ -324,7 +356,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -324,7 +356,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
324 | } | 356 | } |
325 | } | 357 | } |
326 | // 批量取消分红预算单 | 358 | // 批量取消分红预算单 |
327 | - if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, batchCancelEstimateCommand.UserId); err != nil { | 359 | + if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); err != nil { |
328 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 360 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
329 | } else { | 361 | } else { |
330 | if err := transactionContext.CommitTransaction(); err != nil { | 362 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -7,5 +7,5 @@ import ( | @@ -7,5 +7,5 @@ import ( | ||
7 | 7 | ||
8 | type CancelDividendsEstimate interface { | 8 | type CancelDividendsEstimate interface { |
9 | coreDomain.DomainEventPublisher | 9 | coreDomain.DomainEventPublisher |
10 | - CancelEstimate(dividendsEstimateIds []int64, operatorId int64) ([]*domain.DividendsEstimate, error) | 10 | + CancelEstimate(dividendsEstimateIds []int64, operator *domain.User) ([]*domain.DividendsEstimate, error) |
11 | } | 11 | } |
@@ -2,11 +2,9 @@ package domain_service | @@ -2,11 +2,9 @@ package domain_service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | - "github.com/linmadan/egglib-go/core/application" | ||
6 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 5 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
9 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" |
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
12 | ) | 10 | ) |
@@ -16,11 +14,10 @@ type CancelDividendsEstimateService struct { | @@ -16,11 +14,10 @@ type CancelDividendsEstimateService struct { | ||
16 | transactionContext *pgTransaction.TransactionContext | 14 | transactionContext *pgTransaction.TransactionContext |
17 | } | 15 | } |
18 | 16 | ||
19 | -func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEstimateIds []int64, operatorId int64) ([]*domain.DividendsEstimate, error) { | 17 | +func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEstimateIds []int64, operator *domain.User) ([]*domain.DividendsEstimate, error) { |
20 | var dividendsEstimateRepository domain.DividendsEstimateRepository // 分红预算单仓储 | 18 | var dividendsEstimateRepository domain.DividendsEstimateRepository // 分红预算单仓储 |
21 | var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 | 19 | var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 |
22 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 | 20 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 |
23 | - var userService service.UserService // 用户服务 | ||
24 | 21 | ||
25 | // 分红预算单仓储初始化 | 22 | // 分红预算单仓储初始化 |
26 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { | 23 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { |
@@ -40,18 +37,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -40,18 +37,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
40 | } else { | 37 | } else { |
41 | dividendsReturnedOrderRepository = repo | 38 | dividendsReturnedOrderRepository = repo |
42 | } | 39 | } |
43 | - // 用户服务初始化 | ||
44 | - if value, err := NewUserService(); err != nil { | ||
45 | - userService = value | ||
46 | - } | ||
47 | - | ||
48 | - // 获取操作人 | ||
49 | - var operator *domain.User | ||
50 | - if data, err := userService.OperatorFrom(0, 0, operatorId); err != nil { | ||
51 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
52 | - } else { | ||
53 | - operator = data | ||
54 | - } | ||
55 | 40 | ||
56 | // 获取分红预算单 | 41 | // 获取分红预算单 |
57 | if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ | 42 | if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ |
@@ -232,7 +232,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | @@ -232,7 +232,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | ||
232 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { | 232 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { |
233 | return nil, err | 233 | return nil, err |
234 | } | 234 | } |
235 | - dividendsEstimatesUpdated := []*domain.DividendsEstimate{} | 235 | + var dividendsEstimatesUpdated []*domain.DividendsEstimate |
236 | for _, dividendsEstimateModel := range dividendsEstimateModels { | 236 | for _, dividendsEstimateModel := range dividendsEstimateModels { |
237 | if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil { | 237 | if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil { |
238 | return dividendsEstimates, err | 238 | return dividendsEstimates, err |
@@ -272,7 +272,33 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | @@ -272,7 +272,33 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | ||
272 | } | 272 | } |
273 | 273 | ||
274 | func (repository *DividendsOrderRepository) UpdateMany(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { | 274 | func (repository *DividendsOrderRepository) UpdateMany(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { |
275 | - panic("implement me") | 275 | + tx := repository.transactionContext.PgTx |
276 | + var dividendsOrderModels []*models.DividendsOrder | ||
277 | + for _, dividendsOrder := range dividendsOrders { | ||
278 | + dividendsOrderModels = append(dividendsOrderModels, &models.DividendsOrder{ | ||
279 | + DividendsOrderId: dividendsOrder.DividendsOrderId, | ||
280 | + DividendsOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
281 | + DividendsOriginalOrderNum: dividendsOrder.DividendsOriginalOrderNum, | ||
282 | + DividendsOrderAmount: dividendsOrder.DividendsOrderAmount, | ||
283 | + OrderTime: dividendsOrder.OrderTime, | ||
284 | + DividendTime: dividendsOrder.DividendTime, | ||
285 | + DividendStatus: dividendsOrder.DividendStatus, | ||
286 | + Region: dividendsOrder.Region, | ||
287 | + CustomerName: dividendsOrder.CustomerName, | ||
288 | + Org: dividendsOrder.Org, | ||
289 | + Company: dividendsOrder.Company, | ||
290 | + CreatedAt: dividendsOrder.CreatedAt, | ||
291 | + DeletedAt: dividendsOrder.DeletedAt, | ||
292 | + UpdatedAt: time.Now(), | ||
293 | + OperateTime: dividendsOrder.OperateTime, | ||
294 | + Operator: dividendsOrder.Operator, | ||
295 | + Remarks: dividendsOrder.Remarks, | ||
296 | + }) | ||
297 | + } | ||
298 | + if _, err := tx.Model(÷ndsOrderModels).WherePK().Update(); err != nil { | ||
299 | + return nil, err | ||
300 | + } | ||
301 | + return dividendsOrders, nil | ||
276 | } | 302 | } |
277 | 303 | ||
278 | func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.DividendsOrder) (*domain.DividendsOrder, error) { | 304 | func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.DividendsOrder) (*domain.DividendsOrder, error) { |
@@ -271,8 +271,36 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder | @@ -271,8 +271,36 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder | ||
271 | return dividendsReturnedOrder, nil | 271 | return dividendsReturnedOrder, nil |
272 | } | 272 | } |
273 | 273 | ||
274 | -func (repository *DividendsReturnedOrderRepository) UpdateMany(dividendsReturnedOrder []*domain.DividendsReturnedOrder) ([]*domain.DividendsReturnedOrder, error) { | ||
275 | - panic("implement me") | 274 | +func (repository *DividendsReturnedOrderRepository) UpdateMany(dividendsReturnedOrders []*domain.DividendsReturnedOrder) ([]*domain.DividendsReturnedOrder, error) { |
275 | + tx := repository.transactionContext.PgTx | ||
276 | + var dividendsReturnedOrderModels []*models.DividendsReturnedOrder | ||
277 | + for _, dividendsReturnedOrder := range dividendsReturnedOrders { | ||
278 | + dividendsReturnedOrderModels = append(dividendsReturnedOrderModels, &models.DividendsReturnedOrder{ | ||
279 | + DividendsReturnedOrderId: dividendsReturnedOrder.DividendsReturnedOrderId, | ||
280 | + DividendsReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber, | ||
281 | + DividendsReturnedOrderRefund: dividendsReturnedOrder.DividendsReturnedOrderRefund, | ||
282 | + OriginalOrderNum: dividendsReturnedOrder.OriginalOrderNum, | ||
283 | + DividendsOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
284 | + DividendsReturnedCustomerName: dividendsReturnedOrder.DividendsReturnedCustomerName, | ||
285 | + OrderTime: dividendsReturnedOrder.OrderTime, | ||
286 | + DividendsReturnedDate: dividendsReturnedOrder.DividendsReturnedDate, | ||
287 | + Region: dividendsReturnedOrder.Region, | ||
288 | + Remarks: dividendsReturnedOrder.Remarks, | ||
289 | + DividendStatus: dividendsReturnedOrder.DividendStatus, | ||
290 | + DividendTime: dividendsReturnedOrder.DividendTime, | ||
291 | + Org: dividendsReturnedOrder.Org, | ||
292 | + Company: dividendsReturnedOrder.Company, | ||
293 | + CreatedAt: dividendsReturnedOrder.CreatedAt, | ||
294 | + DeletedAt: dividendsReturnedOrder.DeletedAt, | ||
295 | + UpdatedAt: time.Now(), | ||
296 | + Operator: dividendsReturnedOrder.Operator, | ||
297 | + OperateTime: dividendsReturnedOrder.OperateTime, | ||
298 | + }) | ||
299 | + } | ||
300 | + if _, err := tx.Model(÷ndsReturnedOrderModels).WherePK().Update(); err != nil { | ||
301 | + return nil, err | ||
302 | + } | ||
303 | + return dividendsReturnedOrders, nil | ||
276 | } | 304 | } |
277 | 305 | ||
278 | func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) { | 306 | func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) { |
-
请 注册 或 登录 后发表评论