update storeid stuff
This commit is contained in:
@@ -62,6 +62,7 @@ type CartItem struct {
|
||||
ArticleType string `json:"type,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
Outlet *string `json:"outlet,omitempty"`
|
||||
StoreId *string `json:"storeId,omitempty"`
|
||||
}
|
||||
|
||||
type CartDelivery struct {
|
||||
@@ -187,11 +188,12 @@ func getItemData(sku string, qty int, country string) (*messages.AddItem, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *CartGrain) AddItem(sku string, qty int, country string) (*FrameWithPayload, error) {
|
||||
func (c *CartGrain) AddItem(sku string, qty int, country string, storeId *string) (*FrameWithPayload, error) {
|
||||
cartItem, err := getItemData(sku, qty, country)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cartItem.StoreId = storeId
|
||||
return c.HandleMessage(&Message{
|
||||
Type: 2,
|
||||
Content: cartItem,
|
||||
@@ -282,7 +284,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
|
||||
c.Items = make([]*CartItem, 0, len(msg.Items))
|
||||
c.mu.Unlock()
|
||||
for _, item := range msg.Items {
|
||||
c.AddItem(item.Sku, int(item.Quantity), item.Country)
|
||||
c.AddItem(item.Sku, int(item.Quantity), item.Country, item.StoreId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -297,7 +299,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
|
||||
existingItem.Quantity += int(msg.Quantity)
|
||||
c.UpdateTotals()
|
||||
} else {
|
||||
return c.AddItem(msg.Sku, int(msg.Quantity), msg.Country)
|
||||
return c.AddItem(msg.Sku, int(msg.Quantity), msg.Country, msg.StoreId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -349,6 +351,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
|
||||
SellerName: msg.SellerName,
|
||||
Tax: int(taxAmount),
|
||||
TaxRate: tax,
|
||||
StoreId: msg.StoreId,
|
||||
})
|
||||
c.UpdateTotals()
|
||||
c.mu.Unlock()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.9
|
||||
// protoc v6.32.1
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v3.21.12
|
||||
// source: messages.proto
|
||||
|
||||
package messages
|
||||
@@ -156,6 +156,7 @@ type AddItem struct {
|
||||
SellerName string `protobuf:"bytes,20,opt,name=sellerName,proto3" json:"sellerName,omitempty"`
|
||||
Country string `protobuf:"bytes,21,opt,name=country,proto3" json:"country,omitempty"`
|
||||
Outlet *string `protobuf:"bytes,12,opt,name=outlet,proto3,oneof" json:"outlet,omitempty"`
|
||||
StoreId *string `protobuf:"bytes,22,opt,name=storeId,proto3,oneof" json:"storeId,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -337,6 +338,13 @@ func (x *AddItem) GetOutlet() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AddItem) GetStoreId() string {
|
||||
if x != nil && x.StoreId != nil {
|
||||
return *x.StoreId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RemoveItem struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id int64 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||
@@ -895,7 +903,7 @@ const file_messages_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\b_storeId\"<\n" +
|
||||
"\x0eSetCartRequest\x12*\n" +
|
||||
"\x05items\x18\x01 \x03(\v2\x14.messages.AddRequestR\x05items\"\xbe\x04\n" +
|
||||
"\x05items\x18\x01 \x03(\v2\x14.messages.AddRequestR\x05items\"\xe9\x04\n" +
|
||||
"\aAddItem\x12\x17\n" +
|
||||
"\aitem_id\x18\x01 \x01(\x03R\x06itemId\x12\x1a\n" +
|
||||
"\bquantity\x18\x02 \x01(\x05R\bquantity\x12\x14\n" +
|
||||
@@ -922,8 +930,11 @@ const file_messages_proto_rawDesc = "" +
|
||||
"sellerName\x18\x14 \x01(\tR\n" +
|
||||
"sellerName\x12\x18\n" +
|
||||
"\acountry\x18\x15 \x01(\tR\acountry\x12\x1b\n" +
|
||||
"\x06outlet\x18\f \x01(\tH\x00R\x06outlet\x88\x01\x01B\t\n" +
|
||||
"\a_outlet\"\x1c\n" +
|
||||
"\x06outlet\x18\f \x01(\tH\x00R\x06outlet\x88\x01\x01\x12\x1d\n" +
|
||||
"\astoreId\x18\x16 \x01(\tH\x01R\astoreId\x88\x01\x01B\t\n" +
|
||||
"\a_outletB\n" +
|
||||
"\n" +
|
||||
"\b_storeId\"\x1c\n" +
|
||||
"\n" +
|
||||
"RemoveItem\x12\x0e\n" +
|
||||
"\x02Id\x18\x01 \x01(\x03R\x02Id\"<\n" +
|
||||
|
||||
@@ -35,6 +35,7 @@ message AddItem {
|
||||
string sellerName = 20;
|
||||
string country = 21;
|
||||
optional string outlet = 12;
|
||||
optional string storeId = 22;
|
||||
}
|
||||
|
||||
message RemoveItem {
|
||||
@@ -91,4 +92,4 @@ message CreateCheckoutOrder {
|
||||
message OrderCreated {
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user