fix
This commit is contained in:
@@ -130,7 +130,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product size count err")
|
||||
}
|
||||
//拼接返回
|
||||
itemList := make([]types.Items, 0, productLen)
|
||||
itemList := make([]*types.Items, 0, productLen)
|
||||
for _, v := range productList {
|
||||
minPrice, ok := mapProductMinPrice[v.Id]
|
||||
_, tmpOk := mapProductTemplate[v.Id]
|
||||
@@ -138,7 +138,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
if !ok || !tmpOk {
|
||||
continue
|
||||
}
|
||||
item := types.Items{
|
||||
item := &types.Items{
|
||||
Id: v.Id,
|
||||
Sn: *v.Sn,
|
||||
Title: *v.Title,
|
||||
|
||||
@@ -103,8 +103,8 @@ func (l *GetSizeByProductLogic) GetSizeByProduct(userinfo *auth.UserInfo) (resp
|
||||
}
|
||||
|
||||
// 第一层子层
|
||||
func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []types.Children, err error) {
|
||||
childrenList = make([]types.Children, 0, len(productList))
|
||||
func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []*types.Children, err error) {
|
||||
childrenList = make([]*types.Children, 0, len(productList))
|
||||
for _, product := range productList {
|
||||
if *product.Type != tag.Id {
|
||||
continue
|
||||
@@ -114,7 +114,7 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
|
||||
return nil, err
|
||||
}
|
||||
//获取第二层子类
|
||||
data := types.Children{
|
||||
data := &types.Children{
|
||||
Id: product.Id,
|
||||
Name: *product.Title,
|
||||
Cycle: int(*product.DeliveryDays + *product.ProduceDays),
|
||||
@@ -126,24 +126,26 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
|
||||
}
|
||||
|
||||
// 第2层子层
|
||||
func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []types.ChildrenObj, err error) {
|
||||
childrenObjList = make([]types.ChildrenObj, 0, len(productSizeList))
|
||||
func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []*types.ChildrenObj, err error) {
|
||||
childrenObjList = make([]*types.ChildrenObj, 0, len(productSizeList))
|
||||
for _, productSize := range productSizeList {
|
||||
if product.Id != *productSize.ProductId {
|
||||
continue
|
||||
}
|
||||
priceList := make([]types.PriceObj, 0, len(productSizeList))
|
||||
priceList := make([]*types.PriceObj, 0, len(productSizeList))
|
||||
price, ok := mapProductPrice[productSize.Id]
|
||||
//无对应尺寸价格
|
||||
if !ok {
|
||||
childrenObjList = append(childrenObjList, types.ChildrenObj{
|
||||
Id: productSize.Id,
|
||||
Name: *productSize.Capacity,
|
||||
PriceList: []types.PriceObj{
|
||||
{Num: 1, Price: 0},
|
||||
{Num: 1, Price: 0},
|
||||
{Num: 1, Price: 0},
|
||||
},
|
||||
for i := 0; i < 3; i++ {
|
||||
priceList = append(priceList, &types.PriceObj{
|
||||
Num: 1,
|
||||
Price: 0,
|
||||
})
|
||||
}
|
||||
childrenObjList = append(childrenObjList, &types.ChildrenObj{
|
||||
Id: productSize.Id,
|
||||
Name: *productSize.Capacity,
|
||||
PriceList: priceList,
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -169,14 +171,14 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct,
|
||||
index := 0
|
||||
// 最小购买数量小于 最大阶梯数量+5
|
||||
for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 {
|
||||
priceList = append(priceList, types.PriceObj{
|
||||
priceList = append(priceList, &types.PriceObj{
|
||||
Num: int(*price.MinBuyNum * *price.EachBoxNum),
|
||||
Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice),
|
||||
})
|
||||
*price.MinBuyNum++
|
||||
index++
|
||||
}
|
||||
data := types.ChildrenObj{
|
||||
data := &types.ChildrenObj{
|
||||
Id: productSize.Id,
|
||||
Name: *productSize.Capacity,
|
||||
PriceList: priceList,
|
||||
|
||||
@@ -19,9 +19,9 @@ type GetProductListRsp struct {
|
||||
}
|
||||
|
||||
type Ob struct {
|
||||
Items []Items `json:"items"`
|
||||
Links Links `json:"_links"`
|
||||
Meta Meta `json:"_meta"`
|
||||
Items []*Items `json:"items"`
|
||||
Links *Links `json:"_links"`
|
||||
Meta *Meta `json:"_meta"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
@@ -73,22 +73,22 @@ type GetSuccessRecommandRsp struct {
|
||||
}
|
||||
|
||||
type GetSizeByProductRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []Children `json:"children"`
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []*Children `json:"children"`
|
||||
}
|
||||
|
||||
type Children struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Cycle int `json:"cycle"`
|
||||
ChildrenList []ChildrenObj `json:"children"`
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Cycle int `json:"cycle"`
|
||||
ChildrenList []*ChildrenObj `json:"children"`
|
||||
}
|
||||
|
||||
type ChildrenObj struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PriceList []PriceObj `json:"price_list"`
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PriceList []*PriceObj `json:"price_list"`
|
||||
}
|
||||
|
||||
type PriceObj struct {
|
||||
|
||||
Reference in New Issue
Block a user