@@ -0,0 +1,16 @@
|
||||
package productmod
|
||||
|
||||
type VipPositionList struct {
|
||||
ShowType int64 `json:"showType"` //展示样式
|
||||
Position string `json:"position"`
|
||||
List []Product `json:"list"`
|
||||
}
|
||||
|
||||
type RespVipInfoList struct {
|
||||
List []ProductList `json:"list"`
|
||||
}
|
||||
|
||||
type ProductList struct {
|
||||
ID string `bson:"id" json:"id"` // 会员卡ID
|
||||
Name string `bson:"productName" json:"productName" ` // 会员卡名字
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package productmod
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/db"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/models"
|
||||
"91porn-server/models/commod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
const table = models.Product
|
||||
|
||||
// InitIndex 设置index
|
||||
func initIndex() {
|
||||
coll := coll(nil)
|
||||
many := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{{Key: "vipLevel", Value: 1}},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "productType", Value: 1}},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "discountedPrice", Value: 1}},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "productName", Value: 1}},
|
||||
Options: options.Index().SetUnique(true),
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "createdAt", Value: 1}},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: "updatedAt", Value: 1}},
|
||||
},
|
||||
}
|
||||
if _, err := coll.CreateIndex(many); err != nil {
|
||||
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
|
||||
}
|
||||
}
|
||||
|
||||
func coll(t *db.MongoTool) *db.MongoTool {
|
||||
if t == nil {
|
||||
return mdb.Coll(table)
|
||||
}
|
||||
return t.Coll(table)
|
||||
}
|
||||
|
||||
func (this *Product) DiscountedPriceFill(sys string) {
|
||||
sys = common.HandleSysType(sys)
|
||||
if strings.Contains(sys, constant.SysTypeIOS) {
|
||||
this.DiscountedPrice = *this.DiscountedPriceIos
|
||||
} else {
|
||||
this.DiscountedPrice = *this.DiscountedPriceAnd
|
||||
}
|
||||
}
|
||||
|
||||
// FindProduct 查询
|
||||
func FindProduct(id primitive.ObjectID, sys string) (p *Product, err error) {
|
||||
if err = coll(nil).FindOne(&p, bson.M{"_id": id}); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProduct", table, "FindOne", err), log.Any("id", id))
|
||||
return
|
||||
}
|
||||
if p == nil || p.ID.IsZero() {
|
||||
log.Info("product FindProduct not found", log.Any("id", id))
|
||||
return nil, nil
|
||||
}
|
||||
p.DiscountedPriceFill(sys)
|
||||
return
|
||||
}
|
||||
|
||||
// FindByProductType 查询
|
||||
func FindByProductType(productType commod.ProductType) (data []Product, err error) {
|
||||
data = make([]Product, 0)
|
||||
opts := options.FindOptions{Sort: bson.D{{Key: "sort", Value: 1}}}
|
||||
if err = coll(nil).Find(&data, bson.M{"productType": productType, "status": true}, &opts); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProduct", table, "FindOne", err), log.Any("productType", productType))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// FindByProductTypes 查询
|
||||
func FindByProductTypes(productTypes []commod.ProductType) (data []Product, err error) {
|
||||
data = make([]Product, 0)
|
||||
opts := options.FindOptions{Sort: bson.D{{Key: "sort", Value: 1}}}
|
||||
if err = coll(nil).Find(&data, bson.M{"productType": bson.M{"$in": productTypes}, "status": true}, &opts); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProduct", table, "Find", err), log.Any("productType", productTypes))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// FindActiveDramaCards 返回配置了短剧权益天数的在售商品。
|
||||
func FindActiveDramaCards() (data []Product, err error) {
|
||||
opts := options.Find().SetSort(bson.D{{Key: "sort", Value: 1}, {Key: "_id", Value: 1}})
|
||||
err = coll(nil).Find(&data, bson.M{"status": true, "dramaDays": bson.M{"$gt": 0}}, opts)
|
||||
return
|
||||
}
|
||||
|
||||
// FindByVipLevel 查询
|
||||
func FindByVipLevel(vipLevel int) (data []Product, err error) {
|
||||
data = make([]Product, 0)
|
||||
if err = coll(nil).Find(&data, bson.M{"vipLevel": vipLevel, "status": true}); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindByVipLevel", table, "FindOne", err), log.Any("vipLevel", vipLevel))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func FindByProductIDs(ids []primitive.ObjectID) ([]Product, error) {
|
||||
var data []Product
|
||||
return data, coll(nil).Find(&data, bson.M{"_id": bson.M{"$in": ids}})
|
||||
}
|
||||
|
||||
// InsertProduct 插入一条数据
|
||||
func InsertProduct(p *Product) error {
|
||||
p.CreatedAt = time.Now()
|
||||
if _, err := coll(nil).InsertOne(p); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "InsertProduct", table, "InsertOne", err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateProduct 修改Product类型
|
||||
func UpdateProduct(id string, set *ProductSelector) error {
|
||||
set.UpdatedAt = time.Now()
|
||||
oid, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "UpdateProduct", table, "ObjectIDFromHex", err),
|
||||
log.Any("id", id),
|
||||
log.Any("set", set),
|
||||
)
|
||||
return err
|
||||
}
|
||||
if _, err = coll(nil).UpdateOne(bson.M{"_id": oid}, bson.M{"$set": set}); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "UpdateProduct", table, "UpdateOne", err),
|
||||
log.Any("oid", oid),
|
||||
log.Any("set", set),
|
||||
)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateProductRights 清空产品权益
|
||||
func UpdateProductRights(id string) error {
|
||||
oid, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "UpdateProduct", table, "ObjectIDFromHex", err),
|
||||
log.Any("id", id),
|
||||
)
|
||||
return err
|
||||
}
|
||||
if _, err := coll(nil).UpdateOne(bson.M{"_id": oid}, bson.M{"$set": bson.M{"newPrivilege": nil}}); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "UpdateProduct", table, "UpdateOne", err),
|
||||
log.Any("oid", oid),
|
||||
)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveProduct 删除Product类型
|
||||
func RemoveProduct(id string) error {
|
||||
OID, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "RemoveProduct", table, "ObjectIDFromHex", err),
|
||||
log.Any("id", id),
|
||||
)
|
||||
return err
|
||||
}
|
||||
if _, err = coll(nil).DeleteOne(bson.M{"_id": OID}); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "RemoveProduct", table, "DeleteOne", err),
|
||||
log.Any("OID", OID),
|
||||
)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindStd 查询vip和约会卡
|
||||
func FindStd(req ProductListWeb) ([]ProductWeb, error) {
|
||||
query := bson.M{}
|
||||
if req.Status != nil {
|
||||
query["status"] = req.Status
|
||||
}
|
||||
if req.ProductType != nil {
|
||||
query["productType"] = req.ProductType
|
||||
}
|
||||
opts := options.FindOptions{
|
||||
Sort: bson.D{{Key: "sort", Value: 1}},
|
||||
}
|
||||
if req.ProductType == nil {
|
||||
query["productType"] = bson.M{"$in": []commod.ProductType{GameAdvanceCard, AdvanceCard, VIP, MeetingCard, OTHER, NewUser, PHYSICALGOODS, WhoringCard, commod.VideoDiscount, commod.VideoFreeCard, commod.CoinMonthCard}}
|
||||
}
|
||||
data := make([]ProductWeb, 0)
|
||||
if err := coll(nil).Find(&data, query, &opts); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProductsByProductType", table, "Find", err))
|
||||
return data, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// FindProductsByProductType 查询vip和约会卡
|
||||
func FindProductsByProductType(status *bool, newUser bool, sys string) ([]Product, error) {
|
||||
query := bson.M{}
|
||||
if status != nil {
|
||||
query["status"] = *status
|
||||
}
|
||||
types := []commod.ProductType{VIP, MeetingCard, OTHER, PHYSICALGOODS, VideoDiscount, VideoFreeCard, CoinMonthCard, AdvanceCard, GameAdvanceCard, WhoringCard}
|
||||
if newUser {
|
||||
types = append(types, NewUser)
|
||||
}
|
||||
opts := options.FindOptions{
|
||||
Sort: bson.D{{Key: "sort", Value: 1}},
|
||||
}
|
||||
query["productType"] = bson.M{"$in": types}
|
||||
data := make([]Product, 0)
|
||||
if err := coll(nil).Find(&data, query, &opts); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProductsByProductType", table, "Find", err))
|
||||
return data, err
|
||||
}
|
||||
for i := range data {
|
||||
data[i].DiscountedPriceFill(sys)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func FindOne(t *db.MongoTool, cond bson.M, opts ...*options.FindOneOptions) (data *Product, err error) {
|
||||
if err = coll(nil).FindOne(&data, cond, opts...); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindOne", table, "FindOne", err),
|
||||
log.Any("cond", cond),
|
||||
)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListToIDs 获取商品列表
|
||||
func ListToIDs(ids []primitive.ObjectID, sys string) ([]*Product, error) {
|
||||
var items []*Product
|
||||
if err := coll(nil).Find(&items, bson.M{"_id": bson.M{"$in": ids}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range items {
|
||||
items[i].DiscountedPriceFill(sys)
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func ListByIDsMap(ids []primitive.ObjectID) (map[primitive.ObjectID]*Product, error) {
|
||||
var m = make(map[primitive.ObjectID]*Product, 0)
|
||||
list, err := ListToIDs(ids, constant.SysTypeIOS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, product := range list {
|
||||
m[product.ID] = product
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// CheckboxByType 通过类型获取商品复选框列表
|
||||
func CheckboxByType(t commod.ProductType) ([]*ProductCheckbox, error) {
|
||||
var items []*ProductCheckbox
|
||||
return items, coll(nil).Find(&items, bson.M{"productType": t})
|
||||
}
|
||||
|
||||
// FindMany 查询vip和约会卡
|
||||
func FindMany() ([]ProductWeb, error) {
|
||||
query := bson.M{}
|
||||
opts := options.FindOptions{
|
||||
Sort: bson.D{{Key: "sort", Value: 1}},
|
||||
}
|
||||
data := make([]ProductWeb, 0)
|
||||
if err := coll(nil).Find(&data, query, &opts); err != nil {
|
||||
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "FindProductsByProductType", table, "Find", err))
|
||||
return data, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// GetLargestDiscountVIPCard 获取最大折扣VIP卡(PayVidDiscount越小表示折扣力度越大)
|
||||
func GetLargestDiscountVIPCard() (int, error) {
|
||||
sort := bson.D{{Key: "payVidDiscount", Value: 1}}
|
||||
filter := bson.M{
|
||||
"productType": commod.VIP,
|
||||
"status": true,
|
||||
"payVidDiscount": bson.M{
|
||||
"$gt": 0,
|
||||
},
|
||||
}
|
||||
opts := options.FindOptions{}
|
||||
opts.SetSort(sort).SetLimit(1)
|
||||
discounts := []Product{}
|
||||
if err := coll(nil).Find(&discounts, filter, &opts); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if len(discounts) <= 0 {
|
||||
return 0, nil
|
||||
}
|
||||
return discounts[0].PayVidDiscount, nil
|
||||
}
|
||||
|
||||
//func GetRecommendVip() (data *Product, err error) {
|
||||
// return FindOne(nil, bson.M{
|
||||
// "isRecommend": true,
|
||||
// "status": true,
|
||||
// })
|
||||
//}
|
||||
@@ -0,0 +1,196 @@
|
||||
package productmod
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"91porn-server/common/db"
|
||||
"91porn-server/models/commod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const (
|
||||
VIP = commod.VIP // product 0
|
||||
VIDEO = commod.VIDEO // VIDEO视频
|
||||
MODEL = commod.MODEL // MODEL嫩模
|
||||
MeetingCard = commod.MeetingCard // 约会卡
|
||||
OTHER = commod.OTHER // OTHER 1
|
||||
NewUser = commod.NEWUSERCard // 新手卡
|
||||
PHYSICALGOODS = commod.PhysicalGoods // 线上商品
|
||||
VideoDiscount = commod.VideoDiscount // 视频折扣卡
|
||||
VideoFreeCard = commod.VideoFreeCard // 视频免费卡
|
||||
CoinMonthCard = commod.CoinMonthCard // 金币月卡
|
||||
AdvanceCard = commod.AdvanceCard // 预售卡
|
||||
GameAdvanceCard = commod.GameAdvanceCard // 游戏预售卡
|
||||
WhoringCard = commod.WhoringCard // 白嫖卡
|
||||
)
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
RedisSetKey = "productmod"
|
||||
)
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
LevelOne // 1 普通会员
|
||||
LevelTwo // 2 超级会员
|
||||
LevelThree // 3 暗网会员
|
||||
)
|
||||
|
||||
var mdb *db.MongoDB
|
||||
|
||||
// Product 商品类型
|
||||
type Product struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"productID" ` // id
|
||||
VipLevel int `bson:"vipLevel" json:"vipLevel"` // product等级 1 普通vip 2 超级vip 3 暗网会员
|
||||
Name string `bson:"productName" json:"productName" ` // 商品名字
|
||||
Alias string `bson:"alias" json:"alias"` // 别名
|
||||
Desc string `bson:"desc" json:"desc"` // 内容描述
|
||||
Duration int `bson:"duration" json:"duration"` // 持续天数
|
||||
Type int `bson:"type" json:"type"` // 会员卡类型
|
||||
SendGame bool `bson:"sendGame" json:"sendGame"` // 是否赠送VIP
|
||||
BGImg string `bson:"bgImg" json:"bgImg"` // 背景图 (或者为预售卡预售状态背景图)
|
||||
EndBGImg string `bson:"endBgImg" json:"endBgImg"` // 预售卡尾款背景图
|
||||
OriginalPrice int64 `bson:"originalPrice" json:"originalPrice"` // 原价
|
||||
DiscountedPrice int64 `bson:"discountedPrice" json:"discountedPrice"` // 现价/升级价 单位角(金币)
|
||||
DiscountedPriceIos *int64 `bson:"discountedPriceIos,omitempty" json:"discountedPriceIos,omitempty"` // ios现价/升级价
|
||||
DiscountedPriceAnd *int64 `bson:"discountedPriceAnd,omitempty" json:"discountedPriceAnd,omitempty"` // 安卓现价/升级价
|
||||
ProductType commod.ProductType `bson:"productType" json:"productType"` // 产品类型
|
||||
Sort int `bson:"sort" json:"sort"` // 排序字段
|
||||
Status bool `bson:"status" json:"status"` // false 下架 //true 上架
|
||||
Position string `bson:"position" json:"position"` // 位置
|
||||
UnitPriceDisplay bool `bson:"unitPriceDisplay" json:"unitPriceDisplay"` // 单价展示开关
|
||||
ActionDesc string `bson:"actionDesc" json:"actionDesc"` // 活动描述
|
||||
PrivilegeDesc string `bson:"privilegeDesc" json:"privilegeDesc"` // 特权描述 "特权1,特权2"
|
||||
ShowCountdownTime int `bson:"showCountdownTime" json:"showCountdownTime"` // 新手卡倒计时 24
|
||||
IsAmountPay bool `bson:"isAmountPay" json:"isAmountPay"` // 是否可以用金币购买
|
||||
IsHomePopUp bool `bson:"isHomePopUp" json:"isHomePopUp"` // 是否首页弹窗
|
||||
TimesAWeek int `bson:"timesAWeek" json:"timesAWeek"` // 一周几次
|
||||
VideoDiscount int `bson:"videoDiscount" json:"videoDiscount"` // 视频折扣率(金币视频折扣卡)
|
||||
Privilege []int `bson:"privilege" json:"privilege"` // 特权
|
||||
GiveCoin int64 `json:"giveCoin" bson:"giveCoin"` // 购买赠送金币
|
||||
EveryDayGiveCoin int64 `json:"everyDayGiveCoin" bson:"everyDayGiveCoin"` // 金币月卡每日赠送金币
|
||||
GiveFruitCoin int64 `json:"giveFruitCoin" bson:"giveFruitCoin"` // 购买赠送果币
|
||||
GoldVideoFreeDay int `json:"goldVideoFreeDay" bson:"goldVideoFreeDay"` // 金币视频免费天数
|
||||
GoldVideoFreeLimit int64 `json:"goldVideoFreeLimit" bson:"goldVideoFreeLimit"` // 金币视频免费限制门槛
|
||||
ChanSplitMod int `json:"chanSplitMod" bson:"chanSplitMod"` // 渠道分成模式 0不分成 1 正常分成
|
||||
ServiceTime int64 `json:"serviceTime" bson:"serviceTime"` // 服务时长(单位:分钟)
|
||||
PayVidDiscount int `json:"payVidDiscount" bson:"payVidDiscount"` // 支付视频折扣
|
||||
GoldVideoCouponNum int `json:"goldVideoCouponNum" bson:"goldVideoCouponNum"` // 赠送观影券金币数量
|
||||
GoldVideoCouponCount int `json:"goldVideoCouponCount" bson:"goldVideoCouponCount"` // 赠送观影券数量
|
||||
NewName string `bson:"newName" json:"newName"` // 新商品名字
|
||||
NewBgImg string `bson:"newBgImg" json:"newBgImg" ` // 新背景图(或者为预售卡预售状态选中状态背景图),兼容老版本, 新版本(安卓4.3.5,ios4.3.1)以后都用这个字段
|
||||
EndBGSelectImg string `bson:"endBgSelectImg" json:"endBgSelectImg"` // 预售卡尾款背景图(选中)
|
||||
ExclusiveOffer string `bson:"exclusiveOffer" json:"exclusiveOffer"` // 专属特惠
|
||||
VipCardDesc string `bson:"vipCardDesc" json:"vipCardDesc"` // vip卡描述
|
||||
NewPrivilege []PrivilegeInfo `bson:"newPrivilege" json:"newPrivilege"` // 新特权,兼容老版本, 新版本(安卓4.3.5,ios4.3.1)以后都用这个字段
|
||||
AiUndressCount uint64 `bson:"aiUndressCount" json:"aiUndressCount"` // 购买赠送AI免费脱衣次数
|
||||
DownloadCount int64 `bson:"downloadCount" json:"downloadCount"` // 赠送下载次数
|
||||
LuckyDrawCount int64 `bson:"luckyDrawCount" json:"luckyDrawCount"` // 抽奖次数
|
||||
ChatPrice int64 `bson:"chatPrice" json:"chatPrice"` // 私聊价格
|
||||
SignDays uint64 `bson:"signDays" json:"signDays"` // 签到天数
|
||||
AdvanceAmount int64 `bson:"advanceAmount" json:"advanceAmount"` // 预付金额/升级价
|
||||
BalanceAmount int64 `bson:"balanceAmount" json:"balanceAmount"` // 尾款金额
|
||||
AllGoldVideoFree bool `json:"allGoldVideoFree" bson:"allGoldVideoFree"` // 所有金币视频免费
|
||||
StartTime time.Time `bson:"startTime" json:"startTime"` // 支付尾款开始时间
|
||||
EndTime time.Time `bson:"endTime" json:"endTime"` // 支付尾款结束时间
|
||||
ActivityTime time.Time `json:"activityTime" bson:"activityTime,omitempty"` // 活动时间
|
||||
BroadcastDays int `json:"broadcastDays" bson:"broadcastDays"` // 直播有效时间,单位天
|
||||
DramaDays int `json:"dramaDays" bson:"dramaDays" binding:"gte=0,lte=99999"` // 短剧权益有效时间,单位天
|
||||
PrepaidPrivilege *AdvanceCardPrepaidPrivilege `json:"prepaidPrivilege" bson:"prepaidPrivilege"` // 预售卡预付权益
|
||||
AdvanceVipLevel int `json:"advanceVipLevel" bson:"advanceVipLevel"` // 预付卡等级
|
||||
AdvanceDuration int `json:"advanceDuration" bson:"advanceDuration"` // 预付卡持续天数
|
||||
AdvanceExpires time.Time `json:"advanceExpires" bson:"advanceExpires"` // 预付卡会员到期时间
|
||||
AllowedUpgradeCards []CardsInfo `json:"allowedUpgradeCards" bson:"allowedUpgradeCards"` // 允许升级到此卡的会员卡
|
||||
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"` // 更新时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
||||
// 以下为动态升级信息
|
||||
IsUpgrade bool `json:"isUpgrade" bson:"-"` // 是否VIP升级
|
||||
CurrentVipName string `json:"currentVipName" bson:"-"` // 当前VIP名称
|
||||
CurrentVipPrice int64 `json:"currentVipPrice" bson:"-"` // 当前VIP价格
|
||||
PurchasePrice int64 `json:"purchasePrice" bson:"-"` // 原价购买价格
|
||||
}
|
||||
|
||||
type CardsInfo struct {
|
||||
ProductID primitive.ObjectID `json:"productID" bson:"productID"` // ID
|
||||
ProductName string `bson:"productName" json:"productName" ` // 商品名字
|
||||
}
|
||||
|
||||
// CheckUpgrade 检查指定会员卡是否可以升级
|
||||
func (p *Product) CheckUpgrade(pid primitive.ObjectID) bool {
|
||||
if len(p.AllowedUpgradeCards) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, card := range p.AllowedUpgradeCards {
|
||||
if pid == card.ProductID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
type AdvanceCardPrepaidPrivilege struct {
|
||||
CoinVideoLimitPerDay int64 `json:"coinVideoLimitPerDay" bson:"coinVideoLimitPerDay"` // 每日金币视频免费次数
|
||||
LuckyDrawLimitPerDay int64 `json:"luckyDrawLimitPerDay" bson:"luckyDrawLimitPerDay"` // 每日抽奖次数限制
|
||||
AiUndressLimitPerDay int64 `json:"aiUndressLimitPerDay" bson:"aiUndressLimitPerDay"` // 每日ai脱衣次数限制
|
||||
DownloadLimitPerDay int64 `json:"downloadLimitPerDay" bson:"downloadLimitPerDay"` // 每日下载次数限制
|
||||
}
|
||||
|
||||
// PrivilegeInfo 特权详情
|
||||
type PrivilegeInfo struct {
|
||||
//特权图片
|
||||
Image string `bson:"img" json:"img"`
|
||||
//特权名称
|
||||
Name string `bson:"privilegeName" json:"privilegeName"`
|
||||
//特权描述
|
||||
Desc string `bson:"privilegeDesc" json:"privilegeDesc"`
|
||||
//是否核心特权
|
||||
IsCore bool `bson:"isCore" json:"isCore"`
|
||||
}
|
||||
|
||||
func Init() {
|
||||
mdb = db.Init(table)
|
||||
initIndex()
|
||||
}
|
||||
|
||||
var privilegeMap = map[Privilege]string{
|
||||
HDLine: "专属高清线路",
|
||||
Chat: "私信随意聊",
|
||||
highQuality: "优质资源",
|
||||
PriorityReview: "帖子优先审核",
|
||||
FreeComment: "评论区霸主",
|
||||
UnlimitedViewing: "视频无限观看",
|
||||
ExclusiveCustomerService: "专属客服",
|
||||
Freeportrait: "修改个人头像",
|
||||
FreeSignature: "修改个性签名",
|
||||
FreeBrowseNovels: "浏览小说",
|
||||
FreeAudioBook: "畅听有声小说",
|
||||
FreeDrama: "免费看全部短剧",
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
HDLine Privilege = 1 //专属高清线路
|
||||
Chat Privilege = 2 //私信随意聊
|
||||
highQuality Privilege = 3 //优质资源
|
||||
PriorityReview Privilege = 4 //帖子优先审核
|
||||
FreeComment Privilege = 5 //评论区霸主
|
||||
UnlimitedViewing Privilege = 6 //视频无限观看
|
||||
ExclusiveCustomerService Privilege = 7 //专属客服
|
||||
Freeportrait Privilege = 8 //修改个人头像
|
||||
FreeSignature Privilege = 9 //修改个性签名
|
||||
FreeBrowseNovels Privilege = 10 //浏览小说
|
||||
FreeAudioBook Privilege = 11 //畅听有声小说
|
||||
FreeDrama Privilege = 12 //免费看全部短剧
|
||||
)
|
||||
|
||||
type Privilege int64
|
||||
|
||||
func (t Privilege) Key() string {
|
||||
if key, ok := privilegeMap[t]; ok {
|
||||
return key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package productmod
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"91porn-server/models/commod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// ProductSelector 修改结构体
|
||||
type ProductSelector struct {
|
||||
VipLevel *int `bson:"vipLevel,omitempty" json:"vipLevel,omitempty"` // product等级
|
||||
Name *string `bson:"productName,omitempty" json:"productName,omitempty"` // 商品名字
|
||||
Alias *string `bson:"alias,omitempty" json:"alias,omitempty" ` // 别名
|
||||
Desc *string `bson:"desc,omitempty" json:"desc,omitempty" ` // 内容描述
|
||||
Duration *int `bson:"duration,omitempty" json:"duration,omitempty" ` // 持续天数
|
||||
BGImg *string `bson:"bgImg,omitempty" json:"bgImg,omitempty" ` // 背景图
|
||||
EndBGImg *string `bson:"endBgImg" json:"endBgImg"` // 预售卡尾款背景图
|
||||
OriginalPrice *int64 `bson:"originalPrice,omitempty" json:"originalPrice,omitempty"` // 原价
|
||||
DiscountedPriceIos *int64 `bson:"discountedPriceIos,omitempty" json:"discountedPriceIos,omitempty"` // ios现价
|
||||
DiscountedPriceAnd *int64 `bson:"discountedPriceAnd,omitempty" json:"discountedPriceAnd,omitempty"` // 安卓现价
|
||||
ProductType *int `bson:"productType,omitempty" json:"productType,omitempty" ` // 产品类型
|
||||
Sort *int `bson:"sort,omitempty" json:"sort,omitempty" ` // 排序字段
|
||||
Status *bool `bson:"status,omitempty" json:"status,omitempty"` // 0 下架 //1 下架
|
||||
Position *string `bson:"position,omitempty" json:"position,omitempty"` // 位置
|
||||
UnitPriceDisplay *bool `bson:"unitPriceDisplay,omitempty" json:"unitPriceDisplay,omitempty"` // 单价展示开关
|
||||
ActionDesc *string `bson:"actionDesc,omitempty" json:"actionDesc,omitempty"` // 活动描述
|
||||
PrivilegeDesc *string `bson:"privilegeDesc,omitempty" json:"privilegeDesc,omitempty"` // 特权描述 "特权1,特权2"
|
||||
ShowCountdownTime *int `bson:"showCountdownTime,omitempty" json:"showCountdownTime,omitempty"` // 新手卡倒计时 24
|
||||
IsAmountPay *bool `bson:"isAmountPay,omitempty" json:"isAmountPay,omitempty"` // 是否可以用金币购买
|
||||
TimesAWeek *int `bson:"timesAWeek,omitempty" json:"timesAWeek,omitempty"` // 一周几次
|
||||
LouFengDiscount *int `bson:"louFengDiscount,omitempty" json:"louFengDiscount,omitempty"` // 楼凤折扣率
|
||||
LoufengBookDiscount *int `bson:"loufengBookDiscount,omitempty" json:"loufengBookDiscount,omitempty"` // 楼凤预约折扣
|
||||
LoufengBookDiscountDays *int `bson:"loufengBookDiscountDays,omitempty" json:"loufengBookDiscountDays,omitempty"` // 楼凤预约折扣时间
|
||||
Privilege *[]int `bson:"privilege,omitempty" json:"privilege,omitempty"` // 特权
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` // 更新时间
|
||||
GiveCoin int64 `json:"giveCoin" bson:"giveCoin"` // 购买赠送金币
|
||||
EveryDayGiveCoin int64 `json:"everyDayGiveCoin" bson:"everyDayGiveCoin"` // 金币月卡每日赠送金币
|
||||
GiveGameCoin *int64 `json:"giveGameCoin" bson:"giveGameCoin,omitempty"` // 购买赠送游戏金币
|
||||
LouFengUnlockTimes *int `json:"louFengUnlockTimes" bson:"louFengUnlockTimes,omitempty"` // 赠送楼凤解锁次数
|
||||
ChanSplitMod *int `json:"chanSplitMod,omitempty" bson:"chanSplitMod,omitempty"` // 渠道分成模式 0不分成 1 正常分成
|
||||
GoldVideoFreeDay *int `json:"goldVideoFreeDay" bson:"goldVideoFreeDay,omitempty"` // 金币视频免费天数
|
||||
GoldVideoFreeLimit *int `json:"goldVideoFreeLimit" bson:"goldVideoFreeLimit"` // 金币视频免费限制门槛
|
||||
ServiceTime *int64 `json:"serviceTime,omitempty" bson:"serviceTime,omitempty"` // 服务时长(单位:分钟)
|
||||
GiveFruitCoin *int64 `json:"giveFruitCoin,omitempty" bson:"giveFruitCoin,omitempty"` // 购买赠送果币
|
||||
PayVidDiscount *int `json:"payVidDiscount,omitempty" bson:"payVidDiscount,omitempty"` // 支付视频折扣
|
||||
GoldVideoCouponNum *int `json:"goldVideoCouponNum,omitempty" bson:"goldVideoCouponNum,omitempty"` // 赠送观影券金币数量
|
||||
GoldVideoCouponCount *int `json:"goldVideoCouponCount,omitempty" bson:"goldVideoCouponCount,omitempty"` // 赠送观影券数量
|
||||
NewName *string `bson:"newName,omitempty" json:"newName,omitempty"` // 新商品名字
|
||||
NewBgImg *string `bson:"newBgImg,omitempty" json:"newBgImg,omitempty" ` // 新背景图
|
||||
EndBGSelectImg *string `bson:"endBgSelectImg" json:"endBgSelectImg"` // 预售卡尾款背景图(选中)
|
||||
ExclusiveOffer *string `bson:"exclusiveOffer,omitempty" json:"exclusiveOffer,omitempty"` // 是否专属特惠
|
||||
VipCardDesc *string `bson:"vipCardDesc,omitempty" json:"vipCardDesc,omitempty"` // vip卡描述
|
||||
NewPrivilege []*PrivilegeInfo `bson:"newPrivilege,omitempty" json:"newPrivilege,omitempty"` // 新特权
|
||||
AiUndressCount *uint64 `bson:"aiUndressCount,omitempty" json:"aiUndressCount,omitempty"` // ai脱衣次数
|
||||
DownloadCount *int64 `bson:"downloadCount,omitempty" json:"downloadCount,omitempty"` // 赠送下载次数
|
||||
LuckyDrawCount *int64 `bson:"luckyDrawCount,omitempty" json:"luckyDrawCount,omitempty"` // 抽奖次数
|
||||
ChatPrice *int64 `bson:"chatPrice,omitempty" json:"chatPrice,omitempty"` // 私聊价格
|
||||
SignDays *uint64 `json:"signDays,omitempty" bson:"signDays,omitempty"` // 签到天数
|
||||
AdvanceAmount *int64 `bson:"advanceAmount,omitempty" json:"advanceAmount,omitempty"` // 预付金额
|
||||
BalanceAmount *int64 `bson:"balanceAmount,omitempty" json:"balanceAmount,omitempty"` // 尾款金额
|
||||
AllGoldVideoFree *bool `json:"allGoldVideoFree,omitempty" bson:"allGoldVideoFree,omitempty"` // 所有金币视频免费
|
||||
StartTime *time.Time `bson:"startTime,omitempty" json:"startTime,omitempty"` // 开始时间
|
||||
EndTime *time.Time `bson:"endTime,omitempty" json:"endTime,omitempty"` // 结束时间
|
||||
ActivityTime *time.Time `json:"activityTime,omitempty" bson:"activityTime,omitempty"` // 活动时间
|
||||
Type *int `bson:"type,omitempty" json:"type,omitempty"` // 会员卡类型
|
||||
SendGame *bool `bson:"sendGame,omitempty" json:"sendGame,omitempty"` // 是否赠送游戏
|
||||
IsHomePopUp *bool `bson:"isHomePopUp,omitempty" json:"isHomePopUp,omitempty"` // 是否首页弹窗
|
||||
BroadcastDays *int `json:"broadcastDays,omitempty" bson:"broadcastDays,omitempty"` // 直播有效时间,单位天
|
||||
DramaDays *int `json:"dramaDays,omitempty" bson:"dramaDays,omitempty"` // 短剧权益有效时间,单位天
|
||||
PrepaidPrivilege *AdvanceCardPrepaidPrivilege `json:"prepaidPrivilege,omitempty" bson:"prepaidPrivilege,omitempty"` // 预售卡预付权益
|
||||
AdvanceVipLevel *int `json:"advanceVipLevel,omitempty" bson:"advanceVipLevel,omitempty"` // 预付卡等级
|
||||
AdvanceDuration *int `json:"advanceDuration,omitempty" bson:"advanceDuration,omitempty"` // 预付卡持续天数
|
||||
AdvanceExpires *time.Time `json:"advanceExpires,omitempty" bson:"advanceExpires,omitempty"` // 预付卡会员到期时间
|
||||
AllowedUpgradeCards *[]*CardsInfo `json:"allowedUpgradeCards,omitempty" bson:"allowedUpgradeCards,omitempty"` // 允许升级到此卡的会员卡
|
||||
}
|
||||
|
||||
type ProductWeb struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` // ID
|
||||
VipLevel int `bson:"vipLevel" json:"vipLevel"` // product等级 1 普通vip 2 超级vip
|
||||
Name string `bson:"productName" json:"productName" ` // 商品名字
|
||||
Alias string `bson:"alias" json:"alias"` // 别名
|
||||
Desc string `bson:"desc" json:"desc" ` // 内容描述
|
||||
Duration int `bson:"duration" json:"duration" binding:"lte=99999"` // 持续天数
|
||||
BGImg string `bson:"bgImg" json:"bgImg" ` // 背景图
|
||||
EndBGImg string `bson:"endBgImg" json:"endBgImg"` // 预售卡尾款背景图
|
||||
OriginalPrice int64 `bson:"originalPrice" json:"originalPrice" ` // 原价
|
||||
DiscountedPrice int64 `bson:"discountedPrice" json:"discountedPrice"` // 现价
|
||||
DiscountedPriceIos int64 `bson:"discountedPriceIos" json:"discountedPriceIos"` // ios现价
|
||||
DiscountedPriceAnd int64 `bson:"discountedPriceAnd" json:"discountedPriceAnd"` // 安卓现价
|
||||
ProductType commod.ProductType `bson:"productType" json:"productType"` // 产品类型
|
||||
Sort int `bson:"sort" json:"sort"` // 排序字段
|
||||
Status bool `bson:"status" json:"status"` // 0 下架 //1 下架
|
||||
Position string `bson:"position" json:"position"` // 位置
|
||||
UnitPriceDisplay bool `bson:"unitPriceDisplay" json:"unitPriceDisplay"` // 单价展示开关
|
||||
ActionDesc string `bson:"actionDesc" json:"actionDesc"` // 活动描述
|
||||
PrivilegeDesc string `bson:"privilegeDesc" json:"privilegeDesc"` // 特权描述 "特权1,特权2"
|
||||
ShowCountdownTime int `bson:"showCountdownTime" json:"showCountdownTime"` // 新手卡倒计时 24
|
||||
IsAmountPay bool `bson:"isAmountPay" json:"isAmountPay"` // 是否可以用金币购买
|
||||
TimesAWeek int `bson:"timesAWeek" json:"timesAWeek"` // 一周几次
|
||||
LouFengDiscount int `bson:"louFengDiscount" json:"louFengDiscount"` // 楼凤折扣率
|
||||
LoufengBookDiscount int `bson:"loufengBookDiscount" json:"loufengBookDiscount"` // 楼凤预约
|
||||
LoufengBookDiscountDays int `bson:"loufengBookDiscountDays" json:"loufengBookDiscountDays"` // 楼凤预约折扣时间
|
||||
Privilege []int `bson:"privilege" json:"privilege"` // 特权
|
||||
UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"` // 更新时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
||||
GiveCoin int64 `json:"giveCoin" bson:"giveCoin"` // 购买赠送金币
|
||||
GiveGameCoin int64 `json:"giveGameCoin" bson:"giveGameCoin"` // 购买赠送游戏金币
|
||||
LouFengUnlockTimes int `json:"louFengUnlockTimes" bson:"louFengUnlockTimes"` // 赠送楼凤解锁次数
|
||||
GoldVideoFreeDay int `json:"goldVideoFreeDay" bson:"goldVideoFreeDay" binding:"lte=99999"` // 金币视频免费天数
|
||||
GoldVideoFreeLimit int `json:"goldVideoFreeLimit" bson:"goldVideoFreeLimit"` // 金币视频免费限制门槛
|
||||
ChanSplitMod int `json:"chanSplitMod" bson:"chanSplitMod"` // 渠道分成模式 0不分成 1 正常分成
|
||||
ServiceTime int64 `json:"serviceTime" bson:"serviceTime"` // 服务时长(单位:分钟)
|
||||
GiveFruitCoin int64 `json:"giveFruitCoin" bson:"giveFruitCoin"` // 购买赠送果币
|
||||
PayVidDiscount int `json:"payVidDiscount" bson:"payVidDiscount"` // 支付视频折扣
|
||||
GoldVideoCouponNum int `json:"goldVideoCouponNum" bson:"goldVideoCouponNum"` // 赠送观影券金币数量
|
||||
GoldVideoCouponCount int `json:"goldVideoCouponCount" bson:"goldVideoCouponCount"` // 赠送观影券数量
|
||||
VideoDiscount int `json:"videoDiscount" bson:"videoDiscount"` // 视频折扣卡-视频折扣率
|
||||
NewName string `bson:"newName" json:"newName"` // 新商品名字
|
||||
NewBgImg string `bson:"newBgImg" json:"newBgImg" ` // 新背景图
|
||||
EndBGSelectImg string `bson:"endBgSelectImg" json:"endBgSelectImg"` // 预售卡尾款背景图(选中)
|
||||
ExclusiveOffer string `bson:"exclusiveOffer" json:"exclusiveOffer"` // 是否可以用金币购买
|
||||
VipCardDesc string `bson:"vipCardDesc" json:"vipCardDesc"` // vip卡描述
|
||||
NewPrivilege []PrivilegeInfo `bson:"newPrivilege" json:"newPrivilege"` // vip卡描述
|
||||
EveryDayGiveCoin int64 `json:"everyDayGiveCoin" bson:"everyDayGiveCoin"` // 金币月卡每日赠送金币
|
||||
AiUndressCount uint64 `bson:"aiUndressCount" json:"aiUndressCount"` // ai脱衣次数
|
||||
DownloadCount int64 `bson:"downloadCount" json:"downloadCount"` // 赠送下载次数
|
||||
LuckyDrawCount int64 `bson:"luckyDrawCount" json:"luckyDrawCount"` // 抽奖次数
|
||||
AllGoldVideoFree bool `json:"allGoldVideoFree" bson:"allGoldVideoFree"` // 所有金币视频免费
|
||||
AdvanceAmount int64 `bson:"advanceAmount" json:"advanceAmount"` // 预付金额
|
||||
BalanceAmount int64 `bson:"balanceAmount" json:"balanceAmount"` // 尾款金额
|
||||
Type int `bson:"type" json:"type"` // 会员卡类型
|
||||
IsHomePopUp bool `bson:"isHomePopUp" json:"isHomePopUp"` // 是否首页弹窗
|
||||
SendGame bool `bson:"sendGame,omitempty" json:"sendGame,omitempty"` // 是否赠送游戏
|
||||
StartTime time.Time `bson:"startTime" json:"startTime"` // 开始时间
|
||||
EndTime time.Time `bson:"endTime" json:"endTime"` // 结束时间
|
||||
ActivityTime time.Time `json:"activityTime" bson:"activityTime,omitempty"` // 活动时间
|
||||
ChatPrice int64 `bson:"chatPrice" json:"chatPrice"` // 私聊价格
|
||||
SignDays uint64 `bson:"signDays" json:"signDays"` // 签到天数
|
||||
BroadcastDays int `json:"broadcastDays" bson:"broadcastDays"` // 直播有效时间,单位天
|
||||
DramaDays int `json:"dramaDays" bson:"dramaDays" binding:"gte=0,lte=99999"` // 短剧权益有效时间,单位天
|
||||
PrepaidPrivilege *AdvanceCardPrepaidPrivilege `json:"prepaidPrivilege" bson:"prepaidPrivilege"` // 预售卡预付权益
|
||||
AdvanceVipLevel int `json:"advanceVipLevel" bson:"advanceVipLevel"` // 预付卡等级
|
||||
AdvanceDuration int `json:"advanceDuration" bson:"advanceDuration"` // 预付卡持续天数
|
||||
AdvanceExpires time.Time `json:"advanceExpires" bson:"advanceExpires"` // 预付卡会员到期时间
|
||||
AllowedUpgradeCards []CardsInfo `json:"allowedUpgradeCards" bson:"allowedUpgradeCards"` // 允许升级到此卡的会员卡
|
||||
}
|
||||
|
||||
type CheckboxListCond struct {
|
||||
ProductType commod.ProductType `form:"productType" json:"productType"` //产品类型
|
||||
}
|
||||
|
||||
type ProductCheckbox struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
Name string `bson:"productName" json:"productName"` //商品名字
|
||||
}
|
||||
|
||||
type ProductListWeb struct {
|
||||
Status *bool `form:"status" json:"status,omitempty"` //true 上架 //false 下架
|
||||
ProductType *int `form:"productType" json:"productType,omitempty"` // 产品类型
|
||||
}
|
||||
Reference in New Issue
Block a user