复制项目
This commit is contained in:
75
pkg/common/storage/model/redpacket.go
Normal file
75
pkg/common/storage/model/redpacket.go
Normal file
@@ -0,0 +1,75 @@
|
||||
// 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 (
|
||||
RedPacketTableName = "red_packets"
|
||||
RedPacketReceiveTableName = "red_packet_receives"
|
||||
)
|
||||
|
||||
// RedPacketType 红包类型
|
||||
const (
|
||||
RedPacketTypeNormal = 1 // 普通红包(平均分配)
|
||||
RedPacketTypeRandom = 2 // 拼手气红包(随机分配)
|
||||
)
|
||||
|
||||
// RedPacketStatus 红包状态
|
||||
const (
|
||||
RedPacketStatusActive = 0 // 进行中
|
||||
RedPacketStatusFinished = 1 // 已领完
|
||||
RedPacketStatusExpired = 2 // 已过期
|
||||
)
|
||||
|
||||
// RedPacket 红包主表
|
||||
type RedPacket struct {
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID
|
||||
SendUserID string `bson:"send_user_id"` // 发送者ID
|
||||
GroupID string `bson:"group_id"` // 群ID(群红包)
|
||||
ConversationID string `bson:"conversation_id"` // 会话ID
|
||||
SessionType int32 `bson:"session_type"` // 会话类型:1-单聊,3-群聊
|
||||
RedPacketType int32 `bson:"red_packet_type"` // 红包类型:1-普通红包,2-拼手气红包
|
||||
TotalAmount int64 `bson:"total_amount"` // 总金额(分)
|
||||
TotalCount int32 `bson:"total_count"` // 总个数
|
||||
RemainAmount int64 `bson:"remain_amount"` // 剩余金额(分)
|
||||
RemainCount int32 `bson:"remain_count"` // 剩余个数
|
||||
Blessing string `bson:"blessing"` // 祝福语
|
||||
Status int32 `bson:"status"` // 状态:0-进行中,1-已领完,2-已过期
|
||||
ExpireTime time.Time `bson:"expire_time"` // 过期时间(默认24小时)
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
// RedPacketReceive 红包领取记录表
|
||||
type RedPacketReceive struct {
|
||||
ReceiveID string `bson:"receive_id"` // 领取记录ID
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID
|
||||
ReceiveUserID string `bson:"receive_user_id"` // 领取者ID
|
||||
Amount int64 `bson:"amount"` // 领取金额(分)
|
||||
ReceiveTime time.Time `bson:"receive_time"` // 领取时间
|
||||
IsLucky bool `bson:"is_lucky"` // 是否为手气最佳(仅拼手气红包有效)
|
||||
Ex string `bson:"ex"` // 扩展字段
|
||||
}
|
||||
|
||||
func (*RedPacket) TableName() string {
|
||||
return RedPacketTableName
|
||||
}
|
||||
|
||||
func (*RedPacketReceive) TableName() string {
|
||||
return RedPacketReceiveTableName
|
||||
}
|
||||
Reference in New Issue
Block a user