order_bestshop.go 2.7 KB
package domain

import "time"

//OrderBestShop 来源海鲜干货的订单
type OrderBestShop struct {
	Id int64 `json:"id"`
	//订单编号
	OrderCode string `json:"orderCode"`
	//下单时间
	OrderTime string `json:"orderTime"`
	//订单状态
	OrderState int8 `json:"orderState"`
	//发货状态
	DeliveryState int8 `json:"deliveryState"`
	//买家名称
	BuyerName string `json:"buyerName"`
	//买家电话
	BuyerPhone string `json:"buyerPhone"`
	//买家地址
	BuyerAddress string `json:"buyerAddress"`
	//买家备注
	BuyerRemark string `json:"buyerRemark"`
	//
	BuyerId int64 `json:"buyerId"`
	//商品总数
	OrderCount int `json:"orderCount"`
	//d订单总额
	OrderAmount float64 `json:"orderAmount"`
	//发货时间
	DeliveryTime string `json:"deliveryTime"`
	//创建时间
	CreateTime time.Time           `json:"createTime"`
	PartnerId  int64               `json:"partnerId"`
	Goods      []OrderGoodBestShop `json:"goods"`
	//是否将数据同步到 order_base ,order_good
	IsCopy    bool  `json:"isCopy"`
	CompanyId int64 `json:"companyId"`
}

func (order OrderBestShop) CopyToOrderBase(o *OrderBase) {
	o.Buyer = Buyer{
		BuyerName:       order.BuyerName,
		ContactInfo:     order.BuyerPhone,
		ShippingAddress: order.BuyerAddress,
		Remark:          order.BuyerRemark,
	}
	o.DataFrom = OrderDataFrom{
		Platform: OrderDataFromBestShop,
		DataId:   order.Id,
	}
	o.OrderCode = order.OrderCode
	o.OrderCompute.PlanOrderAmount = order.OrderAmount
	o.OrderCompute.PlanOrderCount = order.OrderCount
	o.DeliveryTime, _ = time.Parse("2006-01-02 15:04:05", order.DeliveryTime)
	return
}

type OrderBestshopFindOneQuery struct {
	OrderId int64
}

type OrderBestshopRepository interface {
	Add(order *OrderBestShop) error
	Edit(order *OrderBestShop) error
	FindOne(qureyOptions OrderBestshopFindOneQuery) (*OrderBestShop, error)
}

//OrderGoodBestShop 订单明细
type OrderGoodBestShop struct {
	Id int64 `json:"id"`
	//订单id
	OrderId int64 `json:"orderId"`
	//货品编号
	Sn string `json:"sn"`
	//商品编号
	Bn string `json:"bn"`
	//货品名称
	Name string `json:"name"`
	//单价
	Price float64 `json:"price"`
	//货品数量
	Nums int `json:"nums"`
	//订单总价
	Amount float64 `json:"amount"`
}

func (good OrderGoodBestShop) CopyToOrderGood(g *OrderGood) {
	g.DataFrom = OrderDataFrom{
		Platform: OrderDataFromBestShop,
		DataId:   good.Id,
	}
	g.GoodName = good.Name
	g.Price = good.Price
	g.PlanGoodNumber = good.Nums
	g.GoodCompute.PlanAmount = good.Amount
	return
}

type OrderGoodBestshopFindQuery struct {
	OrderId int64
}

type OrderGoodBestshopRepository interface {
	Add(order *OrderGoodBestShop) error
	Find(qureyOptions OrderGoodBestshopFindQuery) ([]OrderGoodBestShop, error)
}