diff --git a/call/share.go b/call/share.go index 9a31850..0fb8d1b 100644 --- a/call/share.go +++ b/call/share.go @@ -32,12 +32,14 @@ func ShareBind(share string, isOld bool, uid, cid int) { if share == "" || isOld { return } + activityId := 0 now := time.Now().Unix() codeInfo := &common.ShareActivityCode{ShareCode: share} upInfo := &common.ShareInfo{} db.Mysql().Get(codeInfo) if codeInfo.Id > 0 { upInfo.UID = codeInfo.UID + activityId = codeInfo.ActivityId // 判断是否过期 if now < codeInfo.ExpireAt { util.Go(func() { @@ -52,14 +54,14 @@ func ShareBind(share string, isOld bool, uid, cid int) { if upInfo.ID <= 0 { return } - shareInfo := &common.ShareInfo{UID: uid, UP1: upInfo.UID, UP2: upInfo.UP1, UP3: upInfo.UP2, Time: time.Now().Unix(), ChannelID: cid, Share: util.GetShareCode(uid)} + shareInfo := &common.ShareInfo{UID: uid, UP1: upInfo.UID, UP2: upInfo.UP1, UP3: upInfo.UP2, Time: time.Now().Unix(), ChannelID: cid, Share: util.GetShareCode(uid), ActivityId: activityId} db.Mysql().Create(shareInfo) // 更新上级邀请玩家数 db.Mysql().Update(&common.ShareInfo{UID: upInfo.UID}, map[string]interface{}{"invites": gorm.Expr("invites + 1")}) // 完成邀请任务 - CheckTask(Task{Uid: uid, Value: 1, Types: []common.TaskType{common.TaskTypeInvite}}) + CheckTask(Task{Uid: upInfo.UID, Value: 1, Types: []common.TaskType{common.TaskTypeInvite}}) } // 判断分享,发放有效用户奖励 diff --git a/common/share.go b/common/share.go index c6f8ba2..bcf06a4 100644 --- a/common/share.go +++ b/common/share.go @@ -42,6 +42,7 @@ type ShareInfo struct { BetReward int64 `gorm:"column:bet_reward;type:bigint(20);default:0;comment:邀请人下注获得的金额"` AvailableReward int64 `gorm:"column:available_reward;type:bigint(20);default:0;comment:可支配佣金"` Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:加入的时间"` + ActivityId int `gorm:"column:activity_id;type:int(11);default:0;comment:来自于哪个分享活动"` } // 绑定关系