Documentation
¶
Index ¶
- Constants
- Variables
- type CurrencyRate
- type CurrencyRateRepo
- type ICOHistory
- type ICORepo
- type ICORound
- type ICOSubRound
- type ICOUsecase
- func (uc *ICOUsecase) AddICOCoupon(ctx context.Context, userId, coupon, reward, cashback string) error
- func (uc *ICOUsecase) CloseSubRound(ctx context.Context, currentRound *ICOSubRound) error
- func (uc *ICOUsecase) GetICOCoupon(ctx context.Context, coupon string) (*IcoCoupon, error)
- func (uc *ICOUsecase) GetICOCurrentRound(ctx context.Context) (*ICOSubRound, error)
- func (uc *ICOUsecase) GetICORounds(ctx context.Context) ([]*ICORound, error)
- func (uc *ICOUsecase) GetICOUserHistory(ctx context.Context, next string, limit int) ([]*ICOUserBought, int, error)
- func (uc *ICOUsecase) ICOHistories(ctx context.Context, userId, amount, symbol, icoType string) (decimal.Decimal, error)
- func (uc *ICOUsecase) UpdateCurrencyRateICO(ctx context.Context, oldPrice, newPrice string) error
- type ICOUserBought
- type IcoCoupon
- type IcoCouponRepo
- type LockRepo
- type QueueJob
- type QueueRunner
- type Task
- type Transaction
- type TransactionMessage
- type TransactionPublisher
- type TransactionRepo
- type Tx
- type UserWallet
- type UserWalletRepo
- type WalletTransactionUseCase
- func (uc *WalletTransactionUseCase) BuyICO(ctx context.Context, userId, amount, symbol, sourceId, couponCode string) error
- func (uc *WalletTransactionUseCase) CalcChargeFee(ctx context.Context, userId string, req *pb.CalcChargeFeeRequest) (*pb.CalcChargeFeeResponse, error)
- func (uc *WalletTransactionUseCase) ChargeFee(ctx context.Context, userId, amount, symbol, sourceId, typeFee string) (string, error)
- func (uc *WalletTransactionUseCase) CreateTransaction(ctx context.Context, trans *Transaction) (*Transaction, error)
- func (uc *WalletTransactionUseCase) DepositICO(ctx context.Context, userId, amount, symbol, sourceId, icoType string) error
- func (uc *WalletTransactionUseCase) GetCurrentRate(ctx context.Context, req *v1.CurrentRateRequest) (*CurrencyRate, error)
- func (uc *WalletTransactionUseCase) GetTransactionsByUserId(ctx context.Context, userId, nextCursor string, limit int32) ([]*Transaction, string, error)
- func (uc *WalletTransactionUseCase) GetUserWallet(ctx context.Context, userId string) ([]*UserWallet, error)
- func (uc *WalletTransactionUseCase) GetUserWalletOrCreateWithSymbol(ctx context.Context, userId, symbol, walletType string) ([]*UserWallet, error)
- func (uc *WalletTransactionUseCase) GetUserWalletWithSymbol(ctx context.Context, userId, symbol string) ([]*UserWallet, error)
- func (uc *WalletTransactionUseCase) ICOTransaction(ctx context.Context, ...) error
- func (uc *WalletTransactionUseCase) InitData(ctx context.Context)
- func (uc *WalletTransactionUseCase) MarketingRewardInternal(ctx context.Context, userID, amount, symbol, sourceID string) (string, error)
- func (uc *WalletTransactionUseCase) ReferralReward(ctx context.Context, userId, amount, symbol, sourceId string) error
- func (uc *WalletTransactionUseCase) Subscription(ctx context.Context, userId, amount, symbol, sourceId string) error
Constants ¶
View Source
const ( QUEUE_PREFIX = "ico-subround:" ENDROUND_SCHEDULE = "endround" )
Variables ¶
View Source
var ( SUBSCRIPTION = "SUBSCRIPTION" CHARGE_FEE = "CHARGE_FEE" REFERRAL_REWARD = "REFERRAL_REWARD" MarketingReward = "MARKETING_REWARD" ICO = "ICO" ICO_COMISSION = "ICO_COMISSION" ICO_CASHBACK = "ICO_CASHBACK" DEPOSITE = "DEPOSITE" TRANS_STATUS = "COMPLETED" CURRENCY_SUPPORT = []string{"VND", "USD", "USDT"} )
View Source
var (
ProviderSet = wire.NewSet(NewICOUseCase, NewWalletTransactionUseCase)
)
ProviderSet is biz providers.
Functions ¶
This section is empty.
Types ¶
type CurrencyRate ¶
type CurrencyRateRepo ¶
type ICOHistory ¶
type ICORepo ¶
type ICORepo interface { Tx GetRounds(context.Context) ([]*ICORound, error) EndRoundByRoundId(ctx context.Context, roundId int32) error GetRoundByRoundId(ctx context.Context, roundId int32) (*ICORound, error) SaveHistories(ctx context.Context, histories []ICOHistory) error GetCurrentSubRound(context.Context) (*ICOSubRound, error) CloseSubRound(ctx context.Context, roundId, subRound int32, boughtToken string) (*ICOSubRound, error) UpdateSubRoundBought(ctx context.Context, roundId, subRound int32, boughtToken string) error GetSubRoundById(ctx context.Context, id string) (*ICOSubRound, error) InitData(ctx context.Context, startTime time.Time) error GetBuyICOUser(ctx context.Context, limit, offset int) ([]*ICOUserBought, error) GetBuyICOTotalUser(ctx context.Context) (int, error) }
type ICOSubRound ¶
type ICOUsecase ¶
type ICOUsecase struct {
// contains filtered or unexported fields
}
func NewICOUseCase ¶
func NewICOUseCase(repo ICORepo, icoCoupon IcoCouponRepo, currencyRateRepo CurrencyRateRepo) *ICOUsecase
func (*ICOUsecase) AddICOCoupon ¶
func (uc *ICOUsecase) AddICOCoupon(ctx context.Context, userId, coupon, reward, cashback string) error
func (*ICOUsecase) CloseSubRound ¶
func (uc *ICOUsecase) CloseSubRound(ctx context.Context, currentRound *ICOSubRound) error
func (*ICOUsecase) GetICOCoupon ¶
func (*ICOUsecase) GetICOCurrentRound ¶
func (uc *ICOUsecase) GetICOCurrentRound(ctx context.Context) (*ICOSubRound, error)
func (*ICOUsecase) GetICORounds ¶
func (uc *ICOUsecase) GetICORounds(ctx context.Context) ([]*ICORound, error)
func (*ICOUsecase) GetICOUserHistory ¶
func (uc *ICOUsecase) GetICOUserHistory(ctx context.Context, next string, limit int) ([]*ICOUserBought, int, error)
func (*ICOUsecase) ICOHistories ¶
func (*ICOUsecase) UpdateCurrencyRateICO ¶
func (uc *ICOUsecase) UpdateCurrencyRateICO(ctx context.Context, oldPrice, newPrice string) error
type ICOUserBought ¶
type IcoCoupon ¶
type IcoCoupon struct { ID xid.ID `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // UserID holds the value of the "user_id" field. UserID string `json:"user_id,omitempty"` // Coupon holds the value of the "coupon" field. Coupon string `json:"coupon,omitempty"` // Reward holds the value of the "reward" field. Reward string `json:"reward,omitempty"` // Cashback holds the value of the "cashback" field. Cashback string `json:"cashback,omitempty"` }
IcoCoupon is the model entity for the IcoCoupon schema.
type IcoCouponRepo ¶
type QueueRunner ¶
type QueueRunner struct {
// contains filtered or unexported fields
}
func NewQueueRunner ¶
func NewQueueRunner(repo ICORepo, walletRepo UserWalletRepo, transRepo TransactionRepo, icoUc *ICOUsecase, lockRepo LockRepo) *QueueRunner
func (*QueueRunner) GetICOCurrentRound ¶
func (r *QueueRunner) GetICOCurrentRound(ctx context.Context) (*ICOSubRound, error)
type Transaction ¶
type Transaction struct { ID xid.ID `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // TransType holds the value of the "trans_type" field. TransType string `json:"trans_type,omitempty"` // Source holds the value of the "source" field. Source string `json:"source,omitempty"` // SrcSymbol holds the value of the "src_symbol" field. SrcSymbol string `json:"src_symbol,omitempty"` // SrcAmount holds the value of the "src_amount" field. SrcAmount string `json:"src_amount,omitempty"` // Destination holds the value of the "destination" field. Destination string `json:"destination,omitempty"` // DestSymbol holds the value of the "dest_symbol" field. DestSymbol string `json:"dest_symbol,omitempty"` // DestAmount holds the value of the "dest_amount" field. DestAmount string `json:"dest_amount,omitempty"` // Rate holds the value of the "rate" field. Rate string `json:"rate,omitempty"` // SourceService holds the value of the "source_service" field. SourceService string `json:"source_service,omitempty"` SourceId string `json:"source_id,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` }
type TransactionMessage ¶
type TransactionPublisher ¶
type TransactionPublisher interface {
Publish(msg *TransactionMessage)
}
type TransactionRepo ¶
type TransactionRepo interface { Tx CreateTransaction(ctx context.Context, input *Transaction) (*Transaction, error) GetTransactionsByUserId(ctx context.Context, userId, cursor string, limit int32) ([]*Transaction, string, error) }
type UserWallet ¶
type UserWallet struct { ID xid.ID `json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` UserID string `json:"user_id,omitempty"` Type string `json:"type,omitempty"` Symbol string `json:"symbol,omitempty"` Balance string `json:"balance,omitempty"` IsActive bool `json:"is_active,omitempty"` }
type UserWalletRepo ¶
type UserWalletRepo interface { Tx GetWalletByUserId(ctx context.Context, userId, symbol, walletType string) ([]*UserWallet, error) CreateWallet(ctx context.Context, userId, symbol, walletType string) (*UserWallet, error) DecreaseBalance(ctx context.Context, userId, symbol, amount, walletType string) (int, error) IncreaseBalance(ctx context.Context, userId, symbol, amount, walletType string) (int, error) InitData(ctx context.Context) error CalculateBalance(ctx context.Context, userId, amount, symbol string) (bool, error) }
type WalletTransactionUseCase ¶
type WalletTransactionUseCase struct {
// contains filtered or unexported fields
}
func NewWalletTransactionUseCase ¶
func NewWalletTransactionUseCase(repo TransactionRepo, walletRepo UserWalletRepo, icoRepo ICORepo, currencyRateRepo CurrencyRateRepo, icoCoupon IcoCouponRepo, queue QueueJob, publisher TransactionPublisher, icoUc *ICOUsecase, lockRepo LockRepo) *WalletTransactionUseCase
func (*WalletTransactionUseCase) BuyICO ¶
func (uc *WalletTransactionUseCase) BuyICO(ctx context.Context, userId, amount, symbol, sourceId, couponCode string) error
func (*WalletTransactionUseCase) CalcChargeFee ¶
func (uc *WalletTransactionUseCase) CalcChargeFee(ctx context.Context, userId string, req *pb.CalcChargeFeeRequest) (*pb.CalcChargeFeeResponse, error)
func (*WalletTransactionUseCase) CreateTransaction ¶
func (uc *WalletTransactionUseCase) CreateTransaction(ctx context.Context, trans *Transaction) (*Transaction, error)
func (*WalletTransactionUseCase) DepositICO ¶
func (uc *WalletTransactionUseCase) DepositICO(ctx context.Context, userId, amount, symbol, sourceId, icoType string) error
func (*WalletTransactionUseCase) GetCurrentRate ¶
func (uc *WalletTransactionUseCase) GetCurrentRate(ctx context.Context, req *v1.CurrentRateRequest) (*CurrencyRate, error)
func (*WalletTransactionUseCase) GetTransactionsByUserId ¶
func (uc *WalletTransactionUseCase) GetTransactionsByUserId(ctx context.Context, userId, nextCursor string, limit int32) ([]*Transaction, string, error)
func (*WalletTransactionUseCase) GetUserWallet ¶
func (uc *WalletTransactionUseCase) GetUserWallet(ctx context.Context, userId string) ([]*UserWallet, error)
func (*WalletTransactionUseCase) GetUserWalletOrCreateWithSymbol ¶
func (uc *WalletTransactionUseCase) GetUserWalletOrCreateWithSymbol(ctx context.Context, userId, symbol, walletType string) ([]*UserWallet, error)
func (*WalletTransactionUseCase) GetUserWalletWithSymbol ¶
func (uc *WalletTransactionUseCase) GetUserWalletWithSymbol(ctx context.Context, userId, symbol string) ([]*UserWallet, error)
func (*WalletTransactionUseCase) ICOTransaction ¶
func (uc *WalletTransactionUseCase) ICOTransaction(ctx context.Context, userId, amount, symbol, sourceId, transType, icoType string) error
func (*WalletTransactionUseCase) InitData ¶
func (uc *WalletTransactionUseCase) InitData(ctx context.Context)
func (*WalletTransactionUseCase) MarketingRewardInternal ¶
func (uc *WalletTransactionUseCase) MarketingRewardInternal(ctx context.Context, userID, amount, symbol, sourceID string) (string, error)
MarketingRewardInternal is used to increase balance for user with symbol and amount
func (*WalletTransactionUseCase) ReferralReward ¶
func (uc *WalletTransactionUseCase) ReferralReward(ctx context.Context, userId, amount, symbol, sourceId string) error
func (*WalletTransactionUseCase) Subscription ¶
func (uc *WalletTransactionUseCase) Subscription(ctx context.Context, userId, amount, symbol, sourceId string) error
Click to show internal directories.
Click to hide internal directories.