package event_s import ( "git.hilo.cn/hilo-common/domain" "hilo-user/domain/event/gift_ev" "hilo-user/domain/model/cp_m" ) // 送礼增加cp等级 // 送礼增加cp排行榜 func CpGiftEvent() { gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent) if !ok { model.Log.Errorf("AddSendGiftEventAsync event type err") return nil } for _, receiverUid := range sendGiftEvent.ReceiveUserIds { 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 { model.Log.Errorf("AddCpLevelPoints fail:%v", err) } if err := cp_m.AddCpDayRank(model, cpRelation, diamonds); err != nil { model.Log.Errorf("AddCpDayRank fail:%v", err) } return nil // 业务场景允许提前break(cp是唯一的) } } return nil }) }