cp_level.go 787 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package event_s

import (
	"git.hilo.cn/hilo-common/domain"
	"hilo-user/domain/event/gift_ev"
	"hilo-user/domain/model/cp_m"
)

// 送礼增加cp值
func CpLevelEvent() {
	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.GetCpRelation(model, sendGiftEvent.SendUserId, receiverUid); exits {
				return cp_m.AddCpLevelPoints(model, cpRelation, diamonds) // 业务场景允许提前break(cp是唯一的)
			}
		}
		return nil
	})
}