more
This commit is contained in:
@@ -87,24 +87,25 @@ type ConfirmationStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CheckoutGrain struct {
|
type CheckoutGrain struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
lastDeliveryId uint32
|
lastDeliveryId uint32
|
||||||
lastGiftcardId uint32
|
lastGiftcardId uint32
|
||||||
lastAccess time.Time
|
lastAccess time.Time
|
||||||
lastChange time.Time
|
lastChange time.Time
|
||||||
Version uint32 `json:"version"`
|
Version uint32 `json:"version"`
|
||||||
Id CheckoutId `json:"id"`
|
Id CheckoutId `json:"id"`
|
||||||
CartId cart.CartId `json:"cartId"`
|
CartId cart.CartId `json:"cartId"`
|
||||||
CartVersion uint64 `json:"cartVersion"`
|
CartVersion uint64 `json:"cartVersion"`
|
||||||
CartState *cart.CartGrain `json:"cartState"` // snapshot of items
|
CartState *cart.CartGrain `json:"cartState"` // snapshot of items
|
||||||
CartTotalPrice *cart.Price `json:"cartTotalPrice"`
|
CartTotalPrice *cart.Price `json:"cartTotalPrice"`
|
||||||
OrderId *string `json:"orderId"`
|
OrderId *string `json:"orderId"`
|
||||||
Deliveries []*CheckoutDelivery `json:"deliveries,omitempty"`
|
Deliveries []*CheckoutDelivery `json:"deliveries,omitempty"`
|
||||||
PaymentInProgress uint16 `json:"paymentInProgress"`
|
PaymentInProgress uint16 `json:"paymentInProgress"`
|
||||||
InventoryReserved bool `json:"inventoryReserved"`
|
AmountInCentsRemaining int64 `json:"amountRemaining"`
|
||||||
Confirmation *ConfirmationStatus `json:"confirmationViewed,omitempty"`
|
InventoryReserved bool `json:"inventoryReserved"`
|
||||||
Payments []*Payment `json:"payments,omitempty"`
|
Confirmation *ConfirmationStatus `json:"confirmationViewed,omitempty"`
|
||||||
ContactDetails *ContactDetails `json:"contactDetails,omitempty"`
|
Payments []*Payment `json:"payments,omitempty"`
|
||||||
|
ContactDetails *ContactDetails `json:"contactDetails,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCheckoutGrain(id uint64, cartId cart.CartId, cartVersion uint64, ts time.Time, cartState *cart.CartGrain) *CheckoutGrain {
|
func NewCheckoutGrain(id uint64, cartId cart.CartId, cartVersion uint64, ts time.Time, cartState *cart.CartGrain) *CheckoutGrain {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func HandleInitializeCheckout(g *CheckoutGrain, m *messages.InitializeCheckout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.CartTotalPrice = g.CartState.TotalPrice
|
g.CartTotalPrice = g.CartState.TotalPrice
|
||||||
|
g.AmountInCentsRemaining = g.CartTotalPrice.IncVat
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ func HandlePaymentCompleted(g *CheckoutGrain, m *messages.PaymentCompleted) erro
|
|||||||
|
|
||||||
// Update checkout status
|
// Update checkout status
|
||||||
g.PaymentInProgress--
|
g.PaymentInProgress--
|
||||||
|
sum := g.CartState.TotalPrice.IncVat
|
||||||
|
|
||||||
|
for _, payment := range g.SettledPayments() {
|
||||||
|
sum -= payment.Amount
|
||||||
|
}
|
||||||
|
g.AmountInCentsRemaining = sum
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user