Commit 8b973f606f9a9264de272989c59a3c2e8dc996c1
1 parent
669a23b4
Exists in
master
and in
1 other branch
fix🐛:修复星星商店兑换bug
Showing
2 changed files
with
9 additions
and
2 deletions
Show diff stats
service/cardholder/handle.go
| @@ -181,6 +181,7 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model | @@ -181,6 +181,7 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model | ||
| 181 | 181 | ||
| 182 | // 按照规则扣除星星 | 182 | // 按照规则扣除星星 |
| 183 | enough, cardList := GetStarCardList(player, config, confStarShop.NeedStarNumber) | 183 | enough, cardList := GetStarCardList(player, config, confStarShop.NeedStarNumber) |
| 184 | + | ||
| 184 | if !enough { | 185 | if !enough { |
| 185 | code = code_msg.RECODE_MERGE_CARDHOLDER_STAR_NOTENOUGH_ERROR | 186 | code = code_msg.RECODE_MERGE_CARDHOLDER_STAR_NOTENOUGH_ERROR |
| 186 | return | 187 | return |
service/cardholder/logic.go
| @@ -316,10 +316,13 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | @@ -316,10 +316,13 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | ||
| 316 | if confCard.IsGold == 1 { | 316 | if confCard.IsGold == 1 { |
| 317 | continue | 317 | continue |
| 318 | } | 318 | } |
| 319 | + if confCard.Star != i { | ||
| 320 | + continue | ||
| 321 | + } | ||
| 319 | star := confCard.Star | 322 | star := confCard.Star |
| 320 | need := needStar - starAmount | 323 | need := needStar - starAmount |
| 321 | needCardCount := int(math.Ceil(float64(need) / float64(star))) | 324 | needCardCount := int(math.Ceil(float64(need) / float64(star))) |
| 322 | - if cardCount-1 < needCardCount { | 325 | + if needCardCount > cardCount-1 { |
| 323 | needCardCount = cardCount - 1 | 326 | needCardCount = cardCount - 1 |
| 324 | } | 327 | } |
| 325 | cardList[cardId] = needCardCount | 328 | cardList[cardId] = needCardCount |
| @@ -343,10 +346,13 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | @@ -343,10 +346,13 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | ||
| 343 | if confCard.IsGold != 1 { | 346 | if confCard.IsGold != 1 { |
| 344 | continue | 347 | continue |
| 345 | } | 348 | } |
| 349 | + if confCard.Star != i { | ||
| 350 | + continue | ||
| 351 | + } | ||
| 346 | star := confCard.Star + 1 | 352 | star := confCard.Star + 1 |
| 347 | need := needStar - starAmount | 353 | need := needStar - starAmount |
| 348 | needCardCount := int(math.Ceil(float64(need) / float64(star))) | 354 | needCardCount := int(math.Ceil(float64(need) / float64(star))) |
| 349 | - if cardCount-1 < needCardCount { | 355 | + if needCardCount > cardCount-1 { |
| 350 | needCardCount = cardCount - 1 | 356 | needCardCount = cardCount - 1 |
| 351 | } | 357 | } |
| 352 | cardList[cardId] = needCardCount | 358 | cardList[cardId] = needCardCount |