monthlycard.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package monthlycard
  2. import (
  3. "bet24.com/log"
  4. item "bet24.com/servers/micros/item_inventory/proto"
  5. )
  6. const (
  7. Month_ProductId = "200007" //月卡
  8. Week_ProductId = "100002" //周卡
  9. )
  10. const (
  11. Month_GIFT_STATUS_NOT = 0 //0=不能领取
  12. Month_GIFT_STATUS_HAVE = 1 //1=可领取
  13. Month_GIFT_STATUS_RECEIVED = 2 //2=已领取
  14. )
  15. type MonthlyCardInfo struct {
  16. MonthGift int //月卡领取时间戳
  17. MonthExpire int //月卡过期时间戳
  18. MonthGiftStatus int //月卡领取标识(0=不能领取 1=可领取 2=已领取)
  19. MonthDays int //月卡剩余天数
  20. WeekGift int //周卡领取时间戳
  21. WeekExpire int //周卡过期时间戳
  22. }
  23. var mgr *monthlycardmgr
  24. func Run() {
  25. mgr = NewMonthlyCardMgr()
  26. log.Debug("monthcard running")
  27. }
  28. // 获取月卡系统信息
  29. func GetSysInfo() []*sysInfo {
  30. return mgr.getSysList()
  31. }
  32. // 获取用户月卡信息
  33. func GetUserInfo(userId int) *usermonthlycard {
  34. return mgr.getUserInfo(userId)
  35. }
  36. // 购买月卡
  37. func BuyMonth(userId int) (int, []item.ItemPack) {
  38. return mgr.buyMonth(userId)
  39. }
  40. // 领取月卡
  41. func GiftMonth(userId int) (int, []item.ItemPack) {
  42. return mgr.giftMonth(userId)
  43. }
  44. func CheckMonthTip(userId int) bool {
  45. return mgr.checkMonthTip(userId)
  46. }
  47. // 购买周卡
  48. func BuyWeek(userId int) (int, []item.ItemPack) {
  49. return mgr.buyWeek(userId)
  50. }
  51. // 领取周卡
  52. func GiftWeek(userId int) (int, []item.ItemPack) {
  53. return mgr.giftWeek(userId)
  54. }
  55. func AddUser(userId int) {
  56. mgr.onUserEnter(userId)
  57. }
  58. func RemoveUser(userId int) {
  59. mgr.onUserExit(userId)
  60. }