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

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

View File

@@ -21,7 +21,7 @@ import (
"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{
MysqlConn: gormDB,
DelayQueue: delayQueue,
@@ -1099,6 +1099,14 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
Name: in.DeliveryAddress.Name,
}
}
// 预计交付时间
var expectedDeliveryTime = gmodel.ExpectedDelivery{
Current: in.ExpectedDeliveryTime,
Initiate: in.ExpectedDeliveryTime,
}
// 实际交付时间
var actualDeliveryTime gmodel.ExpectedDelivery
for _, shoppingCart := range shoppingCartList {
// 购物车快照
@@ -1186,9 +1194,11 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
Cm: shoppingCartSnapshot.SizeInfo.Cm,
},
},
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
RenderImage: shoppingCartSnapshot.RenderImage,
CartId: shoppingCart.Id,
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
RenderImage: shoppingCartSnapshot.RenderImage,
CartId: shoppingCart.Id,
ExpectedDeliveryTime: expectedDeliveryTime,
ActualDeliveryTime: actualDeliveryTime,
}
orderProductList = append(orderProductList, &productInter)
shoppingProductSnapshotList = append(shoppingProductSnapshotList, shoppingCart.ShoppingCartProduct)
@@ -1268,10 +1278,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
byteShoppingProductSnapshot, _ := json.Marshal(shoppingProductSnapshotList)
byteStatusLink, _ := json.Marshal(statusLink)
byteOrderMetadata, _ := json.Marshal(gmodel.OrderMetadata{
ExpectedDeliveryTime: gmodel.ExpectedDelivery{
Current: in.ExpectedDeliveryTime,
Initiate: in.ExpectedDeliveryTime,
},
ExpectedDeliveryTime: expectedDeliveryTime,
ActualDeliveryTime: actualDeliveryTime,
})
// 创建订单
@@ -1525,16 +1533,17 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
}
orderProductItem := gmodel.OrderProduct{
TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice),
ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice),
ExpectedDeliveryTime: &expectedTime,
PurchaseQuantity: *productValue.PurchaseQuantity,
TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice),
ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice),
ProductId: productValue.ProductId,
ProductSn: productValue.ProductSn,
ProductName: productValue.ProductName,
ProductCover: productValue.ProductCover,
ProductCoverMetadata: productValue.ProductCoverMetadata,
ShoppingCartSnapshot: &shoppingCartSnapshotData,
ExpectedDeliveryTime: &productValue.ExpectedDeliveryTime.Current,
PurchaseQuantity: *productValue.PurchaseQuantity,
DiyInformation: productValue.DiyInformation,
SizeInfo: productValue.SizeInfo,

View File

@@ -10,19 +10,19 @@ import (
"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{
MysqlConn: gormDB,
BLMServiceUrl: bLMServiceUrl,
AwsSession: awsSession,
MysqlConn: gormDB,
BLMServiceUrls: bLMServiceUrls,
AwsSession: awsSession,
}
}
type (
defaultResource struct {
MysqlConn *gorm.DB
BLMServiceUrl *string
AwsSession *session.Session
MysqlConn *gorm.DB
BLMServiceUrls []string
AwsSession *session.Session
}
Resource interface {
// 更新metadata

View File

@@ -11,19 +11,19 @@ import (
"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{
MysqlConn: gormDB,
BLMServiceUrl: bLMServiceUrl,
AwsSession: awsSession,
MysqlConn: gormDB,
BLMServiceUrls: bLMServiceUrls,
AwsSession: awsSession,
}
}
type (
defaultShoppingCart struct {
MysqlConn *gorm.DB
BLMServiceUrl *string
AwsSession *session.Session
MysqlConn *gorm.DB
BLMServiceUrls []string
AwsSession *session.Session
}
ShoppingCart interface {
// 校验订单