feature/pubsub #7
@@ -5,8 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.tornberg.me/go-cart-actor/pkg/cart"
|
||||
messages "git.tornberg.me/go-cart-actor/pkg/messages"
|
||||
@@ -61,27 +59,27 @@ func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country st
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stk := item.GetStock()
|
||||
stock := cart.StockStatus(0)
|
||||
centralStockValue, ok := item.GetStringFieldValue(3)
|
||||
|
||||
if storeId == nil {
|
||||
centralStock, ok := stk[country]
|
||||
if ok {
|
||||
if !item.Buyable {
|
||||
return nil, fmt.Errorf("item not available")
|
||||
}
|
||||
pureNumber := strings.Replace(centralStockValue, "+", "", -1)
|
||||
if centralStock, err := strconv.ParseInt(pureNumber, 10, 64); err == nil {
|
||||
stock = cart.StockStatus(centralStock)
|
||||
}
|
||||
if stock == cart.StockStatus(0) && item.SaleStatus == "TBD" {
|
||||
|
||||
if centralStock == 0 && item.SaleStatus == "TBD" {
|
||||
return nil, fmt.Errorf("no items available")
|
||||
}
|
||||
stock = cart.StockStatus(centralStock)
|
||||
}
|
||||
|
||||
} else {
|
||||
if !item.BuyableInStore {
|
||||
return nil, fmt.Errorf("item not available in store")
|
||||
}
|
||||
storeStock, ok := item.Stock.GetStock()[*storeId]
|
||||
storeStock, ok := stk[*storeId]
|
||||
if ok {
|
||||
stock = cart.StockStatus(storeStock)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func UpsertSubscriptionDetails(g *CartGrain, m *messages.UpsertSubscriptionDetai
|
||||
if !ok {
|
||||
n := &SubscriptionDetails{
|
||||
Id: *m.Id,
|
||||
Version: 1,
|
||||
Version: 0,
|
||||
}
|
||||
g.SubscriptionDetails[*m.Id] = n
|
||||
existing = n
|
||||
|
||||
Reference in New Issue
Block a user