作者 陈志颖

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

Resolve "order-domain-service"

Closes #6

查看合并请求 !8
{"/Users/steve/go/src/partner01/pkg/port/beego":1617679552608984079}
\ No newline at end of file
{"/Users/steve/go/src/partner01/pkg/port/beego":1617694648836700729}
\ No newline at end of file
... ...
... ... @@ -7,7 +7,7 @@ import (
"github.com/beego/beego/v2/core/validation"
)
type ReceivingGoodsCommand struct {
type ReceiveGoodsCommand struct {
// 订单号
OrderNo string `json:"orderNo" valid:"Required"`
// 是否是公司负责人
... ... @@ -38,13 +38,13 @@ type ReceivingGoodsCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"`
}
func (receivingGoodsCommand *ReceivingGoodsCommand) Valid(validation *validation.Validation) {
func (receiveGoodsCommand *ReceiveGoodsCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (receivingGoodsCommand *ReceivingGoodsCommand) ValidateCommand() error {
func (receiveGoodsCommand *ReceiveGoodsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(receivingGoodsCommand)
b, err := valid.Valid(receiveGoodsCommand)
if err != nil {
return err
}
... ...
... ... @@ -15,8 +15,8 @@ import (
type OrderService struct {
}
// 取消订单服务
func (orderService *OrderService) Cancel(cancelCommand *command.CancelOrderCommand) (interface{}, error) {
// 取消订单
func (orderService *OrderService) CancelOrder(cancelCommand *command.CancelOrderCommand) (interface{}, error) {
if err := cancelCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -172,7 +172,7 @@ func (orderService *OrderService) ListOrder(listOrderQuery *query.ListOrderQuery
}
// 订单收货服务
func (orderService *OrderService) Receiving(receivingCommand *command.ReceivingGoodsCommand) (interface{}, error) {
func (orderService *OrderService) ReceiveGoods(receivingCommand *command.ReceiveGoodsCommand) (interface{}, error) {
if err := receivingCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -233,8 +233,8 @@ func (orderService *OrderService) RemoveOrder(removeOrderCommand *command.Remove
}
// 订单退货服务
func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsCommand) (interface{}, error) {
if err := returnCommand.ValidateCommand(); err != nil {
func (orderService *OrderService) ReturnGoods(returnGoodsCommand *command.ReturnGoodsCommand) (interface{}, error) {
if err := returnGoodsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -254,8 +254,8 @@ func (orderService *OrderService) Return(returnCommand *command.ReturnGoodsComma
}
// 订单发货服务
func (orderService *OrderService) Shipping(shippingCommand *command.ShippingGoodsCommand) (interface{}, error) {
if err := shippingCommand.ValidateCommand(); err != nil {
func (orderService *OrderService) ShippingGoods(shippingGoodsCommand *command.ShippingGoodsCommand) (interface{}, error) {
if err := shippingGoodsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ...
... ... @@ -342,22 +342,27 @@ func (order *Order) Identify() interface{} {
return order.OrderId
}
// 更新订单
func (order *Order) Update(data map[string]interface{}) error {
return order.CurrentStatus.Update(order, data)
}
// 发货
func (order *Order) Checkout() error {
return order.CurrentStatus.Checkout(order)
}
// 退货
func (order *Order) Return() error {
return order.CurrentStatus.Return(order)
}
// 收货
func (order *Order) Receive() error {
return order.CurrentStatus.Receive(order)
}
// 取消订单
func (order *Order) Cancel() error {
return order.CurrentStatus.Cancel(order)
}
... ...
... ... @@ -13,8 +13,8 @@ type ReturnGoodsService struct {
transactionContext *pgTransaction.TransactionContext
}
func (service *ReceivingGoodsService) Return(orderId int64) (*domain.Order, error) {
return nil, nil
func (service *ReturnGoodsService) Return(orderId int64) (*domain.Order, error) {
panic("implement me")
}
func NewReturnGoodsService(transactionContext *pgTransaction.TransactionContext) (*ReturnGoodsService, error) {
... ...
... ... @@ -65,6 +65,6 @@ func (controller *OrderController) Shipping() {
_ = controller.Unmarshal(shippingCmd)
orderId, _ := controller.GetInt(":orderId")
shippingCmd.OrderId = orderId
data, err := orderService.Shipping(shippingCmd)
data, err := orderService.ShippingGoods(shippingCmd)
controller.Response(data, err)
}
... ...