service/dbstruct/vas_mongo.go

190 lines
6.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dbstruct
import (
"math"
"service/bizcommon/util"
)
// 用户增值信息
const (
UserVasLockTypeOpen = 0 // 公开
UserVasLockTypeLock = 1 // 私密
)
type UserVasInfo struct {
Mid int64 `json:"mid" bson:"_id"`
WechatLockType int32 `json:"wechat_lock_type" bson:"wechat_lock_type"` // 上锁方式见UserVasLockType*
WechatContact string `json:"wechat_contact" bson:"wechat_contact"` // 微信联系方式
WechatCoinPrice int64 `json:"wechat_coin_price" bson:"wechat_coin_price"` // 微信联系方式价格
WechatUt int64 `json:"wechat_ut" bson:"wechat_ut"` // 微信联系方式更新时间
}
func (p UserVasInfo) GetH5WechatCoinPrice() int64 {
return int64(math.Ceil(float64(p.WechatCoinPrice)/9)) * 10
}
func (p UserVasInfo) GetWechatCoinPrice() int64 {
return p.WechatCoinPrice
}
// 金币订单oplog
const (
OrderOpLogActionAdd = "add"
OrderOpLogActionUpdate = "update"
)
const (
OrderOpLogOperatorTypeUser = "user" // 用户
OrderOpLogOperatorTypeOp = "op" // 运营
)
const (
OrderOpLogResultFail = "fail" // 结果失败
OrderOpLogResultOk = "ok" // 结果成功
)
type OplogCoinOrder struct {
OrderId string `json:"order_id" bson:"order_id"`
Mid int64 `json:"mid" bson:"mid"`
Ct int64 `json:"ct" bson:"ct"`
Action string `json:"action" bson:"action"` // 动作
OperatorType string `json:"operator_type" bson:"operator_type"` // 操作人类型见CoinOrderOpLogOperatorType*
Operator string `json:"operator" bson:"operator"` // 操作人
Detail string `json:"detail" bson:"detail"` // 操作详情
Result string `json:"result" bson:"result"` // 结果
BeforeStatus int32 `json:"before_status" bson:"before_status"`
AfterStatus int32 `json:"after_status" bson:"after_status"`
}
type OplogOrder struct {
OrderId string `json:"order_id" bson:"order_id"`
Mid int64 `json:"mid" bson:"mid"`
Ct int64 `json:"ct" bson:"ct"`
Action string `json:"action" bson:"action"` // 动作
OperatorType string `json:"operator_type" bson:"operator_type"` // 操作人类型见CoinOrderOpLogOperatorType*
Operator string `json:"operator" bson:"operator"` // 操作人
Detail string `json:"detail" bson:"detail"` // 操作详情
Result string `json:"result" bson:"result"` // 结果
BeforeStatus int32 `json:"before_status" bson:"before_status"`
AfterStatus int32 `json:"after_status" bson:"after_status"`
}
const (
SuperfanshipValidPeriodEternal = 0 // 永久生效
SuperfanshipValidPeriodMonth = 1 // 31d
SuperfanshipValidPeriodSeason = 2 // 93d
SuperfanshipValidPeriodHalfYear = 3 // 186d
SuperfanshipValidPeriodYear = 4 // 372d
)
// 空间增值相关,空间价格等
type ZoneVas struct {
Zid int64 `json:"zid" bson:"_id"`
Mid int64 `json:"mid" bson:"mid"` // 主播mid
Ct int64 `json:"ct" bson:"ct"` //
Ut int64 `json:"ut" bson:"ut"` //
AdmissionPrice int64 `json:"admission_price" bson:"admission_price"` // 空间解锁价格, 单位: 分
IronfanshipPrice int64 `json:"ironfanship_price" bson:"ironfanship_price"` // 铁粉解锁价格, 单位: 分
IsSuperfanshipEnabled int `json:"is_superfanship_enabled" bson:"is_superfanship_enabled"` // 是否开启超粉空间 0: 关闭, 1: 开启
SuperfanshipPrice int64 `json:"superfanship_price" bson:"superfanship_price"` // 超粉价格, 单位: 分
SuperfanshipValidPeriod int `json:"superfanship_valid_period" bson:"superfanship_valid_period"` // 超粉有效期类型, SuperfanshipValidPeriod*
IsSuperfanshipGiveWechat int `json:"is_superfanship_give_wechat" bson:"is_superfanship_give_wechat"` // 是否开启超粉空间赠送微信 0: 不赠送, 1: 赠送
}
func (p ZoneVas) GetSuperfanshipDurationSecond() int64 {
switch p.SuperfanshipValidPeriod {
case SuperfanshipValidPeriodEternal:
return -1
case SuperfanshipValidPeriodMonth:
return 86400 * 31
case SuperfanshipValidPeriodSeason:
return 86400 * 31 * 3
case SuperfanshipValidPeriodHalfYear:
return 86400 * 31 * 6
case SuperfanshipValidPeriodYear:
return 86400 * 31 * 12
default:
return -1
}
}
func (p ZoneVas) GetSuperfanshipDurationDesc() string {
switch p.SuperfanshipValidPeriod {
case SuperfanshipValidPeriodEternal:
return "永久"
case SuperfanshipValidPeriodMonth:
return "1个月"
case SuperfanshipValidPeriodSeason:
return "3个月"
case SuperfanshipValidPeriodHalfYear:
return "6个月"
case SuperfanshipValidPeriodYear:
return "12个月"
default:
return "永久"
}
}
func (p ZoneVas) GetAdmissionCoinPrice() int64 {
return util.RoundUp(float64(p.AdmissionPrice) / 10.0)
}
func (p ZoneVas) GetIronfanshipCoinPrice() int64 {
return util.RoundUp(float64(p.IronfanshipPrice) / 10.0)
}
func (p ZoneVas) GetSuperfanshipCoinPrice() int64 {
return util.RoundUp(float64(p.SuperfanshipPrice) / 10.0)
}
// 空间动态价格
type ZoneMomentPrice struct {
MomentId int64 `json:"id" bson:"_id"` // 动态id
Zid int64 `json:"zid" bson:"zid"` // 空间id
Mid int64 `json:"mid" bson:"mid"` // 主播mid
Ct int64 `json:"ct" bson:"ct"` //
Ut int64 `json:"ut" bson:"ut"` //
Price int64 `json:"price" bson:"price"` // 动态价格,单位:分
}
// 空间动态数据相关
type ZoneMomentStat struct {
MomentId int64 `json:"id" bson:"_id"` // 动态id
Zid int64 `json:"zid" bson:"zid"` // 空间id
BuyerCnt int64 `json:"buyer_cnt" bson:"buyer_cnt"` // 动态购买人数
Ct int64 `json:"ct" bson:"ct"` //
Ut int64 `json:"ut" bson:"ut"` //
}
// 收入表
type WeekDashboardSt struct {
Date string `json:"date" bson:"date"` // 日期 x轴
Income int64 `json:"income" bson:"income"` // 收入 y轴
}
type IncomeFromDashboardSt struct {
Desc string `json:"desc" bson:"desc"` // 描述
Income int64 `json:"income" bson:"income"` // 收入
}
type UserIncome struct {
Mid int64 `json:"mid" bson:"_id"`
WeekDashboard []WeekDashboardSt `json:"week_dashboard" bson:"week_dashboard"`
WeekFromDashboard []IncomeFromDashboardSt `json:"week_from_dashboard" bson:"week_from_dashboard"`
}
// 提现历史
const (
WithdrawStatusOk = 1
WithdrawStatusFail = 2
)
type WithdrawHis struct {
Id string `json:"id" bson:"_id"`
Mid int64 `json:"mid" bson:"mid"`
Did string `json:"did" bson:"did"`
Status int `json:"status" bson:"status"` // 见: WithdrawStatusOk
Err string `json:"err" bson:"err"`
Ct int64 `json:"ct" bson:"ct"`
}