Inquiry Fee
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
type Config interface {
|
||||
GetOrderFee() float64
|
||||
GetOrderFee(source string) float64
|
||||
}
|
||||
|
||||
type OrderService struct {
|
||||
@@ -53,9 +53,15 @@ func NewOrderService(
|
||||
}
|
||||
|
||||
func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderRequest) (*entity.OrderResponse, error) {
|
||||
productIDs := make([]int64, len(req.OrderItems))
|
||||
for i, item := range req.OrderItems {
|
||||
productIDs[i] = item.ProductID
|
||||
productIDs := []int64{}
|
||||
for _, item := range req.OrderItems {
|
||||
if item.Quantity != 0 {
|
||||
productIDs = append(productIDs, item.ProductID)
|
||||
}
|
||||
}
|
||||
|
||||
if len(productIDs) < 1 {
|
||||
return nil, errors2.ErrorBadRequest
|
||||
}
|
||||
|
||||
products, err := s.product.GetProductsByIDs(ctx, productIDs, req.PartnerID)
|
||||
@@ -92,8 +98,8 @@ func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderReque
|
||||
RefID: generator.GenerateUUID(),
|
||||
Status: order2.New.String(),
|
||||
Amount: totalAmount,
|
||||
Total: totalAmount + s.cfg.GetOrderFee(),
|
||||
Fee: s.cfg.GetOrderFee(),
|
||||
Total: totalAmount + s.cfg.GetOrderFee(req.Source),
|
||||
Fee: s.cfg.GetOrderFee(req.Source),
|
||||
PaymentType: req.PaymentMethod,
|
||||
SiteID: &siteID,
|
||||
CreatedBy: req.CreatedBy,
|
||||
|
||||
Reference in New Issue
Block a user