Commit d2202b7d authored by hujiebin's avatar hujiebin

feat:applyToUnBind

parent f4a18554
......@@ -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等级
......
......@@ -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
......
......@@ -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,
......
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