invite award
This commit is contained in:
parent
e9ae0e246f
commit
b9be30cea1
@ -8,6 +8,7 @@ import (
|
||||
"main/service"
|
||||
"main/vo"
|
||||
"q5"
|
||||
"wheelserver/mt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -52,6 +53,28 @@ func (this *UserApi) Login(c *gin.Context) {
|
||||
}
|
||||
f5.GetMsgQueue().FireEvent(constant.MSG_CREATE_USER, q5.Args{user})
|
||||
service.Task.List(s.GetAccountId(), nil)
|
||||
if user.Invited != "" {
|
||||
service.Task.UpdateTaskProgress(user.Invited, 0, 1, nil)
|
||||
invitor := new(model.User)
|
||||
err, found := invitor.Find(user.Invited, nowTime)
|
||||
if err == nil && found {
|
||||
var meta *mt.Friend
|
||||
if s.GetPlatVip() != 0 {
|
||||
meta = mt.Table.Friend.GetMetaByType(constant.INVITEE_TYPE_VIP)
|
||||
}
|
||||
|
||||
if meta == nil {
|
||||
meta = mt.Table.Friend.GetMetaByType(constant.INVITEE_TYPE_COMMON)
|
||||
}
|
||||
|
||||
if meta != nil {
|
||||
if meta.GetRewardType() == constant.TASK_AWARD_SCORE {
|
||||
invitor.AddDice(meta.GetReward())
|
||||
invitor.UpdateUserFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
earning := service.Chip.CalcScore(s.GetAccountId())
|
||||
if earning > 0 {
|
||||
|
@ -70,3 +70,8 @@ const (
|
||||
const (
|
||||
TASK_AWARD_SCORE = 1
|
||||
)
|
||||
|
||||
const (
|
||||
INVITEE_TYPE_COMMON = 1
|
||||
INVITEE_TYPE_VIP = 2
|
||||
)
|
||||
|
@ -12,3 +12,16 @@ type Friend struct {
|
||||
type FriendTable struct {
|
||||
f5.IdMetaTable[Friend]
|
||||
}
|
||||
|
||||
func (this *FriendTable) GetMetaByType(typeid int32) (meta *Friend) {
|
||||
|
||||
this.Traverse(func(data *Friend) bool {
|
||||
if data.GetType() == typeid {
|
||||
meta = data
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
return meta
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ type Item struct {
|
||||
|
||||
type Friend struct {
|
||||
id int32
|
||||
level int32
|
||||
type_ int32
|
||||
reward_type int32
|
||||
reward int32
|
||||
|
||||
@ -284,11 +284,11 @@ func (this *Friend) HasId() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *Friend) GetLevel() int32 {
|
||||
return this.level
|
||||
func (this *Friend) GetType() int32 {
|
||||
return this.type_
|
||||
}
|
||||
|
||||
func (this *Friend) HasLevel() bool {
|
||||
func (this *Friend) HasType() bool {
|
||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||
}
|
||||
|
||||
@ -542,7 +542,7 @@ func (this *Item) LoadFromKv(kv map[string]interface{}) {
|
||||
|
||||
func (this *Friend) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.level, "level", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.type_, "type", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.reward_type, "reward_type", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.reward, "reward", &this._flags1_, 4, kv)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ message Item
|
||||
message Friend
|
||||
{
|
||||
optional int32 id = 1;
|
||||
optional int32 level = 2;
|
||||
optional int32 type = 2;
|
||||
optional int32 reward_type = 3;
|
||||
optional int32 reward = 4;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user