Commit 823e90e6b9565bc0272e7a03e81f58abb25056fc

Authored by 王家文
1 parent d188444d
Exists in master

feat✨:卡牌活动增加用户序列组ID

configs-db/confcardholder/config.go
@@ -27,6 +27,7 @@ type ActivityConfig struct { @@ -27,6 +27,7 @@ type ActivityConfig struct {
27 NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置 27 NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置
28 CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置 28 CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置
29 StarShopConfig map[int]StarShopConfig // 星星商店配置 29 StarShopConfig map[int]StarShopConfig // 星星商店配置
  30 + ListSequenceId []int // 用户序列组ID列表
30 31
31 Client *ActivityConfigClient 32 Client *ActivityConfigClient
32 GameId string // 所属游戏ID 33 GameId string // 所属游戏ID
configs-db/confcardholder/decode.go
@@ -2,6 +2,7 @@ package confcardholder @@ -2,6 +2,7 @@ package confcardholder
2 2
3 import ( 3 import (
4 "apigame/util/util-lx/lxalilog" 4 "apigame/util/util-lx/lxalilog"
  5 + "apigame/util/zslice"
5 "encoding/json" 6 "encoding/json"
6 "errors" 7 "errors"
7 "fmt" 8 "fmt"
@@ -83,6 +84,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { @@ -83,6 +84,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) {
83 for _, i2 := range configs { 84 for _, i2 := range configs {
84 combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) 85 combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)
85 c.NormalCardStarConfig[combineId] = i2 86 c.NormalCardStarConfig[combineId] = i2
  87 + if !zslice.Contains(c.ListSequenceId, i2.SequenceId) {
  88 + c.ListSequenceId = append(c.ListSequenceId, i2.SequenceId)
  89 + }
86 } 90 }
87 } 91 }
88 // 卡片星级对应卡牌配置 92 // 卡片星级对应卡牌配置
@@ -96,6 +100,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) { @@ -96,6 +100,9 @@ func (c *ActivityConfig) Decode(gameId string, rawData any) {
96 for _, i2 := range configs { 100 for _, i2 := range configs {
97 combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort) 101 combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)
98 c.CardSequenceConfig[combineId] = i2 102 c.CardSequenceConfig[combineId] = i2
  103 + if !zslice.Contains(c.ListSequenceId, i2.SequenceId) {
  104 + c.ListSequenceId = append(c.ListSequenceId, i2.SequenceId)
  105 + }
99 } 106 }
100 } 107 }
101 // 星星商店配置 108 // 星星商店配置
controllers/demo.go
1 package controllers 1 package controllers
2 2
3 import ( 3 import (
4 - "apigame/configs" 4 + "apigame/configs-db/confcardholder"
5 "apigame/models" 5 "apigame/models"
6 "apigame/service/code-msg" 6 "apigame/service/code-msg"
7 "encoding/json" 7 "encoding/json"
@@ -43,13 +43,19 @@ func (c *DemoController) Demo() { @@ -43,13 +43,19 @@ func (c *DemoController) Demo() {
43 // } 43 // }
44 //} 44 //}
45 { 45 {
46 - cs := configs.GetTable(configs.AbTestCfg{}).Items() 46 + //cs := configs.GetTable(configs.AbTestCfg{}).Items()
47 //for _, dt := range cs { 47 //for _, dt := range cs {
48 // conf := dt.(*configs.AbTestCfg) 48 // conf := dt.(*configs.AbTestCfg)
49 // fmt.Println(conf) 49 // fmt.Println(conf)
50 //} 50 //}
51 //fmt.Println("cs", zjson.Str(cs)) 51 //fmt.Println("cs", zjson.Str(cs))
52 - rsp.Data = cs 52 + //rsp.Data = cs
  53 + }
  54 + {
  55 + config, hasConfig := confcardholder.GetCurrent("10149")
  56 + if hasConfig {
  57 + fmt.Println(config.ListSequenceId)
  58 + }
53 } 59 }
54 60
55 c.RetRspCodeData(code_msg.RECODE_OK, rsp) 61 c.RetRspCodeData(code_msg.RECODE_OK, rsp)
service/cardholder/dto-player.go
@@ -48,6 +48,7 @@ type PlayerDetails struct { @@ -48,6 +48,7 @@ type PlayerDetails struct {
48 StarCount int // 星星点数 48 StarCount int // 星星点数
49 LastStarCount int // 上期活动剩余星星点数 49 LastStarCount int // 上期活动剩余星星点数
50 AutoExchangeHolder int // 活动切换时自动兑换的卡包 2024年4月26日 这里策划要求改为只能兑换一个最高级的 50 AutoExchangeHolder int // 活动切换时自动兑换的卡包 2024年4月26日 这里策划要求改为只能兑换一个最高级的
  51 + SequenceId int // 用户序列组ID
51 } 52 }
52 53
53 func NewPlayerDetails() *PlayerDetails { 54 func NewPlayerDetails() *PlayerDetails {
service/cardholder/handle.go
@@ -102,7 +102,8 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH @@ -102,7 +102,8 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH
102 102
103 // 开始处理抽卡 103 // 开始处理抽卡
104 openMode := 0 104 openMode := 0
105 - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) 105 + sequenceId := player.Details.SequenceId
  106 + cohort := GetCohort(player.Uid)
106 allNewCards := make([]int, 0) 107 allNewCards := make([]int, 0)
107 for _, idCardholder := range req.Ids { 108 for _, idCardholder := range req.Ids {
108 confCardholder, _ := config.CardholderConfig[idCardholder] 109 confCardholder, _ := config.CardholderConfig[idCardholder]
@@ -180,7 +181,8 @@ func HandleCardAdd(req *models.ReqCardAdd) (code string, rsp models.RspCardAdd) @@ -180,7 +181,8 @@ func HandleCardAdd(req *models.ReqCardAdd) (code string, rsp models.RspCardAdd)
180 181
181 // 剩余检查处理 182 // 剩余检查处理
182 openMode := 0 183 openMode := 0
183 - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) 184 + sequenceId := player.Details.SequenceId
  185 + cohort := GetCohort(player.Uid)
184 allNewCards := []int{req.CardId} 186 allNewCards := []int{req.CardId}
185 187
186 // 记录日志 188 // 记录日志
@@ -276,7 +278,8 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model @@ -276,7 +278,8 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model
276 } 278 }
277 // 开始处理抽卡 279 // 开始处理抽卡
278 openMode := 1 280 openMode := 1
279 - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) 281 + sequenceId := player.Details.SequenceId
  282 + cohort := GetCohort(player.Uid)
280 allNewCards := make([]int, 0) 283 allNewCards := make([]int, 0)
281 for cardholderId, cardholderCount := range cardholderIdCount { 284 for cardholderId, cardholderCount := range cardholderIdCount {
282 confCardholder, okCardholder := config.CardholderConfig[cardholderId] 285 confCardholder, okCardholder := config.CardholderConfig[cardholderId]
service/cardholder/logic.go
@@ -38,12 +38,9 @@ func CheckGameData(d *Player, conf *confcardholder.ActivityConfig) string { @@ -38,12 +38,9 @@ func CheckGameData(d *Player, conf *confcardholder.ActivityConfig) string {
38 return code_msg.RECODE_OK 38 return code_msg.RECODE_OK
39 } 39 }
40 40
41 -// GetUserSequenceIdAndCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort)  
42 -func GetUserSequenceIdAndCohort(uid int64) (sequenceId, cohort int) {  
43 - // todo 这里后续要对接 用户序列组ID(sequenceId) 用户分组(cohort)  
44 - sequenceId = 1  
45 - cohort = 1  
46 - return 41 +// GetCohort 获取 用户序列组ID(sequenceId) 用户分组(cohort)
  42 +func GetCohort(uid int64) int {
  43 + return 1
47 } 44 }
48 45
49 // GetOneFromArray 从配置的数组里获取一个值 scale=之前刻度 46 // GetOneFromArray 从配置的数组里获取一个值 scale=之前刻度
@@ -385,7 +382,8 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol @@ -385,7 +382,8 @@ func NextActivityAutoExchange(gameId string, player *Player, config *confcardhol
385 382
386 // 开始处理抽卡 383 // 开始处理抽卡
387 openMode := 2 384 openMode := 2
388 - sequenceId, cohort := GetUserSequenceIdAndCohort(player.Uid) 385 + sequenceId := player.Details.SequenceId
  386 + cohort := GetCohort(player.Uid)
389 allNewCards := make([]int, 0) 387 allNewCards := make([]int, 0)
390 if player.Details.AutoExchangeHolder != 0 { 388 if player.Details.AutoExchangeHolder != 0 {
391 confCardholder, _ := config.CardholderConfig[player.Details.AutoExchangeHolder] 389 confCardholder, _ := config.CardholderConfig[player.Details.AutoExchangeHolder]
service/cardholder/player.go
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "apigame/service-common/svmysql" 5 "apigame/service-common/svmysql"
6 "apigame/util/util-lx/lxalilog" 6 "apigame/util/util-lx/lxalilog"
7 "apigame/util/util-lx/lxtime" 7 "apigame/util/util-lx/lxtime"
  8 + "apigame/util/zslice"
8 ) 9 )
9 10
10 // SavePlayer 存储数据 11 // SavePlayer 存储数据
@@ -52,7 +53,12 @@ func LoadPlayer(gameId string, playerUid int64, config *confcardholder.ActivityC @@ -52,7 +53,12 @@ func LoadPlayer(gameId string, playerUid int64, config *confcardholder.ActivityC
52 player.Details.LastStarCount = starCount 53 player.Details.LastStarCount = starCount
53 NextActivityAutoExchange(gameId, player, config) 54 NextActivityAutoExchange(gameId, player, config)
54 55
  56 + player.Details.SequenceId = zslice.RandomOne(config.ListSequenceId)
  57 +
55 SavePlayer(gameId, player) 58 SavePlayer(gameId, player)
56 } 59 }
  60 + if player.Details.SequenceId == 0 {
  61 + player.Details.SequenceId = 1
  62 + }
57 return 63 return
58 } 64 }