208 lines
6.2 KiB
Go
208 lines
6.2 KiB
Go
package ports
|
||
|
||
import (
|
||
"context"
|
||
|
||
"google.golang.org/grpc"
|
||
activityv1 "hyapp.local/api/proto/activity/v1"
|
||
"hyapp/services/wallet-service/internal/domain/ledger"
|
||
)
|
||
|
||
// ActivityBadgeClient 是 wallet -> activity 的最小投影接口,避免 wallet 依赖 activity 内部包。
|
||
type ActivityBadgeClient interface {
|
||
ConsumeAchievementEvent(ctx context.Context, req *activityv1.ConsumeAchievementEventRequest, opts ...grpc.CallOption) (*activityv1.ConsumeAchievementEventResponse, error)
|
||
}
|
||
|
||
// GooglePlayClient 隔离 Google Play Developer API,service 只依赖购买校验、消耗和订单实付查询能力。
|
||
type GooglePlayClient interface {
|
||
GetProductPurchase(ctx context.Context, packageName string, purchaseToken string) (ledger.GooglePlayPurchase, error)
|
||
ConsumeProduct(ctx context.Context, packageName string, productID string, purchaseToken string) error
|
||
GetOrder(ctx context.Context, packageName string, orderID string) (ledger.GooglePlayOrder, error)
|
||
}
|
||
|
||
// MifaPayCreateOrderRequest 是 wallet-service 传给 MiFaPay client 的已校验下单快照。
|
||
type MifaPayCreateOrderRequest struct {
|
||
OrderID string
|
||
TargetUserID int64
|
||
ProductName string
|
||
CoinAmount int64
|
||
AmountMinor int64
|
||
CurrencyCode string
|
||
CountryCode string
|
||
PayWay string
|
||
PayType string
|
||
NotifyURL string
|
||
ReturnURL string
|
||
ClientIP string
|
||
Language string
|
||
ProviderAmountMinor int64
|
||
PayerName string
|
||
PayerAccount string
|
||
PayerEmail string
|
||
}
|
||
|
||
type MifaPayCreateOrderResponse struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
PayURL string
|
||
RawJSON string
|
||
}
|
||
|
||
type MifaPayQueryOrderRequest struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
OrderCreatedAtMS int64
|
||
}
|
||
|
||
type MifaPayQueryOrderResponse struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
Status string
|
||
Amount string
|
||
Currency string
|
||
PayType string
|
||
RawJSON string
|
||
}
|
||
|
||
type MifaPayNotifyData struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
OrderStatus string
|
||
Amount string
|
||
Currency string
|
||
PayType string
|
||
RawJSON string
|
||
}
|
||
|
||
// V5PayCreateOrderRequest 是 wallet-service 传给 V5Pay client 的已校验下单快照。
|
||
type V5PayCreateOrderRequest struct {
|
||
OrderID string
|
||
TargetUserID int64
|
||
ProductName string
|
||
CoinAmount int64
|
||
AmountMinor int64
|
||
CurrencyCode string
|
||
CountryCode string
|
||
ProductType string
|
||
NotifyURL string
|
||
ReturnURL string
|
||
Language string
|
||
ProviderAmountMinor int64
|
||
PayerName string
|
||
PayerAccount string
|
||
PayerEmail string
|
||
}
|
||
|
||
type V5PayCreateOrderResponse struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
PayURL string
|
||
RawJSON string
|
||
}
|
||
|
||
type V5PayQueryOrderRequest struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
CountryCode string
|
||
CurrencyCode string
|
||
}
|
||
|
||
type V5PayQueryOrderResponse struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
Status string
|
||
Amount string
|
||
Currency string
|
||
ProductType string
|
||
RawJSON string
|
||
}
|
||
|
||
type V5PayNotifyData struct {
|
||
OrderID string
|
||
ProviderOrderID string
|
||
OrderStatus string
|
||
Amount string
|
||
Currency string
|
||
ProductType string
|
||
RawJSON string
|
||
}
|
||
|
||
type V5PayProductTypesRequest struct {
|
||
CountryCode string
|
||
CurrencyCode string
|
||
}
|
||
|
||
type V5PayProductType struct {
|
||
ProductType string
|
||
ProductName string
|
||
Description string
|
||
Logo string
|
||
Currency string
|
||
ProductMode string
|
||
SupportCashierMode int
|
||
}
|
||
|
||
type V5PayProductTypesResponse struct {
|
||
PayinList []V5PayProductType
|
||
RawJSON string
|
||
}
|
||
|
||
// BinanceDepositLookupRequest 是后台 USDT 币商充值使用的 Binance 入金查单条件。
|
||
type BinanceDepositLookupRequest struct {
|
||
AppCode string
|
||
ExternalID string
|
||
Coin string
|
||
Network string
|
||
ToAddress string
|
||
AmountMinor int64
|
||
}
|
||
|
||
// BinanceDepositRecord 是 Binance deposit history 中命中的只读快照;金额按 USD/USDT cent 收敛给上层校验。
|
||
type BinanceDepositRecord struct {
|
||
ID string
|
||
TxID string
|
||
Coin string
|
||
Network string
|
||
Status int64
|
||
Address string
|
||
Amount string
|
||
AmountMinor int64
|
||
TransferType int64
|
||
InsertTimeMS int64
|
||
CompleteTimeMS int64
|
||
ConfirmTimes string
|
||
UnlockConfirm int64
|
||
WalletType int64
|
||
RawJSON string
|
||
}
|
||
|
||
// MifaPayClient 隔离 MiFaPay RSA 签名、验签和 HTTP 协议细节,service 只处理订单状态。
|
||
type MifaPayClient interface {
|
||
CreateOrder(ctx context.Context, req MifaPayCreateOrderRequest) (MifaPayCreateOrderResponse, error)
|
||
QueryOrder(ctx context.Context, req MifaPayQueryOrderRequest) (MifaPayQueryOrderResponse, error)
|
||
ParseNotification(notification ledger.MifaPayNotification) (MifaPayNotifyData, error)
|
||
}
|
||
|
||
// V5PayClient 隔离 V5Pay MD5 签名、验签和 HTTP 协议细节,service 只处理订单状态。
|
||
type V5PayClient interface {
|
||
CreateOrder(ctx context.Context, req V5PayCreateOrderRequest) (V5PayCreateOrderResponse, error)
|
||
QueryOrder(ctx context.Context, req V5PayQueryOrderRequest) (V5PayQueryOrderResponse, error)
|
||
ListProductTypes(ctx context.Context, req V5PayProductTypesRequest) (V5PayProductTypesResponse, error)
|
||
ParseNotification(notification ledger.V5PayNotification) (V5PayNotifyData, error)
|
||
}
|
||
|
||
// TronUSDTClient 校验用户提交的 TRC20 tx_hash 是否真实打到平台共享地址。
|
||
type TronUSDTClient interface {
|
||
VerifyUSDTTransfer(ctx context.Context, txHash string, toAddress string, amountMinor int64) (string, error)
|
||
}
|
||
|
||
// BSCUSDTClient 校验用户提交的 BEP20 tx_hash 是否真实打到平台共享地址。
|
||
type BSCUSDTClient interface {
|
||
VerifyUSDTTransfer(ctx context.Context, txHash string, toAddress string, amountMinor int64) (string, error)
|
||
}
|
||
|
||
// BinanceClient 隔离 Binance signed API;service 只关心入金记录是否匹配后台订单。
|
||
type BinanceClient interface {
|
||
FindUSDTDeposit(ctx context.Context, req BinanceDepositLookupRequest) (BinanceDepositRecord, error)
|
||
}
|