models

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2019 License: Apache-2.0 Imports: 28 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DistributeSubscriberLimit      = 100
	ExpiredDistributedMessageLimit = 100
	PendingDistributedMessageLimit = 20

	MessageStatusSent      = "SENT"
	MessageStatusDelivered = "DELIVERED"
)
View Source
const (
	MessageStatePending = "pending"
	MessageStateSuccess = "success"

	MessageCategoryMessageRecall = "MESSAGE_RECALL"
	MessageCategoryPlainText     = "PLAIN_TEXT"
	MessageCategoryPlainImage    = "PLAIN_IMAGE"
	MessageCategoryPlainVideo    = "PLAIN_VIDEO"
	MessageCategoryPlainData     = "PLAIN_DATA"
	MessageCategoryPlainSticker  = "PLAIN_STICKER"
	MessageCategoryPlainContact  = "PLAIN_CONTACT"
	MessageCategoryPlainAudio    = "PLAIN_AUDIO"
	MessageCategoryAppCard       = "APP_CARD"
)
View Source
const (
	PacketStateInitial  = "INITIAL"
	PacketStatePaid     = "PAID"
	PacketStateExpired  = "EXPIRED"
	PacketStateRefunded = "REFUNDED"
)
View Source
const (
	PaymentStatePending = "pending"
	PaymentStatePaid    = "paid"

	PayMethodMixin  = "mixin"
	PayMethodWechat = "wechat"
	PayMethodCoupon = "coupon"
	PayMethodOffer  = "offer"

	UserActivePeriod = 5 * time.Minute
)
View Source
const (
	PacketMinAmount = "0.0001"
)
View Source
const (
	ProhibitedMessage = "prohibited-message-property"
)
View Source
const WX_TN_PREFIX = "tn-"

Variables

This section is empty.

Functions

func CleanUpExpiredDistributedMessages

func CleanUpExpiredDistributedMessages(ctx context.Context, shard string) (int64, error)

func CreateWxClient

func CreateWxClient() *wxpay.Client

func CreateWxPayment

func CreateWxPayment(client *wxpay.Client, traceId int64, amount, wxOpenId string) (wxpay.Params, error)

func FetchWxPayment

func FetchWxPayment(client *wxpay.Client, traceId int64) (wxpay.Params, error)

func FindDistributedMessageRecipientId

func FindDistributedMessageRecipientId(ctx context.Context, id string) (string, error)

func GetPayJsParams

func GetPayJsParams(client *wxpay.Client, params wxpay.Params) wxpay.Params

func ListExpiredPackets

func ListExpiredPackets(ctx context.Context, limit int) ([]string, error)

func PaidMemberCount

func PaidMemberCount(ctx context.Context) (int64, error)

func PingUserActiveAt

func PingUserActiveAt(ctx context.Context, userId string) error

func ReadProhibitedProperty

func ReadProhibitedProperty(ctx context.Context) (bool, error)

func ReadStatistic

func ReadStatistic(ctx context.Context, user *User) (map[string]interface{}, error)

func SendParticipantTransfer

func SendParticipantTransfer(ctx context.Context, packetId, userId string, amount string) error

func SubscribersCount

func SubscribersCount(ctx context.Context) (int64, error)

func UniqueConversationId

func UniqueConversationId(userId, recipientId string) string

func UpdateMessagesStatus

func UpdateMessagesStatus(ctx context.Context, messages []*DistributedMessage) error

Types

type Asset

type Asset struct {
	AssetId  string
	Symbol   string
	Name     string
	IconURL  string
	PriceBTC string
	PriceUSD string

	Balance string
}

type Blacklist

type Blacklist struct {
	UserId string
}

type Coupon

type Coupon struct {
	CouponId   string
	Code       string
	UserId     string
	OccupiedBy sql.NullString
	OccupiedAt pq.NullTime
	CreatedAt  time.Time

	FullName string
}

func CreateCoupons

func CreateCoupons(ctx context.Context, user *User, quantity int) ([]*Coupon, error)

func Occupied

func Occupied(ctx context.Context, code string, user *User) (*Coupon, error)

func ReadCoupons

func ReadCoupons(ctx context.Context) ([]*Coupon, error)

type DistributedMessage

type DistributedMessage struct {
	MessageId      string
	ConversationId string
	RecipientId    string
	UserId         string
	ParentId       string
	QuoteMessageId string
	Shard          string
	Category       string
	Data           string
	Status         string
	CreatedAt      time.Time
}

func FindDistributedMessage

func FindDistributedMessage(ctx context.Context, id string) (*DistributedMessage, error)

func PendingActiveDistributedMessages

func PendingActiveDistributedMessages(ctx context.Context, shard string, limit int64) ([]*DistributedMessage, error)

type Message

type Message struct {
	MessageId        string
	UserId           string
	Category         string
	QuoteMessageId   string
	Data             string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	State            string
	LastDistributeAt time.Time

	FullName sql.NullString
}

func CreateMessage

func CreateMessage(ctx context.Context, user *User, messageId, category, quoteMessageId, data string, createdAt, updatedAt time.Time) (*Message, error)

func FindMessage

func FindMessage(ctx context.Context, id string) (*Message, error)

func LastestMessageWithUser

func LastestMessageWithUser(ctx context.Context, limit int64) ([]*Message, error)

func PendingMessages

func PendingMessages(ctx context.Context, limit int64) ([]*Message, error)

func (*Message) Distribute

func (message *Message) Distribute(ctx context.Context) error

func (*Message) Leapfrog

func (message *Message) Leapfrog(ctx context.Context, reason string) error

type Order

type Order struct {
	OrderId       string
	UserId        string
	TraceId       int64
	PrepayId      string
	State         string
	Amount        string
	Channel       string
	TransactionId string
	CreatedAt     time.Time
	PaidAt        pq.NullTime
}

func CreateOrder

func CreateOrder(ctx context.Context, userId, amount, wxOpenId string) (*Order, wxpay.Params, wxpay.Params, error)

func GetNotPaidOrders

func GetNotPaidOrders(ctx context.Context, limit int64) ([]*Order, error)

func GetOrder

func GetOrder(ctx context.Context, orderId string) (*Order, error)

func MarkOrderAsPaidByTraceId

func MarkOrderAsPaidByTraceId(ctx context.Context, traceId int64, transactionId string) (*Order, error)

type Packet

type Packet struct {
	PacketId        string
	UserId          string
	AssetId         string
	Amount          string
	Greeting        string
	TotalCount      int64
	RemainingCount  int64
	RemainingAmount string
	State           string
	CreatedAt       time.Time

	User         *User
	Asset        *Asset
	Participants []*Participant
}

func PayPacket

func PayPacket(ctx context.Context, packetId string, assetId, amount string) (*Packet, error)

func RefundPacket

func RefundPacket(ctx context.Context, packetId string) (*Packet, error)

func SendPacketRefundTransfer

func SendPacketRefundTransfer(ctx context.Context, packetId string) (*Packet, error)

func ShowPacket

func ShowPacket(ctx context.Context, packetId string) (*Packet, error)

func (*Packet) GetParticipants

func (packet *Packet) GetParticipants(ctx context.Context) error

type Participant

type Participant struct {
	PacketId  string
	UserId    string
	Amount    string
	CreatedAt time.Time
	PaidAt    pq.NullTime

	FullName  string
	AvatarURL string
}

func ListPendingParticipants

func ListPendingParticipants(ctx context.Context, limit int) ([]*Participant, error)

type Property

type Property struct {
	Name      string
	Value     string
	CreatedAt time.Time
}

func CreateProperty

func CreateProperty(ctx context.Context, name string, value bool) (*Property, error)

func ReadProperty

func ReadProperty(ctx context.Context, name string) (*Property, error)

type RecallMessage

type RecallMessage struct {
	MessageId string `json:"message_id"`
}

type User

type User struct {
	UserId         string
	IdentityNumber int64
	FullName       string
	AccessToken    string
	AvatarURL      string
	TraceId        string
	State          string
	ActiveAt       time.Time
	SubscribedAt   time.Time
	PayMethod      string

	AuthenticationToken string
	// contains filtered or unexported fields
}

func AuthenticateUserByOAuth

func AuthenticateUserByOAuth(ctx context.Context, authorizationCode string) (*User, error)

func AuthenticateUserByToken

func AuthenticateUserByToken(ctx context.Context, authenticationToken string) (*User, error)

func FindUser

func FindUser(ctx context.Context, userId string) (*User, error)

func Subscribers

func Subscribers(ctx context.Context, offset time.Time, identity int64, keywords string) ([]*User, error)

func (*User) ClaimPacket

func (current *User) ClaimPacket(ctx context.Context, packetId string) (*Packet, error)

func (*User) Coupons

func (user *User) Coupons(ctx context.Context) ([]*Coupon, error)

func (*User) CreateBlacklist

func (user *User) CreateBlacklist(ctx context.Context, userId string) (*Blacklist, error)

func (*User) CreatePacket

func (current *User) CreatePacket(ctx context.Context, assetId string, amount number.Decimal, totalCount int64, greeting string) (*Packet, error)

func (*User) DeleteUser

func (user *User) DeleteUser(ctx context.Context, id string) error

func (*User) GetFullName

func (u *User) GetFullName() string

func (*User) GetRole

func (user *User) GetRole() string

func (*User) ListAssets

func (current *User) ListAssets(ctx context.Context) ([]*Asset, error)

func (*User) Payment

func (user *User) Payment(ctx context.Context) error

func (*User) Prepare

func (current *User) Prepare(ctx context.Context) (int64, error)

func (*User) ShowAsset

func (current *User) ShowAsset(ctx context.Context, assetId string) (*Asset, error)

func (*User) Subscribe

func (user *User) Subscribe(ctx context.Context) error

func (*User) Unsubscribe

func (user *User) Unsubscribe(ctx context.Context) error

func (*User) UpdateProfile

func (user *User) UpdateProfile(ctx context.Context, fullName string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL