add discount
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-05 03:54:59 +07:00
parent 5ecaa0f09b
commit 797bf40fdc
6 changed files with 112 additions and 84 deletions
+5 -2
View File
@@ -1,11 +1,12 @@
package cart
import (
"cake_crm/internal/modules/storage"
"cake_crm/proto"
"context"
"errors"
"strconv"
"cake_crm/internal/modules/storage"
"cake_crm/proto"
)
type ProductAndCount struct {
@@ -54,6 +55,7 @@ func (s *Service) GetCart(ctx context.Context, items []*proto.OrderItem) (*proto
Count: item.Count,
Amount: amount,
AmountOld: amountOld,
Discount: amountOld - amount,
Variants: product.Variants,
Labels: product.Labels,
},
@@ -65,6 +67,7 @@ func (s *Service) GetCart(ctx context.Context, items []*proto.OrderItem) (*proto
Items: res,
Amount: cartAmount,
AmountOld: cartAmountOld,
Discount: cartAmountOld - cartAmount,
}, nil
}
-9
View File
@@ -1,9 +0,0 @@
POST http://0.0.0.0:8090/cart
User-Agent: crabs/1.0.0
[
{
"productId": 1,
"count": 20
}
]