Merge branch 'feature/mhw-v1.01' of gitee.com:fusenpack/fusenapi into feature/mhw-v1.01
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"fusenapi/server/auth/internal/handler"
|
||||
"fusenapi/server/auth/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -21,9 +20,8 @@ var configFile = flag.String("f", "etc/auth.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
@@ -5,6 +5,5 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
|
||||
main()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"fusenapi/server/base/internal/handler"
|
||||
"fusenapi/server/base/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -21,9 +20,8 @@ var configFile = flag.String("f", "etc/base.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/canteen.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/home-user-auth.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"fusenapi/server/info/internal/handler"
|
||||
"fusenapi/server/info/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -22,9 +21,8 @@ var configFile = flag.String("f", "etc/info.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/map-library.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"fusenapi/server/pay/internal/handler"
|
||||
"fusenapi/server/pay/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -21,9 +20,8 @@ var configFile = flag.String("f", "etc/pay.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/product-model.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
var mapTemplateTag map[string][][]string
|
||||
var mapMaterialTemplateTag map[string][][]string
|
||||
b, _ := json.Marshal(metaData["template_tag"])
|
||||
if err = json.Unmarshal(b, &mapTemplateTag); err != nil {
|
||||
if err = json.Unmarshal(b, &mapMaterialTemplateTag); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tag")
|
||||
}
|
||||
@@ -90,12 +90,12 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
||||
}
|
||||
//设置选中
|
||||
key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag
|
||||
if _, ok := mapTemplateTag[key]; ok {
|
||||
if _, ok := mapMaterialTemplateTag[key]; ok {
|
||||
mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex
|
||||
}
|
||||
}
|
||||
var templateTagNameList []string
|
||||
for templateTag, _ := range mapTemplateTag {
|
||||
for templateTag, _ := range mapMaterialTemplateTag {
|
||||
templateTagNameList = append(templateTagNameList, templateTag)
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
@@ -127,11 +127,15 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
||||
colors := make([][]string, 0, 10)
|
||||
SelectedColorIndex := 0
|
||||
isDefaultTemplateTag := false
|
||||
if colorsSet, ok := mapTemplateTag[*templateInfo.TemplateTag]; ok {
|
||||
//查看用户素材中标签对应的颜色
|
||||
if colorsSet, ok := mapMaterialTemplateTag[*templateInfo.TemplateTag]; ok {
|
||||
//是不是选中的标签
|
||||
if selectIndex, ok := mapSelectColor[*templateInfo.TemplateTag]; ok {
|
||||
isDefaultTemplateTag = true
|
||||
//标签中选中的索引
|
||||
SelectedColorIndex = selectIndex
|
||||
}
|
||||
//标签颜色
|
||||
colors = colorsSet
|
||||
}
|
||||
var templateTagGroups []interface{}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"fusenapi/server/product-template-tag/internal/handler"
|
||||
"fusenapi/server/product-template-tag/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -21,9 +20,8 @@ var configFile = flag.String("f", "etc/product-template-tag.yaml", "the config f
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/product-template.yaml", "the config file"
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/product.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"fusenapi/service/repositories"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/template_switch_info"
|
||||
|
||||
"context"
|
||||
|
||||
@@ -64,33 +63,41 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
|
||||
// 否则,使用用户ID和用户键名格式
|
||||
userId = userinfo.UserId
|
||||
}
|
||||
// 获取默认
|
||||
if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" || req.Slogan == "" {
|
||||
// 没有查到,先根据模版id 查询模版数据 请求算法数据
|
||||
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
|
||||
// 没有查到,先根据模版id 查询模版数据 请求算法数据
|
||||
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
|
||||
|
||||
if err != nil {
|
||||
logc.Errorf(l.ctx, "productTemplateV2Model.FindOne:%v", err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
|
||||
}
|
||||
templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg)
|
||||
if req.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow {
|
||||
req.Address = templateSwitchInfo.MaterialData.Address.DefaultValue
|
||||
}
|
||||
if req.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow {
|
||||
req.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue
|
||||
}
|
||||
if req.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow {
|
||||
req.Website = templateSwitchInfo.MaterialData.Website.DefaultValue
|
||||
}
|
||||
if req.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow {
|
||||
req.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue
|
||||
}
|
||||
if req.Slogan == "" && templateSwitchInfo.MaterialData.Slogan.IfShow {
|
||||
req.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue
|
||||
}
|
||||
if err != nil {
|
||||
logc.Errorf(l.ctx, "productTemplateV2Model.FindOne:%v", err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
|
||||
}
|
||||
// // 获取默认
|
||||
// if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" || req.Slogan == "" {
|
||||
// // 没有查到,先根据模版id 查询模版数据 请求算法数据
|
||||
// productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
// productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId)
|
||||
|
||||
// if err != nil {
|
||||
// logc.Errorf(l.ctx, "productTemplateV2Model.FindOne:%v", err)
|
||||
// return resp.SetStatus(basic.CodeServiceErr, "模版不存在")
|
||||
// }
|
||||
// templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg)
|
||||
// if req.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow {
|
||||
// req.Address = templateSwitchInfo.MaterialData.Address.DefaultValue
|
||||
// }
|
||||
// if req.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow {
|
||||
// req.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue
|
||||
// }
|
||||
// if req.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow {
|
||||
// req.Website = templateSwitchInfo.MaterialData.Website.DefaultValue
|
||||
// }
|
||||
// if req.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow {
|
||||
// req.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue
|
||||
// }
|
||||
// if req.Slogan == "" && templateSwitchInfo.MaterialData.Slogan.IfShow {
|
||||
// req.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue
|
||||
// }
|
||||
// }
|
||||
|
||||
res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{
|
||||
UserId: userId,
|
||||
@@ -100,8 +107,14 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
|
||||
Slogan: req.Slogan,
|
||||
Phone: req.Phone,
|
||||
Address: req.Address,
|
||||
|
||||
Qrcode: req.Qrcode,
|
||||
Qrcode: req.Qrcode,
|
||||
LogoUrl: req.LogoUrl,
|
||||
TemplateTagColor: repositories.TemplateTagColor{
|
||||
Color: req.TemplateTagColor.Colors,
|
||||
Index: req.TemplateTagColor.SelectedColorIndex,
|
||||
},
|
||||
ProductTemplateTagGroups: req.TemplateTagGroups,
|
||||
ProductTemplateV2Info: productTemplateV2Info,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -28,16 +28,28 @@ type ResourceInfoReq struct {
|
||||
}
|
||||
|
||||
type LogoCombineReq struct {
|
||||
LogoUrl string `json:"logo_url"` // 合图参数
|
||||
TemplateId int64 `json:"template_id"` // 合图参数
|
||||
TemplateTag string `json:"template_tag"` // 合图参数
|
||||
Color [][]string `json:"color"` // 颜色组合
|
||||
SelectedIndex int `json:"selected_index"` // 主色的下标索引
|
||||
Website string `json:"website,optional"` // 合图参数
|
||||
Slogan string `json:"slogan,optional"` // 合图参数
|
||||
Address string `json:"address,optional"` // 合图参数
|
||||
Phone string `json:"phone,optional"` // 合图参数
|
||||
Qrcode string `json:"qrcode,optional"` // 合图参数
|
||||
TemplateId int64 `json:"template_id"` // 合图参数
|
||||
TemplateTag string `json:"template_tag"` // 合图参数
|
||||
Website string `json:"website,optional"` // 合图参数
|
||||
Slogan string `json:"slogan,optional"` // 合图参数
|
||||
Address string `json:"address,optional"` // 合图参数
|
||||
Phone string `json:"phone,optional"` // 合图参数
|
||||
Qrcode string `json:"qrcode,optional"` // 合图参数
|
||||
LogoUrl string `json:"logo_url"` // 合图参数
|
||||
TemplateTagColor TemplateTagColor `json:"template_tag_color"`
|
||||
TemplateTagGroups []TemplateTagGroups `json:"template_tag_groups"`
|
||||
}
|
||||
|
||||
type TemplateTagColor struct {
|
||||
Colors [][]string `json:"colors"` // 颜色组合
|
||||
SelectedColorIndex int `json:"selected_color_index"` // 主色的下标索引
|
||||
}
|
||||
|
||||
type TemplateTagGroups struct {
|
||||
Tag string `json:"tag"`
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
Fixed int64 `json:"fixed"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"fusenapi/server/resource/internal/handler"
|
||||
"fusenapi/server/resource/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -21,9 +20,8 @@ var configFile = flag.String("f", "etc/resource.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
@@ -6,16 +6,13 @@ import (
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/step_price"
|
||||
"fusenapi/utils/shopping_cart"
|
||||
"gorm.io/gorm"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -110,43 +107,27 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("there carts contain some one which have no price info:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
//阶梯数量切片
|
||||
stepNum, err := format.StrSlicToIntSlice(strings.Split(*sizePrice.StepNum, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return errors.New(fmt.Sprintf("failed to parse step number:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
lenStepNum := len(stepNum)
|
||||
//阶梯价格切片
|
||||
stepPrice, err := format.StrSlicToIntSlice(strings.Split(*sizePrice.StepPrice, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return errors.New(fmt.Sprintf("failed to parse step price:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
lenStepPrice := len(stepPrice)
|
||||
if lenStepPrice == 0 || lenStepNum == 0 {
|
||||
return errors.New(fmt.Sprintf("step price or step number is not set:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
//请求的数量
|
||||
reqPurchaseQuantity := mapCalculateQuantity[cart.Id].PurchaseQuantity
|
||||
isSelected := int64(0)
|
||||
if mapCalculateQuantity[cart.Id].IsSelected {
|
||||
isSelected = 1
|
||||
}
|
||||
//购买箱数
|
||||
boxQuantity := int(math.Ceil(float64(reqPurchaseQuantity) / float64(*sizePrice.EachBoxNum)))
|
||||
//根据数量获取阶梯价格中对应的价格
|
||||
itemPrice := step_price.GetCentStepPrice(boxQuantity, stepNum, stepPrice)
|
||||
//如果有配件,单价也要加入配件价格
|
||||
fittingPrice := int64(0)
|
||||
if *cart.FittingId > 0 {
|
||||
if fittingPrice, ok := mapFitting[*cart.FittingId]; ok {
|
||||
itemPrice += fittingPrice
|
||||
if fPrice, ok := mapFitting[*cart.FittingId]; ok {
|
||||
fittingPrice = fPrice
|
||||
} else {
|
||||
return errors.New(fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId))
|
||||
}
|
||||
}
|
||||
//单个购物车总价
|
||||
totalPrice := itemPrice * reqPurchaseQuantity
|
||||
//计算价格
|
||||
itemPrice, totalPrice, _, _, err := shopping_cart.CaculateCartPrice(reqPurchaseQuantity, &sizePrice, fittingPrice)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return err
|
||||
}
|
||||
calculateResultList = append(calculateResultList, types.CalculateResultItem{
|
||||
CartId: cart.Id,
|
||||
ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)),
|
||||
|
||||
@@ -7,17 +7,14 @@ import (
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/s3url_to_s3id"
|
||||
"fusenapi/utils/shopping_cart"
|
||||
"fusenapi/utils/step_price"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -116,29 +113,25 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
||||
if !ok {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("the size`s price info is not exists:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
//阶梯数量切片
|
||||
stepNum, err := format.StrSlicToIntSlice(strings.Split(*sizePrice.StepNum, ","))
|
||||
//如果有配件,单价也要加入配件价格
|
||||
fittingPrice := int64(0)
|
||||
if *cart.FittingId > 0 {
|
||||
if curFittingInfo, ok := mapModel[*cart.FittingId]; ok {
|
||||
fittingPrice = *curFittingInfo.Price
|
||||
} else {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId))
|
||||
}
|
||||
}
|
||||
//计算价格
|
||||
itemPrice, totalPrice, stepNum, _, err := shopping_cart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("failed to parse step number:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||
}
|
||||
lenStepNum := len(stepNum)
|
||||
//阶梯价格切片
|
||||
stepPrice, err := format.StrSlicToIntSlice(strings.Split(*sizePrice.StepPrice, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("failed to parse step price:%d_%d", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
lenStepPrice := len(stepPrice)
|
||||
if lenStepPrice == 0 || lenStepNum == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("step price or step number is not set:%d_%d ", *cart.ProductId, *cart.SizeId))
|
||||
}
|
||||
//购买箱数
|
||||
boxQuantity := int(math.Ceil(float64(*cart.PurchaseQuantity) / float64(*sizePrice.EachBoxNum)))
|
||||
//获取阶梯数量
|
||||
stepQuantityList := make([]int64, 0, 20)
|
||||
tmpMinBuyNum := *sizePrice.MinBuyNum
|
||||
for tmpMinBuyNum < (int64(stepNum[lenStepNum-1]) + 5) {
|
||||
for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) {
|
||||
//阶梯数
|
||||
tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum)
|
||||
stepQuantityList = append(stepQuantityList, tmpQuantity)
|
||||
@@ -148,19 +141,10 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
||||
if sizeInfo, ok := mapSize[*cart.SizeId]; ok {
|
||||
sizeCapacity = *sizeInfo.Capacity
|
||||
}
|
||||
//根据数量获取阶梯价格中对应的价格
|
||||
itemPrice := step_price.GetCentStepPrice(boxQuantity, stepNum, stepPrice)
|
||||
//如果有配件,单价也要加入配件价格
|
||||
if *cart.FittingId > 0 {
|
||||
if curFittingInfo, ok := mapModel[*cart.FittingId]; ok {
|
||||
itemPrice += *curFittingInfo.Price
|
||||
}
|
||||
}
|
||||
fittingName := snapShot.FittingInfo.FittingName
|
||||
if fittingInfo, ok := mapModel[*cart.FittingId]; ok {
|
||||
fittingName = *fittingInfo.Name
|
||||
}
|
||||
totalPrice := itemPrice * (*cart.PurchaseQuantity)
|
||||
productCover := "" //产品封面图
|
||||
productName := snapShot.ProductInfo.ProductName
|
||||
productSn := snapShot.ProductInfo.ProductSn
|
||||
@@ -174,6 +158,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
||||
}
|
||||
}
|
||||
item := types.CartItem{
|
||||
CartId: cart.Id,
|
||||
ProductInfo: types.ProductInfo{
|
||||
ProductId: *cart.ProductId,
|
||||
ProductName: productName,
|
||||
|
||||
@@ -39,6 +39,7 @@ type GetCartsRsp struct {
|
||||
}
|
||||
|
||||
type CartItem struct {
|
||||
CartId int64 `json:"cart_id"`
|
||||
ProductInfo ProductInfo `json:"product_info"` //产品信息
|
||||
SizeInfo SizeInfo `json:"size_info"` //尺寸信息
|
||||
FittingInfo FittingInfo `json:"fitting_info"` //配件信息
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"fusenapi/server/shopping-cart/internal/handler"
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -22,9 +21,8 @@ var configFile = flag.String("f", "etc/shopping-cart.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/upload.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -20,9 +19,8 @@ var configFile = flag.String("f", "etc/webset.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
||||
@@ -110,17 +110,8 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
//用户id赋值
|
||||
renderImageData.RenderData.UserId = w.userId
|
||||
renderImageData.RenderData.GuestId = w.guestId
|
||||
var (
|
||||
model3dInfo *gmodel.FsProductModel3d
|
||||
productTemplate *gmodel.FsProductTemplateV2
|
||||
productSize *gmodel.FsProductSize
|
||||
)
|
||||
//获取信息
|
||||
if renderImageData.RenderData.ProductSizeId > 0 {
|
||||
productSize, productTemplate, model3dInfo, err = w.getProductRelateionInfoWithSizeId(&renderImageData)
|
||||
} else {
|
||||
productSize, productTemplate, model3dInfo, err = w.getProductRelateionInfoWithNoSizeId(&renderImageData)
|
||||
}
|
||||
productSize, productTemplate, model3dInfo, err := w.getProductRelateionInfo(&renderImageData)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return
|
||||
@@ -190,11 +181,6 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
}
|
||||
//发送合图完毕阶段消息
|
||||
w.sendCombineImageStepResponseMessage(renderImageData.RenderId, combineImage, productSize.Id, model3dInfo.Id, productTemplate.Id, res.DiffTimeLogoCombine, res.DiffTimeUploadFile)
|
||||
//如果指定指定只返回刀版图
|
||||
if renderImageData.OnlyReturnCombineImage {
|
||||
logx.Info("云渲染传入only_return_combine_image = true则不走unity云渲染,只返回刀版图,render_id:", renderImageData.RenderId)
|
||||
return
|
||||
}
|
||||
//获取唯一id
|
||||
taskId := w.genRenderTaskId(combineImage, renderImageData, model3dInfo, productTemplate, element)
|
||||
//查询有没有缓存的资源,有就返回
|
||||
@@ -224,57 +210,8 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取模板相关信息(指定尺寸)(尺寸 -> 模型 ->模板)
|
||||
func (w *wsConnectItem) getProductRelateionInfoWithSizeId(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
||||
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOneByIdProductId(w.logic.ctx, renderImageData.RenderData.ProductSizeId, renderImageData.RenderData.ProductId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到产品的指定尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
||||
logx.Error("product size is not found")
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品的指定尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
||||
logx.Error("failed to get product size:", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
//获取模型
|
||||
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.GetOneBySizeIdTag(w.logic.ctx, productSize.Id, constants.TAG_MODEL)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "产品尺寸对应的模型不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, productSize.Id, 0)
|
||||
logx.Error("product model is not found")
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品尺寸对应的模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, productSize.Id, 0)
|
||||
logx.Error("failed to get product model:", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
//获取模板
|
||||
productTemplate, err = w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdModelIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, model3d.Id, renderImageData.RenderData.TemplateTag)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到对应的模板", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, model3d.Id, productSize.Id, 0)
|
||||
logx.Error("找不到对应的模板")
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应的模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, model3d.Id, productSize.Id, 0)
|
||||
logx.Error("获取对应的模板失败:", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
if *productTemplate.ElementModelId <= 0 {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "模板未开启云渲染", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, productSize.Id, 0)
|
||||
return nil, nil, nil, errors.New("模板未开启云渲染")
|
||||
}
|
||||
if productTemplate.TemplateInfo == nil || *productTemplate.TemplateInfo == "" {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "渲染模板的设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, productSize.Id, 0)
|
||||
return nil, nil, nil, errors.New("渲染模板的设计信息是空的")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取模板相关信息(不指定尺寸)
|
||||
func (w *wsConnectItem) getProductRelateionInfoWithNoSizeId(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
||||
//指定尺寸(尺寸 -> 模型 ->模板)
|
||||
// 获取模板相关信息
|
||||
func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
||||
//获取模板
|
||||
productTemplate, err = w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, renderImageData.RenderData.TemplateTag, "sort ASC")
|
||||
if err != nil {
|
||||
@@ -308,7 +245,6 @@ func (w *wsConnectItem) getProductRelateionInfoWithNoSizeId(renderImageData *web
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
|
||||
return nil, nil, nil, errors.New("获取对应尺寸失败")
|
||||
}
|
||||
renderImageData.RenderData.ProductSizeId = productSize.Id
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"fusenapi/server/websocket/internal/handler"
|
||||
"fusenapi/server/websocket/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -23,9 +22,8 @@ var configFile = flag.String("f", "etc/websocket.yaml", "the config file")
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user