fix:算法请求调整

This commit is contained in:
momo 2023-10-10 17:17:28 +08:00
parent 21475d7d52
commit fec42ad634
20 changed files with 98 additions and 99 deletions

View File

@ -17,17 +17,16 @@ type Repositories struct {
type NewAllRepositorieData struct { type NewAllRepositorieData struct {
GormDB *gorm.DB GormDB *gorm.DB
BLMServiceUrl *string BLMServiceUrls []string
BLMServicePorts []string
AwsSession *session.Session AwsSession *session.Session
DelayQueue *queue.DelayMessage DelayQueue *queue.DelayMessage
} }
func NewAllRepositories(newData *NewAllRepositorieData) *Repositories { func NewAllRepositories(newData *NewAllRepositorieData) *Repositories {
return &Repositories{ return &Repositories{
ImageHandle: repositories.NewImageHandle(newData.GormDB, newData.BLMServiceUrl, newData.BLMServicePorts, newData.AwsSession), ImageHandle: repositories.NewImageHandle(newData.GormDB, newData.BLMServiceUrls, newData.AwsSession),
NewShoppingCart: repositories.NewShoppingCart(newData.GormDB, newData.BLMServiceUrl, newData.AwsSession), NewShoppingCart: repositories.NewShoppingCart(newData.GormDB, newData.BLMServiceUrls, newData.AwsSession),
NewResource: repositories.NewResource(newData.GormDB, newData.BLMServiceUrl, newData.AwsSession), NewResource: repositories.NewResource(newData.GormDB, newData.BLMServiceUrls, newData.AwsSession),
NewOrder: repositories.NewOrder(newData.GormDB, newData.BLMServiceUrl, newData.AwsSession, newData.DelayQueue), NewOrder: repositories.NewOrder(newData.GormDB, newData.AwsSession, newData.DelayQueue),
} }
} }

View File

@ -156,7 +156,10 @@ type OrderProductInter struct {
FittingInfo *OrderProductFittingInfo `json:"fitting_info"` FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
IsHighlyCustomized int64 `json:"is_highly_customized"` IsHighlyCustomized int64 `json:"is_highly_customized"`
RenderImage string `json:"render_image"` RenderImage string `json:"render_image"`
ExpectedDeliveryTime ExpectedDelivery `json:"expected_delivery_time"` // 预计到货时间
ActualDeliveryTime ExpectedDelivery `json:"actual_delivery_time"` // 实际到货时间
} }
type OrderMetadata struct { type OrderMetadata struct {
ExpectedDeliveryTime ExpectedDelivery `json:"expected_delivery_time"` // 预计到货时间 ExpectedDeliveryTime ExpectedDelivery `json:"expected_delivery_time"` // 预计到货时间
ActualDeliveryTime ExpectedDelivery `json:"actual_delivery_time"` // 实际到货时间
} }

View File

@ -36,9 +36,7 @@ type Config struct {
} }
} }
BLMService struct { BLMService struct {
Url string Version string
LogoCombine struct { Urls []string
Url string
}
} }
} }

View File

@ -39,7 +39,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: initalize.InitMysql(c.SourceMysql), GormDB: initalize.InitMysql(c.SourceMysql),
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -21,9 +21,7 @@ type Config struct {
} }
} }
BLMService struct { BLMService struct {
Url string Version string
LogoCombine struct { Urls []string
Url string
}
} }
} }

View File

@ -5,10 +5,11 @@ import (
"fmt" "fmt"
"fusenapi/server/product-template-tag/internal/config" "fusenapi/server/product-template-tag/internal/config"
"fusenapi/shared" "fusenapi/shared"
"net/http"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"net/http"
"fusenapi/initalize" "fusenapi/initalize"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
@ -39,7 +40,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn, GormDB: conn,
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -21,10 +21,8 @@ type Config struct {
} }
} }
BLMService struct { BLMService struct {
Url string Version string
LogoCombine struct { Urls []string
Url string
}
} }
Unity struct { Unity struct {
Host string Host string

View File

@ -5,10 +5,11 @@ import (
"fmt" "fmt"
"fusenapi/server/product/internal/config" "fusenapi/server/product/internal/config"
"fusenapi/shared" "fusenapi/shared"
"net/http"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"net/http"
"fusenapi/initalize" "fusenapi/initalize"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
@ -40,7 +41,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn, GormDB: conn,
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -22,7 +22,6 @@ type Config struct {
} }
BLMService struct { BLMService struct {
Version string Version string
Url string Urls []string
Ports []string
} }
} }

View File

@ -43,8 +43,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: initalize.InitMysql(c.SourceMysql), GormDB: initalize.InitMysql(c.SourceMysql),
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
BLMServicePorts: c.BLMService.Ports,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
Tracing: middleware.NewTracingMiddleware().Handle, Tracing: middleware.NewTracingMiddleware().Handle,

View File

@ -2,6 +2,7 @@ package config
import ( import (
"fusenapi/server/shopping-cart/internal/types" "fusenapi/server/shopping-cart/internal/types"
"github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/rest"
) )
@ -20,10 +21,8 @@ type Config struct {
} }
} }
BLMService struct { BLMService struct {
Url string Version string
LogoCombine struct { Urls []string
Url string
}
} }
Unity struct { Unity struct {
Host string Host string

View File

@ -4,6 +4,7 @@ import (
"fusenapi/initalize" "fusenapi/initalize"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
"fusenapi/server/shopping-cart/internal/config" "fusenapi/server/shopping-cart/internal/config"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
@ -32,7 +33,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn, GormDB: conn,
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -23,7 +23,6 @@ type Config struct {
} }
BLMService struct { BLMService struct {
Version string Version string
Url string Urls []string
Ports []string
} }
} }

View File

@ -42,8 +42,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: initalize.InitMysql(c.SourceMysql), GormDB: initalize.InitMysql(c.SourceMysql),
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
BLMServicePorts: c.BLMService.Ports,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -22,10 +22,8 @@ type Config struct {
} }
} }
BLMService struct { BLMService struct {
Url string Version string
LogoCombine struct { Urls []string
Url string
}
} }
Unity struct { Unity struct {
Host string Host string

View File

@ -42,7 +42,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn, GormDB: conn,
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrls: c.BLMService.Urls,
AwsSession: session.Must(session.NewSession(&config)), AwsSession: session.Must(session.NewSession(&config)),
}), }),
} }

View File

@ -21,11 +21,10 @@ import (
var globalBLMServiceIndex int var globalBLMServiceIndex int
func NewImageHandle(gormDB *gorm.DB, bLMServiceUrl *string, bLMServicePorts []string, awsSession *session.Session) ImageHandle { func NewImageHandle(gormDB *gorm.DB, bLMServiceUrls []string, awsSession *session.Session) ImageHandle {
return &defaultImageHandle{ return &defaultImageHandle{
MysqlConn: gormDB, MysqlConn: gormDB,
BLMServiceUrl: bLMServiceUrl, BLMServiceUrls: bLMServiceUrls,
BLMServicePorts: bLMServicePorts,
AwsSession: awsSession, AwsSession: awsSession,
} }
} }
@ -33,8 +32,7 @@ func NewImageHandle(gormDB *gorm.DB, bLMServiceUrl *string, bLMServicePorts []st
type ( type (
defaultImageHandle struct { defaultImageHandle struct {
MysqlConn *gorm.DB MysqlConn *gorm.DB
BLMServiceUrl *string BLMServiceUrls []string
BLMServicePorts []string
AwsSession *session.Session AwsSession *session.Session
} }
@ -174,8 +172,8 @@ type (
func (l *defaultImageHandle) LogoInfoSet(ctx context.Context, in *LogoInfoSetReq) (*LogoInfoSetRes, error) { func (l *defaultImageHandle) LogoInfoSet(ctx context.Context, in *LogoInfoSetReq) (*LogoInfoSetRes, error) {
fmt.Println("算法请求轮训下标:", globalBLMServiceIndex) fmt.Println("算法请求轮训下标:", globalBLMServiceIndex)
var bLMServicePort = l.BLMServicePorts[globalBLMServiceIndex] var bLMServicePort = l.BLMServiceUrls[globalBLMServiceIndex]
if len(l.BLMServicePorts) == (globalBLMServiceIndex + 1) { if len(l.BLMServiceUrls) == (globalBLMServiceIndex + 1) {
globalBLMServiceIndex = 0 globalBLMServiceIndex = 0
} else { } else {
globalBLMServiceIndex = globalBLMServiceIndex + 1 globalBLMServiceIndex = globalBLMServiceIndex + 1
@ -328,8 +326,8 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
postMap["param_data"] = combineParam postMap["param_data"] = combineParam
fmt.Println("算法请求轮训下标:", globalBLMServiceIndex) fmt.Println("算法请求轮训下标:", globalBLMServiceIndex)
var bLMServicePort = l.BLMServicePorts[globalBLMServiceIndex] var bLMServicePort = l.BLMServiceUrls[globalBLMServiceIndex]
if len(l.BLMServicePorts) == (globalBLMServiceIndex + 1) { if len(l.BLMServiceUrls) == (globalBLMServiceIndex + 1) {
globalBLMServiceIndex = 0 globalBLMServiceIndex = 0
} else { } else {
globalBLMServiceIndex = globalBLMServiceIndex + 1 globalBLMServiceIndex = globalBLMServiceIndex + 1
@ -473,8 +471,8 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR
postMap["proportion"] = in.Proportion postMap["proportion"] = in.Proportion
fmt.Println("算法请求轮训下标:", globalBLMServiceIndex) fmt.Println("算法请求轮训下标:", globalBLMServiceIndex)
var bLMServicePort = l.BLMServicePorts[globalBLMServiceIndex] var bLMServicePort = l.BLMServiceUrls[globalBLMServiceIndex]
if len(l.BLMServicePorts) == (globalBLMServiceIndex + 1) { if len(l.BLMServiceUrls) == (globalBLMServiceIndex + 1) {
globalBLMServiceIndex = 0 globalBLMServiceIndex = 0
} else { } else {
globalBLMServiceIndex = globalBLMServiceIndex + 1 globalBLMServiceIndex = globalBLMServiceIndex + 1

View File

@ -21,7 +21,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
func NewOrder(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session.Session, delayQueue *queue.DelayMessage) Order { func NewOrder(gormDB *gorm.DB, awsSession *session.Session, delayQueue *queue.DelayMessage) Order {
return &defaultOrder{ return &defaultOrder{
MysqlConn: gormDB, MysqlConn: gormDB,
DelayQueue: delayQueue, DelayQueue: delayQueue,
@ -1099,6 +1099,14 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
Name: in.DeliveryAddress.Name, Name: in.DeliveryAddress.Name,
} }
} }
// 预计交付时间
var expectedDeliveryTime = gmodel.ExpectedDelivery{
Current: in.ExpectedDeliveryTime,
Initiate: in.ExpectedDeliveryTime,
}
// 实际交付时间
var actualDeliveryTime gmodel.ExpectedDelivery
for _, shoppingCart := range shoppingCartList { for _, shoppingCart := range shoppingCartList {
// 购物车快照 // 购物车快照
@ -1189,6 +1197,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized, IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
RenderImage: shoppingCartSnapshot.RenderImage, RenderImage: shoppingCartSnapshot.RenderImage,
CartId: shoppingCart.Id, CartId: shoppingCart.Id,
ExpectedDeliveryTime: expectedDeliveryTime,
ActualDeliveryTime: actualDeliveryTime,
} }
orderProductList = append(orderProductList, &productInter) orderProductList = append(orderProductList, &productInter)
shoppingProductSnapshotList = append(shoppingProductSnapshotList, shoppingCart.ShoppingCartProduct) shoppingProductSnapshotList = append(shoppingProductSnapshotList, shoppingCart.ShoppingCartProduct)
@ -1268,10 +1278,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
byteShoppingProductSnapshot, _ := json.Marshal(shoppingProductSnapshotList) byteShoppingProductSnapshot, _ := json.Marshal(shoppingProductSnapshotList)
byteStatusLink, _ := json.Marshal(statusLink) byteStatusLink, _ := json.Marshal(statusLink)
byteOrderMetadata, _ := json.Marshal(gmodel.OrderMetadata{ byteOrderMetadata, _ := json.Marshal(gmodel.OrderMetadata{
ExpectedDeliveryTime: gmodel.ExpectedDelivery{ ExpectedDeliveryTime: expectedDeliveryTime,
Current: in.ExpectedDeliveryTime, ActualDeliveryTime: actualDeliveryTime,
Initiate: in.ExpectedDeliveryTime,
},
}) })
// 创建订单 // 创建订单
@ -1527,14 +1535,15 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
orderProductItem := gmodel.OrderProduct{ orderProductItem := gmodel.OrderProduct{
TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice), TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice),
ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice), ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice),
ExpectedDeliveryTime: &expectedTime,
PurchaseQuantity: *productValue.PurchaseQuantity,
ProductId: productValue.ProductId, ProductId: productValue.ProductId,
ProductSn: productValue.ProductSn, ProductSn: productValue.ProductSn,
ProductName: productValue.ProductName, ProductName: productValue.ProductName,
ProductCover: productValue.ProductCover, ProductCover: productValue.ProductCover,
ProductCoverMetadata: productValue.ProductCoverMetadata, ProductCoverMetadata: productValue.ProductCoverMetadata,
ShoppingCartSnapshot: &shoppingCartSnapshotData, ShoppingCartSnapshot: &shoppingCartSnapshotData,
ExpectedDeliveryTime: &productValue.ExpectedDeliveryTime.Current,
PurchaseQuantity: *productValue.PurchaseQuantity,
DiyInformation: productValue.DiyInformation, DiyInformation: productValue.DiyInformation,
SizeInfo: productValue.SizeInfo, SizeInfo: productValue.SizeInfo,

View File

@ -10,10 +10,10 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
func NewResource(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session.Session) Resource { func NewResource(gormDB *gorm.DB, bLMServiceUrls []string, awsSession *session.Session) Resource {
return &defaultResource{ return &defaultResource{
MysqlConn: gormDB, MysqlConn: gormDB,
BLMServiceUrl: bLMServiceUrl, BLMServiceUrls: bLMServiceUrls,
AwsSession: awsSession, AwsSession: awsSession,
} }
} }
@ -21,7 +21,7 @@ func NewResource(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session.Ses
type ( type (
defaultResource struct { defaultResource struct {
MysqlConn *gorm.DB MysqlConn *gorm.DB
BLMServiceUrl *string BLMServiceUrls []string
AwsSession *session.Session AwsSession *session.Session
} }
Resource interface { Resource interface {

View File

@ -11,10 +11,10 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
func NewShoppingCart(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session.Session) ShoppingCart { func NewShoppingCart(gormDB *gorm.DB, bLMServiceUrls []string, awsSession *session.Session) ShoppingCart {
return &defaultShoppingCart{ return &defaultShoppingCart{
MysqlConn: gormDB, MysqlConn: gormDB,
BLMServiceUrl: bLMServiceUrl, BLMServiceUrls: bLMServiceUrls,
AwsSession: awsSession, AwsSession: awsSession,
} }
} }
@ -22,7 +22,7 @@ func NewShoppingCart(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session
type ( type (
defaultShoppingCart struct { defaultShoppingCart struct {
MysqlConn *gorm.DB MysqlConn *gorm.DB
BLMServiceUrl *string BLMServiceUrls []string
AwsSession *session.Session AwsSession *session.Session
} }
ShoppingCart interface { ShoppingCart interface {