Commit d14f8969 authored by hujiebin's avatar hujiebin

调整参数

parent f2613d0e
......@@ -12,20 +12,21 @@ import (
// cp信息
type CvCpInfo struct {
UserInfo user_cv.UserTiny `json:"userInfo"` // 用户信息
CpUserInfo user_cv.UserTiny `json:"cpUserInfo"` // cp用户信息
CpDays int `json:"cpDays"` // cp天数
VisitTimes int64 `json:"visitTimes"` // 空间访问量
ApplyToUnbind bool `json:"applyToUnbind"` // 是否申请撤销cp
UserInfo user_cv.UserTiny `json:"userInfo"` // 用户信息
CpUserInfo user_cv.UserTiny `json:"cpUserInfo,omitempty"` // cp用户信息
CpDays int `json:"cpDays"` // cp天数
VisitTimes int64 `json:"visitTimes"` // 空间访问量
ApplyToUnbind bool `json:"applyToUnbind"` // 是否申请撤销cp
}
// cp等级
type CvCpLevel struct {
Level cp_e.CpLevel `json:"level"` // 等级 0:无称号 1:恋爱CP 2:甜蜜CP 3:忠诚CP 4:炽热CP 5:荣耀CP
Points uint32 `json:"points"` // CP值
NextPoints uint32 `json:"nextPoints,omitempty"` // 下个等级所需CP值
RemainPoints uint32 `json:"remainPoints,omitempty"` // 还需要多少CP值到下一个级别
ExpireAtUnix int64 `json:"expireAtUnix,omitempty"` // 有效期,时间戳
Level cp_e.CpLevel `json:"level"` // 等级 0:无称号 1:恋爱CP 2:甜蜜CP 3:忠诚CP 4:炽热CP 5:荣耀CP
Points uint32 `json:"points"` // CP值
StartPoints uint32 `json:"startPoints,omitempty"` // 上个等级所需CP值
EndPoints uint32 `json:"endPoints,omitempty"` // 下个等级所需CP值
ExpireAtUnix int64 `json:"expireAtUnix,omitempty"` // 有效期,时间戳
SettlementDate string `json:"settlementDate"` // 等级过期时间
}
// 资源等级
......
......@@ -81,7 +81,7 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
CpLevel: cp_cv.CvCpLevel{
Level: cpLevels[rank.CpId].Level,
//Points: cp_e.CpLevelPoints[cpLevel] + curPoints,
//NextPoints: nextPoints,
//EndPoints: nextPoints,
//RemainPoints: remainPoints,
//ExpireAtUnix: expireAtUnix,
},
......
......@@ -14,6 +14,7 @@ import (
"hilo-user/myerr/bizerr"
"hilo-user/req"
"hilo-user/resp"
"time"
)
// @Tags CP v2
......@@ -38,19 +39,21 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) {
if err != nil {
return myContext, err
}
cpUserInfo, err := user_m.GetUserByExtId(model, externalId)
targetUserInfo, err := user_m.GetUserByExtId(model, externalId)
if err != nil {
return myContext, err
}
var cpUserInfo *user_m.User
expireAtUnix, cpLevel := int64(0), cp_e.CpLevel0
visitTimes := int64(0)
cpDays, applyToUnbind := 0, false // todo cp时长
nextPoints, remainPoints, curPoints := cp_e.CpLevelPoints[cp_e.CpLevel1], mysql.Num(0), mysql.Num(0)
cpRelation, exists := cp_m.GetCpRelation(model, cpUserInfo.ID)
settlementDate, cpDays, applyToUnbind := "", 0, false
nextPoints, curPoints := cp_e.CpLevelPoints[cp_e.CpLevel1], mysql.Num(0)
cpRelation, exists := cp_m.GetCpRelation(model, targetUserInfo.ID)
if exists {
level := cp_m.GetCpLevel(model, cpRelation.ID)
cpLevel, curPoints = level.Level, level.Points
expireAtUnix = level.ExpireAt.Unix()
expireAtUnix, settlementDate = level.ExpireAt.Unix(), level.ExpireAt.Format("2006-01-02")
cpDays = int(time.Now().Sub(cpRelation.CreatedTime).Hours()/24) + 1
// cp 存在的时候,发布访问cp空间事件
if err := cp_ev.PublishCpSpaceVisit(model, &cp_ev.SpaceVisitEvent{
UserId: userId,
......@@ -66,10 +69,13 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) {
cpUserId = cpRelation.UserId1
}
applyToUnbind = cp_m.GetApplyToUnbind(model, userId, cpUserId)
cpUserInfo, err = user_m.GetUser(model, cpUserId)
if err != nil {
return myContext, err
}
}
if cpLevel != cp_e.CpLevelMax {
nextPoints = cp_e.CpLevelPoints[cpLevel+1]
remainPoints = nextPoints - cp_e.CpLevelPoints[cpLevel] - curPoints
}
privilegeList := cp_cv.CopyCpLevelPrivilegeList(cpLevel, lang)
userPrivileges, err := cp_m.MGetUserSvipPrivilege(model, []uint64{userId})
......@@ -81,24 +87,28 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) {
privilegeList[i].UserSwitch = userPrivileges[userId][v.Type]
}
}
// 返回值
response := cp_cv.CvSpace{
CpInfo: cp_cv.CvCpInfo{
UserInfo: user_cv.UserToTiny(*userInfo),
CpUserInfo: user_cv.UserToTiny(*cpUserInfo),
VisitTimes: visitTimes,
CpDays: cpDays,
ApplyToUnbind: applyToUnbind,
},
CpLevel: cp_cv.CvCpLevel{
Level: cpLevel,
Points: cp_e.CpLevelPoints[cpLevel] + curPoints,
NextPoints: nextPoints,
RemainPoints: remainPoints,
ExpireAtUnix: expireAtUnix,
Level: cpLevel,
Points: cp_e.CpLevelPoints[cpLevel] + curPoints,
StartPoints: cp_e.CpLevelPoints[cpLevel],
EndPoints: nextPoints,
ExpireAtUnix: expireAtUnix,
SettlementDate: settlementDate,
},
ResLevelList: cp_cv.CvResLevelList,
PrivilegeList: privilegeList,
}
response.CpInfo = cp_cv.CvCpInfo{
UserInfo: user_cv.UserToTiny(*userInfo),
CpDays: cpDays,
VisitTimes: visitTimes,
ApplyToUnbind: applyToUnbind,
}
if cpUserInfo != nil {
response.CpInfo.CpUserInfo = user_cv.UserToTiny(*cpUserInfo)
}
resp.ResponseOk(c, response)
return myContext, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment