Customer Order
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
errors2 "furtuna-be/internal/common/errors"
|
||||
"furtuna-be/internal/common/logger"
|
||||
"furtuna-be/internal/common/mycontext"
|
||||
order2 "furtuna-be/internal/constants/order"
|
||||
@@ -81,6 +82,7 @@ func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderReque
|
||||
SiteID: ctx.GetSiteID(),
|
||||
CreatedBy: req.CreatedBy,
|
||||
OrderItems: []entity.OrderItem{},
|
||||
Source: req.Source,
|
||||
}
|
||||
|
||||
for _, item := range req.OrderItems {
|
||||
@@ -191,6 +193,7 @@ func (s *OrderService) processNonCashPayment(ctx context.Context, order *entity.
|
||||
PaymentReferenceID: generator.GenerateUUIDV4(),
|
||||
TotalAmount: int64(order.Amount),
|
||||
OrderItems: order.OrderItems,
|
||||
PaymentMethod: order.PaymentType,
|
||||
}
|
||||
|
||||
paymentResponse, err := s.midtrans.CreatePayment(paymentRequest)
|
||||
@@ -358,3 +361,17 @@ func (s OrderService) SumAmount(ctx mycontext.Context, req entity.OrderSearch) (
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (s *OrderService) GetByID(ctx mycontext.Context, id int64) (*entity.Order, error) {
|
||||
order, err := s.repo.FindByID(ctx, id)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when getting products by IDs", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if order.CreatedBy != ctx.RequestedBy() {
|
||||
return nil, errors2.NewError(errors2.ErrorBadRequest.ErrorType(), "order not found")
|
||||
}
|
||||
|
||||
return order, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user