Compare commits

...

6 Commits

Author SHA1 Message Date
mofangmin 2bbef647e9 防止循环绑定 1 year ago
mofangmin 532ee6a99b Merge branch 'release' into dev 1 year ago
mofangmin 082625cbd8 分享修改 1 year ago
mofangmin 1d87ca592e Merge branch 'release' into dev 1 year ago
mofangmin bccf1e3b1b 功能修改 1 year ago
mofangmin 017d79fe72 功能添加 1 year ago
  1. 3
      call/pay.go
  2. 75
      call/share.go
  3. 4
      cmd/build.sh
  4. 4
      common/activity.go
  5. 23
      common/share.go
  6. 1
      modules/backend/migrate.go
  7. 2
      modules/common/nats.go
  8. 15
      modules/web/handler/activity.go
  9. 89
      modules/web/handler/share.go
  10. 2
      modules/web/routers/routers_activity.go
  11. 1
      modules/web/routers/routers_share.go
  12. 2
      modules/web/timer.go
  13. 18
      modules/web/values/activity.go
  14. 23
      modules/web/values/share.go

@ -511,9 +511,8 @@ func PayActivity(r *common.RechargeOrder, notCharge bool, user *common.PlayerDBI
// 更新loginrecord // 更新loginrecord
if notCharge { if notCharge {
InsertLoginRecord(r.UID, r.ChannelID, user.IP, user.Birth, user.Platform) InsertLoginRecord(r.UID, r.ChannelID, user.IP, user.Birth, user.Platform)
CheckShare(r)
} }
CheckShare(r)
return nil return nil
} }

@ -82,20 +82,77 @@ func ShareBind(share string, isOld bool, uid, cid int) {
// 判断分享,发放有效用户奖励 // 判断分享,发放有效用户奖励
func CheckShare(r *common.RechargeOrder) { func CheckShare(r *common.RechargeOrder) {
shareInfo := GetShareInfo(r.UID)
reward := GetConfigShareSys().ShareReward reward := GetConfigShareSys().ShareReward
if r.Amount < GetConfigShareSys().ShareRecharge { // 付费分享
// CheckShareTask(shareInfo.UP1, 1, common.TaskTypePayShare)
// 发放奖励
update := map[string]interface{}{
"recharge_amount": gorm.Expr("recharge_amount + ?", r.Amount),
}
if shareInfo.BetAmount != -1 {
update["bet_amount"] = gorm.Expr("bet_amount + ?", r.Amount)
}
db.Mysql().Update(&common.ShareInfo{UID: r.UID}, update)
betAmount := shareInfo.BetAmount
if betAmount == -1 {
betAmount = 0
}
if shareInfo.RechargeAmount+r.Amount < GetConfigShareSys().ShareRecharge {
return return
} }
share := GetShareInfo(r.UID) if shareInfo.UP1 == 0 {
if share.UP1 == 0 {
return return
} }
// 发放奖励 if shareInfo.BetAmount >= 0 {
db.Mysql().Update(&common.ShareInfo{UID: share.UP1}, map[string]interface{}{ db.Mysql().Update(&common.ShareInfo{UID: r.UID}, map[string]interface{}{
"invalid_invites": gorm.Expr("invalid_invites + 1"), "bet_amount": -1,
"invite_reward": gorm.Expr("invite_reward + ?", reward), })
"available_reward": gorm.Expr("available_reward + ?", reward), update = map[string]interface{}{
}) "invalid_invites": gorm.Expr("invalid_invites + 1"),
"invite_reward": gorm.Expr("invite_reward + ?", reward),
"available_reward": gorm.Expr("available_reward + ?", reward),
}
db.Mysql().Update(&common.ShareInfo{UID: shareInfo.UP1}, update)
}
ShareRecharge(r.UID, r.Amount+betAmount)
}
func ShareRecharge(uid int, amount int64) {
shareInfo := &common.ShareInfo{UID: uid}
db.Mysql().Get(shareInfo)
if shareInfo.UP1 == 0 {
return
}
ref := reflect.ValueOf(shareInfo).Elem()
// 循环查询上级
for i := 1; i <= 3; i++ {
upUid := int(ref.FieldByName(fmt.Sprintf("UP%d", i)).Int())
if upUid == 0 {
break
}
con := GetConfigShareByLevel(i)
if con == nil {
log.Error("unknown config share level:%v", i)
continue
}
// 发奖
reward := amount * con.Per / 1000
if reward <= 0 {
continue
}
db.Mysql().Update(&common.ShareInfo{UID: upUid}, map[string]interface{}{
"bet_reward": gorm.Expr("bet_reward + ?", reward),
"available_reward": gorm.Expr("available_reward + ?", reward),
})
db.Mysql().Create(&common.ShareDetail{
UID: uid,
Up: upUid,
RechargeAmount: amount,
Reward: reward,
Time: time.Now().Unix(),
})
}
} }
// 投注奖励结算 // 投注奖励结算

@ -8,5 +8,5 @@ cd pb/proto
# go generate # go generate
cd ../.. cd ../..
#go build main.go #go build main.go
#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go #CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go

@ -307,8 +307,8 @@ func (c *ConfigActivityBreakGift) TableName() string {
type ConfigActivityWeekCard struct { type ConfigActivityWeekCard struct {
ID int `gorm:"primarykey"` ID int `gorm:"primarykey"`
DayOneReward int64 `gorm:"column:day_one_reward;type:bigint(20);default:0;comment:第一天奖励" web:"day_one_reward"` // 下限 DayOneReward int64 `gorm:"column:day_one_reward;type:bigint(20);default:0;comment:第一天奖励" web:"day_one_reward"` // 下限
MiniLimit int64 `gorm:"column:mini_limit;type:bigint(20);default:0;comment:下限" web:"mini_limit"` // 下限 MiniLimit int64 `gorm:"column:mini_limit;type:bigint(20);default:0;comment:下限" web:"mini_limit"` // 下限
RewardAmount int64 `gorm:"column:reward_amount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"reward_amount"` // 第二到第6天奖励金额 RewardAmount int64 `gorm:"column:reward_amount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"reward_amount"` // 第二到第6天奖励金额
Discount int64 `gorm:"column:discount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"discount"` // 满减券折扣 Discount int64 `gorm:"column:discount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"discount"` // 满减券折扣
} }

@ -43,6 +43,25 @@ type ShareInfo struct {
AvailableReward int64 `gorm:"column:available_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:加入的时间"` Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:加入的时间"`
ActivityId int `gorm:"column:activity_id;type:int(11);default:0;comment:来自于哪个分享活动"` ActivityId int `gorm:"column:activity_id;type:int(11);default:0;comment:来自于哪个分享活动"`
RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20);default:0;comment:充值金额"`
BetAmount int64 `gorm:"column:bet_amount;type:bigint(20);default:0;comment:下注金额"`
}
func (a *ShareInfo) TableName() string {
return "share_info"
}
type ShareDetail struct {
ID int `gorm:"primarykey"`
UID int `gorm:"column:uid;not null;type:int(11);"`
Up int `gorm:"column:up;type:int(11);default:0;comment:上级"`
Reward int64 `gorm:"column:reward;type:bigint(20);default:0;comment:获取奖励"`
RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20);default:0;comment:充值金额"`
Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:时间"`
}
func (m *ShareDetail) TableName() string {
return "share_detail"
} }
// 绑定关系 // 绑定关系
@ -75,10 +94,6 @@ type ShareInfo struct {
// Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:加入的时间"` // Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:加入的时间"`
// } // }
func (a *ShareInfo) TableName() string {
return "share_info"
}
type ShareActivityCode struct { type ShareActivityCode struct {
Id int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key;" json:"id"` Id int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key;" json:"id"`
UID int `gorm:"column:uid;type:int(11);index:idx_share;comment:玩家ID" json:"uid"` UID int `gorm:"column:uid;type:int(11);index:idx_share;comment:玩家ID" json:"uid"`

@ -119,6 +119,7 @@ func MigrateDB() {
new(common.ConfigDiscountTicket), new(common.ConfigDiscountTicket),
new(common.ConfigRtp), new(common.ConfigRtp),
new(common.PlayerRtpData), new(common.PlayerRtpData),
new(common.ShareDetail),
) )
if err != nil { if err != nil {
panic("Migrate db fail") panic("Migrate db fail")

@ -33,7 +33,7 @@ type Player struct {
func afterSettle(d *pb.InnerAfterSettle) { func afterSettle(d *pb.InnerAfterSettle) {
log.Debug("afterSettle:%+v", *d) log.Debug("afterSettle:%+v", *d)
UpdateGameData(d) UpdateGameData(d)
call.ShareSettle(d) // call.ShareSettle(d)
// p := &Player{uid: int(d.UID), gid: int(d.GameID), settleData: d} // p := &Player{uid: int(d.UID), gid: int(d.GameID), settleData: d}
// p.ActivityFirstRechargeBack() // p.ActivityFirstRechargeBack()
} }

@ -782,7 +782,8 @@ func ActivityLuckyCodeDraw(c *gin.Context) {
// 判断是否为分享吗 // 判断是否为分享吗
upShareInfo := call.GetShareInfoByCode(req.LuckyCode) upShareInfo := call.GetShareInfoByCode(req.LuckyCode)
if upShareInfo.ID > 0 { if upShareInfo.ID > 0 {
if upShareInfo.UID == a.UID { // 防止循环绑定
if upShareInfo.UID == a.UID || a.UID == upShareInfo.UP1 || a.UID == upShareInfo.UP2 || a.UID == upShareInfo.UP3 {
a.Code = values.CodeRetry a.Code = values.CodeRetry
a.Msg = "code error" a.Msg = "code error"
return return
@ -2198,3 +2199,15 @@ func DiscountTicketInfo(c *gin.Context) {
} }
resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR)
} }
func InviteRankInfo(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
if !a.CheckActivityExpire(common.ActivityIDBetDraw) {
return
}
resp := new(values.InviteInfoResp)
a.Data = resp
}

@ -84,13 +84,6 @@ func ShareInfo(c *gin.Context) {
} }
channel := call.GetChannelByID(a.Channel) channel := call.GetChannelByID(a.Channel)
if channel != nil { if channel != nil {
// resp.ShareLink += channel.URL + "?code=" + "xxxxxx"
// if a.Prefix != "" {
// resp.ShareLink = a.Prefix + "." + resp.ShareLink
// } else {
// resp.ShareLink = "www." + resp.ShareLink
// }
// resp.ShareLink = "https://" + resp.ShareLink
resp.ShareLink = channel.ShareUrl resp.ShareLink = channel.ShareUrl
} }
a.GetUID() a.GetUID()
@ -107,20 +100,7 @@ func ShareInfo(c *gin.Context) {
resp.RechargeCount = call.GetUserShareRecharges(a.UID, 1) resp.RechargeCount = call.GetUserShareRecharges(a.UID, 1)
resp.TotalRecharge = call.GetUserShareRechargeAmount(a.UID, 1) resp.TotalRecharge = call.GetUserShareRechargeAmount(a.UID, 1)
resp.ShareCode = shareInfo.Share resp.ShareCode = shareInfo.Share
// if channel != nil {
// num := 10000
// channelId := channel.ChannelID
// if channel.ChannelID < num {
// channelId += num
// }
// resp.ShareLink = channel.URL + "?code=" + shareInfo.Share + "&ch=" + fmt.Sprintf("%d", channelId)
// if a.Prefix != "" {
// resp.ShareLink = a.Prefix + "." + resp.ShareLink
// } else {
// resp.ShareLink = "www." + resp.ShareLink
// }
// resp.ShareLink = "https://" + resp.ShareLink
// }
num := 0 num := 0
if resp.AvailableReward > 0 { if resp.AvailableReward > 0 {
num = 1 num = 1
@ -130,6 +110,73 @@ func ShareInfo(c *gin.Context) {
} }
} }
func ShareList(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.ShareListReq)
if !a.S(req) {
return
}
resp := &values.ShareListResp{}
a.Data = resp
type TempData struct {
Uid int `gorm:"column:UID"`
Amount int64 `gorm:"column:total_reward"`
RechargeAmount int64 `gorm:"column:total_recharge"`
}
var ret []TempData
if req.Type == 1 {
err := db.Mysql().QueryCountBySql(fmt.Sprintf("select count(*) from (SELECT count(*) FROM share_detail WHERE FROM_UNIXTIME(Time, '%%Y-%%m-%%d') = CURDATE() and up = %d GROUP BY UID ORDER BY SUM(reward) DESC)a", a.UID), &resp.Count)
if err != nil {
log.Error("err:%v", err)
}
err = db.Mysql().QueryBySql(fmt.Sprintf("SELECT UID, SUM(reward) AS total_reward, SUM(recharge_amount) AS total_recharge FROM share_detail WHERE up = %d and FROM_UNIXTIME(Time, '%%Y-%%m-%%d') = CURDATE() GROUP BY UID ORDER BY total_reward DESC limit %d,%d", a.UID, req.Page, req.Size), &ret)
if err != nil {
log.Error("err:%v", err)
}
for _, item := range ret {
resp.TodayRewardList = append(resp.TodayRewardList, values.RewardInfo{
UID: item.Uid,
Amount: util.Decimal(float64(item.Amount)/common.DecimalDigits, 2),
})
}
} else if req.Type == 2 {
err := db.Mysql().QueryCountBySql(fmt.Sprintf("select count(*) from (SELECT count(*) FROM share_detail where up = %d GROUP BY UID ORDER BY SUM(reward) DESC)a", a.UID), &resp.Count)
if err != nil {
log.Error("err:%v", err)
}
err = db.Mysql().QueryBySql(fmt.Sprintf("SELECT UID, SUM(reward) AS total_reward, SUM(recharge_amount) AS total_recharge FROM share_detail where up = %d GROUP BY UID ORDER BY total_reward DESC limit %d,%d", a.UID, req.Page, req.Size), &ret)
if err != nil {
log.Error("err:%v", err)
}
for _, item := range ret {
resp.RewardList = append(resp.RewardList, values.RewardInfo{
UID: item.Uid,
Amount: util.Decimal(float64(item.Amount)/common.DecimalDigits, 2),
})
}
} else if req.Type == 3 {
err := db.Mysql().QueryCountBySql(fmt.Sprintf("select count(*) from (SELECT count(*) FROM share_detail where up = %d GROUP BY UID ORDER BY SUM(recharge_amount) DESC)a", a.UID), &resp.Count)
if err != nil {
log.Error("err:%v", err)
}
err = db.Mysql().QueryBySql(fmt.Sprintf("SELECT UID, SUM(reward) AS total_reward, SUM(recharge_amount) AS total_recharge FROM share_detail where up = %d GROUP BY UID ORDER BY total_recharge DESC limit %d,%d", a.UID, req.Page, req.Size), &ret)
if err != nil {
log.Error("err:%v", err)
}
for _, item := range ret {
user, _ := call.GetUserXInfo(item.Uid, "birth")
resp.InviteList = append(resp.InviteList, values.InviteInfo{
UID: item.Uid,
RechargeAmount: item.RechargeAmount / common.DecimalDigits,
RegisterTime: user.Birth,
})
}
}
}
func GetActivityCode(c *gin.Context) { func GetActivityCode(c *gin.Context) {
a := app.NewApp(c) a := app.NewApp(c)
defer func() { defer func() {

@ -48,4 +48,6 @@ func activity(e *gin.RouterGroup) {
e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw) e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw)
// 优惠券 // 优惠券
e.POST("/activity/discountTicket/info", handler.DiscountTicketInfo) e.POST("/activity/discountTicket/info", handler.DiscountTicketInfo)
// 好友冲冲冲
e.POST("/activity/inviteRank/info", handler.InviteRankInfo)
} }

@ -11,6 +11,7 @@ func share(e *gin.RouterGroup) {
e.POST("/share/platform", handler.SharePlatformInfo) e.POST("/share/platform", handler.SharePlatformInfo)
e.POST("/share/withdraw", handler.ShareWithdraw) e.POST("/share/withdraw", handler.ShareWithdraw)
e.POST("/share/activity_code", handler.GetActivityCode) e.POST("/share/activity_code", handler.GetActivityCode)
e.POST("/share/list", handler.ShareList)
// e.POST("/share/reference", handler.ShareReference) // e.POST("/share/reference", handler.ShareReference)
// e.POST("/share/report", handler.ShareReport) // e.POST("/share/report", handler.ShareReport)
// e.POST("/share/transfer", handler.ShareTransfer) // e.POST("/share/transfer", handler.ShareTransfer)

@ -20,7 +20,7 @@ func FetchDatas() {
var ( var (
FetchInterval = 5 * 60 FetchInterval = 5 * 60
ShareDataRankNum = 8 // 排行榜显示8个 ShareDataRankNum = 20 // 排行榜显示8个
ActivitySlotsRankNum = 10 // slots活动排行榜数目 ActivitySlotsRankNum = 10 // slots活动排行榜数目
) )

@ -325,3 +325,21 @@ type DiscountTicketResp struct {
Ticket *DiscountTicketInfo Ticket *DiscountTicketInfo
ChannelList []*common.ConfigPayChannels ChannelList []*common.ConfigPayChannels
} }
type RewardRankConfig struct {
RankMin int64
RankMax int64
Reward int64
}
type RankInfo struct {
Rank int `json:"Rank"`
Reward int `json:"Reward"`
UserName string `json:"UserName"`
}
type InviteInfoResp struct {
RewardRankConfig []RewardRankConfig
RankInfoList []RankInfo
MyRank RankInfo
}

@ -207,3 +207,26 @@ type GetActivityCodeResp struct {
type ShareCodeBindReq struct { type ShareCodeBindReq struct {
Code string Code string
} }
type ShareListReq struct {
Type int // 1 今日贡献 2 总贡献 3 邀请列表
Page int
Size int
}
type ShareListResp struct {
TodayRewardList []RewardInfo
RewardList []RewardInfo
InviteList []InviteInfo
Count int // 总数
}
type RewardInfo struct {
UID int // UID
Amount float64 // 总额
}
type InviteInfo struct {
UID int // UID
RechargeAmount int64 // 充值总额
RegisterTime int64 // 注册时间
}

Loading…
Cancel
Save