update stuff
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m52s

This commit is contained in:
matst80
2024-11-10 23:05:24 +01:00
parent d01b6675b4
commit c5bc17c44d
6 changed files with 38 additions and 24 deletions

View File

@@ -43,10 +43,10 @@ type CartGrain struct {
lastItemId int
lastDeliveryId int
storageMessages []Message
Id CartId `json:"id"`
Items []CartItem `json:"items"`
TotalPrice int64 `json:"totalPrice"`
Deliveries []string `json:"deliveries,omitempty"`
Id CartId `json:"id"`
Items []*CartItem `json:"items"`
TotalPrice int64 `json:"totalPrice"`
Deliveries []string `json:"deliveries,omitempty"`
}
type Grain interface {
@@ -152,16 +152,17 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) ([]byte, erro
}
if !found {
c.lastItemId++
c.Items = append(c.Items, CartItem{
Id: c.lastItemId,
Sku: msg.Sku,
Name: msg.Name,
Price: msg.Price,
Image: msg.Image,
c.Items = append(c.Items, &CartItem{
Id: c.lastItemId,
Quantity: int(msg.Quantity),
Sku: msg.Sku,
Name: msg.Name,
Price: msg.Price,
Image: msg.Image,
})
c.TotalPrice += msg.Price * int64(msg.Quantity)
}
c.TotalPrice += msg.Price * int64(msg.Quantity)
}
case RemoveItemType:
//msg, ok := message.Content.(*messages.RemoveItem)