-
Notifications
You must be signed in to change notification settings - Fork 9
/
Meal.go
49 lines (44 loc) · 1.77 KB
/
Meal.go
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
package promotion
import (
"sync"
)
// Meal 结构体
type Meal struct {
// 搭配套餐名称。
MealName string `json:"meal_name,omitempty" xml:"meal_name,omitempty"`
// 套餐一口价(单位是:分)
MealPrice string `json:"meal_price,omitempty" xml:"meal_price,omitempty"`
// 搭配套餐商品列表。item_id为商品的id;item_show_name为商品显示名。因最多允许5个商品进行搭配,所以查询最多有5个,以json格式传出。
ItemList string `json:"item_list,omitempty" xml:"item_list,omitempty"`
// 运费模板类型。卖家标识'SELL';买家标识'BUY'。若为'SELL'则字段postage_id为空。若为'BUY',则postage_id为运费模板id,必有值。
TypePostage string `json:"type_postage,omitempty" xml:"type_postage,omitempty"`
// 搭配套餐描述!
MealMemo string `json:"meal_memo,omitempty" xml:"meal_memo,omitempty"`
// 套餐状态。有效:VALID;失效:INVALID(有效套餐为可使用的套餐,无效套餐为套餐中有商品下架或库存为0时)。
Status string `json:"status,omitempty" xml:"status,omitempty"`
// 套餐id。
MealId int64 `json:"meal_id,omitempty" xml:"meal_id,omitempty"`
// 普通运费模板id。若这个字段为空或0时,运费是卖家负责;若这个字段不为空,说明运费模板存在,运费是买家负责。
PostageId int64 `json:"postage_id,omitempty" xml:"postage_id,omitempty"`
}
var poolMeal = sync.Pool{
New: func() any {
return new(Meal)
},
}
// GetMeal() 从对象池中获取Meal
func GetMeal() *Meal {
return poolMeal.Get().(*Meal)
}
// ReleaseMeal 释放Meal
func ReleaseMeal(v *Meal) {
v.MealName = ""
v.MealPrice = ""
v.ItemList = ""
v.TypePostage = ""
v.MealMemo = ""
v.Status = ""
v.MealId = 0
v.PostageId = 0
poolMeal.Put(v)
}