create_order.go 1.5 KB
package command

import (
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)

type CreateOrderCommand struct {
	//订单区域
	OrderRegion string
	//订单编号
	OrderCode string `json:"orderCode"`
	//订单名称
	OrderName string `json:"oderName"`
	//数量
	OrderCount int `json:"orderCount"`
	//实际订单数量
	OrderActualCount int `json:"orderActualCount"`
	//订单金额
	OrderAmount float64 `json:"orderAmount"`
	//订单实际金额
	OrderActualAmount float64 `json:"orderActualAmount"`
	//订单状态
	OrderStatus int `json:"orderStatus"`
	//买家
	BuyerName string `json:"buyerName"`
	//买家电话
	BuyerPhone string `json:"buyerPhone"`
	//地址
	BuyerAddress string `json:"address"`
	//合伙人数据
	PartnerId int64 `json:"partId"`
	//合伙人分红百分比
	PartnerBonusPercent float64 `json:"partnerBonusPercent"`
	//业务员分红百分比
	SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
	OrderType            int     `json:"orderType"`
}

func (command CreateOrderCommand) ValidateCommand() error {
	if len(command.BuyerName) == 0 || 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, "订单区域必填")
	}
	return nil
}