diff --git a/cv/cp_cv/space.go b/cv/cp_cv/space.go index a2c626f0690cd4fb3cf81adbdfe65fdc00046fe5..45320e3182c8c148bf15e9db3781d4dbb6848069 100644 --- a/cv/cp_cv/space.go +++ b/cv/cp_cv/space.go @@ -12,10 +12,11 @@ import ( // cp信息 type CvCpInfo struct { - UserInfo user_cv.UserTiny `json:"userInfo"` // 用户信息 - CpUserInfo user_cv.UserTiny `json:"cpUserInfo"` // cp用户信息 - CpDays int `json:"cpDays"` // cp天数 - VisitTimes int `json:"visitTimes"` // 空间访问量 + 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 } // cp等级 diff --git a/domain/model/cp_m/level.go b/domain/model/cp_m/level.go index 376361667b91e3c4be376c9619dca75d911f74a3..b9e8c0c7ed89885651bf71046ed9c047c60392a2 100644 --- a/domain/model/cp_m/level.go +++ b/domain/model/cp_m/level.go @@ -20,6 +20,17 @@ func (CpRelationTmp) TableName() string { return "cp_relation" } +type CpCancelTmp struct { + mysql.Entity + UserId mysql.ID + RecUserId mysql.ID + Status int // 状态1.未处理2.发起者已撤销3.对方已确认4.到期自动确认 +} + +func (CpCancelTmp) TableName() string { + return "cp_cancel" +} + // cp等级 type CpLevel struct { mysql.Entity @@ -107,6 +118,15 @@ func GetCpRelationPair(model *domain.Model, userId1, userId2 mysql.ID) (cpRelati return } +// 获取是否申请解绑中 +func GetApplyToUnbind(model *domain.Model, userId, cpUserId mysql.ID) bool { + var total int64 + if err := model.DB().Table(CpCancelTmp{}.TableName()).Where("user_id = ? AND rec_user_id = ? AND status = 1", userId, cpUserId).Count(&total).Error; err != nil { + model.Log.Errorf("GetApplyToUnbind fail:%v", err) + } + return total > 0 +} + // 增加cp等级积分 // 送礼1钻石=1点数 // condition diff --git a/route/cp_r/space.go b/route/cp_r/space.go index 9fec5d1b5a14ca024884671f248a20097ef8f30e..3d781e74c527ec63024264941f64f11f8aa86cf1 100644 --- a/route/cp_r/space.go +++ b/route/cp_r/space.go @@ -43,6 +43,8 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } 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) if exists { @@ -58,6 +60,12 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) { }); err != nil { return myContext, err } + visitTimes = cp_m.CountCpSpaceVisitors(model, cpRelation.ID) + cpUserId := cpRelation.UserId2 + if cpUserId == userId { + cpUserId = cpRelation.UserId1 + } + applyToUnbind = cp_m.GetApplyToUnbind(model, userId, cpUserId) } if cpLevel != cp_e.CpLevelMax { nextPoints = cp_e.CpLevelPoints[cpLevel+1] @@ -75,8 +83,11 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) { } response := cp_cv.CvSpace{ CpInfo: cp_cv.CvCpInfo{ - UserInfo: user_cv.UserToTiny(*userInfo), - CpUserInfo: user_cv.UserToTiny(*cpUserInfo), + UserInfo: user_cv.UserToTiny(*userInfo), + CpUserInfo: user_cv.UserToTiny(*cpUserInfo), + VisitTimes: visitTimes, + CpDays: cpDays, + ApplyToUnbind: applyToUnbind, }, CpLevel: cp_cv.CvCpLevel{ Level: cpLevel,