Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
cd4ca1c1e0
18
model/gmodel/fs_logo_preprocess_gen.go
Normal file
18
model/gmodel/fs_logo_preprocess_gen.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_logo_preprocess
|
||||||
|
type FsLogoPreprocess struct {
|
||||||
|
RestaurantName *string `gorm:"index;default:'';" json:"restaurant_name"` // 餐厅名字
|
||||||
|
}
|
||||||
|
type FsLogoPreprocessModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsLogoPreprocessModel(db *gorm.DB) *FsLogoPreprocessModel {
|
||||||
|
return &FsLogoPreprocessModel{db: db, name: "fs_logo_preprocess"}
|
||||||
|
}
|
2
model/gmodel/fs_logo_preprocess_logic.go
Normal file
2
model/gmodel/fs_logo_preprocess_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
23
model/gmodel/fs_product_history_template_gen.go
Normal file
23
model/gmodel/fs_product_history_template_gen.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_product_history_template 模板历史表
|
||||||
|
type FsProductHistoryTemplate struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模板id
|
||||||
|
TemplateInfo *string `gorm:"default:'';" json:"template_info"` //
|
||||||
|
RelativePublicTemplateId *int64 `gorm:"default:0;" json:"relative_public_template_id"` // 变更之前关联的公共模板id(仅供查看)
|
||||||
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
|
}
|
||||||
|
type FsProductHistoryTemplateModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsProductHistoryTemplateModel(db *gorm.DB) *FsProductHistoryTemplateModel {
|
||||||
|
return &FsProductHistoryTemplateModel{db: db, name: "fs_product_history_template"}
|
||||||
|
}
|
2
model/gmodel/fs_product_history_template_logic.go
Normal file
2
model/gmodel/fs_product_history_template_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -17,14 +17,16 @@ type FsProductTemplateV2 struct {
|
|||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
||||||
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
||||||
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以,仅供模型关联)
|
||||||
|
IsPublicTemplate *int64 `gorm:"default:0;" json:"is_public_template"` // 是否是公共模板0非1是(仅针对模板之间)
|
||||||
|
RelativePublicTemplateId *int64 `gorm:"default:0;" json:"relative_public_template_id"` // 模板间关联的公共模板id
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
|
||||||
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
||||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
|
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
|
||||||
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
|
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
|
||||||
ElementModelId *int64 `gorm:"default:0;" json:"element_model_id"` // 云渲染对应模型id
|
ElementModelId *int64 `gorm:"default:0;" json:"element_model_id"` // 云渲染对应模型id
|
||||||
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsProductTemplateV2Model struct {
|
type FsProductTemplateV2Model struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -36,6 +36,7 @@ type FsShoppingCartData struct {
|
|||||||
// 购物车快照数据结构
|
// 购物车快照数据结构
|
||||||
type CartSnapshot struct {
|
type CartSnapshot struct {
|
||||||
Logo string `json:"logo"` //logo地址
|
Logo string `json:"logo"` //logo地址
|
||||||
|
LogoMaterialMetadata interface{} `json:"logo_material_metadata"` //logo素材信息
|
||||||
CombineImage string `json:"combine_image"` //刀版图地址
|
CombineImage string `json:"combine_image"` //刀版图地址
|
||||||
RenderImage string `json:"render_image"` //渲染结果图
|
RenderImage string `json:"render_image"` //渲染结果图
|
||||||
TemplateInfo TemplateInfo `json:"template_info"` //模板数据
|
TemplateInfo TemplateInfo `json:"template_info"` //模板数据
|
||||||
|
@ -53,6 +53,7 @@ type AllModelsGen struct {
|
|||||||
FsGuest *FsGuestModel // fs_guest 游客表
|
FsGuest *FsGuestModel // fs_guest 游客表
|
||||||
FsLog *FsLogModel // fs_log 日志表
|
FsLog *FsLogModel // fs_log 日志表
|
||||||
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
|
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
|
||||||
|
FsLogoPreprocess *FsLogoPreprocessModel // fs_logo_preprocess
|
||||||
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
||||||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||||
@ -72,6 +73,7 @@ type AllModelsGen struct {
|
|||||||
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
|
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
|
||||||
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
|
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
|
||||||
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
|
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
|
||||||
|
FsProductHistoryTemplate *FsProductHistoryTemplateModel // fs_product_history_template 模板历史表
|
||||||
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
|
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
|
||||||
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
|
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
|
||||||
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
|
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
|
||||||
@ -83,7 +85,6 @@ type AllModelsGen struct {
|
|||||||
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
||||||
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
||||||
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
||||||
FsProductTemplateElement22 *FsProductTemplateElement22Model // fs_product_template_element_22
|
|
||||||
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
||||||
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
||||||
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
||||||
@ -166,6 +167,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsGuest: NewFsGuestModel(gdb),
|
FsGuest: NewFsGuestModel(gdb),
|
||||||
FsLog: NewFsLogModel(gdb),
|
FsLog: NewFsLogModel(gdb),
|
||||||
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
|
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
|
||||||
|
FsLogoPreprocess: NewFsLogoPreprocessModel(gdb),
|
||||||
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
||||||
FsMenu: NewFsMenuModel(gdb),
|
FsMenu: NewFsMenuModel(gdb),
|
||||||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||||
@ -185,6 +187,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsProductCopy1: NewFsProductCopy1Model(gdb),
|
FsProductCopy1: NewFsProductCopy1Model(gdb),
|
||||||
FsProductDesign: NewFsProductDesignModel(gdb),
|
FsProductDesign: NewFsProductDesignModel(gdb),
|
||||||
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
|
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
|
||||||
|
FsProductHistoryTemplate: NewFsProductHistoryTemplateModel(gdb),
|
||||||
FsProductModel3d: NewFsProductModel3dModel(gdb),
|
FsProductModel3d: NewFsProductModel3dModel(gdb),
|
||||||
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
|
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
|
||||||
FsProductOption: NewFsProductOptionModel(gdb),
|
FsProductOption: NewFsProductOptionModel(gdb),
|
||||||
@ -196,7 +199,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
||||||
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
||||||
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
||||||
FsProductTemplateElement22: NewFsProductTemplateElement22Model(gdb),
|
|
||||||
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
||||||
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
||||||
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
||||||
|
@ -22,11 +22,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/product/get_model_by_pid",
|
Path: "/api/product/get_model_by_pid",
|
||||||
Handler: GetModelByPidHandler(serverCtx),
|
Handler: GetModelByPidHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_price_by_pid",
|
|
||||||
Handler: GetPriceByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/api/product/get_product_step_price",
|
Path: "/api/product/get_product_step_price",
|
||||||
|
@ -1,165 +0,0 @@
|
|||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"fusenapi/utils/format"
|
|
||||||
"fusenapi/utils/step_price"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetPriceByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetPriceByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPriceByPidLogic {
|
|
||||||
return &GetPriceByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetPriceByPidLogic) GetPriceByPid(req *types.GetPriceByPidReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
|
||||||
req.Pid = strings.Trim(req.Pid, " ")
|
|
||||||
if req.Pid == "" {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
|
|
||||||
}
|
|
||||||
//获取产品信息(只是获取id)
|
|
||||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the product is not exists")
|
|
||||||
}
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
|
|
||||||
}
|
|
||||||
//查询产品价格
|
|
||||||
priceList, err := l.svcCtx.AllModels.FsProductPrice.GetPriceListByProductIds(l.ctx, []int64{productInfo.Id})
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get price list")
|
|
||||||
}
|
|
||||||
if len(priceList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:price list is empty")
|
|
||||||
}
|
|
||||||
//处理价格信息
|
|
||||||
mapRsp := make(map[string]*types.GetPriceByPidRsp)
|
|
||||||
for _, priceInfo := range priceList {
|
|
||||||
stepNumSlice, err := format.StrSlicToIntSlice(strings.Split(*priceInfo.StepNum, ","))
|
|
||||||
if err != nil {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("failed to parse step num,price_id=%d", priceInfo.Id))
|
|
||||||
}
|
|
||||||
stepPriceSlice, err := format.StrSlicToIntSlice(strings.Split(*priceInfo.StepPrice, ","))
|
|
||||||
if err != nil {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("failed to parse step price,id = %d", priceInfo.Id))
|
|
||||||
}
|
|
||||||
if len(stepPriceSlice) == 0 || len(stepNumSlice) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "number of step num or step price is zero")
|
|
||||||
}
|
|
||||||
lenStepNum := len(stepNumSlice)
|
|
||||||
itemList := make([]types.PriceItem, 0, 10)
|
|
||||||
tmpMinBuyNum := *priceInfo.MinBuyNum
|
|
||||||
for tmpMinBuyNum < (int64(stepNumSlice[lenStepNum-1]) + 5) {
|
|
||||||
itemList = append(itemList, types.PriceItem{
|
|
||||||
Num: tmpMinBuyNum,
|
|
||||||
TotalNum: tmpMinBuyNum * (*priceInfo.EachBoxNum),
|
|
||||||
Price: step_price.GetCentStepPrice(int(tmpMinBuyNum), stepNumSlice, stepPriceSlice),
|
|
||||||
})
|
|
||||||
tmpMinBuyNum++
|
|
||||||
}
|
|
||||||
//组装阶梯数量范围价格
|
|
||||||
stepRange := l.dealWithStepRange(stepNumSlice, stepPriceSlice, priceInfo)
|
|
||||||
//排序(必须放在其他逻辑之后)
|
|
||||||
sort.Ints(stepPriceSlice)
|
|
||||||
minPrice := float64(stepPriceSlice[0]) / 100
|
|
||||||
maxPrice := float64(stepPriceSlice[len(stepPriceSlice)-1]) / 100
|
|
||||||
mapKey := l.getSizePriceMapKey(*priceInfo.SizeId)
|
|
||||||
mapRsp[mapKey] = &types.GetPriceByPidRsp{
|
|
||||||
Items: itemList,
|
|
||||||
MinPrice: minPrice,
|
|
||||||
MaxPrice: maxPrice,
|
|
||||||
StepRange: stepRange,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", mapRsp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组装阶梯价格范围
|
|
||||||
func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []int, priceInfo gmodel.FsProductPrice) []types.StepRange {
|
|
||||||
//要求写死不影响前端展示
|
|
||||||
return []types.StepRange{
|
|
||||||
{
|
|
||||||
Begin: 1000,
|
|
||||||
End: 2999,
|
|
||||||
Price: 0.23,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Begin: 3000,
|
|
||||||
End: 4999,
|
|
||||||
Price: 0.2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Begin: 5000,
|
|
||||||
End: -1,
|
|
||||||
Price: 0.1,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
//下面是正常的
|
|
||||||
lenStepNum := len(stepNumSlice)
|
|
||||||
lenStepPrice := len(stepPriceSlice)
|
|
||||||
stepListRsp := make([]types.StepRange, 0, lenStepNum)
|
|
||||||
//只有一个阶梯价格
|
|
||||||
if lenStepPrice == 1 {
|
|
||||||
stepListRsp = append(stepListRsp, types.StepRange{
|
|
||||||
Begin: *priceInfo.MinBuyNum * (*priceInfo.EachBoxNum),
|
|
||||||
End: -1,
|
|
||||||
Price: float64(stepPriceSlice[0]) / 100,
|
|
||||||
})
|
|
||||||
return stepListRsp
|
|
||||||
}
|
|
||||||
begin := int64(0)
|
|
||||||
end := int64(0)
|
|
||||||
for numKey, stepNum := range stepNumSlice {
|
|
||||||
//先取最后一个
|
|
||||||
tmpPrice := float64(stepPriceSlice[lenStepPrice-1]) / 100
|
|
||||||
//如果同下标下面有价格
|
|
||||||
if numKey < lenStepPrice {
|
|
||||||
tmpPrice = float64(stepPriceSlice[numKey]) / 100
|
|
||||||
}
|
|
||||||
begin = int64(stepNum) * (*priceInfo.EachBoxNum)
|
|
||||||
//不是最后一个
|
|
||||||
if numKey < lenStepNum-1 {
|
|
||||||
nextBegin := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum)
|
|
||||||
end = nextBegin - 1
|
|
||||||
} else {
|
|
||||||
end = -1
|
|
||||||
}
|
|
||||||
stepListRsp = append(stepListRsp, types.StepRange{
|
|
||||||
Begin: begin,
|
|
||||||
End: end,
|
|
||||||
Price: tmpPrice,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return stepListRsp
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取mapKey
|
|
||||||
func (l *GetPriceByPidLogic) getSizePriceMapKey(sizeId int64) string {
|
|
||||||
return fmt.Sprintf("_%d", sizeId)
|
|
||||||
}
|
|
@ -339,7 +339,7 @@ func (l *GetProductDetailLogic) getRenderDefaultSize(productId int64, templateTa
|
|||||||
|
|
||||||
// 获取对应模板标签颜色信息
|
// 获取对应模板标签颜色信息
|
||||||
func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailReq, userinfo *auth.UserInfo) (resp types.TemplateTagColorInfo, err error) {
|
func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailReq, userinfo *auth.UserInfo) (resp types.TemplateTagColorInfo, err error) {
|
||||||
if req.SelectColorIndex < 0 {
|
if req.SelectedColorIndex < 0 {
|
||||||
return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid")
|
return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid")
|
||||||
}
|
}
|
||||||
//根据logo查询素材资源
|
//根据logo查询素材资源
|
||||||
@ -387,7 +387,7 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR
|
|||||||
if !ok {
|
if !ok {
|
||||||
return types.TemplateTagColorInfo{}, errors.New("the template tag is not found from this logo material`s metadata")
|
return types.TemplateTagColorInfo{}, errors.New("the template tag is not found from this logo material`s metadata")
|
||||||
}
|
}
|
||||||
if req.SelectColorIndex >= len(colors) {
|
if req.SelectedColorIndex >= len(colors) {
|
||||||
return types.TemplateTagColorInfo{}, errors.New("select color index is out of range !!")
|
return types.TemplateTagColorInfo{}, errors.New("select color index is out of range !!")
|
||||||
}
|
}
|
||||||
var templateTagGroups interface{}
|
var templateTagGroups interface{}
|
||||||
@ -399,7 +399,7 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR
|
|||||||
}
|
}
|
||||||
return types.TemplateTagColorInfo{
|
return types.TemplateTagColorInfo{
|
||||||
Colors: colors,
|
Colors: colors,
|
||||||
SelectedColorIndex: req.SelectColorIndex,
|
SelectedColorIndex: req.SelectedColorIndex,
|
||||||
TemplateTagGroups: templateTagGroups,
|
TemplateTagGroups: templateTagGroups,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
"fusenapi/utils/image"
|
|
||||||
"fusenapi/utils/s3url_to_s3id"
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
"strings"
|
||||||
@ -36,11 +35,10 @@ func NewGetRecommandProductListLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
req.Num = 4 //写死4个
|
if req.Num > 100 || req.Num < 0 {
|
||||||
if req.Size > 0 {
|
req.Num = 4
|
||||||
req.Size = int32(image.GetCurrentSize(uint32(req.Size)))
|
|
||||||
}
|
}
|
||||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Sn)
|
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOne(l.ctx, req.ProductId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "detail`s product is not found")
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "detail`s product is not found")
|
||||||
@ -62,6 +60,10 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get recommend product list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get recommend product list")
|
||||||
}
|
}
|
||||||
|
//超过了截取
|
||||||
|
if len(recommendProductList) > int(req.Num) {
|
||||||
|
recommendProductList = recommendProductList[:req.Num]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//资源id集合
|
//资源id集合
|
||||||
resourceIds := make([]string, 0, 50)
|
resourceIds := make([]string, 0, 50)
|
||||||
@ -92,6 +94,32 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
recommendProductList = append(recommendProductList, v)
|
recommendProductList = append(recommendProductList, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//获取商品可选配件
|
||||||
|
productOptionalPartList, err := l.svcCtx.AllModels.FsProductModel3d.GetGroupPartListByProductIds(l.ctx, productIds)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product part list")
|
||||||
|
}
|
||||||
|
//存储有配件的map
|
||||||
|
mapProductHaveOptionFitting := make(map[int64]struct{})
|
||||||
|
for _, partList := range productOptionalPartList {
|
||||||
|
partList.PartList = strings.Trim(partList.PartList, " ")
|
||||||
|
partList.PartList = strings.Trim(partList.PartList, ",")
|
||||||
|
if partList.PartList == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mapProductHaveOptionFitting[partList.ProductId] = struct{}{}
|
||||||
|
}
|
||||||
|
//获取产品尺寸数量
|
||||||
|
productSizeCountList, err := l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get ")
|
||||||
|
}
|
||||||
|
mapProductSizeCount := make(map[int64]int64)
|
||||||
|
for _, v := range productSizeCountList {
|
||||||
|
mapProductSizeCount[v.ProductId] = v.Num
|
||||||
|
}
|
||||||
//获取产品最低价
|
//获取产品最低价
|
||||||
mapProductMinPrice := make(map[int64]int64)
|
mapProductMinPrice := make(map[int64]int64)
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByProductIdsTags(l.ctx, []int64{productInfo.Id}, []int{constants.TAG_MODEL, constants.TAG_PARTS}, "id,size_id,product_id,price,tag,part_id,step_price")
|
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByProductIdsTags(l.ctx, []int64{productInfo.Id}, []int{constants.TAG_MODEL, constants.TAG_PARTS}, "id,size_id,product_id,price,tag,part_id,step_price")
|
||||||
@ -144,6 +172,14 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
||||||
minPrice = minVal
|
minPrice = minVal
|
||||||
}
|
}
|
||||||
|
sizeCount := int64(0)
|
||||||
|
if sc, ok := mapProductSizeCount[v.Id]; ok {
|
||||||
|
sizeCount = sc
|
||||||
|
}
|
||||||
|
haveOptionalFitting := false
|
||||||
|
if _, ok := mapProductHaveOptionFitting[v.Id]; ok {
|
||||||
|
haveOptionalFitting = true
|
||||||
|
}
|
||||||
item := types.GetRecommandProductListRsp{
|
item := types.GetRecommandProductListRsp{
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Sn: *v.Sn,
|
Sn: *v.Sn,
|
||||||
@ -158,6 +194,8 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
Recommend: recommend,
|
Recommend: recommend,
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
IsCustomization: *v.IsCustomization,
|
IsCustomization: *v.IsCustomization,
|
||||||
|
SizeCount: sizeCount,
|
||||||
|
HaveOptionalFitting: haveOptionalFitting,
|
||||||
}
|
}
|
||||||
if _, ok := mapTagProp[productInfo.Id]; ok {
|
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||||
|
@ -6,9 +6,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GetRecommandProductListReq struct {
|
type GetRecommandProductListReq struct {
|
||||||
Size int32 `form:"size,optional"`
|
|
||||||
Num int64 `form:"num,optional"`
|
Num int64 `form:"num,optional"`
|
||||||
Sn string `form:"sn"`
|
ProductId int64 `form:"product_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetRecommandProductListRsp struct {
|
type GetRecommandProductListRsp struct {
|
||||||
@ -25,6 +24,8 @@ type GetRecommandProductListRsp struct {
|
|||||||
Recommend bool `json:"recommend"`
|
Recommend bool `json:"recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
IsCustomization int64 `json:"is_customization"`
|
IsCustomization int64 `json:"is_customization"`
|
||||||
|
SizeCount int64 `json:"size_count"`
|
||||||
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTagProductListReq struct {
|
type GetTagProductListReq struct {
|
||||||
@ -73,29 +74,6 @@ type GetModelByPidReq struct {
|
|||||||
Pid string `form:"pid"` //实际上是产品sn
|
Pid string `form:"pid"` //实际上是产品sn
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetPriceByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetPriceByPidRsp struct {
|
|
||||||
Items []PriceItem `json:"items"`
|
|
||||||
MinPrice float64 `json:"min_price"`
|
|
||||||
MaxPrice float64 `json:"max_price"`
|
|
||||||
StepRange []StepRange `json:"step_range"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StepRange struct {
|
|
||||||
Begin int64 `json:"begin"`
|
|
||||||
End int64 `json:"end"`
|
|
||||||
Price float64 `json:"price"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PriceItem struct {
|
|
||||||
Num int64 `json:"num"`
|
|
||||||
TotalNum int64 `json:"total_num"`
|
|
||||||
Price int64 `json:"price"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetProductStepPriceReq struct {
|
type GetProductStepPriceReq struct {
|
||||||
ProductId int64 `form:"product_id"`
|
ProductId int64 `form:"product_id"`
|
||||||
}
|
}
|
||||||
@ -194,7 +172,7 @@ type HomePageRecommendProductListRsp struct {
|
|||||||
type GetProductDetailReq struct {
|
type GetProductDetailReq struct {
|
||||||
ProductId int64 `form:"product_id"` //产品id
|
ProductId int64 `form:"product_id"` //产品id
|
||||||
TemplateTag string `form:"template_tag"` //模板标签
|
TemplateTag string `form:"template_tag"` //模板标签
|
||||||
SelectColorIndex int `form:"select_color_index"` //模板标签颜色索引
|
SelectedColorIndex int `form:"selected_color_index"` //模板标签颜色索引
|
||||||
Logo string `form:"logo"` //logo地址
|
Logo string `form:"logo"` //logo地址
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,27 +6,27 @@ import (
|
|||||||
|
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
"fusenapi/server/shopping-cart/internal/logic"
|
||||||
"fusenapi/server/product/internal/svc"
|
"fusenapi/server/shopping-cart/internal/svc"
|
||||||
"fusenapi/server/product/internal/types"
|
"fusenapi/server/shopping-cart/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetPriceByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetCartNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
var req types.GetPriceByPidReq
|
var req types.Request
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
// 创建一个业务逻辑层实例
|
||||||
l := logic.NewGetPriceByPidLogic(r.Context(), svcCtx)
|
l := logic.NewGetCartNumLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
rl := reflect.ValueOf(l)
|
||||||
basic.BeforeLogic(w, r, rl)
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
resp := l.GetPriceByPid(&req, userinfo)
|
resp := l.GetCartNum(&req, userinfo)
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
basic.NormalAfterLogic(w, r, resp)
|
@ -32,6 +32,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/shopping-cart/calculate_cart_price",
|
Path: "/api/shopping-cart/calculate_cart_price",
|
||||||
Handler: CalculateCartPriceHandler(serverCtx),
|
Handler: CalculateCartPriceHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/shopping-cart/get_cart_num",
|
||||||
|
Handler: GetCartNumHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/file"
|
"fusenapi/utils/file"
|
||||||
"fusenapi/utils/hash"
|
"fusenapi/utils/hash"
|
||||||
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -54,6 +55,20 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
|||||||
if cartCount >= 100 {
|
if cartCount >= 100 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100")
|
||||||
}
|
}
|
||||||
|
logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
|
||||||
|
//获取用户素材信息
|
||||||
|
userMaterialInfo, err := l.svcCtx.AllModels.FsUserMaterial.FindOneByLogoResourceId(l.ctx, logoResourceId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp.SetStatusAddMessage(basic.CodeDbRecordNotFoundErr, "the user logo material info is not found")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get user logo material info")
|
||||||
|
}
|
||||||
|
var logoMaterialMetadata interface{}
|
||||||
|
if userMaterialInfo.Metadata != nil && len(*userMaterialInfo.Metadata) != 0 {
|
||||||
|
_ = json.Unmarshal(*userMaterialInfo.Metadata, &logoMaterialMetadata)
|
||||||
|
}
|
||||||
//不是传路径则就是传base64
|
//不是传路径则就是传base64
|
||||||
if !strings.Contains(req.RenderImage, "https://") {
|
if !strings.Contains(req.RenderImage, "https://") {
|
||||||
//上传base64文件
|
//上传base64文件
|
||||||
@ -207,6 +222,7 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
|||||||
//快照数据
|
//快照数据
|
||||||
snapshot := gmodel.CartSnapshot{
|
snapshot := gmodel.CartSnapshot{
|
||||||
Logo: req.Logo,
|
Logo: req.Logo,
|
||||||
|
LogoMaterialMetadata: logoMaterialMetadata,
|
||||||
CombineImage: req.CombineImage,
|
CombineImage: req.CombineImage,
|
||||||
RenderImage: req.RenderImage,
|
RenderImage: req.RenderImage,
|
||||||
TemplateInfo: gmodel.TemplateInfo{
|
TemplateInfo: gmodel.TemplateInfo{
|
||||||
@ -268,7 +284,7 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error {
|
|||||||
return errors.New("product_id is required")
|
return errors.New("product_id is required")
|
||||||
}
|
}
|
||||||
if req.SizeId <= 0 {
|
if req.SizeId <= 0 {
|
||||||
return errors.New("product size is required")
|
return errors.New("product size id is required")
|
||||||
}
|
}
|
||||||
if req.PurchaseQuantity <= 0 {
|
if req.PurchaseQuantity <= 0 {
|
||||||
return errors.New("purchase quantity can not less than 0 or equal 0")
|
return errors.New("purchase quantity can not less than 0 or equal 0")
|
||||||
@ -280,6 +296,9 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error {
|
|||||||
if req.SelectColorIndex < 0 {
|
if req.SelectColorIndex < 0 {
|
||||||
return errors.New("invalid select color index")
|
return errors.New("invalid select color index")
|
||||||
}
|
}
|
||||||
|
if req.Logo == "" {
|
||||||
|
return errors.New("logo is required")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
server/shopping-cart/internal/logic/getcartnumlogic.go
Normal file
50
server/shopping-cart/internal/logic/getcartnumlogic.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/shopping-cart/internal/svc"
|
||||||
|
"fusenapi/server/shopping-cart/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetCartNumLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetCartNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCartNumLogic {
|
||||||
|
return &GetCartNumLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *GetCartNumLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *GetCartNumLogic) GetCartNum(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
if !userinfo.IsUser() {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in")
|
||||||
|
}
|
||||||
|
count, err := l.svcCtx.AllModels.FsShoppingCart.CountUserCart(l.ctx, userinfo.UserId)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get cart num")
|
||||||
|
}
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetCartNumRsp{
|
||||||
|
TotalCount: count,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *GetCartNumLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
@ -114,6 +114,10 @@ type CalculateResultItem struct {
|
|||||||
TotalPrice string `json:"total_price"` //总价
|
TotalPrice string `json:"total_price"` //总价
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetCartNumRsp struct {
|
||||||
|
TotalCount int64 `json:"total_count"`
|
||||||
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,14 +118,18 @@ func (l *DataTransferLogic) DataTransfer(req *types.DataTransferReq, w http.Resp
|
|||||||
case 2:
|
case 2:
|
||||||
token = strings.Trim(tokenSlice[0], " ")
|
token = strings.Trim(tokenSlice[0], " ")
|
||||||
debugToken = strings.Trim(tokenSlice[1], " ")
|
debugToken = strings.Trim(tokenSlice[1], " ")
|
||||||
r.Header.Set("Debug-Token", debugToken)
|
|
||||||
default:
|
default:
|
||||||
logx.Error("invalid ws token:", tokens)
|
logx.Error("invalid ws token:", tokens)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if token != "empty_token" && token != "" {
|
||||||
r.Header.Set("Authorization", "Bearer "+token)
|
r.Header.Set("Authorization", "Bearer "+token)
|
||||||
|
}
|
||||||
|
if debugToken != "empty_debug_token" && debugToken != "" {
|
||||||
|
r.Header.Set("Debug-Token", debugToken)
|
||||||
|
}
|
||||||
//设置Sec-Websocket-Protocol
|
//设置Sec-Websocket-Protocol
|
||||||
upgrader.Subprotocols = []string{tokens}
|
upgrader.Subprotocols = strings.Split(tokens, ",")
|
||||||
}
|
}
|
||||||
//判断下是否火狐浏览器(获取浏览器第一条消息返回有收不到的bug需要延迟1秒)
|
//判断下是否火狐浏览器(获取浏览器第一条消息返回有收不到的bug需要延迟1秒)
|
||||||
userAgent := r.Header.Get("User-Agent")
|
userAgent := r.Header.Get("User-Agent")
|
||||||
@ -178,7 +182,10 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
|
|||||||
uniqueId, err := l.getUniqueId(userInfo, userAgent, 10)
|
uniqueId, err := l.getUniqueId(userInfo, userAgent, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//发送获取唯一标识失败的消息
|
//发送获取唯一标识失败的消息
|
||||||
l.sendGetUniqueIdErrResponse(conn)
|
if isFirefoxBrowser {
|
||||||
|
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
||||||
|
}
|
||||||
|
l.sendGetUniqueIdErrResponse(conn, userInfo.Debug)
|
||||||
return wsConnectItem{}, err
|
return wsConnectItem{}, err
|
||||||
}
|
}
|
||||||
//传入绑定的wid判断是否可重用
|
//传入绑定的wid判断是否可重用
|
||||||
@ -239,6 +246,13 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
|
|||||||
},
|
},
|
||||||
debug: userInfo.Debug,
|
debug: userInfo.Debug,
|
||||||
}
|
}
|
||||||
|
//********强制开启debug 后面删掉
|
||||||
|
e := int64(1700359131)
|
||||||
|
ws.debug = &auth.Debug{
|
||||||
|
Exp: &e,
|
||||||
|
IsCache: 1,
|
||||||
|
IsAllTemplateTag: 0,
|
||||||
|
}
|
||||||
//保存连接
|
//保存连接
|
||||||
mapConnPool.Store(uniqueId, ws)
|
mapConnPool.Store(uniqueId, ws)
|
||||||
//非白板用户,需要为这个用户建立map索引便于通过用户查询
|
//非白板用户,需要为这个用户建立map索引便于通过用户查询
|
||||||
@ -246,17 +260,12 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
|
|||||||
if isFirefoxBrowser {
|
if isFirefoxBrowser {
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
||||||
}
|
}
|
||||||
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, websocket_data.ConnectSuccessMsg{Wid: uniqueId, Debug: ws.debug != nil}))
|
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, websocket_data.ConnectSuccessMsg{Wid: uniqueId}))
|
||||||
//发送累加统计连接数
|
//发送累加统计连接数
|
||||||
increaseWebsocketConnectCount()
|
increaseWebsocketConnectCount()
|
||||||
return ws, nil
|
return ws, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取websocket发送到前端使用的数据传输类型(debug开启是文本,否则是二进制)
|
|
||||||
func getWebsocketBaseTransferDataFormat() int {
|
|
||||||
return websocket.TextMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取唯一id
|
// 获取唯一id
|
||||||
func (l *DataTransferLogic) getUniqueId(userInfo *auth.UserInfo, userAgent string, retryTimes int) (uniqueId string, err error) {
|
func (l *DataTransferLogic) getUniqueId(userInfo *auth.UserInfo, userAgent string, retryTimes int) (uniqueId string, err error) {
|
||||||
if retryTimes < 0 {
|
if retryTimes < 0 {
|
||||||
@ -294,36 +303,6 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a
|
|||||||
return true, userInfo
|
return true, userInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// 鉴权失败通知
|
|
||||||
func (l *DataTransferLogic) unAuthResponse(conn *websocket.Conn, isFirefoxBrowser bool, errMessage string) {
|
|
||||||
rsp := websocket_data.DataTransferData{
|
|
||||||
T: constants.WEBSOCKET_UNAUTH,
|
|
||||||
D: websocket_data.ConnectUnAuth{Message: errMessage},
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(rsp)
|
|
||||||
if isFirefoxBrowser {
|
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
|
||||||
}
|
|
||||||
//先发一条正常信息
|
|
||||||
_ = conn.WriteMessage(getWebsocketBaseTransferDataFormat(), b)
|
|
||||||
//发送关闭信息
|
|
||||||
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取唯一标识失败通知
|
|
||||||
func (l *DataTransferLogic) sendGetUniqueIdErrResponse(conn *websocket.Conn) {
|
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
|
||||||
rsp := websocket_data.DataTransferData{
|
|
||||||
T: constants.WEBSOCKET_CONNECT_ERR,
|
|
||||||
D: websocket_data.ConnectErrMsg{Message: "err to gen unique id "},
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(rsp)
|
|
||||||
//先发一条正常信息
|
|
||||||
_ = conn.WriteMessage(getWebsocketBaseTransferDataFormat(), b)
|
|
||||||
//发送关闭信息
|
|
||||||
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 心跳检测
|
// 心跳检测
|
||||||
func (w *wsConnectItem) heartbeat() {
|
func (w *wsConnectItem) heartbeat() {
|
||||||
tick := time.Tick(time.Second * 5)
|
tick := time.Tick(time.Second * 5)
|
||||||
@ -467,6 +446,7 @@ func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data inte
|
|||||||
d := websocket_data.DataTransferData{
|
d := websocket_data.DataTransferData{
|
||||||
T: msgType,
|
T: msgType,
|
||||||
D: data,
|
D: data,
|
||||||
|
Debug: w.debug != nil,
|
||||||
}
|
}
|
||||||
b, _ := json.Marshal(d)
|
b, _ := json.Marshal(d)
|
||||||
return b
|
return b
|
||||||
|
@ -1,8 +1,46 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import "fusenapi/constants"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/websocket_data"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// 入口数据格式错误
|
// 获取唯一标识失败通知
|
||||||
|
func (l *DataTransferLogic) sendGetUniqueIdErrResponse(conn *websocket.Conn, debug *auth.Debug) {
|
||||||
|
rsp := websocket_data.DataTransferData{
|
||||||
|
T: constants.WEBSOCKET_CONNECT_ERR,
|
||||||
|
D: websocket_data.ConnectErrMsg{Message: "err to gen unique id "},
|
||||||
|
Debug: debug != nil,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(rsp)
|
||||||
|
//先发一条正常信息
|
||||||
|
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||||
|
//发送关闭信息
|
||||||
|
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 鉴权失败通知
|
||||||
|
func (l *DataTransferLogic) unAuthResponse(conn *websocket.Conn, isFirefoxBrowser bool, errMessage string) {
|
||||||
|
rsp := websocket_data.DataTransferData{
|
||||||
|
T: constants.WEBSOCKET_UNAUTH,
|
||||||
|
D: websocket_data.ConnectUnAuth{Message: errMessage},
|
||||||
|
Debug: false,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(rsp)
|
||||||
|
if isFirefoxBrowser {
|
||||||
|
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
||||||
|
}
|
||||||
|
//先发一条正常信息
|
||||||
|
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||||
|
//发送关闭信息
|
||||||
|
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用入口数据格式错误
|
||||||
func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
|
func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
|
||||||
if w.debug == nil {
|
if w.debug == nil {
|
||||||
return
|
return
|
||||||
|
63
server/websocket/internal/logic/ws_ok_response.go
Normal file
63
server/websocket/internal/logic/ws_ok_response.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/websocket_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
// *******************************合图相关begin******************************
|
||||||
|
// 发送合图完毕阶段通知消息
|
||||||
|
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
|
||||||
|
if w.debug == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
combineTakesTime := "cache"
|
||||||
|
uploadCombineImageTakesTime := "cache"
|
||||||
|
if debugData.DiffTimeLogoCombine > 0 {
|
||||||
|
combineTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeLogoCombine)
|
||||||
|
}
|
||||||
|
if debugData.DiffTimeUploadFile > 0 {
|
||||||
|
uploadCombineImageTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeUploadFile)
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
|
||||||
|
RenderId: renderId,
|
||||||
|
RequestId: requestId,
|
||||||
|
CombineImage: combineImage,
|
||||||
|
SizeId: sizeId,
|
||||||
|
ModelId: modelId,
|
||||||
|
TemplateId: templateId,
|
||||||
|
CombineProcessTime: websocket_data.CombineProcessTime{
|
||||||
|
CombineTakesTime: combineTakesTime,
|
||||||
|
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送组装unity需要的数据完毕消息
|
||||||
|
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
|
||||||
|
if w.debug == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送组装数据到unity完毕阶段通知消息
|
||||||
|
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
|
||||||
|
if w.debug == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送渲染最终结果数据到前端
|
||||||
|
func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) {
|
||||||
|
//没开启debug
|
||||||
|
if w.debug == nil {
|
||||||
|
data.RenderProcessTime = websocket_data.RenderProcessTime{}
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// *******************************合图相关end******************************
|
@ -6,11 +6,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/service/repositories"
|
"fusenapi/service/repositories"
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/curl"
|
"fusenapi/utils/curl"
|
||||||
"fusenapi/utils/hash"
|
"fusenapi/utils/hash"
|
||||||
"fusenapi/utils/websocket_data"
|
"fusenapi/utils/websocket_data"
|
||||||
@ -146,7 +143,7 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||||||
|
|
||||||
// 执行渲染任务
|
// 执行渲染任务
|
||||||
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
|
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
|
||||||
if !strings.Contains(renderImageData.RenderData.Logo, "storage.fusenpack.com") {
|
if !strings.Contains(renderImageData.RenderData.Logo, "fusen") {
|
||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "非法的logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "非法的logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -465,52 +462,3 @@ func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData web
|
|||||||
}
|
}
|
||||||
return hash.JsonHashKey(hashMap)
|
return hash.JsonHashKey(hashMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****************************下面的发送消息的*********************************
|
|
||||||
// 发送合图完毕阶段通知消息
|
|
||||||
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
|
|
||||||
if w.debug == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
combineTakesTime := "cache"
|
|
||||||
uploadCombineImageTakesTime := "cache"
|
|
||||||
if debugData.DiffTimeLogoCombine > 0 {
|
|
||||||
combineTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeLogoCombine)
|
|
||||||
}
|
|
||||||
if debugData.DiffTimeUploadFile > 0 {
|
|
||||||
uploadCombineImageTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeUploadFile)
|
|
||||||
}
|
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
|
|
||||||
RenderId: renderId,
|
|
||||||
RequestId: requestId,
|
|
||||||
CombineImage: combineImage,
|
|
||||||
SizeId: sizeId,
|
|
||||||
ModelId: modelId,
|
|
||||||
TemplateId: templateId,
|
|
||||||
CombineProcessTime: websocket_data.CombineProcessTime{
|
|
||||||
CombineTakesTime: combineTakesTime,
|
|
||||||
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送组装unity需要的数据完毕消息
|
|
||||||
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
|
|
||||||
if w.debug == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送组装数据到unity完毕阶段通知消息
|
|
||||||
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
|
|
||||||
if w.debug == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送渲染最终结果数据到前端
|
|
||||||
func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) {
|
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data))
|
|
||||||
}
|
|
||||||
|
@ -16,9 +16,6 @@ service product {
|
|||||||
//获取产品模型信息
|
//获取产品模型信息
|
||||||
@handler GetModelByPidHandler
|
@handler GetModelByPidHandler
|
||||||
get /api/product/get_model_by_pid(GetModelByPidReq) returns (response);
|
get /api/product/get_model_by_pid(GetModelByPidReq) returns (response);
|
||||||
//获取产品阶梯价格列表(即将废弃)
|
|
||||||
@handler GetPriceByPidHandler
|
|
||||||
get /api/product/get_price_by_pid(GetPriceByPidReq) returns (response);
|
|
||||||
//获取产品阶梯价格信息
|
//获取产品阶梯价格信息
|
||||||
@handler GetProductStepPriceHandler
|
@handler GetProductStepPriceHandler
|
||||||
get /api/product/get_product_step_price(GetProductStepPriceReq) returns (response);
|
get /api/product/get_product_step_price(GetProductStepPriceReq) returns (response);
|
||||||
@ -53,9 +50,8 @@ service product {
|
|||||||
|
|
||||||
//获取详情页推荐产品列表
|
//获取详情页推荐产品列表
|
||||||
type GetRecommandProductListReq {
|
type GetRecommandProductListReq {
|
||||||
Size int32 `form:"size,optional"`
|
|
||||||
Num int64 `form:"num,optional"`
|
Num int64 `form:"num,optional"`
|
||||||
Sn string `form:"sn"`
|
ProductId int64 `form:"product_id"`
|
||||||
}
|
}
|
||||||
type GetRecommandProductListRsp {
|
type GetRecommandProductListRsp {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
@ -71,6 +67,8 @@ type GetRecommandProductListRsp {
|
|||||||
Recommend bool `json:"recommend"`
|
Recommend bool `json:"recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
IsCustomization int64 `json:"is_customization"`
|
IsCustomization int64 `json:"is_customization"`
|
||||||
|
SizeCount int64 `json:"size_count"`
|
||||||
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
}
|
}
|
||||||
//获取分类产品列表
|
//获取分类产品列表
|
||||||
type GetTagProductListReq {
|
type GetTagProductListReq {
|
||||||
@ -115,26 +113,6 @@ type CoverDefaultItem {
|
|||||||
type GetModelByPidReq {
|
type GetModelByPidReq {
|
||||||
Pid string `form:"pid"` //实际上是产品sn
|
Pid string `form:"pid"` //实际上是产品sn
|
||||||
}
|
}
|
||||||
//获取产品阶梯价格
|
|
||||||
type GetPriceByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
type GetPriceByPidRsp {
|
|
||||||
Items []PriceItem `json:"items"`
|
|
||||||
MinPrice float64 `json:"min_price"`
|
|
||||||
MaxPrice float64 `json:"max_price"`
|
|
||||||
StepRange []StepRange `json:"step_range"`
|
|
||||||
}
|
|
||||||
type StepRange {
|
|
||||||
Begin int64 `json:"begin"`
|
|
||||||
End int64 `json:"end"`
|
|
||||||
Price float64 `json:"price"`
|
|
||||||
}
|
|
||||||
type PriceItem {
|
|
||||||
Num int64 `json:"num"`
|
|
||||||
TotalNum int64 `json:"total_num"`
|
|
||||||
Price int64 `json:"price"`
|
|
||||||
}
|
|
||||||
//获取产品阶梯价格信息
|
//获取产品阶梯价格信息
|
||||||
type GetProductStepPriceReq {
|
type GetProductStepPriceReq {
|
||||||
ProductId int64 `form:"product_id"`
|
ProductId int64 `form:"product_id"`
|
||||||
@ -230,7 +208,7 @@ type HomePageRecommendProductListRsp {
|
|||||||
type GetProductDetailReq {
|
type GetProductDetailReq {
|
||||||
ProductId int64 `form:"product_id"` //产品id
|
ProductId int64 `form:"product_id"` //产品id
|
||||||
TemplateTag string `form:"template_tag"` //模板标签
|
TemplateTag string `form:"template_tag"` //模板标签
|
||||||
SelectColorIndex int `form:"select_color_index"` //模板标签颜色索引
|
SelectedColorIndex int `form:"selected_color_index"` //模板标签颜色索引
|
||||||
Logo string `form:"logo"` //logo地址
|
Logo string `form:"logo"` //logo地址
|
||||||
}
|
}
|
||||||
type GetProductDetailRsp {
|
type GetProductDetailRsp {
|
||||||
|
@ -21,6 +21,9 @@ service shopping-cart {
|
|||||||
//计算购物车价格
|
//计算购物车价格
|
||||||
@handler CalculateCartPriceHandler
|
@handler CalculateCartPriceHandler
|
||||||
post /api/shopping-cart/calculate_cart_price(CalculateCartPriceReq) returns (response);
|
post /api/shopping-cart/calculate_cart_price(CalculateCartPriceReq) returns (response);
|
||||||
|
//获取购物车数量
|
||||||
|
@handler GetCartNumHandler
|
||||||
|
get /api/shopping-cart/get_cart_num(request) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//加入购物车
|
//加入购物车
|
||||||
@ -123,3 +126,7 @@ type CalculateResultItem {
|
|||||||
ItemPrice string `json:"item_price"` //单价
|
ItemPrice string `json:"item_price"` //单价
|
||||||
TotalPrice string `json:"total_price"` //总价
|
TotalPrice string `json:"total_price"` //总价
|
||||||
}
|
}
|
||||||
|
//获取购物车数量
|
||||||
|
type GetCartNumRsp {
|
||||||
|
TotalCount int64 `json:"total_count"`
|
||||||
|
}
|
@ -93,6 +93,8 @@ func (l *defaultImageHandle) LogoInfoSet(ctx context.Context, in *LogoInfoSetReq
|
|||||||
|
|
||||||
if in.Debug != nil && in.Debug.IsAllTemplateTag == 1 {
|
if in.Debug != nil && in.Debug.IsAllTemplateTag == 1 {
|
||||||
postMap["is_all_template"] = "1"
|
postMap["is_all_template"] = "1"
|
||||||
|
} else {
|
||||||
|
postMap["is_all_template"] = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
logc.Infof(ctx, "算法请求--LOGO基础信息--开始时间:%v", time.Now().UTC())
|
logc.Infof(ctx, "算法请求--LOGO基础信息--开始时间:%v", time.Now().UTC())
|
||||||
|
@ -4,7 +4,7 @@ import "strings"
|
|||||||
|
|
||||||
// 通过url解析资源id
|
// 通过url解析资源id
|
||||||
func GetS3ResourceIdFormUrl(s3Url string) string {
|
func GetS3ResourceIdFormUrl(s3Url string) string {
|
||||||
if !strings.Contains(s3Url, "storage.fusenpack.com") {
|
if !strings.Contains(s3Url, "fusen") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
s := strings.Split(s3Url, "/")
|
s := strings.Split(s3Url, "/")
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
package websocket_data
|
package websocket_data
|
||||||
|
|
||||||
|
import "fusenapi/constants"
|
||||||
|
|
||||||
|
// websocket数据交互基本数据类型
|
||||||
|
type DataTransferData struct {
|
||||||
|
T constants.Websocket `json:"t"` //消息类型
|
||||||
|
D interface{} `json:"d"` //传递的消息
|
||||||
|
Debug bool `json:"debug"` //是否开启debug
|
||||||
|
}
|
||||||
|
|
||||||
// 基础连接成功返回
|
// 基础连接成功返回
|
||||||
type ConnectSuccessMsg struct {
|
type ConnectSuccessMsg struct {
|
||||||
Wid string `json:"wid"` //websocket连接唯一标识
|
Wid string `json:"wid"` //websocket连接唯一标识
|
||||||
Debug bool `json:"debug"` //是否开启debug
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 连接失败
|
// 连接失败
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package websocket_data
|
package websocket_data
|
||||||
|
|
||||||
import "fusenapi/constants"
|
|
||||||
|
|
||||||
// websocket数据交互基本数据类型
|
|
||||||
type DataTransferData struct {
|
|
||||||
T constants.Websocket `json:"t"` //消息类型
|
|
||||||
D interface{} `json:"d"` //传递的消息
|
|
||||||
}
|
|
||||||
|
|
||||||
// websocket接受要云渲染处理的数据
|
// websocket接受要云渲染处理的数据
|
||||||
type RenderImageReqMsg struct {
|
type RenderImageReqMsg struct {
|
||||||
RenderId string `json:"render_id"` //渲染id
|
RenderId string `json:"render_id"` //渲染id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user