package pay

import (
	"time"

	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
)

type PayOpStatus int

const (
	OpStatusFailed    PayOpStatus = 0
	OpStatusSuccessed PayOpStatus = 1
)

type CreatePayParam struct {
	PayOrderID    string
	VendorPayType string

	VendorOrderID string
	ProductDesc   string
	ProductDetail string
	FeeType       string
	TotalFee      int
	TimeStart     time.Time
	TimeExpire    time.Time

	UserData string
}

type PayOpResult struct {
	Status       PayOpStatus
	VendorStatus string
	ErrMsg       string

	ID       string
	VendorID string

	OriginalData string
}

type ResponseHandler interface {
	OnCreatePay(vendorID int, result *PayOpResult) (err error)
	OnRefundPay(vendorID int, result *PayOpResult) (err error)
}

type IPayPlatformHandler interface {
	CreatePay(ctx *jxcontext.Context, param *CreatePayParam, isOffline bool) (prepayID, qrCodeURL string, err error)
	ClosePay(ctx *jxcontext.Context, payOrderID, vendorPayOrderID string) (err error)
	RefundPay(ctx *jxcontext.Context, payOrderID, vendorPayOrderID, refundID, reason string, totalFee, refundFee int) (vendorRefundID string, err error)
}
