Commit d14f8969 authored by hujiebin's avatar hujiebin

调整参数

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