check storestock
This commit is contained in:
@@ -16,12 +16,6 @@ import (
|
|||||||
|
|
||||||
type StockStatus int
|
type StockStatus int
|
||||||
|
|
||||||
const (
|
|
||||||
OutOfStock StockStatus = 0
|
|
||||||
LowStock StockStatus = 1
|
|
||||||
InStock StockStatus = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
type ItemMeta struct {
|
type ItemMeta struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Brand string `json:"brand,omitempty"`
|
Brand string `json:"brand,omitempty"`
|
||||||
|
|||||||
@@ -40,22 +40,27 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
orgPrice, _ := getInt(item.GetNumberFieldValue(5)) // getInt(item.Fields[5])
|
return ToItemAddMessage(item, storeId, qty, country), nil
|
||||||
|
|
||||||
price, priceErr := getInt(item.GetNumberFieldValue(4)) //Fields[4]
|
|
||||||
|
|
||||||
if priceErr != nil {
|
|
||||||
return nil, fmt.Errorf("invalid price")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stock := InStock
|
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) *messages.AddItem {
|
||||||
item.HasStock()
|
orgPrice, _ := getInt(item.GetNumberFieldValue(5)) // getInt(item.Fields[5])
|
||||||
stockValue, ok := item.GetNumberFieldValue(3)
|
|
||||||
if !ok || stockValue == 0 {
|
price, err := getInt(item.GetNumberFieldValue(4)) //Fields[4]
|
||||||
stock = OutOfStock
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
stock := StockStatus(0)
|
||||||
|
centralStockValue, ok := item.GetNumberFieldValue(3)
|
||||||
|
if storeId == nil {
|
||||||
|
if ok {
|
||||||
|
stock = StockStatus(centralStockValue)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if stockValue < 5 {
|
storeStock, ok := item.Stock.GetStock()[*storeId]
|
||||||
stock = LowStock
|
if ok {
|
||||||
|
stock = StockStatus(storeStock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +85,7 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
|
|||||||
Quantity: int32(qty),
|
Quantity: int32(qty),
|
||||||
Price: int64(price),
|
Price: int64(price),
|
||||||
OrgPrice: int64(orgPrice),
|
OrgPrice: int64(orgPrice),
|
||||||
Sku: sku,
|
Sku: item.GetSku(),
|
||||||
Name: item.Title,
|
Name: item.Title,
|
||||||
Image: item.Img,
|
Image: item.Img,
|
||||||
Stock: int32(stock),
|
Stock: int32(stock),
|
||||||
@@ -98,7 +103,7 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
|
|||||||
Country: country,
|
Country: country,
|
||||||
Outlet: outlet,
|
Outlet: outlet,
|
||||||
StoreId: storeId,
|
StoreId: storeId,
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTax(articleType string) int32 {
|
func getTax(articleType string) int32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user