fix
This commit is contained in:
parent
02c41a5069
commit
519d9952e0
|
@ -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,23 +126,23 @@ 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 {
|
||||
for i := 0; i < 3; i++ {
|
||||
priceList = append(priceList, &types.PriceObj{
|
||||
priceList = append(priceList, types.PriceObj{
|
||||
Num: 1,
|
||||
Price: 0,
|
||||
})
|
||||
}
|
||||
childrenObjList = append(childrenObjList, &types.ChildrenObj{
|
||||
childrenObjList = append(childrenObjList, types.ChildrenObj{
|
||||
Id: productSize.Id,
|
||||
Name: *productSize.Capacity,
|
||||
PriceList: priceList,
|
||||
|
@ -171,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,23 +19,8 @@ type GetProductListRsp struct {
|
|||
}
|
||||
|
||||
type Ob struct {
|
||||
Items []*Items `json:"items"`
|
||||
Links *Links `json:"_links"`
|
||||
Meta *Meta `json:"_meta"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
TotalCount int32 `json:"totalCount"`
|
||||
PageCount int32 `json:"pageCount"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
PerPage int32 `json:"perPage"`
|
||||
}
|
||||
|
||||
type Links struct {
|
||||
Self HrefUrl `json:"self"`
|
||||
First HrefUrl `json:"first"`
|
||||
Last HrefUrl `json:"last"`
|
||||
Next HrefUrl `json:"next"`
|
||||
Items []Items `json:"items"`
|
||||
Meta Meta `json:"_meta"`
|
||||
}
|
||||
|
||||
type HrefUrl struct {
|
||||
|
@ -75,20 +60,20 @@ type GetSuccessRecommandRsp struct {
|
|||
type GetSizeByProductRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []*Children `json:"children"`
|
||||
Children []Children `json:"children"`
|
||||
}
|
||||
|
||||
type Children struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Cycle int `json:"cycle"`
|
||||
ChildrenList []*ChildrenObj `json:"children"`
|
||||
ChildrenList []ChildrenObj `json:"children"`
|
||||
}
|
||||
|
||||
type ChildrenObj struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PriceList []*PriceObj `json:"price_list"`
|
||||
PriceList []PriceObj `json:"price_list"`
|
||||
}
|
||||
|
||||
type PriceObj struct {
|
||||
|
@ -110,26 +95,28 @@ type GetProductDesignRsp struct {
|
|||
Info string `json:"info"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type ResponseJwt struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
AccessSecret string `json:"accessSecret"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
}
|
||||
|
||||
type Auth struct {
|
||||
AccessSecret string `json:"accessSecret"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
TotalCount int64 `json:"totalCount"`
|
||||
PageCount int64 `json:"pageCount"`
|
||||
CurrentPage int `json:"currentPage"`
|
||||
PerPage int `json:"perPage"`
|
||||
}
|
||||
|
||||
// Set 设置Response的Code和Message值
|
||||
func (resp *Response) Set(Code int, Message string) *Response {
|
||||
return &Response{
|
||||
|
|
|
@ -37,21 +37,8 @@ type GetProductListRsp {
|
|||
Description string `json:"description"`
|
||||
}
|
||||
type Ob {
|
||||
Items []*Items `json:"items"`
|
||||
Links *Links `json:"_links"`
|
||||
Meta *Meta `json:"_meta"`
|
||||
}
|
||||
type Meta {
|
||||
TotalCount int32 `json:"totalCount"`
|
||||
PageCount int32 `json:"pageCount"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
PerPage int32 `json:"perPage"`
|
||||
}
|
||||
type Links {
|
||||
Self HrefUrl `json:"self"`
|
||||
First HrefUrl `json:"first"`
|
||||
Last HrefUrl `json:"last"`
|
||||
Next HrefUrl `json:"next"`
|
||||
Items []Items `json:"items"`
|
||||
Meta Meta `json:"_meta"`
|
||||
}
|
||||
type HrefUrl {
|
||||
Href string `json:"href"`
|
||||
|
@ -89,18 +76,18 @@ type GetSuccessRecommandRsp {
|
|||
type GetSizeByProductRsp {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []*Children `json:"children"`
|
||||
Children []Children `json:"children"`
|
||||
}
|
||||
type Children {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Cycle int `json:"cycle"`
|
||||
ChildrenList []*ChildrenObj `json:"children"`
|
||||
ChildrenList []ChildrenObj `json:"children"`
|
||||
}
|
||||
type ChildrenObj {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PriceList []*PriceObj `json:"price_list"`
|
||||
PriceList []PriceObj `json:"price_list"`
|
||||
}
|
||||
type PriceObj {
|
||||
Num int `json:"num"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user