Commit 4f4b4144 authored by hujiebin's avatar hujiebin

群组中送礼升级

parent db812065
......@@ -4,10 +4,13 @@ import (
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/txop/headwear_tx"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-user/_const/enum/cp_e"
"hilo-user/_const/enum/gift_e"
"hilo-user/domain/model/user_m"
"hilo-user/myerr"
"time"
)
......@@ -134,7 +137,7 @@ func InitCpLevel(model *domain.Model, cpId, userId1, userId2 mysql.ID) error {
// 2.记录存在
// 2.1 在有效期内,直接加points后判断新level,升级需要更新有效期
// 2.2 不有效期内,算首充,重置points后判断新level,升级需要更新有效期
func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.Num) (err error) {
func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.Num, sceneType gift_e.GiftOperateSceneType) (err error) {
start := time.Now()
defer func() {
model.Log.Infof("AddCpLevelPoints cost:%v,err:%v", time.Now().Sub(start), err)
......@@ -281,6 +284,21 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N
return err
}
}
// 群组中送礼升级
if oldLevel != cpLevel.Level && sceneType == gift_e.GroupSceneType {
go func() {
userId1, userId2 := cpRelation.UserId1, cpRelation.UserId2
model := domain.CreateModelContext(model.MyContext)
users, err := user_m.GetUserMapByIds(model, []mysql.ID{userId1, userId2})
if err != nil {
model.Log.Errorf("")
return
}
if err := rpc.SendCpUpgrade(users[userId1].Nick, users[userId2].Nick, users[userId1].Avatar, users[userId2].Avatar, uint32(cpLevel.Level), "成为 todo"); err != nil {
model.Log.Errorf("SendCpUpgrade fail:%v", err)
}
}()
}
return cpLevel.Persistence(model)
}
......
......@@ -26,7 +26,7 @@ func CpGiftEvent() {
diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum
// 有cp关系
if cpRelation, exits := cp_m.GetCpRelationPair(model, sendGiftEvent.SendUserId, receiverUid); exits {
if err := cp_m.AddCpLevelPoints(model, cpRelation, diamonds); err != nil {
if err := cp_m.AddCpLevelPoints(model, cpRelation, diamonds, sendGiftEvent.SceneType); err != nil {
model.Log.Errorf("AddCpLevelPoints fail:%v", err)
}
if err := cp_m.AddCpDayRank(model, cpRelation, diamonds); err != 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