正在显示
19 个修改的文件
包含
170 行增加
和
42 行删除
1 | version: v1 | 1 | version: v1 |
2 | kind: Method | 2 | kind: Method |
3 | metadata: | 3 | metadata: |
4 | - name: cancel | 4 | + name: cancelOrder |
5 | type: command | 5 | type: command |
6 | description: 取消订单服务 | 6 | description: 取消订单服务 |
7 | payload: | 7 | payload: |
8 | + - ref: orderId | ||
9 | + description: 订单id | ||
10 | + required: true | ||
8 | - ref: orderNo | 11 | - ref: orderNo |
9 | description: 订单编号 | 12 | description: 订单编号 |
10 | required: true | 13 | required: true |
1 | version: v1 | 1 | version: v1 |
2 | kind: Method | 2 | kind: Method |
3 | metadata: | 3 | metadata: |
4 | - name: receiving | 4 | + name: receivingGoods |
5 | type: command | 5 | type: command |
6 | description: 订单收货服务 | 6 | description: 订单收货服务 |
7 | payload: | 7 | payload: |
8 | + - ref: orderId | ||
9 | + description: 订单id | ||
10 | + required: true | ||
8 | - ref: orderNo | 11 | - ref: orderNo |
9 | description: 订单号 | 12 | description: 订单号 |
10 | required: true | 13 | required: true |
@@ -6,10 +6,26 @@ import ( | @@ -6,10 +6,26 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/domainService" | 6 | "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/domainService" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | -func CreateShippingService(options map[string]interface{}) (service.ShippingService, error) { | 9 | +func CreateShippingService(options map[string]interface{}) (service.ShippingGoodsService, error) { |
10 | var transactionContext *pgTransaction.TransactionContext | 10 | var transactionContext *pgTransaction.TransactionContext |
11 | if value, ok := options["transactionContext"]; ok { | 11 | if value, ok := options["transactionContext"]; ok { |
12 | transactionContext = value.(*pgTransaction.TransactionContext) | 12 | transactionContext = value.(*pgTransaction.TransactionContext) |
13 | } | 13 | } |
14 | - return domainService.NewShippingService(transactionContext) | 14 | + return domainService.NewShippingGoodsService(transactionContext) |
15 | +} | ||
16 | + | ||
17 | +func CreateReceivingService(options map[string]interface{}) (service.ReceivingGoodsService, error) { | ||
18 | + var transactionContext *pgTransaction.TransactionContext | ||
19 | + if value, ok := options["transactionContext"]; ok { | ||
20 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
21 | + } | ||
22 | + return domainService.NewReceivingGoodsService(transactionContext) | ||
23 | +} | ||
24 | + | ||
25 | +func CreateCancelOrderService(options map[string]interface{}) (service.CancelOrderService, error) { | ||
26 | + var transactionContext *pgTransaction.TransactionContext | ||
27 | + if value, ok := options["transactionContext"]; ok { | ||
28 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
29 | + } | ||
30 | + return domainService.NewCancelOrderService(transactionContext) | ||
15 | } | 31 | } |
@@ -7,7 +7,9 @@ import ( | @@ -7,7 +7,9 @@ import ( | ||
7 | "github.com/beego/beego/v2/core/validation" | 7 | "github.com/beego/beego/v2/core/validation" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | -type CancelCommand struct { | 10 | +type CancelOrderCommand struct { |
11 | + // 订单ID | ||
12 | + OrderId int64 `json:"orderId" valid:"Required"` | ||
11 | // 订单编号 | 13 | // 订单编号 |
12 | OrderNo string `json:"orderNo" valid:"Required"` | 14 | OrderNo string `json:"orderNo" valid:"Required"` |
13 | // 公司id | 15 | // 公司id |
@@ -38,13 +40,13 @@ type CancelCommand struct { | @@ -38,13 +40,13 @@ type CancelCommand struct { | ||
38 | JobNumber string `json:"jobNumber" valid:"Required"` | 40 | JobNumber string `json:"jobNumber" valid:"Required"` |
39 | } | 41 | } |
40 | 42 | ||
41 | -func (cancelCommand *CancelCommand) Valid(validation *validation.Validation) { | ||
42 | - validation.SetError("CustomValid", "未实现的自定义认证") | 43 | +func (cancelOrderCommand *CancelOrderCommand) Valid(validation *validation.Validation) { |
44 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
43 | } | 45 | } |
44 | 46 | ||
45 | -func (cancelCommand *CancelCommand) ValidateCommand() error { | 47 | +func (cancelOrderCommand *CancelOrderCommand) ValidateCommand() error { |
46 | valid := validation.Validation{} | 48 | valid := validation.Validation{} |
47 | - b, err := valid.Valid(cancelCommand) | 49 | + b, err := valid.Valid(cancelOrderCommand) |
48 | if err != nil { | 50 | if err != nil { |
49 | return err | 51 | return err |
50 | } | 52 | } |
@@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
7 | "github.com/beego/beego/v2/core/validation" | 7 | "github.com/beego/beego/v2/core/validation" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | -type ReturnCommand struct { | 10 | +type ReceivingGoodsCommand struct { |
11 | // 订单号 | 11 | // 订单号 |
12 | OrderNo string `json:"orderNo" valid:"Required"` | 12 | OrderNo string `json:"orderNo" valid:"Required"` |
13 | // 是否是公司负责人 | 13 | // 是否是公司负责人 |
@@ -38,13 +38,13 @@ type ReturnCommand struct { | @@ -38,13 +38,13 @@ type ReturnCommand struct { | ||
38 | CompanyId int64 `json:"companyId" valid:"Required"` | 38 | CompanyId int64 `json:"companyId" valid:"Required"` |
39 | } | 39 | } |
40 | 40 | ||
41 | -func (returnCommand *ReturnCommand) Valid(validation *validation.Validation) { | ||
42 | - validation.SetError("CustomValid", "未实现的自定义认证") | 41 | +func (receivingGoodsCommand *ReceivingGoodsCommand) Valid(validation *validation.Validation) { |
42 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
43 | } | 43 | } |
44 | 44 | ||
45 | -func (returnCommand *ReturnCommand) ValidateCommand() error { | 45 | +func (receivingGoodsCommand *ReceivingGoodsCommand) ValidateCommand() error { |
46 | valid := validation.Validation{} | 46 | valid := validation.Validation{} |
47 | - b, err := valid.Valid(returnCommand) | 47 | + b, err := valid.Valid(receivingGoodsCommand) |
48 | if err != nil { | 48 | if err != nil { |
49 | return err | 49 | return err |
50 | } | 50 | } |
@@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
7 | "github.com/beego/beego/v2/core/validation" | 7 | "github.com/beego/beego/v2/core/validation" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | -type ReceivingCommand struct { | 10 | +type ReturnGoodsCommand struct { |
11 | // 订单号 | 11 | // 订单号 |
12 | OrderNo string `json:"orderNo" valid:"Required"` | 12 | OrderNo string `json:"orderNo" valid:"Required"` |
13 | // 是否是公司负责人 | 13 | // 是否是公司负责人 |
@@ -38,13 +38,13 @@ type ReceivingCommand struct { | @@ -38,13 +38,13 @@ type ReceivingCommand struct { | ||
38 | CompanyId int64 `json:"companyId" valid:"Required"` | 38 | CompanyId int64 `json:"companyId" valid:"Required"` |
39 | } | 39 | } |
40 | 40 | ||
41 | -func (receivingCommand *ReceivingCommand) Valid(validation *validation.Validation) { | ||
42 | - validation.SetError("CustomValid", "未实现的自定义认证") | 41 | +func (returnGoodsCommand *ReturnGoodsCommand) Valid(validation *validation.Validation) { |
42 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
43 | } | 43 | } |
44 | 44 | ||
45 | -func (receivingCommand *ReceivingCommand) ValidateCommand() error { | 45 | +func (returnGoodsCommand *ReturnGoodsCommand) ValidateCommand() error { |
46 | valid := validation.Validation{} | 46 | valid := validation.Validation{} |
47 | - b, err := valid.Valid(receivingCommand) | 47 | + b, err := valid.Valid(returnGoodsCommand) |
48 | if err != nil { | 48 | if err != nil { |
49 | return err | 49 | return err |
50 | } | 50 | } |
@@ -6,7 +6,9 @@ import ( | @@ -6,7 +6,9 @@ import ( | ||
6 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | -type ShippingCommand struct { | 9 | +type ShippingGoodsCommand struct { |
10 | + // 订单ID | ||
11 | + OrderId int `json:"orderId" valid:"Required"` | ||
10 | // 发货单号 | 12 | // 发货单号 |
11 | DeliveryCode string `json:"deliveryCode" valid:"Required"` | 13 | DeliveryCode string `json:"deliveryCode" valid:"Required"` |
12 | // 订单编号 | 14 | // 订单编号 |
@@ -15,13 +17,13 @@ type ShippingCommand struct { | @@ -15,13 +17,13 @@ type ShippingCommand struct { | ||
15 | OrderNum int64 `json:"orderNum" valid:"Required"` | 17 | OrderNum int64 `json:"orderNum" valid:"Required"` |
16 | } | 18 | } |
17 | 19 | ||
18 | -func (shippingCommand *ShippingCommand) Valid(validation *validation.Validation) { | ||
19 | - validation.SetError("CustomValid", "未实现的自定义认证") | 20 | +func (shippingGoodsCommand *ShippingGoodsCommand) Valid(validation *validation.Validation) { |
21 | + //_ = validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | } | 22 | } |
21 | 23 | ||
22 | -func (shippingCommand *ShippingCommand) ValidateCommand() error { | 24 | +func (shippingGoodsCommand *ShippingGoodsCommand) ValidateCommand() error { |
23 | valid := validation.Validation{} | 25 | valid := validation.Validation{} |
24 | - b, err := valid.Valid(shippingCommand) | 26 | + b, err := valid.Valid(shippingGoodsCommand) |
25 | if err != nil { | 27 | if err != nil { |
26 | return err | 28 | return err |
27 | } | 29 | } |
@@ -16,7 +16,7 @@ type OrderService struct { | @@ -16,7 +16,7 @@ type OrderService struct { | ||
16 | } | 16 | } |
17 | 17 | ||
18 | // 取消订单服务 | 18 | // 取消订单服务 |
19 | -func (orderService *OrderService) Cancel(cancelCommand *command.CancelCommand) (interface{}, error) { | 19 | +func (orderService *OrderService) Cancel(cancelCommand *command.CancelOrderCommand) (interface{}, error) { |
20 | if err := cancelCommand.ValidateCommand(); err != nil { | 20 | if err := cancelCommand.ValidateCommand(); err != nil { |
21 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 21 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
22 | } | 22 | } |
@@ -78,8 +78,8 @@ func (orderService *OrderService) CreateOrder(createOrderCommand *command.Create | @@ -78,8 +78,8 @@ func (orderService *OrderService) CreateOrder(createOrderCommand *command.Create | ||
78 | } | 78 | } |
79 | 79 | ||
80 | // 订单分红服务 | 80 | // 订单分红服务 |
81 | -func (orderService *OrderService) DarwDividends(darwDividendsCommand *command.DrawDividendsCommand) (interface{}, error) { | ||
82 | - if err := darwDividendsCommand.ValidateCommand(); err != nil { | 81 | +func (orderService *OrderService) DrawDividends(drawDividendsCommand *command.DrawDividendsCommand) (interface{}, error) { |
82 | + if err := drawDividendsCommand.ValidateCommand(); err != nil { | ||
83 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 83 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
84 | } | 84 | } |
85 | transactionContext, err := factory.CreateTransactionContext(nil) | 85 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -172,7 +172,7 @@ func (orderService *OrderService) ListOrder(listOrderQuery *query.ListOrderQuery | @@ -172,7 +172,7 @@ func (orderService *OrderService) ListOrder(listOrderQuery *query.ListOrderQuery | ||
172 | } | 172 | } |
173 | 173 | ||
174 | // 订单收货服务 | 174 | // 订单收货服务 |
175 | -func (orderService *OrderService) Receiving(receivingCommand *command.ReceivingCommand) (interface{}, error) { | 175 | +func (orderService *OrderService) Receiving(receivingCommand *command.ReceivingGoodsCommand) (interface{}, error) { |
176 | if err := receivingCommand.ValidateCommand(); err != nil { | 176 | if err := receivingCommand.ValidateCommand(); err != nil { |
177 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 177 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
178 | } | 178 | } |
@@ -233,7 +233,7 @@ func (orderService *OrderService) RemoveOrder(removeOrderCommand *command.Remove | @@ -233,7 +233,7 @@ func (orderService *OrderService) RemoveOrder(removeOrderCommand *command.Remove | ||
233 | } | 233 | } |
234 | 234 | ||
235 | // 订单退货服务 | 235 | // 订单退货服务 |
236 | -func (orderService *OrderService) Return(returnCommand *command.ReturnCommand) (interface{}, error) { | 236 | +func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsCommand) (interface{}, error) { |
237 | if err := returnCommand.ValidateCommand(); err != nil { | 237 | if err := returnCommand.ValidateCommand(); err != nil { |
238 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 238 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
239 | } | 239 | } |
@@ -254,7 +254,7 @@ func (orderService *OrderService) Return(returnCommand *command.ReturnCommand) ( | @@ -254,7 +254,7 @@ func (orderService *OrderService) Return(returnCommand *command.ReturnCommand) ( | ||
254 | } | 254 | } |
255 | 255 | ||
256 | // 订单发货服务 | 256 | // 订单发货服务 |
257 | -func (orderService *OrderService) Shipping(shippingCommand *command.ShippingCommand) (interface{}, error) { | 257 | +func (orderService *OrderService) Shipping(shippingCommand *command.ShippingGoodsCommand) (interface{}, error) { |
258 | if err := shippingCommand.ValidateCommand(); err != nil { | 258 | if err := shippingCommand.ValidateCommand(); err != nil { |
259 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 259 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
260 | } | 260 | } |
pkg/domain/service/cancel_order.go
0 → 100644
pkg/domain/service/receiving_goods.go
0 → 100644
pkg/domain/service/shipping.go
已删除
100644 → 0
pkg/domain/service/shipping_goods.go
0 → 100644
@@ -2,19 +2,26 @@ package domainService | @@ -2,19 +2,26 @@ package domainService | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | ||
5 | 7 | ||
6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
7 | ) | 9 | ) |
8 | 10 | ||
9 | -type ShippingService struct { | 11 | +type CancelOrderService struct { |
12 | + coreDomain.BaseEventPublisher | ||
10 | transactionContext *pgTransaction.TransactionContext | 13 | transactionContext *pgTransaction.TransactionContext |
11 | } | 14 | } |
12 | 15 | ||
13 | -func NewShippingService(transactionContext *pgTransaction.TransactionContext) (*ShippingService, error) { | 16 | +func (service *CancelOrderService) Cancel(orderId int64) (*domain.Order, error) { |
17 | + return nil, nil | ||
18 | +} | ||
19 | + | ||
20 | +func NewCancelOrderService(transactionContext *pgTransaction.TransactionContext) (*CancelOrderService, error) { | ||
14 | if transactionContext == nil { | 21 | if transactionContext == nil { |
15 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 22 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
16 | } else { | 23 | } else { |
17 | - return &ShippingService{ | 24 | + return &CancelOrderService{ |
18 | transactionContext: transactionContext, | 25 | transactionContext: transactionContext, |
19 | }, nil | 26 | }, nil |
20 | } | 27 | } |
1 | +package domainService | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | ||
7 | + | ||
8 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
9 | +) | ||
10 | + | ||
11 | +type ReceivingGoodsService struct { | ||
12 | + coreDomain.BaseEventPublisher | ||
13 | + transactionContext *pgTransaction.TransactionContext | ||
14 | +} | ||
15 | + | ||
16 | +func (service *ReceivingGoodsService) Receiving(orderId int64) (*domain.Order, error) { | ||
17 | + return nil, nil | ||
18 | +} | ||
19 | + | ||
20 | +func NewReceivingGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReceivingGoodsService, error) { | ||
21 | + if transactionContext == nil { | ||
22 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
23 | + } else { | ||
24 | + return &ReceivingGoodsService{ | ||
25 | + transactionContext: transactionContext, | ||
26 | + }, nil | ||
27 | + } | ||
28 | +} |
1 | +package domainService | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + coreDomain "github.com/linmadan/egglib-go/core/domain" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain" | ||
7 | + | ||
8 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
9 | +) | ||
10 | + | ||
11 | +type ShippingGoodsService struct { | ||
12 | + coreDomain.BaseEventPublisher | ||
13 | + transactionContext *pgTransaction.TransactionContext | ||
14 | +} | ||
15 | + | ||
16 | +func (service *ShippingGoodsService) Shipping(orderId int64) (*domain.Order, error) { | ||
17 | + return nil, nil | ||
18 | +} | ||
19 | + | ||
20 | +func NewShippingGoodsService(transactionContext *pgTransaction.TransactionContext) (*ShippingGoodsService, error) { | ||
21 | + if transactionContext == nil { | ||
22 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
23 | + } else { | ||
24 | + return &ShippingGoodsService{ | ||
25 | + transactionContext: transactionContext, | ||
26 | + }, nil | ||
27 | + } | ||
28 | +} |
@@ -22,7 +22,7 @@ func (controller *OrderController) CreateOrder() { | @@ -22,7 +22,7 @@ func (controller *OrderController) CreateOrder() { | ||
22 | func (controller *OrderController) UpdateOrder() { | 22 | func (controller *OrderController) UpdateOrder() { |
23 | orderService := service.NewOrderService(nil) | 23 | orderService := service.NewOrderService(nil) |
24 | updateOrderCommand := &command.UpdateOrderCommand{} | 24 | updateOrderCommand := &command.UpdateOrderCommand{} |
25 | - controller.Unmarshal(updateOrderCommand) | 25 | + _ = controller.Unmarshal(updateOrderCommand) |
26 | orderId, _ := controller.GetInt64(":orderId") | 26 | orderId, _ := controller.GetInt64(":orderId") |
27 | updateOrderCommand.OrderId = orderId | 27 | updateOrderCommand.OrderId = orderId |
28 | data, err := orderService.UpdateOrder(updateOrderCommand) | 28 | data, err := orderService.UpdateOrder(updateOrderCommand) |
@@ -41,7 +41,7 @@ func (controller *OrderController) GetOrder() { | @@ -41,7 +41,7 @@ func (controller *OrderController) GetOrder() { | ||
41 | func (controller *OrderController) RemoveOrder() { | 41 | func (controller *OrderController) RemoveOrder() { |
42 | orderService := service.NewOrderService(nil) | 42 | orderService := service.NewOrderService(nil) |
43 | removeOrderCommand := &command.RemoveOrderCommand{} | 43 | removeOrderCommand := &command.RemoveOrderCommand{} |
44 | - controller.Unmarshal(removeOrderCommand) | 44 | + _ = controller.Unmarshal(removeOrderCommand) |
45 | orderId, _ := controller.GetInt64(":orderId") | 45 | orderId, _ := controller.GetInt64(":orderId") |
46 | removeOrderCommand.OrderId = orderId | 46 | removeOrderCommand.OrderId = orderId |
47 | data, err := orderService.RemoveOrder(removeOrderCommand) | 47 | data, err := orderService.RemoveOrder(removeOrderCommand) |
@@ -58,3 +58,13 @@ func (controller *OrderController) ListOrder() { | @@ -58,3 +58,13 @@ func (controller *OrderController) ListOrder() { | ||
58 | data, err := orderService.ListOrder(listOrderQuery) | 58 | data, err := orderService.ListOrder(listOrderQuery) |
59 | controller.Response(data, err) | 59 | controller.Response(data, err) |
60 | } | 60 | } |
61 | + | ||
62 | +func (controller *OrderController) Shipping() { | ||
63 | + orderService := service.NewOrderService(nil) | ||
64 | + shippingCmd := &command.ShippingGoodsCommand{} | ||
65 | + _ = controller.Unmarshal(shippingCmd) | ||
66 | + orderId, _ := controller.GetInt(":orderId") | ||
67 | + shippingCmd.OrderId = orderId | ||
68 | + data, err := orderService.Shipping(shippingCmd) | ||
69 | + controller.Response(data, err) | ||
70 | +} |
-
请 注册 或 登录 后发表评论