27 lines
482 B
Go
27 lines
482 B
Go
package checkout
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
messages "git.k6n.net/go-cart-actor/proto/checkout"
|
|
)
|
|
|
|
func HandleConfirmationViewed(g *CheckoutGrain, m *messages.ConfirmationViewed) error {
|
|
if m == nil {
|
|
return fmt.Errorf("ConfirmationViewed: nil payload")
|
|
}
|
|
|
|
if g.Confirmation != nil {
|
|
g.Confirmation = &ConfirmationStatus{
|
|
ViewCount: 1,
|
|
LastViewedAt: time.Now(),
|
|
}
|
|
} else {
|
|
g.Confirmation.ViewCount++
|
|
g.Confirmation.LastViewedAt = time.Now()
|
|
}
|
|
|
|
return nil
|
|
}
|