Merge branch 'feature/pubsub' of git-ssh.tornberg.me:mats/go-cart-actor into feature/pubsub
This commit is contained in:
@@ -38,16 +38,24 @@ func (c *CartMutationContext) AddItem(g *CartGrain, m *messages.AddItem) error {
|
||||
if !sameStore {
|
||||
continue
|
||||
}
|
||||
existing.Quantity += int(m.Quantity)
|
||||
if m.ReservationEndTime != nil {
|
||||
t := m.ReservationEndTime.AsTime()
|
||||
if existing.ReservationEndTime == nil || existing.ReservationEndTime.Before(m.ReservationEndTime.AsTime()) {
|
||||
existing.ReservationEndTime = &t
|
||||
existing.Quantity += int(m.Quantity)
|
||||
} else {
|
||||
existing.ReservationEndTime = &t
|
||||
}
|
||||
|
||||
} else {
|
||||
existing.Quantity += int(m.Quantity)
|
||||
}
|
||||
existing.Stock = uint16(m.Stock)
|
||||
// If existing had nil store but new has one, adopt it.
|
||||
if existing.StoreId == nil && m.StoreId != nil {
|
||||
existing.StoreId = m.StoreId
|
||||
}
|
||||
if m.ReservationEndTime != nil {
|
||||
t := m.ReservationEndTime.AsTime()
|
||||
existing.ReservationEndTime = &t
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user