删除产品服务无用的接口
This commit is contained in:
parent
0c3e93bba6
commit
55f1be350b
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetFittingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetFittingByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetFittingByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetFittingByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetLightByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetLightByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetLightByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetLightByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetModelByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetModelByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetModelByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetModelByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetRenderSettingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetRenderSettingByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetRenderSettingByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetRenderSettingByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetSizeByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetSizeByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetSizeByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetSizeByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/logic"
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetTemplateByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
|
|
||||||
var req types.GetTemplateByPidReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewGetTemplateByPidLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.GetTemplateByPid(&req, userinfo)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,11 +17,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/api/product/tag_product_list",
|
Path: "/api/product/tag_product_list",
|
||||||
Handler: GetTagProductListHandler(serverCtx),
|
Handler: GetTagProductListHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_model_by_pid",
|
|
||||||
Handler: GetModelByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/api/product/get_product_step_price",
|
Path: "/api/product/get_product_step_price",
|
||||||
|
@ -32,31 +27,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/api/product/calculate_product_price",
|
Path: "/api/product/calculate_product_price",
|
||||||
Handler: CalculateProductPriceHandler(serverCtx),
|
Handler: CalculateProductPriceHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_size_by_pid",
|
|
||||||
Handler: GetSizeByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_template_by_pid",
|
|
||||||
Handler: GetTemplateByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_fitting_by_pid",
|
|
||||||
Handler: GetFittingByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_light_by_pid",
|
|
||||||
Handler: GetLightByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Method: http.MethodGet,
|
|
||||||
Path: "/api/product/get_render_setting_by_pid",
|
|
||||||
Handler: GetRenderSettingByPidHandler(serverCtx),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/api/product/recommend",
|
Path: "/api/product/recommend",
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"fusenapi/utils/format"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetFittingByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetFittingByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFittingByPidLogic {
|
|
||||||
return &GetFittingByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, 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")
|
|
||||||
}
|
|
||||||
//获取尺寸列表(只获取id)
|
|
||||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "", "id")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
|
||||||
}
|
|
||||||
if len(sizeList) == 0 {
|
|
||||||
return resp.SetStatusAddMessage(basic.CodeOK, "success:size list is empty")
|
|
||||||
}
|
|
||||||
sizeIds := make([]int64, 0, len(sizeList))
|
|
||||||
for _, v := range sizeList {
|
|
||||||
sizeIds = append(sizeIds, v.Id)
|
|
||||||
}
|
|
||||||
//获取配件id
|
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "part_id")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
|
||||||
}
|
|
||||||
if len(modelList) == 0 {
|
|
||||||
return resp.SetStatusAddMessage(basic.CodeOK, "success:model list is empty")
|
|
||||||
}
|
|
||||||
partIds := make([]int64, 0, len(modelList))
|
|
||||||
for _, v := range modelList {
|
|
||||||
if v.PartId == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
partIds = append(partIds, *v.PartId)
|
|
||||||
}
|
|
||||||
//获取配件数据
|
|
||||||
fittingList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "is_hot DESC,price ASC")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get part list")
|
|
||||||
}
|
|
||||||
if len(fittingList) == 0 {
|
|
||||||
return resp.SetStatusAddMessage(basic.CodeOK, "success:fitting list is empty")
|
|
||||||
}
|
|
||||||
//处理组装数据返回
|
|
||||||
listRsp := make([]types.GetFittingByPidRsp, 0, len(fittingList))
|
|
||||||
for _, fitting := range fittingList {
|
|
||||||
materialImg := ""
|
|
||||||
var tInfo *gmodel.FsProductTemplateV2
|
|
||||||
//贴图,如果绑定了公共模板,则获取公共模板的贴图数据
|
|
||||||
if *fitting.OptionTemplate > 0 {
|
|
||||||
tInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.FindOne(l.ctx, *fitting.OptionTemplate)
|
|
||||||
} else { //否则取该配件下的模板贴图
|
|
||||||
tInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.FindOneByModelId(l.ctx, fitting.Id)
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
materialImg = *tInfo.MaterialImg
|
|
||||||
} else {
|
|
||||||
logx.Error(err)
|
|
||||||
}
|
|
||||||
var modelInfo interface{}
|
|
||||||
if fitting.ModelInfo != nil && *fitting.ModelInfo != "" {
|
|
||||||
if err = json.Unmarshal([]byte(*fitting.ModelInfo), &modelInfo); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model json info")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listRsp = append(listRsp, types.GetFittingByPidRsp{
|
|
||||||
Id: fitting.Id,
|
|
||||||
MaterialImg: materialImg,
|
|
||||||
Title: *fitting.Title,
|
|
||||||
Price: format.CentitoDollar(*fitting.Price, 3),
|
|
||||||
ModelInfo: modelInfo,
|
|
||||||
IsPopular: *fitting.IsHot > 0,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetLightByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetLightByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLightByPidLogic {
|
|
||||||
return &GetLightByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetLightByPidLogic) GetLightByPid(req *types.GetLightByPidReq, 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")
|
|
||||||
}
|
|
||||||
//获取尺寸ids
|
|
||||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
|
||||||
}
|
|
||||||
if len(sizeList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:size list is empty")
|
|
||||||
}
|
|
||||||
sizeIds := make([]int64, 0, len(sizeList))
|
|
||||||
for _, v := range sizeList {
|
|
||||||
sizeIds = append(sizeIds, v.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 model list")
|
|
||||||
}
|
|
||||||
if len(modelList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:model list is empty")
|
|
||||||
}
|
|
||||||
lightIds := make([]int64, 0, len(modelList))
|
|
||||||
for _, v := range modelList {
|
|
||||||
lightIds = append(lightIds, *v.Light)
|
|
||||||
}
|
|
||||||
//获取光源数据
|
|
||||||
lightList, err := l.svcCtx.AllModels.FsProductModel3dLight.GetAllByIds(l.ctx, lightIds)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get light list")
|
|
||||||
}
|
|
||||||
//组装数据
|
|
||||||
listRsp := make([]interface{}, 0, len(lightList))
|
|
||||||
for _, v := range lightList {
|
|
||||||
var lightInfo map[string]interface{}
|
|
||||||
if v.Info == nil || *v.Info == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err = json.Unmarshal([]byte(*v.Info), &lightInfo); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light info")
|
|
||||||
}
|
|
||||||
lightInfo["id"] = v.Id
|
|
||||||
listRsp = append(listRsp, lightInfo)
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetModelByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetModelByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetModelByPidLogic {
|
|
||||||
return &GetModelByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetModelByPidLogic) GetModelByPid(req *types.GetModelByPidReq, 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")
|
|
||||||
}
|
|
||||||
//获取产品尺寸列表(只是获取id)
|
|
||||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "id")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
|
||||||
}
|
|
||||||
if len(sizeList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:size list is empty", []interface{}{})
|
|
||||||
}
|
|
||||||
sizeIds := make([]int64, 0, len(sizeList))
|
|
||||||
for _, v := range sizeList {
|
|
||||||
sizeIds = append(sizeIds, v.Id)
|
|
||||||
}
|
|
||||||
//获取模型数据(只是获取model_info)
|
|
||||||
model3dList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id,model_info")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
|
||||||
}
|
|
||||||
if len(model3dList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:model list is empty", []interface{}{})
|
|
||||||
}
|
|
||||||
//处理数据
|
|
||||||
mapModel := make(map[int64]interface{})
|
|
||||||
for _, v := range model3dList {
|
|
||||||
if v.ModelInfo == nil || *v.ModelInfo == "" {
|
|
||||||
mapModel[v.Id] = nil
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var info interface{}
|
|
||||||
if err = json.Unmarshal([]byte(*v.ModelInfo), &info); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info json")
|
|
||||||
}
|
|
||||||
mapModel[v.Id] = info
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", mapModel)
|
|
||||||
}
|
|
|
@ -1,153 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"fusenapi/utils/color_list"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetRenderSettingByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetRenderSettingByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRenderSettingByPidLogic {
|
|
||||||
return &GetRenderSettingByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetRenderSettingByPidLogic) GetRenderSettingByPid(req *types.GetRenderSettingByPidReq, 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")
|
|
||||||
}
|
|
||||||
//获取产品信息
|
|
||||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid)
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
//获取产品分类
|
|
||||||
tagInfo, err := l.svcCtx.AllModels.FsTags.FindOne(l.ctx, *productInfo.Type)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product tag is not exists")
|
|
||||||
}
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info")
|
|
||||||
}
|
|
||||||
//是否低效果渲染
|
|
||||||
isLowRendering := false
|
|
||||||
//是否移除背景
|
|
||||||
isRemoveBg := false
|
|
||||||
//是否存在最新设计
|
|
||||||
lastDesign := false
|
|
||||||
//是否拥有云渲染设计方案
|
|
||||||
renderDesign := false
|
|
||||||
renderDesign, err = l.checkRenderDesign(req.ClientNo)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to checkRenderDesign")
|
|
||||||
}
|
|
||||||
if userinfo.UserId != 0 {
|
|
||||||
user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return resp.SetStatusAddMessage(basic.CodeDbRecordNotFoundErr, "user info is not exists")
|
|
||||||
}
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user info")
|
|
||||||
}
|
|
||||||
isLowRendering = true
|
|
||||||
isRemoveBg = true
|
|
||||||
lastDesign, err = l.checkLastDesignExists(user.Id)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to check if exists last design ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetRenderSettingByPidRsp{
|
|
||||||
Id: productInfo.Id,
|
|
||||||
Type: *productInfo.Type,
|
|
||||||
Title: *productInfo.Title,
|
|
||||||
IsEnv: *productInfo.IsProtection,
|
|
||||||
IsMicro: *productInfo.IsMicrowave,
|
|
||||||
TypeName: *tagInfo.Title,
|
|
||||||
IsLowRendering: isLowRendering,
|
|
||||||
IsCustomization: *productInfo.IsCustomization,
|
|
||||||
IsRemoveBg: isRemoveBg,
|
|
||||||
RenderDesign: renderDesign,
|
|
||||||
LastDesign: lastDesign,
|
|
||||||
Colors: color_list.GetColor(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询是否存在渲染设计
|
|
||||||
func (l *GetRenderSettingByPidLogic) checkRenderDesign(clientNo string) (bool, error) {
|
|
||||||
if clientNo == "" {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
renderDesign, err := l.svcCtx.AllModels.FsProductRenderDesign.FindOneRenderDesignByParams(l.ctx, gmodel.FindOneRenderDesignByParamsReq{
|
|
||||||
ClientNo: &clientNo,
|
|
||||||
Fields: "id,info,material_id,optional_id,size_id,template_id",
|
|
||||||
OrderBy: "`id` DESC",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if renderDesign.Info != nil && *renderDesign.Info != "" {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询是否存在最新设计
|
|
||||||
func (l *GetRenderSettingByPidLogic) checkLastDesignExists(userId int64) (bool, error) {
|
|
||||||
//查询用户最近下单成功的数据
|
|
||||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
|
||||||
// if err != nil {
|
|
||||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
// return false, nil
|
|
||||||
// }
|
|
||||||
// return false, err
|
|
||||||
// }
|
|
||||||
//获取该订单相关设计信息
|
|
||||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
|
||||||
// if err != nil {
|
|
||||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
// return false, nil
|
|
||||||
// }
|
|
||||||
// return false, err
|
|
||||||
// }
|
|
||||||
// //获取设计模板详情,便于获得design_id
|
|
||||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
|
||||||
// if err != nil {
|
|
||||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
// return false, nil
|
|
||||||
// }
|
|
||||||
// return false, err
|
|
||||||
// }
|
|
||||||
return false, nil
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"fusenapi/utils/format"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetSizeByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetSizeByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSizeByPidLogic {
|
|
||||||
return &GetSizeByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, 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")
|
|
||||||
}
|
|
||||||
if req.TemplateTag == "" {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag 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")
|
|
||||||
}
|
|
||||||
//获取跟列表页云渲染一样的默认渲染尺寸(模板->尺寸)
|
|
||||||
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 {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "the template`s model is not exists ")
|
|
||||||
}
|
|
||||||
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 {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
|
||||||
}
|
|
||||||
sizeIds := make([]int64, 0, len(sizeList))
|
|
||||||
for _, v := range sizeList {
|
|
||||||
sizeIds = append(sizeIds, v.Id)
|
|
||||||
}
|
|
||||||
//获取产品价格列表
|
|
||||||
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")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
|
||||||
}
|
|
||||||
if err = l.svcCtx.AllModels.FsProductModel3d.GetProductMinPrice(modelList, mapProductMinPrice); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product min price")
|
|
||||||
}
|
|
||||||
mapSizeModel := make(map[int64]int) //size id为key
|
|
||||||
for k, v := range modelList {
|
|
||||||
if *v.Tag != constants.TAG_MODEL {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
mapSizeModel[*v.SizeId] = k
|
|
||||||
}
|
|
||||||
//处理
|
|
||||||
listRsp := make([]types.GetSizeByPidRsp, 0, len(sizeList))
|
|
||||||
for _, sizeInfo := range sizeList {
|
|
||||||
//没有模型的不能使用
|
|
||||||
modelIndex, ok := mapSizeModel[sizeInfo.Id]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var title interface{}
|
|
||||||
_ = json.Unmarshal([]byte(*sizeInfo.Title), &title)
|
|
||||||
minPrice := int64(0)
|
|
||||||
if price, ok := mapProductMinPrice[*sizeInfo.ProductId]; ok {
|
|
||||||
minPrice = price
|
|
||||||
}
|
|
||||||
listRsp = append(listRsp, types.GetSizeByPidRsp{
|
|
||||||
Id: sizeInfo.Id,
|
|
||||||
Title: title,
|
|
||||||
Capacity: *sizeInfo.Capacity,
|
|
||||||
Cover: *sizeInfo.Cover,
|
|
||||||
PartsCanDeleted: *sizeInfo.PartsCanDeleted > 0,
|
|
||||||
ModelId: modelList[modelIndex].Id,
|
|
||||||
IsPopular: *sizeInfo.IsHot > 0,
|
|
||||||
MinPrice: format.CentitoDollar(minPrice, 3),
|
|
||||||
IsDefault: defaultSizeId == sizeInfo.Id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
|
||||||
}
|
|
|
@ -1,110 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"fusenapi/utils/template_switch_info"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
|
||||||
"fusenapi/server/product/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetTemplateByPidLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGetTemplateByPidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTemplateByPidLogic {
|
|
||||||
return &GetTemplateByPidLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, 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")
|
|
||||||
}
|
|
||||||
if req.TemplateTag == "" {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag")
|
|
||||||
}
|
|
||||||
//获取产品信息(只获取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")
|
|
||||||
}
|
|
||||||
//没有指定物料
|
|
||||||
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 model list")
|
|
||||||
}
|
|
||||||
if len(modelList) == 0 {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "model list is empty")
|
|
||||||
}
|
|
||||||
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, req.TemplateTag, "")
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
|
||||||
}
|
|
||||||
rsp := make(map[string]interface{})
|
|
||||||
for _, templateInfo := range templateList {
|
|
||||||
//没有设置模板据不要
|
|
||||||
modelIndex, ok := mapModel[*templateInfo.ModelId]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//基础模板信息
|
|
||||||
var info 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))
|
|
||||||
}
|
|
||||||
modelInfo := modelList[modelIndex]
|
|
||||||
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
|
|
||||||
rsp[mapKey] = template_switch_info.GetTemplateSwitchInfo(templateInfo.Id, templateInfo.TemplateInfo, *templateInfo.MaterialImg)
|
|
||||||
}
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
|
|
||||||
}
|
|
|
@ -70,10 +70,6 @@ type CoverDefaultItem struct {
|
||||||
CoverMetadata interface{} `json:"cover_metadata"`
|
CoverMetadata interface{} `json:"cover_metadata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetModelByPidReq struct {
|
|
||||||
Pid string `form:"pid"` //实际上是产品sn
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetProductStepPriceReq struct {
|
type GetProductStepPriceReq struct {
|
||||||
ProductId int64 `form:"product_id"`
|
ProductId int64 `form:"product_id"`
|
||||||
}
|
}
|
||||||
|
@ -91,66 +87,6 @@ type CalculateProductPriceRsp struct {
|
||||||
StepRange interface{} `json:"step_range"`
|
StepRange interface{} `json:"step_range"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetSizeByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
TemplateTag string `form:"template_tag"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetSizeByPidRsp struct {
|
|
||||||
Id int64 `json:"id"` //尺寸id
|
|
||||||
Title interface{} `json:"title"`
|
|
||||||
Capacity string `json:"capacity"` //容量、尺寸、尺码描述
|
|
||||||
Cover string `json:"cover"` //缩略图
|
|
||||||
PartsCanDeleted bool `json:"parts_can_deleted"` //用户可否删除配件
|
|
||||||
ModelId int64 `json:"model_id"` //产品主模型id
|
|
||||||
IsPopular bool `json:"is_popular"` //是否受欢迎
|
|
||||||
MinPrice string `json:"min_price"` //最小价格
|
|
||||||
IsDefault bool `json:"is_default"` //是否默认(这里的默认是跟列表页一致)
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetTemplateByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
|
||||||
TemplateTag string `form:"template_tag"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetFittingByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetFittingByPidRsp struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
MaterialImg string `json:"material_img"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Price string `json:"price"`
|
|
||||||
IsPopular bool `json:"is_popular"`
|
|
||||||
ModelInfo interface{} `json:"model_info"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetLightByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRenderSettingByPidReq struct {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
ClientNo string `form:"client_no,optional"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRenderSettingByPidRsp struct {
|
|
||||||
Id int64 `json:"id"` //产品id
|
|
||||||
Type int64 `json:"type"` //产品typeid
|
|
||||||
Title string `json:"title"` //产品名称
|
|
||||||
IsEnv int64 `json:"isEnv"` //产品标签之一
|
|
||||||
IsMicro int64 `json:"isMicro"` //产品标签之一
|
|
||||||
TypeName string `json:"typeName"` //产品类型名称
|
|
||||||
IsLowRendering bool `json:"is_low_rendering"` //低质量画质渲染开关
|
|
||||||
IsCustomization int64 `json:"is_customization"` //产品是否可定制
|
|
||||||
IsRemoveBg bool `json:"is_remove_bg"` //logo上传是否去背景
|
|
||||||
RenderDesign bool `json:"render_design"` //是否拥有云渲染设计方案
|
|
||||||
LastDesign bool `json:"last_design"` //是否拥有千人千面设计方案
|
|
||||||
Colors interface{} `json:"colors"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HomePageRecommendProductListReq struct {
|
type HomePageRecommendProductListReq struct {
|
||||||
MerchantType int64 `form:"merchant_type"`
|
MerchantType int64 `form:"merchant_type"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,37 +13,19 @@ service product {
|
||||||
//获取分类产品列表
|
//获取分类产品列表
|
||||||
@handler GetTagProductListHandler
|
@handler GetTagProductListHandler
|
||||||
get /api/product/tag_product_list(GetTagProductListReq) returns (response);
|
get /api/product/tag_product_list(GetTagProductListReq) returns (response);
|
||||||
//获取产品模型信息(即将废弃)
|
|
||||||
@handler GetModelByPidHandler
|
|
||||||
get /api/product/get_model_by_pid(GetModelByPidReq) 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);
|
||||||
//根据产品+配件搭配计算价格
|
//根据产品+配件搭配计算价格
|
||||||
@handler CalculateProductPriceHandler
|
@handler CalculateProductPriceHandler
|
||||||
post /api/product/calculate_product_price(CalculateProductPriceReq) returns (response);
|
post /api/product/calculate_product_price(CalculateProductPriceReq) returns (response);
|
||||||
//获取产品尺寸列表(即将废弃)
|
|
||||||
@handler GetSizeByPidHandler
|
|
||||||
get /api/product/get_size_by_pid(GetSizeByPidReq) returns (response);
|
|
||||||
//获取产品模板(即将废弃)
|
|
||||||
@handler GetTemplateByPidHandler
|
|
||||||
get /api/product/get_template_by_pid(GetTemplateByPidReq) returns (response);
|
|
||||||
//获取产品配件数据(即将废弃)
|
|
||||||
@handler GetFittingByPidHandler
|
|
||||||
get /api/product/get_fitting_by_pid(GetFittingByPidReq) returns (response);
|
|
||||||
//获取产品灯光数据(即将废弃)
|
|
||||||
@handler GetLightByPidHandler
|
|
||||||
get /api/product/get_light_by_pid(GetLightByPidReq) returns (response);
|
|
||||||
//获取产品渲染设置(即将废弃)
|
|
||||||
@handler GetRenderSettingByPidHandler
|
|
||||||
get /api/product/get_render_setting_by_pid(GetRenderSettingByPidReq) returns (response);
|
|
||||||
//获取详情页推荐产品列表
|
//获取详情页推荐产品列表
|
||||||
@handler GetRecommendProductListHandler
|
@handler GetRecommendProductListHandler
|
||||||
get /api/product/recommend(GetRecommendProductListReq) returns (response);
|
get /api/product/recommend(GetRecommendProductListReq) returns (response);
|
||||||
//获取列表页推荐产品列表
|
//获取列表页推荐产品列表
|
||||||
@handler HomePageRecommendProductListHandler
|
@handler HomePageRecommendProductListHandler
|
||||||
get /api/product/home_page_recommend(HomePageRecommendProductListReq) returns (response);
|
get /api/product/home_page_recommend(HomePageRecommendProductListReq) returns (response);
|
||||||
//获取产品详情(重构版)
|
//获取产品详情
|
||||||
@handler GetProductDetailHandler
|
@handler GetProductDetailHandler
|
||||||
get /api/product/get_product_detail(GetProductDetailReq) returns (response);
|
get /api/product/get_product_detail(GetProductDetailReq) returns (response);
|
||||||
}
|
}
|
||||||
|
@ -109,10 +91,6 @@ type CoverDefaultItem {
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
CoverMetadata interface{} `json:"cover_metadata"`
|
CoverMetadata interface{} `json:"cover_metadata"`
|
||||||
}
|
}
|
||||||
//获取产品模型信息
|
|
||||||
type GetModelByPidReq {
|
|
||||||
Pid string `form:"pid"` //实际上是产品sn
|
|
||||||
}
|
|
||||||
//获取产品阶梯价格信息
|
//获取产品阶梯价格信息
|
||||||
type GetProductStepPriceReq {
|
type GetProductStepPriceReq {
|
||||||
ProductId int64 `form:"product_id"`
|
ProductId int64 `form:"product_id"`
|
||||||
|
@ -129,63 +107,7 @@ type CalculateProductPriceRsp {
|
||||||
TotalPrice string `json:"total_price"`
|
TotalPrice string `json:"total_price"`
|
||||||
StepRange interface{} `json:"step_range"`
|
StepRange interface{} `json:"step_range"`
|
||||||
}
|
}
|
||||||
//获取产品尺寸列表
|
|
||||||
type GetSizeByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
TemplateTag string `form:"template_tag"`
|
|
||||||
}
|
|
||||||
type GetSizeByPidRsp {
|
|
||||||
Id int64 `json:"id"` //尺寸id
|
|
||||||
Title interface{} `json:"title"`
|
|
||||||
Capacity string `json:"capacity"` //容量、尺寸、尺码描述
|
|
||||||
Cover string `json:"cover"` //缩略图
|
|
||||||
PartsCanDeleted bool `json:"parts_can_deleted"` //用户可否删除配件
|
|
||||||
ModelId int64 `json:"model_id"` //产品主模型id
|
|
||||||
IsPopular bool `json:"is_popular"` //是否受欢迎
|
|
||||||
MinPrice string `json:"min_price"` //最小价格
|
|
||||||
IsDefault bool `json:"is_default"` //是否默认(这里的默认是跟列表页一致)
|
|
||||||
}
|
|
||||||
//获取产品模板
|
|
||||||
type GetTemplateByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
|
||||||
TemplateTag string `form:"template_tag"`
|
|
||||||
}
|
|
||||||
//获取产品配件数据
|
|
||||||
type GetFittingByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
type GetFittingByPidRsp {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
MaterialImg string `json:"material_img"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Price string `json:"price"`
|
|
||||||
IsPopular bool `json:"is_popular"`
|
|
||||||
ModelInfo interface{} `json:"model_info"`
|
|
||||||
}
|
|
||||||
//获取产品灯光数据
|
|
||||||
type GetLightByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
}
|
|
||||||
//获取产品渲染设置
|
|
||||||
type GetRenderSettingByPidReq {
|
|
||||||
Pid string `form:"pid"`
|
|
||||||
ClientNo string `form:"client_no,optional"`
|
|
||||||
}
|
|
||||||
type GetRenderSettingByPidRsp {
|
|
||||||
Id int64 `json:"id"` //产品id
|
|
||||||
Type int64 `json:"type"` //产品typeid
|
|
||||||
Title string `json:"title"` //产品名称
|
|
||||||
IsEnv int64 `json:"isEnv"` //产品标签之一
|
|
||||||
IsMicro int64 `json:"isMicro"` //产品标签之一
|
|
||||||
TypeName string `json:"typeName"` //产品类型名称
|
|
||||||
IsLowRendering bool `json:"is_low_rendering"` //低质量画质渲染开关
|
|
||||||
IsCustomization int64 `json:"is_customization"` //产品是否可定制
|
|
||||||
IsRemoveBg bool `json:"is_remove_bg"` //logo上传是否去背景
|
|
||||||
RenderDesign bool `json:"render_design"` //是否拥有云渲染设计方案
|
|
||||||
LastDesign bool `json:"last_design"` //是否拥有千人千面设计方案
|
|
||||||
Colors interface{} `json:"colors"`
|
|
||||||
}
|
|
||||||
//获取列表页推荐产品(返回是这个维度数组)
|
//获取列表页推荐产品(返回是这个维度数组)
|
||||||
type HomePageRecommendProductListReq {
|
type HomePageRecommendProductListReq {
|
||||||
MerchantType int64 `form:"merchant_type"`
|
MerchantType int64 `form:"merchant_type"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user