复制项目
This commit is contained in:
56
pkg/common/storage/model/wallet.go
Normal file
56
pkg/common/storage/model/wallet.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
WalletTableName = "wallets"
|
||||
WalletBalanceRecordTableName = "wallet_balance_records"
|
||||
)
|
||||
|
||||
// Wallet 用户钱包表
|
||||
type Wallet struct {
|
||||
UserID string `bson:"user_id"` // 用户ID(唯一)
|
||||
Balance int64 `bson:"balance"` // 余额(分)
|
||||
Version int64 `bson:"version"` // 版本号(用于乐观锁,防止并发覆盖)
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
type WalletBalanceRecord struct {
|
||||
ID string `bson:"_id"` // 记录ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Amount int64 `bson:"amount"` // 变动金额(单位:分,正数表示增加,负数表示减少)
|
||||
Type int32 `bson:"type"` // 变动类型:1-充值,2-提现/提款,3-消费,4-退款,5-奖励,6-后台充值,7-发红包,8-抢红包,99-其他
|
||||
BeforeBalance int64 `bson:"before_balance"` // 变动前余额(单位:分)
|
||||
AfterBalance int64 `bson:"after_balance"` // 变动后余额(单位:分)
|
||||
OrderID string `bson:"order_id"` // 关联订单ID(可选)
|
||||
TransactionID string `bson:"transaction_id"` // 交易ID(可选)
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID(用于发红包和抢红包记录关联,可选)
|
||||
Remark string `bson:"remark"` // 备注
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
func (*Wallet) TableName() string {
|
||||
return WalletTableName
|
||||
}
|
||||
|
||||
func (*WalletBalanceRecord) TableName() string {
|
||||
return WalletBalanceRecordTableName
|
||||
}
|
||||
Reference in New Issue
Block a user