fix
This commit is contained in:
parent
50c5e28381
commit
13420cd400
|
@ -6,9 +6,7 @@ import (
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/format"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
@ -81,32 +79,10 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||||
productIds = append(productIds, *v.ProductId)
|
productIds = append(productIds, *v.ProductId)
|
||||||
}
|
}
|
||||||
//获取产品价格列表
|
//获取产品价格列表
|
||||||
productPriceList, err := l.svcCtx.AllModels.FsProductPrice.GetSimplePriceListByProductIds(l.ctx, productIds)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product min price list")
|
|
||||||
}
|
|
||||||
mapProductMinPrice := make(map[int64]int64)
|
mapProductMinPrice := make(map[int64]int64)
|
||||||
//存储产品最小价格
|
if err = l.svcCtx.AllModels.FsProductModel3d.GetProductMinPrice(l.ctx, productIds, mapProductMinPrice); err != nil {
|
||||||
for _, v := range productPriceList {
|
|
||||||
priceStrSlic := strings.Split(v.Price, ",")
|
|
||||||
priceSlice, err := format.StrSlicToIntSlice(priceStrSlic)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product min price")
|
||||||
}
|
|
||||||
if len(priceSlice) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//正序排序价格(注意排序后的阶梯价格不能用作阶梯数量价格计算)
|
|
||||||
sort.Ints(priceSlice)
|
|
||||||
if min, ok := mapProductMinPrice[v.ProductId]; ok {
|
|
||||||
if min > int64(priceSlice[0]) {
|
|
||||||
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//获取对应模型数据
|
//获取对应模型数据
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id,size_id")
|
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id,size_id")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user