update handle quantity change
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 27s
Build and Publish / BuildAndDeploy (push) Successful in 2m29s

This commit is contained in:
matst80
2024-11-15 10:29:38 +01:00
parent 79b66c216d
commit de3d6a8beb

View File

@@ -294,11 +294,12 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
for i, item := range c.Items {
if item.Id == int(msg.Id) {
if item.Quantity <= int(msg.Quantity) {
c.TotalPrice -= item.Price * int64(msg.Quantity)
c.Items = append(c.Items[:i], c.Items[i+1:]...)
} else {
item.Quantity -= int(msg.Quantity)
c.TotalPrice -= item.Price * int64(msg.Quantity)
}
c.TotalPrice -= item.Price * int64(msg.Quantity)
break
}