jackpot.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package rezekislot
  2. import (
  3. coreservice "bet24.com/servers/coreservice/client"
  4. )
  5. const (
  6. JackpotLevelNone = iota // 不产生jackpot
  7. JackpotLevelMini
  8. JackpotLevelMinor
  9. JackpotLevelMajor
  10. JackpotLevelGrand
  11. )
  12. type JackpotManager struct {
  13. jackpotFanId []int //扇子id
  14. jackpotFanCount int
  15. grandJackpotPercent int
  16. inGrandJackpotPercent int
  17. isChipRoom bool
  18. }
  19. func newJackpotManager(jackpotFanId []int, count int, isChipRoom bool) *JackpotManager {
  20. ret := new(JackpotManager)
  21. ret.jackpotFanCount = count
  22. ret.jackpotFanId = jackpotFanId
  23. ret.isChipRoom = isChipRoom
  24. ret.loadData()
  25. return ret
  26. }
  27. func (jm *JackpotManager) loadData() { // 从redis读取jackpot数量
  28. jm.inGrandJackpotPercent = 1
  29. jm.grandJackpotPercent = 100 //设置返还为百分之百
  30. }
  31. func (jm *JackpotManager) getAmount() int {
  32. return coreservice.GetJackpotAmount(GAMEID, jm.isChipRoom)
  33. }
  34. //每次下注抽取投注额的十万分之一
  35. func (jm *JackpotManager) addJackpot(slots []int, betAmount int, isFree bool, userId int) bool {
  36. //免费的情况下不扣
  37. if isFree {
  38. return false
  39. }
  40. if betAmount < 100000 {
  41. return false
  42. }
  43. jm.modifyAmount(betAmount/100000, userId)
  44. return true
  45. }
  46. //修改奖池金额
  47. func (jm *JackpotManager) modifyAmount(amount int, userId int) {
  48. coreservice.ModifyJackpot(amount, GAMEID, userId, "rezekislot bet", jm.isChipRoom)
  49. }
  50. func (jm *JackpotManager) checkJackpot(fan FanResult, betAmount int, betLevel int, userId int) (level int, winAmount int) {
  51. if fan.FanID < 0 {
  52. return
  53. }
  54. if !fan.IsGrand {
  55. return
  56. }
  57. count := 0
  58. for _, v := range jm.jackpotFanId {
  59. if v == fan.FanID {
  60. count++
  61. }
  62. }
  63. if count < jm.jackpotFanCount {
  64. return
  65. }
  66. if count == 1 {
  67. //无论下注等级是多少 只要中就全部返还
  68. level = JackpotLevelGrand
  69. grandAmount := jm.getAmount() / 100 * jm.grandJackpotPercent //抽取的比例中大奖时为百分百返还
  70. jm.modifyAmount(-grandAmount, userId)
  71. winAmount = grandAmount
  72. }
  73. return
  74. }