update
This commit is contained in:
@@ -26,7 +26,7 @@ func (NoopTracer) Trace(string, map[string]any) {}
|
||||
// for the purpose of promotion condition evaluation.
|
||||
type PromotionItem struct {
|
||||
SKU string
|
||||
Quantity int
|
||||
Quantity uint16
|
||||
Category string
|
||||
PriceIncVat int64
|
||||
}
|
||||
@@ -36,7 +36,7 @@ type PromotionItem struct {
|
||||
// customer/order metadata.
|
||||
type PromotionEvalContext struct {
|
||||
CartTotalIncVat int64
|
||||
TotalItemQuantity int
|
||||
TotalItemQuantity uint32
|
||||
Items []PromotionItem
|
||||
CustomerSegment string
|
||||
CustomerLifetimeValue float64
|
||||
@@ -89,7 +89,7 @@ func NewContextFromCart(g *cart.CartGrain, opts ...ContextOption) *PromotionEval
|
||||
Category: strings.ToLower(category),
|
||||
PriceIncVat: it.Price.IncVat,
|
||||
})
|
||||
ctx.TotalItemQuantity += it.Quantity
|
||||
ctx.TotalItemQuantity += uint32(it.Quantity)
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(ctx)
|
||||
|
||||
@@ -58,7 +58,7 @@ func (t *testTracer) Count(name string) int {
|
||||
func makeCart(totalOverride int64, items []struct {
|
||||
sku string
|
||||
category string
|
||||
qty int
|
||||
qty uint16
|
||||
priceInc int64
|
||||
}) *cart.CartGrain {
|
||||
g := cart.NewCartGrain(1, time.Now())
|
||||
@@ -92,7 +92,7 @@ func TestEvaluateRuleBasicAND(t *testing.T) {
|
||||
g := makeCart(12000, []struct {
|
||||
sku string
|
||||
category string
|
||||
qty int
|
||||
qty uint16
|
||||
priceInc int64
|
||||
}{
|
||||
{"SKU-1", "summer", 2, 3000},
|
||||
@@ -226,7 +226,7 @@ func TestEvaluateProductCategoryIN(t *testing.T) {
|
||||
g := makeCart(-1, []struct {
|
||||
sku string
|
||||
category string
|
||||
qty int
|
||||
qty uint16
|
||||
priceInc int64
|
||||
}{
|
||||
{"A", "shoes", 1, 5000},
|
||||
@@ -268,7 +268,7 @@ func TestEvaluateGroupOR(t *testing.T) {
|
||||
g := makeCart(3000, []struct {
|
||||
sku string
|
||||
category string
|
||||
qty int
|
||||
qty uint16
|
||||
priceInc int64
|
||||
}{
|
||||
{"ONE", "x", 1, 3000},
|
||||
|
||||
Reference in New Issue
Block a user