Bladeren bron

更新

three
huangjiajun 1 jaar geleden
bovenliggende
commit
f3d389ec77
6 gewijzigde bestanden met toevoegingen van 288 en 104 verwijderingen
  1. +8
    -0
      app/db/db_new_acquisition.go
  2. +1
    -0
      app/db/model/new_acquisition_reward_log.go
  3. +2
    -1
      consume/init.go
  4. +10
    -0
      consume/md/consume_key.go
  5. +22
    -10
      consume/md/md.go
  6. +245
    -93
      consume/zhios_acquisition_condition.go

+ 8
- 0
app/db/db_new_acquisition.go Bestand weergeven

@@ -15,6 +15,14 @@ func GetNewAcquisitionRewardLog(Db *xorm.Engine, condition *model.NewAcquisition
}
return condition, has, nil
}
func GetNewAcquisitionRewardLogWhere(Db *xorm.Engine, uid, toUid, lv int) (*model.NewAcquisitionRewardLog, bool, error) {
var data model.NewAcquisitionRewardLog
has, err := Db.Where("uid=? and to_uid=? and lv=?", uid, toUid, lv).Get(&data)
if err != nil {
return nil, false, err
}
return &data, has, nil
}

// 获取拉新记录
func GetNewAcquisitionLog(Db *xorm.Engine, condition *model.NewAcquisitionLog) (*model.NewAcquisitionLog, bool, error) {


+ 1
- 0
app/db/model/new_acquisition_reward_log.go Bestand weergeven

@@ -24,5 +24,6 @@ type NewAcquisitionRewardLog struct {
IsFull int `json:"is_full" xorm:"default 0 INT(11)"`
FullTime int `json:"full_time" xorm:"default 0 INT(11)"`
ToRewardTime int `json:"to_reward_time" xorm:"default 0 INT(11)"`
Lv int `json:"lv" xorm:"default 0 INT(11)"`
CompleteCon string `json:"complete_con" xorm:"not null default '0' comment('完成的条件') VARCHAR(255)"`
}

+ 2
- 1
consume/init.go Bestand weergeven

@@ -17,8 +17,9 @@ func Init() {

// 增加消费任务队列
func initConsumes() {
jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
//jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition

jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume


+ 10
- 0
consume/md/consume_key.go Bestand weergeven

@@ -183,6 +183,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "ZhiosAcquisitionCondition",
},
{
ExchangeName: "zhios.acquisition.exchange",
Name: "zhios_acquisition_condition_dev",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "acq_dev",
BindKey: "",
ConsumeFunName: "ZhiosAcquisitionConditionDev",
},
{
ExchangeName: "zhios.recharge.order.exchange",
Name: "zhios_recharge_order_fail_dev",
@@ -225,4 +234,5 @@ const (
ZhiosTikTokAllUpdateFunName = "ZhiosTikTokAllUpdate"
CloudIssuanceAsyncMLoginFunName = "CloudIssuanceAsyncMLoginConsume"
ZhiosAcquisitionConditionFunName = "ZhiosAcquisitionCondition"
ZhiosAcquisitionConditionDevFunName = "ZhiosAcquisitionConditionDev"
)

+ 22
- 10
consume/md/md.go Bestand weergeven

@@ -48,22 +48,24 @@ type AcquisitionCfg struct {
AdData string `json:"ad_data"`
} `json:"ad_setting"`
RewardRule struct {
DirectTime string `json:"direct_time"`
IndirectTime string `json:"indirect_time"`
DirectSuccess string `json:"direct_success"`
IndirectSuccess string `json:"indirect_success"`
InvitedReward string `json:"invited_reward"`
DirectSuccessMax string `json:"direct_success_max"`
IndirectSuccessMax string `json:"indirect_success_max"`
InvitedRewardMax string `json:"invited_reward_max"`
RewardType string `json:"reward_type"`
RewardCoinId string `json:"reward_coin_id"`
DirectTime string `json:"direct_time"`
IndirectTime string `json:"indirect_time"`
DirectSuccess string `json:"direct_success"`
IndirectSuccess string `json:"indirect_success"`
InvitedReward string `json:"invited_reward"`
DirectSuccessMax string `json:"direct_success_max"`
IndirectSuccessMax string `json:"indirect_success_max"`
InvitedRewardMax string `json:"invited_reward_max"`
RewardType string `json:"reward_type"`
RewardCoinId string `json:"reward_coin_id"`
LvRewardList []LvRewardList `json:"lv_reward_list"`
} `json:"reward_rule"`
ExtraRewardSetting struct {
Status string `json:"status"`
RewardStep []struct {
Number string `json:"number"`
Money string `json:"money"`
Lv string `json:"lv"`
} `json:"reward_step"`
} `json:"extra_reward_setting"`
RankRule struct {
@@ -80,6 +82,16 @@ type AcquisitionCfg struct {
} `json:"rank_rule"`
RankData string `json:"rank_data"`
}
type LvRewardList struct {
Id string `json:"id"`
DirectSuccess string `json:"direct_success"`
IndirectSuccess string `json:"indirect_success"`
Name string `json:"name"`
InvitedReward string `json:"invited_reward"`
DirectSuccessMax string `json:"direct_success_max"`
IndirectSuccessMax string `json:"indirect_success_max"`
InvitedRewardMax string `json:"invited_reward_max"`
}

type User struct {
Info *model.User


+ 245
- 93
consume/zhios_acquisition_condition.go Bestand weergeven

@@ -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)
}
}



Laden…
Annuleren
Opslaan