|
|
@@ -102,119 +102,271 @@ func handleZhiosAcquisition(msg []byte) error { |
|
|
|
toRewardTime = int(time.Now().Unix()) + utils.StrToInt(cfg.RewardAccountDay)*86400 |
|
|
|
} |
|
|
|
//写入奖励记录 |
|
|
|
InvitedReward := cfg.RewardRule.InvitedReward |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
InvitedReward = Rands(cfg.RewardRule.InvitedReward, cfg.RewardRule.InvitedRewardMax) |
|
|
|
} |
|
|
|
if utils.StrToFloat64(InvitedReward) > 0 { |
|
|
|
ownRewardLog, ownhas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: userProfile.Uid, |
|
|
|
ToUid: 0, |
|
|
|
}) |
|
|
|
if !ownhas { |
|
|
|
ownRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.Uid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: 0, |
|
|
|
SourceText: "注册奖励", |
|
|
|
Money: InvitedReward, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
|
|
|
|
//新的设置 读第一个新注册的奖励 |
|
|
|
lv := 0 |
|
|
|
if len(cfg.RewardRule.LvRewardList) > 0 { |
|
|
|
isEnd := 0 |
|
|
|
for k, v := range cfg.RewardRule.LvRewardList { |
|
|
|
if isEnd == 1 { |
|
|
|
continue |
|
|
|
} |
|
|
|
if utils.StrToInt(v.Id) == user.Info.Level { |
|
|
|
isEnd = 1 |
|
|
|
} |
|
|
|
lv = utils.StrToInt(v.Id) |
|
|
|
InvitedReward := v.InvitedReward |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
InvitedReward = Rands(v.InvitedReward, v.InvitedRewardMax) |
|
|
|
} |
|
|
|
//直推 |
|
|
|
DirectSuccess := v.DirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
DirectSuccess = Rands(v.DirectSuccess, v.DirectSuccessMax) |
|
|
|
} |
|
|
|
//间推 |
|
|
|
IndirectSuccess := v.IndirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
IndirectSuccess = Rands(v.IndirectSuccess, v.IndirectSuccessMax) |
|
|
|
} |
|
|
|
InvitedSource := 0 |
|
|
|
DirectSource := 1 |
|
|
|
IndirectSource := 2 |
|
|
|
InvitedSourceStr := "注册奖励" |
|
|
|
DirectSourceStr := "直推好友" |
|
|
|
IndirectSourceStr := "间推好友" |
|
|
|
if k > 0 { |
|
|
|
InvitedSource = 3 |
|
|
|
DirectSource = 4 |
|
|
|
IndirectSource = 5 |
|
|
|
InvitedSourceStr = "升级" + v.Name + "奖励" |
|
|
|
DirectSourceStr = "直推好友升级" + v.Name + "奖励" |
|
|
|
IndirectSourceStr = "间推好友升级" + v.Name + "奖励" |
|
|
|
} |
|
|
|
if utils.StrToFloat64(InvitedReward) > 0 { |
|
|
|
ownRewardLog, ownhas, _ := db.GetNewAcquisitionRewardLogWhere(eg, userProfile.Uid, user.Profile.Uid, lv) |
|
|
|
if !ownhas { |
|
|
|
ownRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.Uid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: InvitedSource, |
|
|
|
SourceText: InvitedSourceStr, |
|
|
|
Money: InvitedReward, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
|
|
|
|
db.InsertNewRewardLog(eg, ownRewardLog) |
|
|
|
} |
|
|
|
ownRewardLog.CompleteCon = str |
|
|
|
ownRewardLog.IsFull = isFull |
|
|
|
if ownRewardLog.FullTime == 0 { |
|
|
|
ownRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if ownRewardLog.ToRewardTime == 0 { |
|
|
|
ownRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", ownRewardLog.Id).Update(ownRewardLog) |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, ownRewardLog) |
|
|
|
} |
|
|
|
if ownRewardLog.GivenAt == 0 { |
|
|
|
|
|
|
|
//直推 |
|
|
|
DirectSuccess := cfg.RewardRule.DirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
DirectSuccess = Rands(cfg.RewardRule.DirectSuccess, cfg.RewardRule.DirectSuccessMax) |
|
|
|
} |
|
|
|
if utils.StrToFloat64(DirectSuccess) > 0 { |
|
|
|
if userProfile.ParentUid > 0 { |
|
|
|
//写入奖励记录 |
|
|
|
extendRewardLog, extendHas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: userProfile.ParentUid, |
|
|
|
ToUid: userProfile.Uid, |
|
|
|
}) |
|
|
|
if !extendHas { |
|
|
|
extendRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.ParentUid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: 1, |
|
|
|
SourceText: "直推好友", |
|
|
|
Money: DirectSuccess, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
ownRewardLog.CompleteCon = str |
|
|
|
ownRewardLog.IsFull = isFull |
|
|
|
if ownRewardLog.FullTime == 0 { |
|
|
|
ownRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if ownRewardLog.ToRewardTime == 0 { |
|
|
|
ownRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", ownRewardLog.Id).Update(ownRewardLog) |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, extendRewardLog) |
|
|
|
} |
|
|
|
extendRewardLog.CompleteCon = str |
|
|
|
extendRewardLog.IsFull = isFull |
|
|
|
if extendRewardLog.FullTime == 0 { |
|
|
|
extendRewardLog.FullTime = fullTime |
|
|
|
if utils.StrToFloat64(DirectSuccess) > 0 { |
|
|
|
if userProfile.ParentUid > 0 { |
|
|
|
//写入奖励记录 |
|
|
|
extendRewardLog, extendHas, _ := db.GetNewAcquisitionRewardLogWhere(eg, userProfile.ParentUid, userProfile.Uid, lv) |
|
|
|
if !extendHas { |
|
|
|
extendRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.ParentUid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: DirectSource, |
|
|
|
SourceText: DirectSourceStr, |
|
|
|
Money: DirectSuccess, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, extendRewardLog) |
|
|
|
} |
|
|
|
if extendRewardLog.GivenAt == 0 { |
|
|
|
|
|
|
|
extendRewardLog.CompleteCon = str |
|
|
|
extendRewardLog.IsFull = isFull |
|
|
|
if extendRewardLog.FullTime == 0 { |
|
|
|
extendRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if extendRewardLog.ToRewardTime == 0 { |
|
|
|
extendRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", extendRewardLog.Id).Update(extendRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if extendRewardLog.ToRewardTime == 0 { |
|
|
|
extendRewardLog.ToRewardTime = toRewardTime |
|
|
|
if utils.StrToFloat64(IndirectSuccess) > 0 { |
|
|
|
if nextUserProfile != nil && nextUserProfile.ParentUid > 0 { |
|
|
|
IndirectRewardLog, IndirectHas, _ := db.GetNewAcquisitionRewardLogWhere(eg, nextUserProfile.ParentUid, userProfile.Uid, lv) |
|
|
|
if !IndirectHas { |
|
|
|
IndirectRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: nextUserProfile.ParentUid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: IndirectSource, |
|
|
|
SourceText: IndirectSourceStr, |
|
|
|
Money: IndirectSuccess, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, IndirectRewardLog) |
|
|
|
} |
|
|
|
if IndirectRewardLog.GivenAt == 0 { |
|
|
|
IndirectRewardLog.CompleteCon = str |
|
|
|
IndirectRewardLog.IsFull = isFull |
|
|
|
if IndirectRewardLog.FullTime == 0 { |
|
|
|
IndirectRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if IndirectRewardLog.ToRewardTime == 0 { |
|
|
|
IndirectRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", IndirectRewardLog.Id).Update(IndirectRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
eg.Where("id=?", extendRewardLog.Id).Update(extendRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//间推 |
|
|
|
IndirectSuccess := cfg.RewardRule.IndirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
IndirectSuccess = Rands(cfg.RewardRule.IndirectSuccess, cfg.RewardRule.IndirectSuccessMax) |
|
|
|
} |
|
|
|
if utils.StrToFloat64(IndirectSuccess) > 0 { |
|
|
|
if nextUserProfile != nil && nextUserProfile.ParentUid > 0 { |
|
|
|
IndirectRewardLog, IndirectHas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: nextUserProfile.ParentUid, |
|
|
|
ToUid: userProfile.Uid, |
|
|
|
} else { |
|
|
|
InvitedReward := cfg.RewardRule.InvitedReward |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
InvitedReward = Rands(cfg.RewardRule.InvitedReward, cfg.RewardRule.InvitedRewardMax) |
|
|
|
} |
|
|
|
//直推 |
|
|
|
DirectSuccess := cfg.RewardRule.DirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
DirectSuccess = Rands(cfg.RewardRule.DirectSuccess, cfg.RewardRule.DirectSuccessMax) |
|
|
|
} |
|
|
|
//间推 |
|
|
|
IndirectSuccess := cfg.RewardRule.IndirectSuccess |
|
|
|
if cfg.RewardRule.RewardType == "1" { |
|
|
|
IndirectSuccess = Rands(cfg.RewardRule.IndirectSuccess, cfg.RewardRule.IndirectSuccessMax) |
|
|
|
} |
|
|
|
if utils.StrToFloat64(InvitedReward) > 0 { |
|
|
|
ownRewardLog, ownhas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.Uid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
}) |
|
|
|
if !IndirectHas { |
|
|
|
IndirectRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: nextUserProfile.ParentUid, |
|
|
|
if !ownhas { |
|
|
|
ownRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.Uid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: 2, |
|
|
|
SourceText: "间推好友", |
|
|
|
Money: IndirectSuccess, |
|
|
|
Source: 0, |
|
|
|
SourceText: "注册奖励", |
|
|
|
Money: InvitedReward, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
|
|
|
|
db.InsertNewRewardLog(eg, ownRewardLog) |
|
|
|
} |
|
|
|
if ownRewardLog.GivenAt == 0 { |
|
|
|
ownRewardLog.CompleteCon = str |
|
|
|
ownRewardLog.IsFull = isFull |
|
|
|
if ownRewardLog.FullTime == 0 { |
|
|
|
ownRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, IndirectRewardLog) |
|
|
|
if ownRewardLog.ToRewardTime == 0 { |
|
|
|
ownRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", ownRewardLog.Id).Update(ownRewardLog) |
|
|
|
} |
|
|
|
IndirectRewardLog.CompleteCon = str |
|
|
|
IndirectRewardLog.IsFull = isFull |
|
|
|
if IndirectRewardLog.FullTime == 0 { |
|
|
|
IndirectRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if utils.StrToFloat64(DirectSuccess) > 0 { |
|
|
|
if userProfile.ParentUid > 0 { |
|
|
|
//写入奖励记录 |
|
|
|
extendRewardLog, extendHas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: userProfile.ParentUid, |
|
|
|
ToUid: userProfile.Uid, |
|
|
|
}) |
|
|
|
if !extendHas { |
|
|
|
extendRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: user.Profile.ParentUid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: 1, |
|
|
|
SourceText: "直推好友", |
|
|
|
Money: DirectSuccess, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, extendRewardLog) |
|
|
|
} |
|
|
|
if extendRewardLog.GivenAt == 0 { |
|
|
|
extendRewardLog.CompleteCon = str |
|
|
|
extendRewardLog.IsFull = isFull |
|
|
|
if extendRewardLog.FullTime == 0 { |
|
|
|
extendRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if extendRewardLog.ToRewardTime == 0 { |
|
|
|
extendRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", extendRewardLog.Id).Update(extendRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
if IndirectRewardLog.ToRewardTime == 0 { |
|
|
|
IndirectRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
if utils.StrToFloat64(IndirectSuccess) > 0 { |
|
|
|
if nextUserProfile != nil && nextUserProfile.ParentUid > 0 { |
|
|
|
IndirectRewardLog, IndirectHas, _ := db.GetNewAcquisitionRewardLog(eg, &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: nextUserProfile.ParentUid, |
|
|
|
ToUid: userProfile.Uid, |
|
|
|
}) |
|
|
|
if !IndirectHas { |
|
|
|
IndirectRewardLog = &model.NewAcquisitionRewardLog{ |
|
|
|
Uid: nextUserProfile.ParentUid, |
|
|
|
ToUid: user.Profile.Uid, |
|
|
|
Title: user.Info.Nickname, |
|
|
|
Source: 2, |
|
|
|
SourceText: "间推好友", |
|
|
|
Money: IndirectSuccess, |
|
|
|
CreatedAt: int(time.Now().Unix()), |
|
|
|
State: 0, |
|
|
|
CoinId: utils.StrToInt(cfg.RewardRule.RewardCoinId), |
|
|
|
RewardType: utils.StrToInt(cfg.RewardRule.RewardType), |
|
|
|
InviteTime: int(userInfo.CreateAt.Unix()), |
|
|
|
Lv: lv, |
|
|
|
} |
|
|
|
db.InsertNewRewardLog(eg, IndirectRewardLog) |
|
|
|
} |
|
|
|
if IndirectRewardLog.GivenAt == 0 { |
|
|
|
IndirectRewardLog.CompleteCon = str |
|
|
|
IndirectRewardLog.IsFull = isFull |
|
|
|
if IndirectRewardLog.FullTime == 0 { |
|
|
|
IndirectRewardLog.FullTime = fullTime |
|
|
|
} |
|
|
|
if IndirectRewardLog.ToRewardTime == 0 { |
|
|
|
IndirectRewardLog.ToRewardTime = toRewardTime |
|
|
|
} |
|
|
|
eg.Where("id=?", IndirectRewardLog.Id).Update(IndirectRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
eg.Where("id=?", IndirectRewardLog.Id).Update(IndirectRewardLog) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|