Complete refactor to new grpc control plane and only http proxy for carts #4

Merged
mats merged 75 commits from refactor/http-proxy into main 2025-10-14 22:31:28 +02:00
2 changed files with 18 additions and 19 deletions
Showing only changes of commit 4bec3f8cc0 - Show all commits

View File

@@ -16,12 +16,6 @@ import (
type StockStatus int
const (
OutOfStock StockStatus = 0
LowStock StockStatus = 1
InStock StockStatus = 2
)
type ItemMeta struct {
Name string `json:"name"`
Brand string `json:"brand,omitempty"`

View File

@@ -40,22 +40,27 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
if err != nil {
return nil, err
}
return ToItemAddMessage(item, storeId, qty, country), nil
}
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) *messages.AddItem {
orgPrice, _ := getInt(item.GetNumberFieldValue(5)) // getInt(item.Fields[5])
price, priceErr := getInt(item.GetNumberFieldValue(4)) //Fields[4]
if priceErr != nil {
return nil, fmt.Errorf("invalid price")
price, err := getInt(item.GetNumberFieldValue(4)) //Fields[4]
if err != nil {
return nil
}
stock := InStock
item.HasStock()
stockValue, ok := item.GetNumberFieldValue(3)
if !ok || stockValue == 0 {
stock = OutOfStock
stock := StockStatus(0)
centralStockValue, ok := item.GetNumberFieldValue(3)
if storeId == nil {
if ok {
stock = StockStatus(centralStockValue)
}
} else {
if stockValue < 5 {
stock = LowStock
storeStock, ok := item.Stock.GetStock()[*storeId]
if ok {
stock = StockStatus(storeStock)
}
}
@@ -80,7 +85,7 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
Quantity: int32(qty),
Price: int64(price),
OrgPrice: int64(orgPrice),
Sku: sku,
Sku: item.GetSku(),
Name: item.Title,
Image: item.Img,
Stock: int32(stock),
@@ -98,7 +103,7 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
Country: country,
Outlet: outlet,
StoreId: storeId,
}, nil
}
}
func getTax(articleType string) int32 {