Add refund order
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"enaklo-pos-be/internal/constants"
|
||||
"enaklo-pos-be/internal/entity"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
@@ -36,6 +37,20 @@ func (s *orderSvc) ExecuteOrderInquiry(ctx mycontext.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *orderSvc) RefundRequest(ctx mycontext.Context, partnerID, orderID int64, reason string) error {
|
||||
order, err := s.repo.FindByIDAndPartnerID(ctx, partnerID, orderID)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("failed to create order", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
if order.Status != "PAID" {
|
||||
return errors.New("only paid order can be refund")
|
||||
}
|
||||
|
||||
return s.repo.UpdateOrder(ctx, order.ID, "REFUNDED", reason)
|
||||
}
|
||||
|
||||
func (s *orderSvc) processPostOrderActions(
|
||||
ctx mycontext.Context,
|
||||
order *entity.Order,
|
||||
|
||||
Reference in New Issue
Block a user