审查视图

pkg/domain/order_bestshop.go 2.9 KB
1 2 3 4 5 6 7 8 9 10 11 12
package domain

import "time"

//OrderBestShop 来源海鲜干货的订单
type OrderBestShop struct {
	Id int64 `json:"id"`
	//订单编号
	OrderCode string `json:"orderCode"`
	//下单时间
	OrderTime string `json:"orderTime"`
	//订单状态
唐旭辉 authored
13
	OrderState int8 `json:"orderState"`
14
	//发货状态
唐旭辉 authored
15
	DeliveryState int8 `json:"deliveryState"`
16 17 18 19 20 21 22 23
	//买家名称
	BuyerName string `json:"buyerName"`
	//买家电话
	BuyerPhone string `json:"buyerPhone"`
	//买家地址
	BuyerAddress string `json:"buyerAddress"`
	//买家备注
	BuyerRemark string `json:"buyerRemark"`
唐旭辉 authored
24 25
	//
	BuyerId int64 `json:"buyerId"`
26 27 28 29 30
	//商品总数
	OrderCount int `json:"orderCount"`
	//d订单总额
	OrderAmount float64 `json:"orderAmount"`
	//发货时间
唐旭辉 authored
31
	DeliveryTime string `json:"deliveryTime"`
32 33
	//创建时间
	CreateTime time.Time           `json:"createTime"`
唐旭辉 authored
34
	PartnerId  int64               `json:"partnerId"`
35
	Goods      []OrderGoodBestShop `json:"goods"`
唐旭辉 authored
36
	//是否将数据同步到 order_base ,order_good
唐旭辉 authored
37 38 39
	IsCopy    bool   `json:"isCopy"`
	CompanyId int64  `json:"companyId"`
	OrderArea string `json:"orderArea"`
40 41 42 43 44 45 46 47 48 49 50 51 52
}

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,
	}
53
	o.OrderType = OrderTypeBestShop
54 55 56
	o.OrderCode = order.OrderCode
	o.OrderCompute.PlanOrderAmount = order.OrderAmount
	o.OrderCompute.PlanOrderCount = order.OrderCount
唐旭辉 authored
57
	o.DeliveryTime, _ = time.Parse("2006-01-02 15:04:05", order.DeliveryTime)
唐旭辉 authored
58
	o.RegionInfo.RegionName = order.OrderArea
59 60 61 62
	return
}

type OrderBestshopFindOneQuery struct {
唐旭辉 authored
63 64
	OrderId   int64
	OrderCode string
65 66 67 68
}

type OrderBestshopRepository interface {
	Add(order *OrderBestShop) error
唐旭辉 authored
69
	Edit(order *OrderBestShop) error
70 71 72 73 74 75 76
	FindOne(qureyOptions OrderBestshopFindOneQuery) (*OrderBestShop, error)
}

//OrderGoodBestShop 订单明细
type OrderGoodBestShop struct {
	Id int64 `json:"id"`
	//订单id
77
	OrderId int64 `json:"orderId"`
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
	//货品编号
	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
唐旭辉 authored
101 102
	g.BonusStatus = OrderGoodWaitPay
	g.CurrentBonusStatus = OrderGoodBonusWaitPay{}
唐旭辉 authored
103
104 105 106 107 108 109 110 111 112
	return
}

type OrderGoodBestshopFindQuery struct {
	OrderId int64
}

type OrderGoodBestshopRepository interface {
	Add(order *OrderGoodBestShop) error
唐旭辉 authored
113
	Edit(good *OrderGoodBestShop) error
114 115
	Find(qureyOptions OrderGoodBestshopFindQuery) ([]OrderGoodBestShop, error)
}