update
Some checks failed
Build and Publish / BuildAndDeployAmd64 (push) Successful in 45s
Build and Publish / BuildAndDeployArm64 (push) Has been cancelled

This commit is contained in:
matst80
2025-11-20 22:37:01 +01:00
parent a01feb615b
commit c859796b1e
2 changed files with 41 additions and 28 deletions

View File

@@ -90,32 +90,37 @@ type Marking struct {
}
type CartGrain struct {
mu sync.RWMutex
lastItemId uint32
lastDeliveryId uint32
lastVoucherId uint32
lastAccess time.Time
lastChange time.Time // unix seconds of last successful mutation (replay sets from event ts)
userId string
InventoryReserved bool `json:"inventoryReserved"`
Id CartId `json:"id"`
Items []*CartItem `json:"items"`
TotalPrice *Price `json:"totalPrice"`
TotalDiscount *Price `json:"totalDiscount"`
Deliveries []*CartDelivery `json:"deliveries,omitempty"`
Processing bool `json:"processing"`
PaymentInProgress bool `json:"paymentInProgress"`
OrderReference string `json:"orderReference,omitempty"`
PaymentStatus string `json:"paymentStatus,omitempty"`
Vouchers []*Voucher `json:"vouchers,omitempty"`
Notifications []CartNotification `json:"cartNotification,omitempty"`
SubscriptionDetails map[string]*SubscriptionDetails `json:"subscriptionDetails,omitempty"`
PaymentDeclinedNotices []Notice `json:"paymentDeclinedNotices,omitempty"`
ConfirmationViewCount int `json:"confirmationViewCount,omitempty"`
ConfirmationLastViewedAt time.Time `json:"confirmationLastViewedAt,omitempty"`
CheckoutOrderId string `json:"checkoutOrderId,omitempty"`
CheckoutStatus string `json:"checkoutStatus,omitempty"`
CheckoutCountry string `json:"checkoutCountry,omitempty"`
mu sync.RWMutex
lastItemId uint32
lastDeliveryId uint32
lastVoucherId uint32
lastAccess time.Time
lastChange time.Time // unix seconds of last successful mutation (replay sets from event ts)
userId string
InventoryReserved bool `json:"inventoryReserved"`
Id CartId `json:"id"`
Items []*CartItem `json:"items"`
TotalPrice *Price `json:"totalPrice"`
TotalDiscount *Price `json:"totalDiscount"`
Deliveries []*CartDelivery `json:"deliveries,omitempty"`
Processing bool `json:"processing"`
PaymentInProgress bool `json:"paymentInProgress"`
OrderReference string `json:"orderReference,omitempty"`
PaymentStatus string `json:"paymentStatus,omitempty"`
Vouchers []*Voucher `json:"vouchers,omitempty"`
Notifications []CartNotification `json:"cartNotification,omitempty"`
SubscriptionDetails map[string]*SubscriptionDetails `json:"subscriptionDetails,omitempty"`
PaymentDeclinedNotices []Notice `json:"paymentDeclinedNotices,omitempty"`
Confirmation *ConfirmationStatus `json:"confirmation,omitempty"`
CheckoutOrderId string `json:"checkoutOrderId,omitempty"`
CheckoutStatus string `json:"checkoutStatus,omitempty"`
CheckoutCountry string `json:"checkoutCountry,omitempty"`
}
type ConfirmationStatus struct {
Code *string `json:"code,omitempty"`
ViewCount int `json:"viewCount"`
LastViewedAt time.Time `json:"lastViewedAt"`
}
type Voucher struct {

View File

@@ -7,7 +7,15 @@ import (
)
func ConfirmationViewed(grain *CartGrain, req *messages.ConfirmationViewed) error {
grain.ConfirmationViewCount++
grain.ConfirmationLastViewedAt = time.Now()
if grain.Confirmation == nil {
grain.Confirmation = &ConfirmationStatus{
ViewCount: 1,
LastViewedAt: time.Now(),
}
} else {
grain.Confirmation.ViewCount++
grain.Confirmation.LastViewedAt = time.Now()
}
return nil
}