正在显示
4 个修改的文件
包含
81 行增加
和
1 行删除
@@ -2,8 +2,10 @@ package domainService | @@ -2,8 +2,10 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" |
8 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/repository" | ||
7 | 9 | ||
8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
9 | ) | 11 | ) |
@@ -14,6 +16,24 @@ type CancelOrderService struct { | @@ -14,6 +16,24 @@ type CancelOrderService struct { | ||
14 | } | 16 | } |
15 | 17 | ||
16 | func (service *CancelOrderService) Cancel(orderId int64) (*domain.Order, error) { | 18 | func (service *CancelOrderService) Cancel(orderId int64) (*domain.Order, error) { |
19 | + var orderRepository domain.OrderRepository | ||
20 | + if value, err := repository.NewOrderRepository(service.transactionContext); err != nil { | ||
21 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
22 | + } else { | ||
23 | + orderRepository = value | ||
24 | + } | ||
25 | + order, err := orderRepository.FindOne(map[string]interface{}{"orderId": orderId}) | ||
26 | + if err != nil { | ||
27 | + return nil, err | ||
28 | + } | ||
29 | + if err := order.Cancel(); err != nil { | ||
30 | + return nil, err | ||
31 | + } | ||
32 | + if order, err := orderRepository.Save(order); err != nil { | ||
33 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
34 | + } else { | ||
35 | + return order, nil | ||
36 | + } | ||
17 | return nil, nil | 37 | return nil, nil |
18 | } | 38 | } |
19 | 39 |
@@ -2,8 +2,10 @@ package domainService | @@ -2,8 +2,10 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" |
8 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/repository" | ||
7 | 9 | ||
8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
9 | ) | 11 | ) |
@@ -14,6 +16,24 @@ type ReceivingGoodsService struct { | @@ -14,6 +16,24 @@ type ReceivingGoodsService struct { | ||
14 | } | 16 | } |
15 | 17 | ||
16 | func (service *ReceivingGoodsService) Receiving(orderId int64) (*domain.Order, error) { | 18 | func (service *ReceivingGoodsService) Receiving(orderId int64) (*domain.Order, error) { |
19 | + var orderRepository domain.OrderRepository | ||
20 | + if value, err := repository.NewOrderRepository(service.transactionContext); err != nil { | ||
21 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
22 | + } else { | ||
23 | + orderRepository = value | ||
24 | + } | ||
25 | + order, err := orderRepository.FindOne(map[string]interface{}{"orderId": orderId}) | ||
26 | + if err != nil { | ||
27 | + return nil, err | ||
28 | + } | ||
29 | + if err := order.Receive(); err != nil { | ||
30 | + return nil, err | ||
31 | + } | ||
32 | + if order, err := orderRepository.Save(order); err != nil { | ||
33 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
34 | + } else { | ||
35 | + return order, nil | ||
36 | + } | ||
17 | return nil, nil | 37 | return nil, nil |
18 | } | 38 | } |
19 | 39 |
@@ -2,8 +2,10 @@ package domainService | @@ -2,8 +2,10 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" |
8 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/repository" | ||
7 | 9 | ||
8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
9 | ) | 11 | ) |
@@ -14,7 +16,25 @@ type ReturnGoodsService struct { | @@ -14,7 +16,25 @@ type ReturnGoodsService struct { | ||
14 | } | 16 | } |
15 | 17 | ||
16 | func (service *ReturnGoodsService) Return(orderId int64) (*domain.Order, error) { | 18 | func (service *ReturnGoodsService) Return(orderId int64) (*domain.Order, error) { |
17 | - panic("implement me") | 19 | + var orderRepository domain.OrderRepository |
20 | + if value, err := repository.NewOrderRepository(service.transactionContext); err != nil { | ||
21 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
22 | + } else { | ||
23 | + orderRepository = value | ||
24 | + } | ||
25 | + order, err := orderRepository.FindOne(map[string]interface{}{"orderId": orderId}) | ||
26 | + if err != nil { | ||
27 | + return nil, err | ||
28 | + } | ||
29 | + if err := order.Return(); err != nil { | ||
30 | + return nil, err | ||
31 | + } | ||
32 | + if order, err := orderRepository.Save(order); err != nil { | ||
33 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
34 | + } else { | ||
35 | + return order, nil | ||
36 | + } | ||
37 | + return nil, nil | ||
18 | } | 38 | } |
19 | 39 | ||
20 | func NewReturnGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReturnGoodsService, error) { | 40 | func NewReturnGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReturnGoodsService, error) { |
@@ -2,8 +2,10 @@ package domainService | @@ -2,8 +2,10 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" |
8 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/repository" | ||
7 | 9 | ||
8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
9 | ) | 11 | ) |
@@ -14,6 +16,24 @@ type ShippingGoodsService struct { | @@ -14,6 +16,24 @@ type ShippingGoodsService struct { | ||
14 | } | 16 | } |
15 | 17 | ||
16 | func (service *ShippingGoodsService) Shipping(orderId int64) (*domain.Order, error) { | 18 | func (service *ShippingGoodsService) Shipping(orderId int64) (*domain.Order, error) { |
19 | + var orderRepository domain.OrderRepository | ||
20 | + if value, err := repository.NewOrderRepository(service.transactionContext); err != nil { | ||
21 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
22 | + } else { | ||
23 | + orderRepository = value | ||
24 | + } | ||
25 | + order, err := orderRepository.FindOne(map[string]interface{}{"orderId": orderId}) | ||
26 | + if err != nil { | ||
27 | + return nil, err | ||
28 | + } | ||
29 | + if err := order.Shipping(); err != nil { | ||
30 | + return nil, err | ||
31 | + } | ||
32 | + if order, err := orderRepository.Save(order); err != nil { | ||
33 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
34 | + } else { | ||
35 | + return order, nil | ||
36 | + } | ||
17 | return nil, nil | 37 | return nil, nil |
18 | } | 38 | } |
19 | 39 |
-
请 注册 或 登录 后发表评论