Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson 2023-06-20 19:37:08 +08:00
commit e6971575f1
22 changed files with 406 additions and 485 deletions

View File

@ -1,2 +1,10 @@
package gmodel package gmodel
import "context"
// TODO: 使用model的属性做你想做的 // TODO: 使用model的属性做你想做的
func (g *FsGerentModel) Find(ctx context.Context, authKey string) (resp FsGerent, err error) {
err = g.db.WithContext(ctx).Model(&FsGerent{}).Where("`auth_key` = ?", authKey).Take(&resp).Error
return resp, err
}

View File

@ -94,9 +94,9 @@ func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq,
mapSize[v.Id] = v mapSize[v.Id] = v
} }
//组装返回 //组装返回
list := make([]types.CanteenProduct, 0, len(canteenProductList)) list := make([]*types.CanteenProduct, 0, len(canteenProductList))
for _, v := range canteenProductList { for _, v := range canteenProductList {
data := types.CanteenProduct{ data := &types.CanteenProduct{
Id: v.Id, Id: v.Id,
SizeId: *v.SizeId, SizeId: *v.SizeId,
SId: *v.Sid, SId: *v.Sid,

View File

@ -12,7 +12,7 @@ type GetCanteenDetailReq struct {
type GetCanteenDetailRsp struct { type GetCanteenDetailRsp struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
ProductList []CanteenProduct `json:"product_list"` ProductList []*CanteenProduct `json:"product_list"`
} }
type CanteenProduct struct { type CanteenProduct struct {

View File

@ -63,7 +63,7 @@ func (l *GetMapLibraryListLogic) GetMapLibraryList(userinfo *auth.UserInfo) (res
} }
//tag拼装 //tag拼装
if tagIndex, ok := mapTag[*v.TagId]; ok { if tagIndex, ok := mapTag[*v.TagId]; ok {
data.Tag = types.MapLibraryListTag{ data.Tag = &types.MapLibraryListTag{
Id: templateTagList[tagIndex].Id, Id: templateTagList[tagIndex].Id,
Title: *templateTagList[tagIndex].Title, Title: *templateTagList[tagIndex].Title,
} }

View File

@ -8,7 +8,7 @@ import (
type GetMapLibraryListRsp struct { type GetMapLibraryListRsp struct {
Mid int64 `json:"mid"` Mid int64 `json:"mid"`
Ctime string `json:"ctime"` Ctime string `json:"ctime"`
Tag MapLibraryListTag `json:"tag"` Tag *MapLibraryListTag `json:"tag"`
Info interface{} `json:"info"` Info interface{} `json:"info"`
} }
@ -52,11 +52,11 @@ type Info struct {
X float64 `json:"x,optional"` X float64 `json:"x,optional"`
Y float64 `json:"Y,optional"` Y float64 `json:"Y,optional"`
Opacity float64 `json:"opacity,optional"` Opacity float64 `json:"opacity,optional"`
OptionalColor []OptionalColor `json:"optionalColor,optional"` OptionalColor []*OptionalColor `json:"optionalColor,optional"`
ZIndex int64 `json:"zIndex,optional"` ZIndex int64 `json:"zIndex,optional"`
SvgPath string `json:"svgPath,optional"` SvgPath string `json:"svgPath,optional"`
Follow Follow `json:"follow,optional"` Follow Follow `json:"follow,optional"`
Group []Group `json:"group,optional"` Group []*Group `json:"group,optional"`
CameraStand CameraStand `json:"cameraStand,optional"` CameraStand CameraStand `json:"cameraStand,optional"`
} }

View File

@ -45,32 +45,6 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info") return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
} }
address := types.Address{}
//直接邮寄才有地址信息
if *orderInfo.DeliveryMethod == int64(constants.DELIVERY_METHOD_ADDRESS) {
addressInfo, err := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn).GetOne(l.ctx, *orderInfo.AddressId, userinfo.UserId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
}
address.Id = addressInfo.Id
address.UserId = *addressInfo.UserId
address.Name = *addressInfo.Name
address.FirstName = *addressInfo.FirstName
address.LastName = *addressInfo.LastName
address.Mobile = *addressInfo.Mobile
address.Street = *addressInfo.Street
address.Suite = *addressInfo.Suite
address.City = *addressInfo.City
address.State = *addressInfo.State
address.Country = *addressInfo.Country
address.ZipCode = *addressInfo.ZipCode
address.Status = *addressInfo.Status
address.IsDefault = *addressInfo.IsDefault
}
//获取订单详情 //获取订单详情
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn) orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
orderDetails, err := orderDetailModel.GetOrderDetailsByOrderId(l.ctx, orderInfo.Id) orderDetails, err := orderDetailModel.GetOrderDetailsByOrderId(l.ctx, orderInfo.Id)
@ -149,7 +123,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
//处理订单状态 //处理订单状态
orderStatus := order.GetOrderStatus(constants.Order(*orderInfo.Status), constants.DeliveryMethod(*orderInfo.DeliveryMethod)) orderStatus := order.GetOrderStatus(constants.Order(*orderInfo.Status), constants.DeliveryMethod(*orderInfo.DeliveryMethod))
//组装 //组装
productListRsp := make([]types.Product, 0, len(orderDetails)) productListRsp := make([]*types.Product, 0, len(orderDetails))
for _, v := range orderDetails { for _, v := range orderDetails {
cover := *v.Cover cover := *v.Cover
if req.Size >= 200 { if req.Size >= 200 {
@ -174,7 +148,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
if productIndex, ok := mapProduct[*v.ProductId]; ok { if productIndex, ok := mapProduct[*v.ProductId]; ok {
Title = *productList[productIndex].Title Title = *productList[productIndex].Title
} }
productListRsp = append(productListRsp, types.Product{ productListRsp = append(productListRsp, &types.Product{
Cover: cover, Cover: cover,
Fitting: Fitting, Fitting: Fitting,
OptionPrice: *v.OptionPrice, OptionPrice: *v.OptionPrice,
@ -198,10 +172,36 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
Sn: *orderInfo.Sn, Sn: *orderInfo.Sn,
Status: int64(orderStatus), Status: int64(orderStatus),
Ctime: time.Unix(*orderInfo.Ctime, 0).Format("2006-01-02 15:04:05"), Ctime: time.Unix(*orderInfo.Ctime, 0).Format("2006-01-02 15:04:05"),
PayInfo: types.PayInfo{}, Address: nil,
Address: address,
ProductList: productListRsp, ProductList: productListRsp,
} }
//直接邮寄才有地址信息
if *orderInfo.DeliveryMethod == int64(constants.DELIVERY_METHOD_ADDRESS) {
addressInfo, err := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn).GetOne(l.ctx, *orderInfo.AddressId, userinfo.UserId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
}
data.Address = &types.Address{
Id: addressInfo.Id,
UserId: *addressInfo.UserId,
Name: *addressInfo.Name,
FirstName: *addressInfo.FirstName,
LastName: *addressInfo.LastName,
Mobile: *addressInfo.Mobile,
Street: *addressInfo.Street,
Suite: *addressInfo.Suite,
City: *addressInfo.City,
State: *addressInfo.State,
Country: *addressInfo.Country,
ZipCode: *addressInfo.ZipCode,
Status: *addressInfo.Status,
IsDefault: *addressInfo.IsDefault,
}
}
//首款 //首款
if payIndex, ok := mapPay[1]; ok { if payIndex, ok := mapPay[1]; ok {
data.PayInfo.Deposit = types.Deposit{ data.PayInfo.Deposit = types.Deposit{

View File

@ -30,9 +30,9 @@ type GetOrderDetailRsp struct {
Sn string `json:"sn"` Sn string `json:"sn"`
Status int64 `json:"status"` Status int64 `json:"status"`
Ctime string `json:"ctime"` Ctime string `json:"ctime"`
PayInfo PayInfo `json:"pay_info"` PayInfo *PayInfo `json:"pay_info"`
Address Address `json:"address"` Address *Address `json:"address"`
ProductList []Product `json:"productList"` ProductList []*Product `json:"productList"`
} }
type Product struct { type Product struct {

View File

@ -7,7 +7,6 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
"fusenapi/server/product-templatev2/internal/logic" "fusenapi/server/product-templatev2/internal/logic"
@ -17,42 +16,6 @@ import (
func GetTemplatevDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { func GetTemplatevDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var (
// 定义错误变量
err error
// 定义用户信息变量
userinfo *auth.UserInfo
)
// 解析JWT token,并对空用户进行判断
claims, err := svcCtx.ParseJwtToken(r)
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
if err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 401, // 返回401状态码,表示未授权
Message: "unauthorized", // 返回未授权信息
})
logx.Info("unauthorized:", err.Error()) // 记录错误日志
return
}
if claims != nil {
// 从token中获取对应的用户信息
userinfo, err = auth.GetUserInfoFormMapClaims(claims)
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
if err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 401,
Message: "unauthorized",
})
logx.Info("unauthorized:", err.Error())
return
}
} else {
// 如果claims为nil,则认为用户身份为白板用户
userinfo = &auth.UserInfo{UserId: 0, GuestId: 0}
}
var req types.GetTemplatevDetailReq var req types.GetTemplatevDetailReq
// 如果端点有请求结构体则使用httpx.Parse方法从HTTP请求体中解析请求数据 // 如果端点有请求结构体则使用httpx.Parse方法从HTTP请求体中解析请求数据
if err := httpx.Parse(r, &req); err != nil { if err := httpx.Parse(r, &req); err != nil {
@ -65,7 +28,7 @@ func GetTemplatevDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
} }
// 创建一个业务逻辑层实例 // 创建一个业务逻辑层实例
l := logic.NewGetTemplatevDetailLogic(r.Context(), svcCtx) l := logic.NewGetTemplatevDetailLogic(r.Context(), svcCtx)
resp := l.GetTemplatevDetail(&req, userinfo) resp := l.GetTemplatevDetail(&req, r)
// 如果响应不为nil则使用httpx.OkJsonCtx方法返回JSON响应; // 如果响应不为nil则使用httpx.OkJsonCtx方法返回JSON响应;
if resp != nil { if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp) httpx.OkJsonCtx(r.Context(), w, resp)

View File

@ -1,10 +1,9 @@
package logic package logic
import ( import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context" "context"
"fusenapi/utils/basic"
"net/http"
"fusenapi/server/product-templatev2/internal/svc" "fusenapi/server/product-templatev2/internal/svc"
"fusenapi/server/product-templatev2/internal/types" "fusenapi/server/product-templatev2/internal/types"
@ -26,9 +25,41 @@ func NewGetTemplatevDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext)
} }
} }
func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDetailReq, userinfo *auth.UserInfo) (resp *basic.Response) { func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDetailReq, r *http.Request) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) /*authKey := r.Header.Get("Auth-Key")
// userinfo 传入值时, 一定不为null if authKey == "" {
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first")
}
if req.TemplateId <= 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param template_id")
}
if req.ModelId <= 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param model_id")
}
genentModel := gmodel.NewFsGerentModel(l.svcCtx.MysqlConn)
_, err := genentModel.Find(l.ctx, authKey)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first..")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeUnAuth, "failed to get user info")
}
//查询产品模型并肩测数据完整性
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
model3dInfo, err := productModel3dModel.FindOne(l.ctx, req.ModelId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product model info is not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product model info")
}
//配件ids
partIds, err := format.StrSlicToIntSlice(strings.Split(*model3dInfo.PartList, ","))
//产品模型数据解析model_info
if model3dInfo.ModelInfo != nil && *model3dInfo.ModelInfo != "" {
}*/
return resp.SetStatus(basic.CodeOK) return resp.SetStatus(basic.CodeOK)
} }

View File

@ -11,42 +11,13 @@ type GetTemplatevDetailReq struct {
} }
type GetTemplatevDetailRsp struct { type GetTemplatevDetailRsp struct {
ProductModelInfo ProductModelInfo `json:"product_model_info"` ProductModelInfo interface{} `json:"product_model_info"`
ProductTemplate ProductTemplate `json:"product_template"` ProductTemplate ProductTemplate `json:"product_template"`
LightList []Light `json:"light_list"` LightList []*Light `json:"light_list"`
OptionModelInfo []interface{} `json:"option_model_info"` OptionModelInfo []interface{} `json:"option_model_info"`
Tag int64 `json:"tag"` Tag int64 `json:"tag"`
} }
type ProductModelInfo struct {
Id int64 `json:"id"`
Name string `json:"name"`
KnifeTerritory string `json:"knifeTerritory"`
Cover string `json:"cover"`
CameraData CameraData `json:"cameraData"`
ControlsData ControlsData `json:"controlsData"`
Material ModelMaterial `json:"material"`
ModelData ModelData `json:"modelData"`
LightData int64 `json:"lightData"`
LightList []int64 `json:"lightList"`
Parts string `json:"parts"`
PartsList []int64 `json:"partsList"`
Tag int64 `json:"tag"`
}
type CameraData struct {
X int64 `json:"x"`
Y int64 `json:"y"`
Z int64 `json:"z"`
}
type ControlsData struct {
MinDistance int64 `json:"minDistance"`
MaxDistance int64 `json:"maxDistance"`
MaxPolarAngle float64 `json:"maxPolarAngle"`
MinPolarAngle float64 `json:"minPolarAngle"`
}
type Tag struct { type Tag struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Title string `json:"title"` Title string `json:"title"`
@ -58,7 +29,7 @@ type TemplateInfo struct {
Cover string `json:"cover"` Cover string `json:"cover"`
IsPublic bool `json:"isPublic"` IsPublic bool `json:"isPublic"`
Material string `json:"material"` Material string `json:"material"`
MaterialList TemplateMateria `json:"materialList"` MaterialList []*TemplateMateria `json:"materialList"`
} }
type ProductTemplate struct { type ProductTemplate struct {
@ -73,7 +44,7 @@ type ProductTemplate struct {
ProductId int64 `json:"product_id"` ProductId int64 `json:"product_id"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
Tag Tag `json:"tag"` Tag Tag `json:"tag"`
TemplateInfo TemplateInfo `json:"template_info"` TemplateInfo *TemplateInfo `json:"template_info"`
Title string `json:"title"` Title string `json:"title"`
} }
@ -82,22 +53,6 @@ type Light struct {
Info LightInfo `json:"info"` Info LightInfo `json:"info"`
} }
type ModelMaterial struct {
AoMap string `json:"aoMap"`
AoMapint64ensity int64 `json:"aoMapint64ensity"`
NormalMap string `json:"normalMap"`
NormalScale []int64 `json:"normalScale"`
SpecularMap string `json:"specularMap"`
Roughness int64 `json:"roughness"`
MetalnessMap string `json:"metalnessMap"`
Metalness int64 `json:"metalness"`
}
type ModelData struct {
Path string `json:"path"`
Shadow string `json:"shadow"`
}
type TemplateMateria struct { type TemplateMateria struct {
Id string `json:"id"` Id string `json:"id"`
Tag string `json:"tag"` Tag string `json:"tag"`
@ -125,7 +80,7 @@ type TemplateMateria struct {
X int64 `json:"x"` X int64 `json:"x"`
Y int64 `json:"y"` Y int64 `json:"y"`
Opacity int64 `json:"opacity"` Opacity int64 `json:"opacity"`
OptionalColor []OptionalColor `json:"optionalColor"` OptionalColor []*OptionalColor `json:"optionalColor"`
ZIndex int64 `json:"zIndex"` ZIndex int64 `json:"zIndex"`
SvgPath string `json:"svgPath"` SvgPath string `json:"svgPath"`
Follow Follow `json:"follow"` Follow Follow `json:"follow"`

View File

@ -130,7 +130,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product size count err") return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product size count err")
} }
//拼接返回 //拼接返回
itemList := make([]types.Items, 0, productLen) itemList := make([]*types.Items, 0, productLen)
for _, v := range productList { for _, v := range productList {
minPrice, ok := mapProductMinPrice[v.Id] minPrice, ok := mapProductMinPrice[v.Id]
_, tmpOk := mapProductTemplate[v.Id] _, tmpOk := mapProductTemplate[v.Id]
@ -138,7 +138,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
if !ok || !tmpOk { if !ok || !tmpOk {
continue continue
} }
item := types.Items{ item := &types.Items{
Id: v.Id, Id: v.Id,
Sn: *v.Sn, Sn: *v.Sn,
Title: *v.Title, Title: *v.Title,

View File

@ -103,8 +103,8 @@ func (l *GetSizeByProductLogic) GetSizeByProduct(userinfo *auth.UserInfo) (resp
} }
// 第一层子层 // 第一层子层
func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []types.Children, err error) { func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productList []gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenList []*types.Children, err error) {
childrenList = make([]types.Children, 0, len(productList)) childrenList = make([]*types.Children, 0, len(productList))
for _, product := range productList { for _, product := range productList {
if *product.Type != tag.Id { if *product.Type != tag.Id {
continue continue
@ -114,7 +114,7 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
return nil, err return nil, err
} }
//获取第二层子类 //获取第二层子类
data := types.Children{ data := &types.Children{
Id: product.Id, Id: product.Id,
Name: *product.Title, Name: *product.Title,
Cycle: int(*product.DeliveryDays + *product.ProduceDays), Cycle: int(*product.DeliveryDays + *product.ProduceDays),
@ -126,24 +126,26 @@ func (l *GetSizeByProductLogic) GetFirstChildrenList(tag gmodel.FsTags, productL
} }
// 第2层子层 // 第2层子层
func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []types.ChildrenObj, err error) { func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct, productSizeList []gmodel.FsProductSize, mapProductPrice map[int64]gmodel.FsProductPrice) (childrenObjList []*types.ChildrenObj, err error) {
childrenObjList = make([]types.ChildrenObj, 0, len(productSizeList)) childrenObjList = make([]*types.ChildrenObj, 0, len(productSizeList))
for _, productSize := range productSizeList { for _, productSize := range productSizeList {
if product.Id != *productSize.ProductId { if product.Id != *productSize.ProductId {
continue continue
} }
priceList := make([]types.PriceObj, 0, len(productSizeList)) priceList := make([]*types.PriceObj, 0, len(productSizeList))
price, ok := mapProductPrice[productSize.Id] price, ok := mapProductPrice[productSize.Id]
//无对应尺寸价格 //无对应尺寸价格
if !ok { if !ok {
childrenObjList = append(childrenObjList, types.ChildrenObj{ for i := 0; i < 3; i++ {
priceList = append(priceList, &types.PriceObj{
Num: 1,
Price: 0,
})
}
childrenObjList = append(childrenObjList, &types.ChildrenObj{
Id: productSize.Id, Id: productSize.Id,
Name: *productSize.Capacity, Name: *productSize.Capacity,
PriceList: []types.PriceObj{ PriceList: priceList,
{Num: 1, Price: 0},
{Num: 1, Price: 0},
{Num: 1, Price: 0},
},
}) })
continue continue
} }
@ -169,14 +171,14 @@ func (l *GetSizeByProductLogic) GetSecondChildrenList(product gmodel.FsProduct,
index := 0 index := 0
// 最小购买数量小于 最大阶梯数量+5 // 最小购买数量小于 最大阶梯数量+5
for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 { for int(*price.MinBuyNum) < (stepNum[len(stepNum)-1]+5) && index < 3 {
priceList = append(priceList, types.PriceObj{ priceList = append(priceList, &types.PriceObj{
Num: int(*price.MinBuyNum * *price.EachBoxNum), Num: int(*price.MinBuyNum * *price.EachBoxNum),
Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice), Price: step_price.GetStepPrice(int(*price.MinBuyNum), stepNum, stepPrice),
}) })
*price.MinBuyNum++ *price.MinBuyNum++
index++ index++
} }
data := types.ChildrenObj{ data := &types.ChildrenObj{
Id: productSize.Id, Id: productSize.Id,
Name: *productSize.Capacity, Name: *productSize.Capacity,
PriceList: priceList, PriceList: priceList,

View File

@ -19,9 +19,9 @@ type GetProductListRsp struct {
} }
type Ob struct { type Ob struct {
Items []Items `json:"items"` Items []*Items `json:"items"`
Links Links `json:"_links"` Links *Links `json:"_links"`
Meta Meta `json:"_meta"` Meta *Meta `json:"_meta"`
} }
type Meta struct { type Meta struct {
@ -75,20 +75,20 @@ type GetSuccessRecommandRsp struct {
type GetSizeByProductRsp struct { type GetSizeByProductRsp struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Children []Children `json:"children"` Children []*Children `json:"children"`
} }
type Children struct { type Children struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Cycle int `json:"cycle"` Cycle int `json:"cycle"`
ChildrenList []ChildrenObj `json:"children"` ChildrenList []*ChildrenObj `json:"children"`
} }
type ChildrenObj struct { type ChildrenObj struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
PriceList []PriceObj `json:"price_list"` PriceList []*PriceObj `json:"price_list"`
} }
type PriceObj struct { type PriceObj struct {

View File

@ -83,46 +83,49 @@ func (l *CartListLogic) CartList(req *types.CartListReq, userinfo *auth.UserInfo
name = *cartRelativeData.ProductList[productIndex].Title name = *cartRelativeData.ProductList[productIndex].Title
productSn = strings.ToLower(*cartRelativeData.ProductList[productIndex].Sn) productSn = strings.ToLower(*cartRelativeData.ProductList[productIndex].Sn)
} }
capacity := ""
var sizeList types.CartSizeItem
if sizeIndex, ok := mapProductSize[*v.SizeId]; ok {
capacity = *cartRelativeData.ProductSizeList[sizeIndex].Capacity
err = json.Unmarshal([]byte(*cartRelativeData.ProductSizeList[sizeIndex].Title), &sizeList)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse product size`s title")
}
}
designSn := "" designSn := ""
if designIndex, ok := mapProductDesign[*v.DesignId]; ok { if designIndex, ok := mapProductDesign[*v.DesignId]; ok {
designSn = strings.ToLower(*cartRelativeData.ProductDesignList[designIndex].Sn) designSn = strings.ToLower(*cartRelativeData.ProductDesignList[designIndex].Sn)
} }
option := types.CartOption{}
if model3dIndex, ok := mapProductModel3d[*v.OptionalId]; ok {
option.Id = cartRelativeData.ProductModel3dList[model3dIndex].Id
option.Title = *cartRelativeData.ProductModel3dList[model3dIndex].Title
option.Price = float64(*cartRelativeData.ProductModel3dList[model3dIndex].Price) / float64(100)
}
pcList, err := l.getPcList(cartRelativeData.ProductPriceList, *v.ProductId, *v.MaterialId, *v.SizeId) pcList, err := l.getPcList(cartRelativeData.ProductPriceList, *v.ProductId, *v.MaterialId, *v.SizeId)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to calculate step price") return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to calculate step price")
} }
rspList = append(rspList, types.CartListRsp{ d := types.CartListRsp{
Id: v.Id, Id: v.Id,
Cover: *v.Cover, Cover: *v.Cover,
Name: name, Name: name,
Capacity: capacity, Capacity: "",
ETA: time.Now().AddDate(0, 0, 60).Format("2006-01-02 15:04:05"), ETA: time.Now().AddDate(0, 0, 60).Format("2006-01-02 15:04:05"),
Pcs: *v.BuyNum, Pcs: *v.BuyNum,
ProductSn: productSn, ProductSn: productSn,
DesignSn: designSn, DesignSn: designSn,
Option: option, Option: nil,
IsCheck: *v.IsCheck, IsCheck: *v.IsCheck,
TsTime: v.TsTime.Format("2006-01-02 15:04:05"), TsTime: v.TsTime.Format("2006-01-02 15:04:05"),
PcsList: pcList, PcsList: pcList,
Size: sizeList, Size: nil,
}) }
var sizeList types.CartSizeItem
if sizeIndex, ok := mapProductSize[*v.SizeId]; ok {
d.Capacity = *cartRelativeData.ProductSizeList[sizeIndex].Capacity
err = json.Unmarshal([]byte(*cartRelativeData.ProductSizeList[sizeIndex].Title), &sizeList)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse product size`s title")
}
d.Size = &sizeList
}
if model3dIndex, ok := mapProductModel3d[*v.OptionalId]; ok {
d.Option = &types.CartOption{
Id: cartRelativeData.ProductModel3dList[model3dIndex].Id,
Title: *cartRelativeData.ProductModel3dList[model3dIndex].Title,
Price: float64(*cartRelativeData.ProductModel3dList[model3dIndex].Price) / float64(100),
}
}
rspList = append(rspList, d)
} }
return resp.SetStatusWithMessage(basic.CodeOK, "success", rspList) return resp.SetStatusWithMessage(basic.CodeOK, "success", rspList)
} }
@ -138,7 +141,7 @@ type GetUserCartRelativeListRsp struct {
} }
// 获取阶梯对应的价格 // 获取阶梯对应的价格
func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, productId int64, materialId int64, sizeId int64) (list []types.PcsItem, err error) { func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, productId int64, materialId int64, sizeId int64) (list []*types.PcsItem, err error) {
for _, price := range productPriceList { for _, price := range productPriceList {
if *price.ProductId != productId || *price.MaterialId != materialId || *price.SizeId != sizeId { if *price.ProductId != productId || *price.MaterialId != materialId || *price.SizeId != sizeId {
continue continue
@ -159,7 +162,7 @@ func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, prod
return nil, errors.New("step num or step price item count can`t be 0 ") return nil, errors.New("step num or step price item count can`t be 0 ")
} }
for int(*price.MinBuyNum) < stepNumSlice[lenStepNumSlice-1]+5 { for int(*price.MinBuyNum) < stepNumSlice[lenStepNumSlice-1]+5 {
list = append(list, types.PcsItem{ list = append(list, &types.PcsItem{
Num: *price.MinBuyNum, Num: *price.MinBuyNum,
TotalNum: *price.MinBuyNum * *price.EachBoxNum, TotalNum: *price.MinBuyNum * *price.EachBoxNum,
Title: *price.Title, Title: *price.Title,

View File

@ -109,9 +109,9 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address") return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address")
} }
//处理订单数据 //处理订单数据
addressItems := make([]types.CartAddr, 0, len(addressList)) addressItems := make([]*types.CartAddr, 0, len(addressList))
for _, v := range addressList { for _, v := range addressList {
addressItems = append(addressItems, types.CartAddr{ addressItems = append(addressItems, &types.CartAddr{
Id: v.Id, Id: v.Id,
Name: *v.Name, Name: *v.Name,
FirstName: *v.FirstName, FirstName: *v.FirstName,
@ -125,7 +125,7 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
IsDefault: *v.IsDefault, IsDefault: *v.IsDefault,
}) })
} }
items := make([]types.CartDetailItem, 0, len(orderDetailList)) items := make([]*types.CartDetailItem, 0, len(orderDetailList))
totalAmount := int64(0) //订单总金额 totalAmount := int64(0) //订单总金额
for _, v := range orderDetailList { for _, v := range orderDetailList {
thisTotal := (*v.BuyNum) * (*v.Amount) thisTotal := (*v.BuyNum) * (*v.Amount)
@ -140,7 +140,7 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
if productIndex, ok := mapProduct[*v.ProductId]; ok { if productIndex, ok := mapProduct[*v.ProductId]; ok {
name = *productList[productIndex].Title name = *productList[productIndex].Title
} }
items = append(items, types.CartDetailItem{ items = append(items, &types.CartDetailItem{
Cover: *v.Cover, Cover: *v.Cover,
Pcs: *v.BuyNum, Pcs: *v.BuyNum,
Amount: fmt.Sprintf("$ %.2f", float64(thisTotal)/100), Amount: fmt.Sprintf("$ %.2f", float64(thisTotal)/100),

View File

@ -32,11 +32,11 @@ type CartListRsp struct {
Pcs int64 `json:"pcs"` Pcs int64 `json:"pcs"`
ProductSn string `json:"product_sn"` ProductSn string `json:"product_sn"`
DesignSn string `json:"designSn"` DesignSn string `json:"designSn"`
Option CartOption `json:"option"` Option *CartOption `json:"option"`
IsCheck int64 `json:"is_check"` IsCheck int64 `json:"is_check"`
TsTime string `json:"ts_time"` TsTime string `json:"ts_time"`
PcsList []PcsItem `json:"pcs_list"` PcsList []*PcsItem `json:"pcs_list"`
Size CartSizeItem `json:"size"` Size *CartSizeItem `json:"size"`
} }
type CartOption struct { type CartOption struct {
@ -70,8 +70,8 @@ type CartOrderDetailRsp struct {
Subtotal string `json:"subtotal"` Subtotal string `json:"subtotal"`
Total string `json:"total"` Total string `json:"total"`
Remaining string `json:"remaining"` Remaining string `json:"remaining"`
AddrList []CartAddr `json:"addr_list"` AddrList []*CartAddr `json:"addr_list"`
Items []CartDetailItem `json:"items"` Items []*CartDetailItem `json:"items"`
} }
type CartDetailItem struct { type CartDetailItem struct {

View File

@ -23,7 +23,7 @@ type GetCanteenDetailReq {
type GetCanteenDetailRsp { type GetCanteenDetailRsp {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
ProductList []CanteenProduct `json:"product_list"` ProductList []*CanteenProduct `json:"product_list"`
} }
type CanteenProduct { type CanteenProduct {
Id int64 `json:"id"` Id int64 `json:"id"`

View File

@ -21,7 +21,7 @@ service map-library {
type GetMapLibraryListRsp { type GetMapLibraryListRsp {
Mid int64 `json:"mid"` Mid int64 `json:"mid"`
Ctime string `json:"ctime"` Ctime string `json:"ctime"`
Tag MapLibraryListTag `json:"tag"` Tag *MapLibraryListTag `json:"tag"`
Info interface{} `json:"info"` Info interface{} `json:"info"`
} }
type MapLibraryListTag { type MapLibraryListTag {
@ -64,11 +64,11 @@ type Info {
X float64 `json:"x,optional"` X float64 `json:"x,optional"`
Y float64 `json:"Y,optional"` Y float64 `json:"Y,optional"`
Opacity float64 `json:"opacity,optional"` Opacity float64 `json:"opacity,optional"`
OptionalColor []OptionalColor `json:"optionalColor,optional"` OptionalColor []*OptionalColor `json:"optionalColor,optional"`
ZIndex int64 `json:"zIndex,optional"` ZIndex int64 `json:"zIndex,optional"`
SvgPath string `json:"svgPath,optional"` SvgPath string `json:"svgPath,optional"`
Follow Follow `json:"follow,optional"` Follow Follow `json:"follow,optional"`
Group []Group `json:"group,optional"` Group []*Group `json:"group,optional"`
CameraStand CameraStand `json:"cameraStand,optional"` CameraStand CameraStand `json:"cameraStand,optional"`
} }
type Group { type Group {

View File

@ -40,9 +40,9 @@ type GetOrderDetailRsp {
Sn string `json:"sn"` Sn string `json:"sn"`
Status int64 `json:"status"` Status int64 `json:"status"`
Ctime string `json:"ctime"` Ctime string `json:"ctime"`
PayInfo PayInfo `json:"pay_info"` PayInfo *PayInfo `json:"pay_info"`
Address Address `json:"address"` Address *Address `json:"address"`
ProductList []Product `json:"productList"` ProductList []*Product `json:"productList"`
} }
type Product { type Product {
Cover string `json:"cover"` Cover string `json:"cover"`

View File

@ -19,40 +19,13 @@ type GetTemplatevDetailReq {
TemplateId int64 `form:"template_id"` TemplateId int64 `form:"template_id"`
} }
type GetTemplatevDetailRsp { type GetTemplatevDetailRsp {
ProductModelInfo ProductModelInfo `json:"product_model_info"` ProductModelInfo interface{} `json:"product_model_info"`
ProductTemplate ProductTemplate `json:"product_template"` ProductTemplate ProductTemplate `json:"product_template"`
LightList []Light `json:"light_list"` LightList []*Light `json:"light_list"`
OptionModelInfo []interface{} `json:"option_model_info"` OptionModelInfo []interface{} `json:"option_model_info"`
Tag int64 `json:"tag"` Tag int64 `json:"tag"`
} }
type ProductModelInfo {
Id int64 `json:"id"`
Name string `json:"name"`
KnifeTerritory string `json:"knifeTerritory"`
Cover string `json:"cover"`
CameraData CameraData `json:"cameraData"`
ControlsData ControlsData `json:"controlsData"`
Material ModelMaterial `json:"material"`
ModelData ModelData `json:"modelData"`
LightData int64 `json:"lightData"`
LightList []int64 `json:"lightList"`
Parts string `json:"parts"`
PartsList []int64 `json:"partsList"`
Tag int64 `json:"tag"`
}
type CameraData {
X int64 `json:"x"`
Y int64 `json:"y"`
Z int64 `json:"z"`
}
type ControlsData {
MinDistance int64 `json:"minDistance"`
MaxDistance int64 `json:"maxDistance"`
MaxPolarAngle float64 `json:"maxPolarAngle"`
MinPolarAngle float64 `json:"minPolarAngle"`
}
type Tag { type Tag {
Id int64 `json:"id"` Id int64 `json:"id"`
Title string `json:"title"` Title string `json:"title"`
@ -63,7 +36,7 @@ type TemplateInfo {
Cover string `json:"cover"` Cover string `json:"cover"`
IsPublic bool `json:"isPublic"` IsPublic bool `json:"isPublic"`
Material string `json:"material"` Material string `json:"material"`
MaterialList TemplateMateria `json:"materialList"` MaterialList []*TemplateMateria `json:"materialList"`
} }
type ProductTemplate { type ProductTemplate {
CoverImg string `json:"cover_img"` CoverImg string `json:"cover_img"`
@ -77,7 +50,7 @@ type ProductTemplate {
ProductId int64 `json:"product_id"` ProductId int64 `json:"product_id"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
Tag Tag `json:"tag"` Tag Tag `json:"tag"`
TemplateInfo TemplateInfo `json:"template_info"` TemplateInfo *TemplateInfo `json:"template_info"`
Title string `json:"title"` Title string `json:"title"`
} }
type Light { type Light {
@ -85,20 +58,6 @@ type Light {
Info LightInfo `json:"info"` Info LightInfo `json:"info"`
} }
type ModelMaterial {
AoMap string `json:"aoMap"`
AoMapint64ensity int64 `json:"aoMapint64ensity"`
NormalMap string `json:"normalMap"`
NormalScale []int64 `json:"normalScale"`
SpecularMap string `json:"specularMap"`
Roughness int64 `json:"roughness"`
MetalnessMap string `json:"metalnessMap"`
Metalness int64 `json:"metalness"`
}
type ModelData {
Path string `json:"path"`
Shadow string `json:"shadow"`
}
type TemplateMateria { type TemplateMateria {
Id string `json:"id"` Id string `json:"id"`
Tag string `json:"tag"` Tag string `json:"tag"`
@ -126,7 +85,7 @@ type TemplateMateria {
X int64 `json:"x"` X int64 `json:"x"`
Y int64 `json:"y"` Y int64 `json:"y"`
Opacity int64 `json:"opacity"` Opacity int64 `json:"opacity"`
OptionalColor []OptionalColor `json:"optionalColor"` OptionalColor []*OptionalColor `json:"optionalColor"`
ZIndex int64 `json:"zIndex"` ZIndex int64 `json:"zIndex"`
SvgPath string `json:"svgPath"` SvgPath string `json:"svgPath"`
Follow Follow `json:"follow"` Follow Follow `json:"follow"`

View File

@ -35,9 +35,9 @@ type GetProductListRsp {
Description string `json:"description"` Description string `json:"description"`
} }
type Ob { type Ob {
Items []Items `json:"items"` Items []*Items `json:"items"`
Links Links `json:"_links"` Links *Links `json:"_links"`
Meta Meta `json:"_meta"` Meta *Meta `json:"_meta"`
} }
type Meta { type Meta {
TotalCount int32 `json:"totalCount"` TotalCount int32 `json:"totalCount"`
@ -87,18 +87,18 @@ type GetSuccessRecommandRsp {
type GetSizeByProductRsp { type GetSizeByProductRsp {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Children []Children `json:"children"` Children []*Children `json:"children"`
} }
type Children { type Children {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Cycle int `json:"cycle"` Cycle int `json:"cycle"`
ChildrenList []ChildrenObj `json:"children"` ChildrenList []*ChildrenObj `json:"children"`
} }
type ChildrenObj { type ChildrenObj {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
PriceList []PriceObj `json:"price_list"` PriceList []*PriceObj `json:"price_list"`
} }
type PriceObj { type PriceObj {
Num int `json:"num"` Num int `json:"num"`

View File

@ -55,11 +55,11 @@ type CartListRsp {
Pcs int64 `json:"pcs"` Pcs int64 `json:"pcs"`
ProductSn string `json:"product_sn"` ProductSn string `json:"product_sn"`
DesignSn string `json:"designSn"` DesignSn string `json:"designSn"`
Option CartOption `json:"option"` Option *CartOption `json:"option"`
IsCheck int64 `json:"is_check"` IsCheck int64 `json:"is_check"`
TsTime string `json:"ts_time"` TsTime string `json:"ts_time"`
PcsList []PcsItem `json:"pcs_list"` PcsList []*PcsItem `json:"pcs_list"`
Size CartSizeItem `json:"size"` Size *CartSizeItem `json:"size"`
} }
type CartOption { type CartOption {
Id int64 `json:"id"` Id int64 `json:"id"`
@ -89,8 +89,8 @@ type CartOrderDetailRsp {
Subtotal string `json:"subtotal"` Subtotal string `json:"subtotal"`
Total string `json:"total"` Total string `json:"total"`
Remaining string `json:"remaining"` Remaining string `json:"remaining"`
AddrList []CartAddr `json:"addr_list"` AddrList []*CartAddr `json:"addr_list"`
Items []CartDetailItem `json:"items"` Items []*CartDetailItem `json:"items"`
} }
type CartDetailItem { type CartDetailItem {
Cover string `json:"cover"` Cover string `json:"cover"`