Inquiry Fee
This commit is contained in:
parent
c4e0c6d2c8
commit
6063713ad2
@ -4,6 +4,9 @@ type Order struct {
|
||||
Fee float64 `mapstructure:"fee"`
|
||||
}
|
||||
|
||||
func (w *Order) GetOrderFee() float64 {
|
||||
func (w *Order) GetOrderFee(source string) float64 {
|
||||
if source == "POS" {
|
||||
return 0
|
||||
}
|
||||
return w.Fee
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user