Commit 86b72f1a authored by hujiebin's avatar hujiebin

赠送cp头像头饰 todo

parent b93434ea
...@@ -126,6 +126,7 @@ func InitCpLevel(model *domain.Model, cpId, userId1, userId2 mysql.ID) error { ...@@ -126,6 +126,7 @@ func InitCpLevel(model *domain.Model, cpId, userId1, userId2 mysql.ID) error {
} }
// 增加cp等级积分 // 增加cp等级积分
// 此函数并发不安全,利用mysql事件串行执行保证顺序
// 送礼1钻石=1点数 // 送礼1钻石=1点数
// condition // condition
// 1.记录不存在,首充加points计算level增加90天有效期 // 1.记录不存在,首充加points计算level增加90天有效期
...@@ -137,6 +138,7 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N ...@@ -137,6 +138,7 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N
defer func() { defer func() {
model.Log.Infof("AddCpLevelPoints cost:%v,err:%v", time.Now().Sub(start), err) model.Log.Infof("AddCpLevelPoints cost:%v,err:%v", time.Now().Sub(start), err)
}() }()
var oldLevel cp_e.CpLevel
var cpLevel CpLevel var cpLevel CpLevel
var cpLevelDetails []CpLevelDetail var cpLevelDetails []CpLevelDetail
if err := model.DB().Model(CpLevel{}).Where("cp_id = ?", cpRelation.Id).First(&cpLevel).Error; err != nil { if err := model.DB().Model(CpLevel{}).Where("cp_id = ?", cpRelation.Id).First(&cpLevel).Error; err != nil {
...@@ -200,7 +202,7 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N ...@@ -200,7 +202,7 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N
AftNum: cpLevel.Points, AftNum: cpLevel.Points,
Remark: fmt.Sprintf("send %d gift diamonds", points), Remark: fmt.Sprintf("send %d gift diamonds", points),
}) })
oldLevel := cpLevel.Level oldLevel = cpLevel.Level
levelPoint := cp_e.CpLevelPoints[oldLevel] // 已经用于升级的积分 levelPoint := cp_e.CpLevelPoints[oldLevel] // 已经用于升级的积分
for level := cp_e.CpLevelMax; level > oldLevel; level-- { for level := cp_e.CpLevelMax; level > oldLevel; level-- {
if cp_e.CpLevelPoints[level] <= cpLevel.Points+levelPoint { if cp_e.CpLevelPoints[level] <= cpLevel.Points+levelPoint {
...@@ -269,6 +271,10 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N ...@@ -269,6 +271,10 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N
return myerr.WrapErr(err) return myerr.WrapErr(err)
} }
} }
// 赠送cp头像头饰
if oldLevel < 3 && cpLevel.Level >= 3 {
//headwear_tx.SendHeadwear() // todo headwear id !
}
return cpLevel.Persistence(model) return cpLevel.Persistence(model)
} }
......
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