From 84088a7a12d6da277887e35ff5e76a6e8c8b64c2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 27 Jun 2023 17:47:44 +0800 Subject: [PATCH] fix --- .../internal/logic/getcloudlistlogic.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/server/inventory/internal/logic/getcloudlistlogic.go b/server/inventory/internal/logic/getcloudlistlogic.go index 880d15fc..47be6dd1 100644 --- a/server/inventory/internal/logic/getcloudlistlogic.go +++ b/server/inventory/internal/logic/getcloudlistlogic.go @@ -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) }