Add refund order

This commit is contained in:
aditya.siregar
2025-06-14 21:17:13 +07:00
parent 58d3b32c40
commit ebb33186b8
42 changed files with 1152 additions and 2094 deletions
@@ -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,