|
|
|
|
@ -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}}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断分享,发放有效用户奖励
|
|
|
|
|
|