fix
This commit is contained in:
@@ -10,4 +10,22 @@ type Config struct {
|
||||
SourceMysql string
|
||||
Auth types.Auth
|
||||
SourceRabbitMq string
|
||||
AWS struct {
|
||||
S3 struct {
|
||||
Credentials struct {
|
||||
AccessKeyID string
|
||||
Secret string
|
||||
Token string
|
||||
}
|
||||
}
|
||||
}
|
||||
BLMService struct {
|
||||
Url string
|
||||
LogoCombine struct {
|
||||
Url string
|
||||
}
|
||||
}
|
||||
Unity struct {
|
||||
Host string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
||||
}
|
||||
}
|
||||
//计算价格
|
||||
itemPrice, totalPrice, _, _, err := shopping_cart.CaculateCartPrice(reqPurchaseQuantity, &sizePrice, fittingPrice)
|
||||
itemPrice, totalPrice, _, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(reqPurchaseQuantity, &sizePrice, fittingPrice)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return err
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
"fusenapi/service/repositories"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
@@ -90,9 +91,9 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
||||
}
|
||||
//定义map收集变更信息
|
||||
mapCartChange := make(map[int64]string)
|
||||
mapSnapshot := make(map[int64]shopping_cart.CartSnapshot)
|
||||
mapSnapshot := make(map[int64]gmodel.CartSnapshot)
|
||||
//校验购物车数据是否变更
|
||||
err = shopping_cart.VerifyShoppingCartSnapshotDataChange(shopping_cart.VerifyShoppingCartSnapshotDataChangeReq{
|
||||
err = l.svcCtx.Repositories.NewShoppingCart.VerifyShoppingCartSnapshotDataChange(repositories.VerifyShoppingCartSnapshotDataChangeReq{
|
||||
Carts: carts,
|
||||
MapSize: mapSize,
|
||||
MapModel: mapModel,
|
||||
@@ -123,7 +124,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
||||
}
|
||||
}
|
||||
//计算价格
|
||||
itemPrice, totalPrice, stepNum, _, err := shopping_cart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice)
|
||||
itemPrice, totalPrice, stepNum, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||
|
||||
@@ -4,23 +4,34 @@ import (
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart/internal/config"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
Config config.Config
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
Repositories *initalize.Repositories
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
|
||||
config := aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token),
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: conn,
|
||||
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
||||
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
|
||||
GormDB: conn,
|
||||
BLMServiceUrl: &c.BLMService.Url,
|
||||
AwsSession: session.Must(session.NewSession(&config)),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user