Documentation
¶
Index ¶
- Constants
- type AccountCreatedDTO
- type AccountDTO
- type AccountLogDTO
- type AccountService
- type AccountTransferDTO
- type AccountType
- type ActivityStatus
- type ChangeFlag
- type ChangeType
- type EnvelopeType
- type OrderStatus
- type OrderType
- type PayStatus
- type RedEnvelopeActivity
- type RedEnvelopeGoodsDTO
- type RedEnvelopeItemDTO
- type RedEnvelopeReceiveDTO
- type RedEnvelopeSendingDTO
- type RedEnvelopeService
- type TradeParticipator
- type TransferredStatus
Constants ¶
View Source
const (
DefaultBlessing = "恭喜发财"
)
View Source
const DefaultCurrencyCode = "CNY"
货币类型
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountCreatedDTO ¶
type AccountCreatedDTO struct { // 用户编号 账户所属用户 UserId string `json:"userId" validate:"required"` // 用户名称 Username string `json:"username" validate:"required"` // 账户名称 用来说明账户的简短描述 比如xxx积分 xxx零钱 AccountName string `json:"accountName" validate:"required"` // 账户类型 用来区分不同类型的账户 积分账户 会员卡账户 钱包账户 红包账户 AccountType int `json:"accountType"` // 货币类型编码 CNY人民币 EUR欧元 USD美元 CurrencyCode string `json:"currencyCode"` // TODO:NOTICE 金额 在Go中 float32 float64 计算时会丢失精度 所以金额用字符串来传递避免丢失精度 Amount string `json:"amount" validate:"required"` }
账户创建
type AccountDTO ¶
type AccountDTO struct { // 用户编号 账户所属用户 UserId string `json:"userId" validate:"required"` // 用户名称 Username string `json:"username" validate:"required"` // 账户名称 用来说明账户的简短描述 比如xxx积分 xxx零钱 AccountName string `json:"accountName" validate:"required"` // 账户类型 用来区分不同类型的账户 积分账户 会员卡账户 钱包账户 红包账户 AccountType int `json:"accountType"` // 货币类型编码 CNY人民币 EUR欧元 USD美元 CurrencyCode string `json:"currencyCode"` // TODO:NOTICE 金额 在Go中 float32 float64 计算时会丢失精度 所以金额用字符串来传递避免丢失精度 Amount string `json:"amount" validate:"required"` // 账户编号 账户唯一标识 AccountNo string `json:"accountNo"` // 账户创建时间 CreatedAt time.Time `json:"createdAt"` Balance decimal.Decimal `json:"balance"` //账户可用余额 Status int `json:"status"` //账户状态,账户状态:0账户初始化,1启用,2停用 UpdatedAt time.Time `json:"updatedAt"` //更新时间 }
账户
type AccountLogDTO ¶
type AccountLogDTO struct { LogNo string //流水编号 全局不重复字符或数字,唯一性标识 TradeNo string //交易单号 全局不重复字符或数字,唯一性标识 AccountNo string //账户编号 账户ID TargetAccountNo string //账户编号 账户ID UserId string //用户编号 Username string //用户名称 TargetUserId string //目标用户编号 TargetUsername string //目标用户名称 Amount decimal.Decimal //交易金额,该交易涉及的金额 Balance decimal.Decimal //交易后余额,该交易后的余额 ChangeType ChangeType //流水交易类型,0 创建账户,>0 为收入类型,<0 为支出类型,自定义 ChangeFlag ChangeFlag //交易变化标识:-1 出账 1为进账,枚举 Status int //交易状态: Decs string //交易描述 CreatedAt time.Time //创建时间 }
账户流水
type AccountService ¶
type AccountService interface { // 创建账户 CreateAccount(dto AccountCreatedDTO) (*AccountDTO, error) // 转账 Transfer(dto AccountTransferDTO) (TransferredStatus, error) // 储值 StoreValue(dto AccountTransferDTO) (TransferredStatus, error) // 红包账户查询 GetEnvelopeAccountByUserId(userId string) *AccountDTO GetAccount(accountNo string) *AccountDTO }
var IAccountService AccountService
type AccountTransferDTO ¶
type AccountTransferDTO struct { // 交易订单号 TradeNo string `validate:"required" json:"tradeNo"` // 交易主体 TradeBody TradeParticipator `validate:"required" json:"tradeBody"` // 交易对方 TradeTarget TradeParticipator `validate:"required" json:"tradeTarget"` // 交易金额 AmountStr string `validate:"required" json:"amountStr"` Amount decimal.Decimal `` // 转账变化类型 ChangeType ChangeType `validate:"required,numeric" json:"changeType"` // 资金交易是否成功的变化标识 ChangeFlag ChangeFlag `validate:"required,numeric" json:"changeFlag"` // 交易描述 Desc string `json:"desc"` }
账户转账
type AccountType ¶
type AccountType int8
账户类型
const ( EnvelopeAccountType AccountType = 1 SystemEnvelopeAccountType AccountType = 2 )
type ActivityStatus ¶
type ActivityStatus int
红包活动 创建 激活 过期 失效
const ( ActivityCreate ActivityStatus = 1 ActivityActivated ActivityStatus = 2 ActivityExpired ActivityStatus = 3 ActivityDisabled ActivityStatus = 4 )
type ChangeFlag ¶
type ChangeFlag int8
资金交易的变化标识
const ( // 创建账户 0 FlagAccountCreated ChangeFlag = 0 // 所有支出出账 -1 FlagTransferOut ChangeFlag = -1 // 所有收入入账 1 FlagTransferIn ChangeFlag = 1 )
type ChangeType ¶
type ChangeType int8
转账类型 0:创建账户 >=1:进账 <=-1 支出
const ( // 账户创建 AccountCreated ChangeType = 0 // 账户储值 AccountStoreValue ChangeType = 1 // 红包资金的支出 EnvelopeOutgoing ChangeType = -2 // 红包资金的收入 EnvelopeIncoming ChangeType = 2 // 交易主体用户红包资金的过期退款 EnvelopeExpiredRefund ChangeType = 3 // 系统方红包资金的过期退款 SysEnvelopeExpiredRefund ChangeType = -3 )
type EnvelopeType ¶
type EnvelopeType int
红包类型 普通红包 碰运气红包
const ( GeneralEnvelopeType EnvelopeType = 1 LuckyEnvelopeType EnvelopeType = 2 )
type OrderStatus ¶
type OrderStatus int
红包订单状态 创建 发布 过期 失效
const ( OrderCreate OrderStatus = 1 OrderSending OrderStatus = 2 OrderExpired OrderStatus = 3 OrderDisabled OrderStatus = 4 OrderExpiredRefundSucceed OrderStatus = 5 OrderExpiredRefundFiled OrderStatus = 6 )
type RedEnvelopeActivity ¶
type RedEnvelopeActivity struct { // 红包商品 RedEnvelopeGoodsDTO // 活动链接 动态生成全局唯一 发给收红包的人群 Link string `json:"link"` }
func (*RedEnvelopeActivity) CopyTo ¶
func (this *RedEnvelopeActivity) CopyTo(target *RedEnvelopeActivity)
type RedEnvelopeGoodsDTO ¶
type RedEnvelopeGoodsDTO struct { EnvelopeNo string `json:"envelopeNo"` EnvelopeType int `json:"envelopeType" validate:"required,numeric"` Username string `json:"username" validate:"required"` UserId string `json:"userId" validate:"required"` Blessing string `json:"blessing"` // Amount decimal.Decimal `json:"amount" validate:"required,numeric"` Amount string `json:"amount" validate:"required"` // AmountOne decimal.Decimal `json:"amountOne"` AmountOne string `json:"amountOne"` Quantity int `json:"quantity" validate:"required,numeric"` RemainAmount decimal.Decimal `json:"remainAmount"` RemainQuantity int `json:"remainQuantity"` ExpiredAt time.Time `json:"expiredAt"` Status int `json:"status"` OrderType OrderType `json:"orderType"` PayStatus PayStatus `json:"payStatus"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` AccountNo string `json:"accountNo"` // 原关联订单号 OriginEnvelopeNo string `json:"originEnvelopeNo"` }
红包商品
type RedEnvelopeItemDTO ¶
type RedEnvelopeItemDTO struct { ItemNo string `json:"itemNo"` // 红包订单详情编号 EnvelopeNo string `json:"envelopeNo"` // 红包编号 RecvUsername string `json:"recvUsername"` // 接收者用户名 RecvUserId string `json:"recvUserId"` // 接收者用户id Amount decimal.Decimal `json:"amount"` // 收到金额 Quantity int `json:"quantity"` // 收到数量 RemainAmount decimal.Decimal `json:"remainAmount"` // 剩余金额 AccountNo string `json:"accountNo"` // 红包接收者账户ID PayStatus int `json:"payStatus"` // 支付状态 CreatedAt time.Time `json:"createdAt"` // 创建时间 UpdatedAt time.Time `json:"updatedAt"` // 修改时间 Desc string `json:"desc"` IsLuckiest bool `json:"isLuckiest"` // 是否是最幸运的 }
红包详情
func (*RedEnvelopeItemDTO) CopyTo ¶
func (this *RedEnvelopeItemDTO) CopyTo(target *RedEnvelopeItemDTO)
type RedEnvelopeReceiveDTO ¶
type RedEnvelopeReceiveDTO struct { EnvelopeNo string `json:"envelopeNo" validate:"required"` RecvUsername string `json:"recvUsername" validate:"required"` RecvUserId string `json:"recvUserId" validate:"required"` // 内部通过 RecvUserId 查询出账号 AccountNo string `json:"accountNo"` }
收红包
type RedEnvelopeSendingDTO ¶
type RedEnvelopeSendingDTO struct { EnvelopeType int `json:"envelopeType" validate:"required"` Username string `json:"username" validate:"required"` UserId string `json:"userId" validate:"required"` Blessing string `json:"blessing"` // 根据红包类型 EnvelopeType 区分 普通红包指单个红包金额 碰运气红包指红包总金额 // Amount decimal.Decimal `json:"amount" validate:"required,numeric"` Amount string `json:"amount" validate:"required"` Quantity int `json:"quantity" validate:"required,numeric"` }
发红包
func (*RedEnvelopeSendingDTO) ToGoods ¶
func (dto *RedEnvelopeSendingDTO) ToGoods() *RedEnvelopeGoodsDTO
type RedEnvelopeService ¶
type RedEnvelopeService interface { // 发红包 SendOut(RedEnvelopeSendingDTO) (*RedEnvelopeActivity, error) // 收红包 返回订单详情信息 Receive(RedEnvelopeReceiveDTO) (*RedEnvelopeItemDTO, error) // 退款 返回红包商品信息 Refund(envelopeNo string) (order *RedEnvelopeGoodsDTO) // 查询红包订单 Get(envelopeNo string) (order *RedEnvelopeGoodsDTO) // 查询本人发送的红包列表 ListSent(string, int, int) []*RedEnvelopeGoodsDTO ListReceived(userId string, page, size int) []*RedEnvelopeItemDTO ListItems(envelopeNo string) []*RedEnvelopeItemDTO ListReceivable(int, int) []*RedEnvelopeGoodsDTO }
红包服务接口
var IRedEnvelopeService RedEnvelopeService
func GetRedEnvelopeService ¶
func GetRedEnvelopeService() RedEnvelopeService
type TradeParticipator ¶
type TradeParticipator struct { // 账户编号 AccountNo string `validate:"required" json:"accountNo"` // 用户编号 UserId string `validate:"required" json:"userId"` // 用户名 Username string `validate:"required" json:"username"` }
账户交易参与者 交易主体 交易对方 信息一致
type TransferredStatus ¶
type TransferredStatus int8
转账状态 使用类型别名
const ( // 转账失败 TransferredStatusFailure TransferredStatus = -1 // 余额不足 TransferredStatusSufficientFunds TransferredStatus = 0 // 转账成功 TransferredStatusSuccess TransferredStatus = 1 )
Click to show internal directories.
Click to hide internal directories.