This commit is contained in:
laodaming
2023-06-13 17:47:48 +08:00
parent da347feac9
commit d941402ef1
13 changed files with 502 additions and 18 deletions

View File

@@ -77,7 +77,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, login
productIds = append(productIds, v.Id)
}
productPriceModel := gmodel.NewFsProductPriceModel(l.svcCtx.MysqlConn)
productPriceList, err := productPriceModel.GetPriceListByProductIds(l.ctx, productIds)
productPriceList, err := productPriceModel.GetSimplePriceListByProductIds(l.ctx, productIds)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product min price list")

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/format"
"fusenapi/utils/step_price"
"strings"
"fusenapi/server/product/internal/svc"
@@ -167,7 +168,7 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct,
for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 {
priceList = append(priceList, types.PriceObj{
Num: int(*price.MinBuyNum * *price.EachBoxNum),
Price: l.GetPrice(int(*price.MinBuyNum), stepNum, stepPrice),
Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice),
})
*price.MinBuyNum++
index++
@@ -181,17 +182,3 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct,
}
return
}
func (l *GetSizeByProductLogic) GetPrice(minBuyNum int, stepNum []int, stepPrice []int) float64 {
if minBuyNum > stepNum[len(stepNum)-1] {
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
}
for k, v := range stepNum {
if minBuyNum <= v {
if k <= (len(stepPrice) - 1) {
return float64(stepPrice[k]) / float64(100)
}
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
}
}
return float64(stepPrice[len(stepPrice)-1]) / float64(100)
}