@@ -0,0 +1,111 @@
|
||||
package advance_ser
|
||||
|
||||
import (
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/v/advanceordermod"
|
||||
"91porn-server/models/v/productmod"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GainAdvanceStatus(uid uint64) (resp advanceordermod.AdvanceStatus) {
|
||||
var (
|
||||
data advanceordermod.AdvanceStatus
|
||||
pId primitive.ObjectID
|
||||
activityPopUp bool
|
||||
gameActivityPopUp bool
|
||||
)
|
||||
//str, err := appg.Redis.Get(redisconst.AdvanceKey(uid))
|
||||
//if err != nil {
|
||||
// log.Warn(fmt.Sprintf("uid:%v;缓存获取预售列表信息异常:%v", uid, err))
|
||||
//}
|
||||
//if str != nil {
|
||||
// if err = msgpack.Unmarshal([]byte(*str), &data); err == nil {
|
||||
// return data
|
||||
// }
|
||||
// log.Warn(fmt.Sprintf("uid:%v;解析预售缓存数据异常:%v", uid, err))
|
||||
//}
|
||||
|
||||
// 1 获取活动开启状态
|
||||
var types = []commod.ProductType{productmod.AdvanceCard, productmod.GameAdvanceCard}
|
||||
pr, err := productmod.FindByProductTypes(types)
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
if pr != nil && len(pr) > 0 {
|
||||
for _, p := range pr {
|
||||
if p.ProductType == productmod.AdvanceCard && p.ActivityTime.Before(now) && p.EndTime.After(now) {
|
||||
if !activityPopUp && p.IsHomePopUp {
|
||||
activityPopUp = true
|
||||
}
|
||||
data.ActivityStatus = true
|
||||
pId = p.ID
|
||||
data.BalanceAmount = p.BalanceAmount / 10
|
||||
data.StartTime = p.StartTime
|
||||
data.EndTime = p.EndTime
|
||||
continue
|
||||
}
|
||||
if p.ProductType == productmod.GameAdvanceCard && p.ActivityTime.Before(now) && p.EndTime.After(now) {
|
||||
if !gameActivityPopUp && p.IsHomePopUp {
|
||||
gameActivityPopUp = true
|
||||
}
|
||||
data.GameActivityStatus = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
data.ActivityPopUp = activityPopUp
|
||||
data.GameActivityPopUp = gameActivityPopUp
|
||||
|
||||
// 2 获取尾款支付状态
|
||||
advanceOrders, err := advanceordermod.IsExist(bson.M{"uid": uid, "productID": pId})
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
|
||||
if advanceOrders != nil && !advanceOrders.ID.IsZero() {
|
||||
if (advanceOrders.Status == advanceordermod.AdvanceSUCCESS || advanceOrders.Status == advanceordermod.BalanceProcessing) && advanceOrders.EndTime.After(now) {
|
||||
data.BalancePayment = true
|
||||
data.OId = advanceOrders.ID.Hex()
|
||||
// 预付款相关免费权益信息
|
||||
data.PrivilegeLimit = advanceordermod.PrivilegeLimit{
|
||||
HasLimit: true,
|
||||
Limit: struct {
|
||||
CoinVideoLimitPerDay int64 `json:"coinVideoLimitPerDay"`
|
||||
LuckyDrawLimitPerDay int64 `json:"luckyDrawLimitPerDay"`
|
||||
AiUndressLimitPerDay int64 `json:"aiUndressLimitPerDay"`
|
||||
DownloadLimitPerDay int64 `json:"downloadLimitPerDay"`
|
||||
}{
|
||||
advanceOrders.PrepaidPrivilege.CoinVideoLimitPerDay,
|
||||
advanceOrders.PrepaidPrivilege.LuckyDrawLimitPerDay,
|
||||
advanceOrders.PrepaidPrivilege.AiUndressLimitPerDay,
|
||||
advanceOrders.PrepaidPrivilege.DownloadLimitPerDay,
|
||||
},
|
||||
Remain: struct {
|
||||
TodayCoinVideoCount int64 `json:"todayCoinVideoCount"`
|
||||
TodayLuckyDrawCount int64 `json:"todayLuckyDrawCount"`
|
||||
TodayAiUndressCount int64 `json:"todayAiUndressCount"`
|
||||
TodayDownloadCount int64 `json:"todayDownloadCount"`
|
||||
}{
|
||||
advanceOrders.PrepaidPrivilege.CoinVideoLimitPerDay - advanceOrders.TodayUse.CoinVideoCount,
|
||||
advanceOrders.PrepaidPrivilege.LuckyDrawLimitPerDay - advanceOrders.TodayUse.LuckyDrawCount,
|
||||
advanceOrders.PrepaidPrivilege.AiUndressLimitPerDay - advanceOrders.TodayUse.AiUndressCount,
|
||||
advanceOrders.PrepaidPrivilege.DownloadLimitPerDay - advanceOrders.TodayUse.DownloadCount,
|
||||
},
|
||||
}
|
||||
}
|
||||
data.Status = advanceOrders.Status
|
||||
}
|
||||
|
||||
//common.Go(func() {
|
||||
// bytes, _ := msgpack.Marshal(data)
|
||||
// if err = appg.Redis.Set(redisconst.AdvanceKey(uid), bytes, 2*time.Minute); err != nil {
|
||||
// log.Warn(fmt.Sprintf("uid:%v;保存预售缓存数据异常:%v", uid, err))
|
||||
// }
|
||||
//})
|
||||
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user