11
This commit is contained in:
@@ -50,6 +50,21 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
|
||||
}
|
||||
//获取跟列表页云渲染一样的默认渲染尺寸(模板->尺寸)
|
||||
defaultSizeId := int64(0)
|
||||
defaultTemplate, err := l.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(l.ctx, productInfo.Id, req.TemplateTag, "sort ASC", "model_id")
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default template ")
|
||||
} else {
|
||||
//根据模板找到模型sizeId
|
||||
defaultModel3d, err := l.svcCtx.AllModels.FsProductModel3d.FindOne(l.ctx, *defaultTemplate.ModelId, "size_id")
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default model ")
|
||||
}
|
||||
defaultSizeId = *defaultModel3d.SizeId
|
||||
}
|
||||
//获取产品尺寸列表(需要正序排序)
|
||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "is_hot DESC,sort ASC")
|
||||
if err != nil {
|
||||
@@ -58,9 +73,13 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||
}
|
||||
sizeIds := make([]int64, 0, len(sizeList))
|
||||
productIds := make([]int64, 0, len(sizeList))
|
||||
for _, v := range sizeList {
|
||||
for k, v := range sizeList {
|
||||
sizeIds = append(sizeIds, v.Id)
|
||||
productIds = append(productIds, *v.ProductId)
|
||||
//把默认的排第一
|
||||
if v.Id == defaultSizeId {
|
||||
sizeList[0], sizeList[k] = sizeList[k], sizeList[0]
|
||||
}
|
||||
}
|
||||
//获取产品价格列表
|
||||
productPriceList, err := l.svcCtx.AllModels.FsProductPrice.GetSimplePriceListByProductIds(l.ctx, productIds)
|
||||
|
||||
Reference in New Issue
Block a user