This commit is contained in:
laodaming 2023-06-27 17:47:44 +08:00
parent 66ed487249
commit 84088a7a12

View File

@ -5,6 +5,8 @@ import (
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/format"
"strings"
"context"
@ -119,5 +121,34 @@ func (l *GetCloudListLogic) GetCloudList(req *types.GetCloudListReq, userinfo *a
for k, v := range productModel3dList {
mapProductModel[v.Id] = k
}
//根据产品ids获取产品价格
priceList, err := l.svcCtx.AllModels.FsProductPrice.GetPriceListByProductIds(l.ctx, productIds)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product price list")
}
for _, v := range priceList {
if *v.StepNum == "" || *v.StepPrice == "" {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "price data`s step num or step price is empty")
}
stepNum, err := format.StrSlicToIntSlice(strings.Split(*v.StepNum, ","))
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "parse step num err")
}
lenStepNum := len(stepNum)
stepPrice, err := format.StrSlicToIntSlice(strings.Split(*v.StepPrice, ","))
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "parse step price err")
}
lenStepPrice := len(stepPrice)
for *v.MinBuyNum < int64(stepPrice[lenStepPrice-1]+5) {
//根据材质,尺寸,价格计算阶梯价
*v.MinBuyNum++
}
}
return resp.SetStatus(basic.CodeOK)
}