feat:新增商户列表/保存用户信息
This commit is contained in:
commit
fde5ef8b25
|
@ -10,6 +10,15 @@ import (
|
|||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
func (m *FsMerchantCategoryModel) FindOne(ctx context.Context, id int64) (resp *FsMerchantCategory, err error) {
|
||||
err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("id = ? and status = ?", id, 1).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (m *FsMerchantCategoryModel) FindRandOne(ctx context.Context) (resp *FsMerchantCategory, err error) {
|
||||
err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("status = ?", 1).Order("RAND()").Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (m *FsMerchantCategoryModel) BuilderDB(ctx context.Context, selectData []string) *gorm.DB {
|
||||
if selectData != nil {
|
||||
return m.db.WithContext(ctx).Select(selectData)
|
||||
|
|
|
@ -101,3 +101,14 @@ func (d *FsProductModel3dModel) FindOneJoinSize(ctx context.Context, productId i
|
|||
Order("s.sort ASC").Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (d *FsProductModel3dModel) GetOneBySizeIdTag(ctx context.Context, sizeId int64, tag int64, fields ...string) (resp *FsProductModel3d, err error) {
|
||||
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).
|
||||
Where("`size_id` = ? and `tag` = ? and `status` = ?", sizeId, tag, 1).
|
||||
Order("sort DESC")
|
||||
if len(fields) != 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_product_recommend 推荐商品表
|
||||
type FsProductRecommend struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID
|
||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态 1正常 0不正常
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsProductRecommendModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsProductRecommendModel(db *gorm.DB) *FsProductRecommendModel {
|
||||
return &FsProductRecommendModel{db: db, name: "fs_product_recommend"}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type GetRecommendProductListReq struct {
|
||||
Ctx context.Context
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) {
|
||||
db := r.db.WithContext(req.Ctx).
|
||||
Table("fs_product_recommend as r").
|
||||
Joins("inner join fs_product as p on r.product_id = p.id").
|
||||
Where("r.status = ? ", 1).
|
||||
Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1)
|
||||
if err = db.Limit(1).Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
db = db.Select("p.*")
|
||||
offset := (req.Page - 1) * req.Limit
|
||||
err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error
|
||||
return resp, total, err
|
||||
}
|
||||
func (r *FsProductRecommendModel) CreateOrUpdate(ctx context.Context, productId int64, data *FsProductRecommend) error {
|
||||
var info FsProductRecommend
|
||||
err := r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Take(&info).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
if info.Id == 0 {
|
||||
return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Create(data).Error
|
||||
}
|
||||
return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Updates(data).Error
|
||||
}
|
|
@ -140,22 +140,6 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont
|
|||
return resp, err
|
||||
}
|
||||
|
||||
// 获取产品某个物料下的第一个模板
|
||||
func (t *FsProductTemplateV2Model) GetSizeLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||
Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0).
|
||||
Order("sort ASC").Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 获取产品第一个物料下的第一个模板
|
||||
func (t *FsProductTemplateV2Model) GetProductLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||
Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0).
|
||||
Order("sort ASC").Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 获取产品在指定模板标签下的所有模板
|
||||
func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||
|
|
|
@ -62,7 +62,6 @@ type AllModelsGen struct {
|
|||
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
|
||||
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
|
||||
FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表
|
||||
FsProductRecommend *FsProductRecommendModel // fs_product_recommend 推荐商品表
|
||||
FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design
|
||||
FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表
|
||||
FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表
|
||||
|
@ -159,7 +158,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
|
||||
FsProductOption: NewFsProductOptionModel(gdb),
|
||||
FsProductPrice: NewFsProductPriceModel(gdb),
|
||||
FsProductRecommend: NewFsProductRecommendModel(gdb),
|
||||
FsProductRenderDesign: NewFsProductRenderDesignModel(gdb),
|
||||
FsProductScene: NewFsProductSceneModel(gdb),
|
||||
FsProductSize: NewFsProductSizeModel(gdb),
|
||||
|
|
|
@ -113,14 +113,27 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
}
|
||||
}
|
||||
//获取用户信息(不用判断存在)
|
||||
user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
||||
/*user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user")
|
||||
}*/
|
||||
//获取产品标签相关属性
|
||||
productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property")
|
||||
}
|
||||
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||
for _, v := range productTagPropList {
|
||||
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||
Tag: v.Title,
|
||||
Cover: *v.Cover,
|
||||
})
|
||||
}
|
||||
list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList))
|
||||
for _, v := range recommendProductList {
|
||||
r := image.ThousandFaceImageFormatReq{
|
||||
/*r := image.ThousandFaceImageFormatReq{
|
||||
Size: int(req.Size),
|
||||
IsThousandFace: 0,
|
||||
Cover: *v.Cover,
|
||||
|
@ -133,7 +146,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
r.IsThousandFace = int(*user.IsThousandFace)
|
||||
}
|
||||
//千人前面处理
|
||||
image.ThousandFaceImageFormat(&r)
|
||||
image.ThousandFaceImageFormat(&r)*/
|
||||
isRecommend := int64(0)
|
||||
if _, ok := mapRecommend[v.Id]; ok {
|
||||
isRecommend = 1
|
||||
|
@ -142,18 +155,22 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
||||
minPrice = minVal
|
||||
}
|
||||
list = append(list, types.GetRecommandProductListRsp{
|
||||
item := types.GetRecommandProductListRsp{
|
||||
Id: v.Id,
|
||||
Sn: *v.Sn,
|
||||
Title: *v.Title,
|
||||
TitleCn: *v.TitleCn,
|
||||
Cover: r.Cover,
|
||||
CoverImg: r.CoverImg,
|
||||
CoverDefault: r.CoverDefault,
|
||||
Cover: *productInfo.Cover,
|
||||
CoverImg: *productInfo.CoverImg,
|
||||
CoverDefault: []types.CoverDefaultItem{},
|
||||
Intro: *v.Intro,
|
||||
IsRecommend: isRecommend,
|
||||
MinPrice: minPrice,
|
||||
})
|
||||
}
|
||||
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||
}
|
||||
|
|
|
@ -366,12 +366,13 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||
MinPrice: minPrice,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
Recommended: *productInfo.IsRecommend > 0,
|
||||
Cover: *productInfo.Cover,
|
||||
}
|
||||
if _, ok = req.MapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = req.MapTagProp[productInfo.Id]
|
||||
}
|
||||
//千人千面处理
|
||||
r := image.ThousandFaceImageFormatReq{
|
||||
/*r := image.ThousandFaceImageFormatReq{
|
||||
Size: int(req.Size),
|
||||
IsThousandFace: 0,
|
||||
Cover: *productInfo.Cover,
|
||||
|
@ -383,7 +384,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||
r.IsThousandFace = int(*req.User.IsThousandFace)
|
||||
}
|
||||
image.ThousandFaceImageFormat(&r)
|
||||
item.Cover = r.Cover
|
||||
item.Cover = r.Cover*/
|
||||
//加入分类产品切片
|
||||
productListRsp = append(productListRsp, item)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
|
@ -40,7 +40,6 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||
if req.ProductTemplateTagId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id")
|
||||
}
|
||||
|
||||
//获取产品信息(只获取id)
|
||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
||||
if err != nil {
|
||||
|
@ -50,46 +49,77 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
|
||||
}
|
||||
//获取该产品该模板标签下的模板列表(只获取id)
|
||||
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.
|
||||
GetListByProductAndTemplateTag(l.ctx, fmt.Sprintf("%d", req.ProductTemplateTagId), productInfo.Id, "id")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get templates")
|
||||
}
|
||||
if len(templateList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "templates are not exists")
|
||||
}
|
||||
templateIds := make([]int64, 0, len(templateList))
|
||||
for _, v := range templateList {
|
||||
templateIds = append(templateIds, v.Id)
|
||||
}
|
||||
var (
|
||||
templateInfo *gmodel.FsProductTemplateV2
|
||||
)
|
||||
//传了指定物料,则获取该物料的第一个模板
|
||||
if req.ProductSizeId > 0 {
|
||||
templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetSizeLatestTemplate(l.ctx, templateIds, productInfo.Id)
|
||||
} else { //没有指定物料则获取第一个物料的第一个模板
|
||||
templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetProductLatestTemplate(l.ctx, templateIds, productInfo.Id)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info not found")
|
||||
//没有指定物料
|
||||
sizeIds := make([]int64, 0, 10)
|
||||
if req.ProductSizeId <= 0 {
|
||||
//获取产品所有物料
|
||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "id")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get product size list")
|
||||
}
|
||||
if len(sizeList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product size list is empty")
|
||||
}
|
||||
for _, v := range sizeList {
|
||||
sizeIds = append(sizeIds, v.Id)
|
||||
}
|
||||
} else { //指定物料
|
||||
sizeIds = append(sizeIds, req.ProductSizeId)
|
||||
}
|
||||
//根据尺寸id获取模型
|
||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template info")
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
||||
}
|
||||
if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "template info is not set")
|
||||
if len(modelList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "model list is empty")
|
||||
}
|
||||
var info interface{}
|
||||
if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil {
|
||||
modelIds := make([]int64, 0, len(modelList))
|
||||
mapModel := make(map[int64]int)
|
||||
for k, v := range modelList {
|
||||
modelIds = append(modelIds, v.Id)
|
||||
mapModel[v.Id] = k
|
||||
}
|
||||
//查询模型ids下对应tag标签的模板
|
||||
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json product template info:", templateInfo.Id)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTemplateByPidRsp{
|
||||
TemplateId: templateInfo.Id,
|
||||
TemplateInfo: info,
|
||||
})
|
||||
rsp := make(map[string]interface{})
|
||||
for _, templateInfo := range templateList {
|
||||
//没有设置模板据不要
|
||||
if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" {
|
||||
continue
|
||||
}
|
||||
modelIndex, ok := mapModel[*templateInfo.ModelId]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
//基础模板信息
|
||||
var info map[string]map[string]interface{}
|
||||
if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id))
|
||||
}
|
||||
//后台隐藏/显示信息
|
||||
var switchInfo interface{}
|
||||
if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" {
|
||||
_ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo)
|
||||
}
|
||||
modelInfo := modelList[modelIndex]
|
||||
var material interface{}
|
||||
if info["module_data"] != nil && info["module_data"]["material"] != nil {
|
||||
material = info["module_data"]["material"]
|
||||
}
|
||||
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
|
||||
rsp[mapKey] = map[string]interface{}{
|
||||
"id": templateInfo.Id,
|
||||
"material": material,
|
||||
"material_data": switchInfo,
|
||||
}
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/image"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -36,28 +35,51 @@ func NewHomePageRecommendProductListLogic(ctx context.Context, svcCtx *svc.Servi
|
|||
|
||||
func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *types.HomePageRecommendProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
//查询用户信息(不用判断存在)
|
||||
user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
||||
_, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get user info err")
|
||||
}
|
||||
var (
|
||||
merchantInfo *gmodel.FsMerchantCategory
|
||||
recommendProductList []gmodel.FsProduct //产品列表(select 字段需要看查询的地方)
|
||||
productOptionalPartList []gmodel.GetGroupPartListByProductIdsRsp //产品配件列表
|
||||
mapProductHaveOptionFitting = make(map[int64]struct{})
|
||||
productPriceList []gmodel.GetPriceListByProductIdsRsp //产品价格列表(select 字段需要看查询的地方)
|
||||
mapProductMinPrice = make(map[int64]int64) //产品最小价格map
|
||||
productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方)
|
||||
productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方)
|
||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||
mapProductTemplate = make(map[int64]struct{}) //产品模板map
|
||||
mapProductHaveOptionFitting = make(map[int64]struct{}) //是否有配件map
|
||||
productPriceList []gmodel.GetPriceListByProductIdsRsp //产品价格列表(select 字段需要看查询的地方)
|
||||
mapProductMinPrice = make(map[int64]int64) //产品最小价格map
|
||||
productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方)
|
||||
productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方)
|
||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||
mapProductTemplate = make(map[int64]struct{}) //产品模板map
|
||||
)
|
||||
//选了商家类型
|
||||
if req.MerchantType > 0 {
|
||||
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType)
|
||||
} else {
|
||||
//随机获取一个商家类型
|
||||
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindRandOne(l.ctx)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of merchant type found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant type info")
|
||||
}
|
||||
if *merchantInfo.RecommendProduct == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
}
|
||||
recommendProductIds, err := format.StrSlicToInt64Slice(strings.Split(*merchantInfo.RecommendProduct, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse recommend product")
|
||||
}
|
||||
//获取列表推荐产品
|
||||
recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
|
||||
Ctx: l.ctx,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
})
|
||||
recommendProductList, err = l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, recommendProductIds, "sort-desc")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list")
|
||||
}
|
||||
if len(recommendProductList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
}
|
||||
|
@ -125,6 +147,19 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||
for _, v := range productSizeCountList {
|
||||
mapProductSizeCount[v.ProductId] = v.Num
|
||||
}
|
||||
//获取产品标签相关属性
|
||||
productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property")
|
||||
}
|
||||
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||
for _, v := range productTagPropList {
|
||||
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||
Tag: v.Title,
|
||||
Cover: *v.Cover,
|
||||
})
|
||||
}
|
||||
//组装返回
|
||||
listRsp := make([]types.HomePageRecommendProductListRsp, 0, len(recommendProductList))
|
||||
for _, productInfo := range recommendProductList {
|
||||
|
@ -147,12 +182,17 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||
Id: productInfo.Id,
|
||||
Sn: *productInfo.Sn,
|
||||
Title: *productInfo.Title,
|
||||
Cover: *productInfo.Cover,
|
||||
CoverDefault: []types.CoverDefaultItem{},
|
||||
SizeNum: uint32(sizeNum),
|
||||
MinPrice: minPrice,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
}
|
||||
if _, ok = mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
}
|
||||
//千人千面处理
|
||||
r := image.ThousandFaceImageFormatReq{
|
||||
/*r := image.ThousandFaceImageFormatReq{
|
||||
Size: int(req.Size),
|
||||
IsThousandFace: 0,
|
||||
Cover: *productInfo.Cover,
|
||||
|
@ -166,7 +206,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||
}
|
||||
image.ThousandFaceImageFormat(&r)
|
||||
item.Cover = r.Cover
|
||||
item.CoverDefault = r.CoverDefault
|
||||
item.CoverDefault = r.CoverDefault*/
|
||||
//加入分类产品切片
|
||||
listRsp = append(listRsp, item)
|
||||
}
|
||||
|
|
|
@ -234,16 +234,16 @@ type GetRecommandProductListReq struct {
|
|||
}
|
||||
|
||||
type GetRecommandProductListRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
}
|
||||
|
||||
type GetTagProductListReq struct {
|
||||
|
@ -341,13 +341,8 @@ type GetSizeByPidRsp struct {
|
|||
|
||||
type GetTemplateByPidReq struct {
|
||||
Pid string `form:"pid"`
|
||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
||||
}
|
||||
|
||||
type GetTemplateByPidRsp struct {
|
||||
TemplateId int64 `json:"template_id"` //模板id
|
||||
TemplateInfo interface{} `json:"template_info"` //模板信息
|
||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
||||
}
|
||||
|
||||
type GetFittingByPidReq struct {
|
||||
|
@ -395,18 +390,19 @@ type GetLastProductDesignRsp struct {
|
|||
}
|
||||
|
||||
type HomePageRecommendProductListReq struct {
|
||||
Size uint32 `form:"size"`
|
||||
Size uint32 `form:"size"`
|
||||
MerchantType int64 `form:"merchant_type"`
|
||||
}
|
||||
|
||||
type HomePageRecommendProductListRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
SizeNum uint32 `json:"size_num"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
SizeNum uint32 `json:"size_num"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -183,10 +183,10 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
|
|||
//需要替换的参数
|
||||
replaceData := map[string]interface{}{
|
||||
"logo_url": parseInfo.RenderData.Logo,
|
||||
"website": "",
|
||||
"slogan": "",
|
||||
"address": "",
|
||||
"phone": "",
|
||||
"website": parseInfo.RenderData.Website,
|
||||
"slogan": parseInfo.RenderData.Slogan,
|
||||
"address": parseInfo.RenderData.Address,
|
||||
"phone": parseInfo.RenderData.Phone,
|
||||
"colors": []string{},
|
||||
"template_tagid": []string{"b1a"},
|
||||
"is_crop": false,
|
||||
|
|
|
@ -286,16 +286,16 @@ type GetRecommandProductListReq {
|
|||
Sn string `form:"sn"`
|
||||
}
|
||||
type GetRecommandProductListRsp {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
}
|
||||
//获取分类产品列表
|
||||
type GetTagProductListReq {
|
||||
|
@ -386,12 +386,8 @@ type GetSizeByPidRsp {
|
|||
//获取产品模板
|
||||
type GetTemplateByPidReq {
|
||||
Pid string `form:"pid"`
|
||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
||||
}
|
||||
type GetTemplateByPidRsp {
|
||||
TemplateId int64 `json:"template_id"` //模板id
|
||||
TemplateInfo interface{} `json:"template_info"` //模板信息
|
||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
||||
}
|
||||
//获取产品配件数据
|
||||
type GetFittingByPidReq {
|
||||
|
@ -437,15 +433,16 @@ type GetLastProductDesignRsp {
|
|||
}
|
||||
//获取列表页推荐产品(返回是这个维度数组)
|
||||
type HomePageRecommendProductListReq {
|
||||
Size uint32 `form:"size"`
|
||||
Size uint32 `form:"size"`
|
||||
MerchantType int64 `form:"merchant_type"`
|
||||
}
|
||||
type HomePageRecommendProductListRsp {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
SizeNum uint32 `json:"size_num"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
SizeNum uint32 `json:"size_num"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
}
|
|
@ -16,6 +16,10 @@ type RenderData struct {
|
|||
ProductId int64 `json:"product_id"` //产品id
|
||||
UserMaterialId int64 `json:"user_material_id"` //用户素材id
|
||||
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
|
||||
Website string `json:"website"` //网站
|
||||
Slogan string `json:"slogan"` //slogan
|
||||
Address string `json:"address"` //地址
|
||||
Phone string `json:"phone"` //电话
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user