update storeid stuff
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 4m12s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 51s

This commit is contained in:
matst80
2025-10-10 06:16:46 +00:00
parent 92ebb49b09
commit f735540c3d
3 changed files with 24 additions and 9 deletions

View File

@@ -62,6 +62,7 @@ type CartItem struct {
ArticleType string `json:"type,omitempty"` ArticleType string `json:"type,omitempty"`
Image string `json:"image,omitempty"` Image string `json:"image,omitempty"`
Outlet *string `json:"outlet,omitempty"` Outlet *string `json:"outlet,omitempty"`
StoreId *string `json:"storeId,omitempty"`
} }
type CartDelivery struct { type CartDelivery struct {
@@ -187,11 +188,12 @@ func getItemData(sku string, qty int, country string) (*messages.AddItem, error)
}, nil }, 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) cartItem, err := getItemData(sku, qty, country)
if err != nil { if err != nil {
return nil, err return nil, err
} }
cartItem.StoreId = storeId
return c.HandleMessage(&Message{ return c.HandleMessage(&Message{
Type: 2, Type: 2,
Content: cartItem, Content: cartItem,
@@ -282,7 +284,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
c.Items = make([]*CartItem, 0, len(msg.Items)) c.Items = make([]*CartItem, 0, len(msg.Items))
c.mu.Unlock() c.mu.Unlock()
for _, item := range msg.Items { 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) existingItem.Quantity += int(msg.Quantity)
c.UpdateTotals() c.UpdateTotals()
} else { } 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, SellerName: msg.SellerName,
Tax: int(taxAmount), Tax: int(taxAmount),
TaxRate: tax, TaxRate: tax,
StoreId: msg.StoreId,
}) })
c.UpdateTotals() c.UpdateTotals()
c.mu.Unlock() c.mu.Unlock()

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.36.9 // protoc-gen-go v1.36.10
// protoc v6.32.1 // protoc v3.21.12
// source: messages.proto // source: messages.proto
package messages package messages
@@ -156,6 +156,7 @@ type AddItem struct {
SellerName string `protobuf:"bytes,20,opt,name=sellerName,proto3" json:"sellerName,omitempty"` SellerName string `protobuf:"bytes,20,opt,name=sellerName,proto3" json:"sellerName,omitempty"`
Country string `protobuf:"bytes,21,opt,name=country,proto3" json:"country,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"` 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 unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@@ -337,6 +338,13 @@ func (x *AddItem) GetOutlet() string {
return "" return ""
} }
func (x *AddItem) GetStoreId() string {
if x != nil && x.StoreId != nil {
return *x.StoreId
}
return ""
}
type RemoveItem struct { type RemoveItem struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` Id int64 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
@@ -895,7 +903,7 @@ const file_messages_proto_rawDesc = "" +
"\n" + "\n" +
"\b_storeId\"<\n" + "\b_storeId\"<\n" +
"\x0eSetCartRequest\x12*\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" + "\aAddItem\x12\x17\n" +
"\aitem_id\x18\x01 \x01(\x03R\x06itemId\x12\x1a\n" + "\aitem_id\x18\x01 \x01(\x03R\x06itemId\x12\x1a\n" +
"\bquantity\x18\x02 \x01(\x05R\bquantity\x12\x14\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\x18\x14 \x01(\tR\n" +
"sellerName\x12\x18\n" + "sellerName\x12\x18\n" +
"\acountry\x18\x15 \x01(\tR\acountry\x12\x1b\n" + "\acountry\x18\x15 \x01(\tR\acountry\x12\x1b\n" +
"\x06outlet\x18\f \x01(\tH\x00R\x06outlet\x88\x01\x01B\t\n" + "\x06outlet\x18\f \x01(\tH\x00R\x06outlet\x88\x01\x01\x12\x1d\n" +
"\a_outlet\"\x1c\n" + "\astoreId\x18\x16 \x01(\tH\x01R\astoreId\x88\x01\x01B\t\n" +
"\a_outletB\n" +
"\n" +
"\b_storeId\"\x1c\n" +
"\n" + "\n" +
"RemoveItem\x12\x0e\n" + "RemoveItem\x12\x0e\n" +
"\x02Id\x18\x01 \x01(\x03R\x02Id\"<\n" + "\x02Id\x18\x01 \x01(\x03R\x02Id\"<\n" +

View File

@@ -35,6 +35,7 @@ message AddItem {
string sellerName = 20; string sellerName = 20;
string country = 21; string country = 21;
optional string outlet = 12; optional string outlet = 12;
optional string storeId = 22;
} }
message RemoveItem { message RemoveItem {
@@ -91,4 +92,4 @@ message CreateCheckoutOrder {
message OrderCreated { message OrderCreated {
string orderId = 1; string orderId = 1;
string status = 2; string status = 2;
} }