payment.go 607 B

1234567891011121314151617181920212223
  1. package service
  2. import (
  3. "net/http"
  4. "sghgogs.com/micro/common/errorcode"
  5. req "sghgogs.com/micro/shopping-service/domain/model/request"
  6. pb "sghgogs.com/micro/shopping-service/proto"
  7. "time"
  8. )
  9. func (svc *Service) CreatePayment(add *pb.CreatePaymentRequest) error {
  10. if err := svc.Repository.CreatePayment(&req.Payment{
  11. OrderID: add.OrderId,
  12. Amount: add.Amount,
  13. Status: add.Status,
  14. PaymentMethod: add.PaymentMethod,
  15. CreatedAt: time.Now(),
  16. UpdatedAt: nil,
  17. }); err != nil {
  18. return errorcode.New(svc.Namespace, err.Error(), http.StatusBadRequest)
  19. }
  20. return nil
  21. }