作者 陈志颖

合并分支 '6-order-domain-service' 到 'dev'

Resolve "order-domain-service"

Closes #6

查看合并请求 !8
1 -{"/Users/steve/go/src/partner01/pkg/port/beego":1617679552608984079}  
  1 +{"/Users/steve/go/src/partner01/pkg/port/beego":1617694648836700729}
@@ -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 ReceivingGoodsCommand struct { 10 +type ReceiveGoodsCommand struct {
11 // 订单号 11 // 订单号
12 OrderNo string `json:"orderNo" valid:"Required"` 12 OrderNo string `json:"orderNo" valid:"Required"`
13 // 是否是公司负责人 13 // 是否是公司负责人
@@ -38,13 +38,13 @@ type ReceivingGoodsCommand struct { @@ -38,13 +38,13 @@ type ReceivingGoodsCommand struct {
38 CompanyId int64 `json:"companyId" valid:"Required"` 38 CompanyId int64 `json:"companyId" valid:"Required"`
39 } 39 }
40 40
41 -func (receivingGoodsCommand *ReceivingGoodsCommand) Valid(validation *validation.Validation) { 41 +func (receiveGoodsCommand *ReceiveGoodsCommand) Valid(validation *validation.Validation) {
42 //validation.SetError("CustomValid", "未实现的自定义认证") 42 //validation.SetError("CustomValid", "未实现的自定义认证")
43 } 43 }
44 44
45 -func (receivingGoodsCommand *ReceivingGoodsCommand) ValidateCommand() error { 45 +func (receiveGoodsCommand *ReceiveGoodsCommand) ValidateCommand() error {
46 valid := validation.Validation{} 46 valid := validation.Validation{}
47 - b, err := valid.Valid(receivingGoodsCommand) 47 + b, err := valid.Valid(receiveGoodsCommand)
48 if err != nil { 48 if err != nil {
49 return err 49 return err
50 } 50 }
@@ -15,8 +15,8 @@ import ( @@ -15,8 +15,8 @@ import (
15 type OrderService struct { 15 type OrderService struct {
16 } 16 }
17 17
18 -// 取消订单服务  
19 -func (orderService *OrderService) Cancel(cancelCommand *command.CancelOrderCommand) (interface{}, error) { 18 +// 取消订单
  19 +func (orderService *OrderService) CancelOrder(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 }
@@ -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.ReceivingGoodsCommand) (interface{}, error) { 175 +func (orderService *OrderService) ReceiveGoods(receivingCommand *command.ReceiveGoodsCommand) (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,8 +233,8 @@ func (orderService *OrderService) RemoveOrder(removeOrderCommand *command.Remove @@ -233,8 +233,8 @@ func (orderService *OrderService) RemoveOrder(removeOrderCommand *command.Remove
233 } 233 }
234 234
235 // 订单退货服务 235 // 订单退货服务
236 -func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsCommand) (interface{}, error) {  
237 - if err := returnCommand.ValidateCommand(); err != nil { 236 +func (orderService *OrderService) ReturnGoods(returnGoodsCommand *command.ReturnGoodsCommand) (interface{}, error) {
  237 + if err := returnGoodsCommand.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 }
240 transactionContext, err := factory.CreateTransactionContext(nil) 240 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -254,8 +254,8 @@ func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsComma @@ -254,8 +254,8 @@ func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsComma
254 } 254 }
255 255
256 // 订单发货服务 256 // 订单发货服务
257 -func (orderService *OrderService) Shipping(shippingCommand *command.ShippingGoodsCommand) (interface{}, error) {  
258 - if err := shippingCommand.ValidateCommand(); err != nil { 257 +func (orderService *OrderService) ShippingGoods(shippingGoodsCommand *command.ShippingGoodsCommand) (interface{}, error) {
  258 + if err := shippingGoodsCommand.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 }
261 transactionContext, err := factory.CreateTransactionContext(nil) 261 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -342,22 +342,27 @@ func (order *Order) Identify() interface{} { @@ -342,22 +342,27 @@ func (order *Order) Identify() interface{} {
342 return order.OrderId 342 return order.OrderId
343 } 343 }
344 344
  345 +// 更新订单
345 func (order *Order) Update(data map[string]interface{}) error { 346 func (order *Order) Update(data map[string]interface{}) error {
346 return order.CurrentStatus.Update(order, data) 347 return order.CurrentStatus.Update(order, data)
347 } 348 }
348 349
  350 +// 发货
349 func (order *Order) Checkout() error { 351 func (order *Order) Checkout() error {
350 return order.CurrentStatus.Checkout(order) 352 return order.CurrentStatus.Checkout(order)
351 } 353 }
352 354
  355 +// 退货
353 func (order *Order) Return() error { 356 func (order *Order) Return() error {
354 return order.CurrentStatus.Return(order) 357 return order.CurrentStatus.Return(order)
355 } 358 }
356 359
  360 +// 收货
357 func (order *Order) Receive() error { 361 func (order *Order) Receive() error {
358 return order.CurrentStatus.Receive(order) 362 return order.CurrentStatus.Receive(order)
359 } 363 }
360 364
  365 +// 取消订单
361 func (order *Order) Cancel() error { 366 func (order *Order) Cancel() error {
362 return order.CurrentStatus.Cancel(order) 367 return order.CurrentStatus.Cancel(order)
363 } 368 }
@@ -13,8 +13,8 @@ type ReturnGoodsService struct { @@ -13,8 +13,8 @@ type ReturnGoodsService struct {
13 transactionContext *pgTransaction.TransactionContext 13 transactionContext *pgTransaction.TransactionContext
14 } 14 }
15 15
16 -func (service *ReceivingGoodsService) Return(orderId int64) (*domain.Order, error) {  
17 - return nil, nil 16 +func (service *ReturnGoodsService) Return(orderId int64) (*domain.Order, error) {
  17 + panic("implement me")
18 } 18 }
19 19
20 func NewReturnGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReturnGoodsService, error) { 20 func NewReturnGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReturnGoodsService, error) {
@@ -65,6 +65,6 @@ func (controller *OrderController) Shipping() { @@ -65,6 +65,6 @@ func (controller *OrderController) Shipping() {
65 _ = controller.Unmarshal(shippingCmd) 65 _ = controller.Unmarshal(shippingCmd)
66 orderId, _ := controller.GetInt(":orderId") 66 orderId, _ := controller.GetInt(":orderId")
67 shippingCmd.OrderId = orderId 67 shippingCmd.OrderId = orderId
68 - data, err := orderService.Shipping(shippingCmd) 68 + data, err := orderService.ShippingGoods(shippingCmd)
69 controller.Response(data, err) 69 controller.Response(data, err)
70 } 70 }