update_order.go
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package command
import (
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
type UpdateOrderCommand struct {
//id
Id int64 `json:"id"`
//订单编号
OrderCode string `json:"orderCode"`
//订单名称
OrderName string `json:"oderName"`
//数量
OrderCount int `json:"orderCount"`
//订单金额
OrderAmount float64 `json:"orderAmount"`
//买家
BuyerPhone string `json:"buyerPhone"`
//地址
BuyerAddress string `json:"address"`
//订单区域
OrderRegion string `json:"orderRegion"`
//合伙人分红百分比
PartnerBonusPercent float64 `json:"partnerBonusPercent"`
//业务员分红百分比
SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
//订单状态
OrderStatus int `json:"orderStatus"`
//订单类型
OrderType int `json:"orderType"`
}
func (command UpdateOrderCommand) ValidateCommand() error {
if command.Id == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单id错误")
}
if len(command.BuyerPhone) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "买家信息必填")
}
if len(command.BuyerAddress) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "买家地址必填")
}
if len(command.OrderCode) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单编号必填")
}
if len(command.OrderRegion) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单区域必填")
}
if !(command.OrderType == domain.OrderReal ||
command.OrderType == domain.OrderIntention) {
return lib.ThrowError(lib.ARG_ERROR, "订单类型错误")
}
if !(command.OrderStatus == domain.OrderStatusDeliverSome ||
command.OrderStatus == domain.OrderStatusDeliverAll ||
command.OrderStatus == domain.OrderStatusReserve) {
return lib.ThrowError(lib.ARG_ERROR, "订单状态设置错误")
}
return nil
}