This commit is contained in:
laodaming 2023-06-29 11:43:07 +08:00
parent 02c41a5069
commit 519d9952e0
4 changed files with 46 additions and 72 deletions

View File

@ -130,7 +130,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product size count err") 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 { for _, v := range productList {
minPrice, ok := mapProductMinPrice[v.Id] minPrice, ok := mapProductMinPrice[v.Id]
_, tmpOk := mapProductTemplate[v.Id] _, tmpOk := mapProductTemplate[v.Id]
@ -138,7 +138,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
if !ok || !tmpOk { if !ok || !tmpOk {
continue continue
} }
item := &types.Items{ item := types.Items{
Id: v.Id, Id: v.Id,
Sn: *v.Sn, Sn: *v.Sn,
Title: *v.Title, Title: *v.Title,

View File

@ -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) { 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)) childrenList = make([]types.Children, 0, len(productList))
for _, product := range productList { for _, product := range productList {
if *product.Type != tag.Id { if *product.Type != tag.Id {
continue continue
@ -114,7 +114,7 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
return nil, err return nil, err
} }
//获取第二层子类 //获取第二层子类
data := &types.Children{ data := types.Children{
Id: product.Id, Id: product.Id,
Name: *product.Title, Name: *product.Title,
Cycle: int(*product.DeliveryDays + *product.ProduceDays), Cycle: int(*product.DeliveryDays + *product.ProduceDays),
@ -126,23 +126,23 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
} }
// 第2层子层 // 第2层子层
func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []*types.ChildrenObj, err error) { 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)) childrenObjList = make([]types.ChildrenObj, 0, len(productSizeList))
for _, productSize := range productSizeList { for _, productSize := range productSizeList {
if product.Id != *productSize.ProductId { if product.Id != *productSize.ProductId {
continue continue
} }
priceList := make([]*types.PriceObj, 0, len(productSizeList)) priceList := make([]types.PriceObj, 0, len(productSizeList))
price, ok := mapProductPrice[productSize.Id] price, ok := mapProductPrice[productSize.Id]
//无对应尺寸价格 //无对应尺寸价格
if !ok { if !ok {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
priceList = append(priceList, &types.PriceObj{ priceList = append(priceList, types.PriceObj{
Num: 1, Num: 1,
Price: 0, Price: 0,
}) })
} }
childrenObjList = append(childrenObjList, &types.ChildrenObj{ childrenObjList = append(childrenObjList, types.ChildrenObj{
Id: productSize.Id, Id: productSize.Id,
Name: *productSize.Capacity, Name: *productSize.Capacity,
PriceList: priceList, PriceList: priceList,
@ -171,14 +171,14 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct,
index := 0 index := 0
// 最小购买数量小于 最大阶梯数量+5 // 最小购买数量小于 最大阶梯数量+5
for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 { 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), Num: int(*price.MinBuyNum * *price.EachBoxNum),
Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice), Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice),
}) })
*price.MinBuyNum++ *price.MinBuyNum++
index++ index++
} }
data := &types.ChildrenObj{ data := types.ChildrenObj{
Id: productSize.Id, Id: productSize.Id,
Name: *productSize.Capacity, Name: *productSize.Capacity,
PriceList: priceList, PriceList: priceList,

View File

@ -19,23 +19,8 @@ type GetProductListRsp struct {
} }
type Ob struct { type Ob struct {
Items []*Items `json:"items"` Items []Items `json:"items"`
Links *Links `json:"_links"` Meta Meta `json:"_meta"`
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"`
} }
type HrefUrl struct { type HrefUrl struct {
@ -73,22 +58,22 @@ type GetSuccessRecommandRsp struct {
} }
type GetSizeByProductRsp struct { type GetSizeByProductRsp struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Children []*Children `json:"children"` Children []Children `json:"children"`
} }
type Children struct { type Children struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Cycle int `json:"cycle"` Cycle int `json:"cycle"`
ChildrenList []*ChildrenObj `json:"children"` ChildrenList []ChildrenObj `json:"children"`
} }
type ChildrenObj struct { type ChildrenObj struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
PriceList []*PriceObj `json:"price_list"` PriceList []PriceObj `json:"price_list"`
} }
type PriceObj struct { type PriceObj struct {
@ -110,26 +95,28 @@ type GetProductDesignRsp struct {
Info string `json:"info"` Info string `json:"info"`
} }
type Request struct {
}
type Response struct { type Response struct {
Code int `json:"code"` Code int `json:"code"`
Message string `json:"msg"` Message string `json:"msg"`
Data interface{} `json:"data"` 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 { type Auth struct {
AccessSecret string `json:"accessSecret"` AccessSecret string `json:"accessSecret"`
AccessExpire int64 `json:"accessExpire"` AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"` 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值 // Set 设置Response的Code和Message值
func (resp *Response) Set(Code int, Message string) *Response { func (resp *Response) Set(Code int, Message string) *Response {
return &Response{ return &Response{

View File

@ -37,21 +37,8 @@ type GetProductListRsp {
Description string `json:"description"` Description string `json:"description"`
} }
type Ob { type Ob {
Items []*Items `json:"items"` Items []Items `json:"items"`
Links *Links `json:"_links"` Meta Meta `json:"_meta"`
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"`
} }
type HrefUrl { type HrefUrl {
Href string `json:"href"` Href string `json:"href"`
@ -87,20 +74,20 @@ type GetSuccessRecommandRsp {
//获取分类下的产品以及尺寸 //获取分类下的产品以及尺寸
type GetSizeByProductRsp { type GetSizeByProductRsp {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Children []*Children `json:"children"` Children []Children `json:"children"`
} }
type Children { type Children {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Cycle int `json:"cycle"` Cycle int `json:"cycle"`
ChildrenList []*ChildrenObj `json:"children"` ChildrenList []ChildrenObj `json:"children"`
} }
type ChildrenObj { type ChildrenObj {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
PriceList []*PriceObj `json:"price_list"` PriceList []PriceObj `json:"price_list"`
} }
type PriceObj { type PriceObj {
Num int `json:"num"` Num int `json:"num"`