reviewmgr.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package review
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/common"
  5. "bet24.com/servers/coreservice/serviceconfig"
  6. cash "bet24.com/servers/micros/money/proto"
  7. )
  8. type reviewmgr struct {
  9. }
  10. func newReviewMgr() *reviewmgr {
  11. log.Debug("review manager running")
  12. return &reviewmgr{}
  13. }
  14. // 获取评论信息
  15. func (this *reviewmgr) info(userId int, appName string) int {
  16. if !this.appExist(appName) {
  17. log.Error("reviewmgr.info userId=%d appName=%s is not exist", userId, appName)
  18. return 0
  19. }
  20. return info(userId, appName)
  21. }
  22. // 领取评论
  23. func (this *reviewmgr) gift(userId int, appName, ipAddress string) (bool, int) {
  24. if !this.appExist(appName) {
  25. log.Error("reviewmgr.gift userId=%d appName=%s ipAddress=%s is not exist", userId, appName, ipAddress)
  26. return false, 0
  27. }
  28. succ := gift(userId, appName)
  29. if !succ {
  30. return false, 0
  31. }
  32. //加金币
  33. ret := cash.GiveMoney(userId, serviceconfig.Server.ReviewAmount, common.LOGTYPE_SEND_REVIEW, "评论模块", "评论赠送", ipAddress)
  34. if ret != 1 {
  35. return false, 0
  36. }
  37. return true, serviceconfig.Server.ReviewAmount
  38. }
  39. // 判断app应用是否存在
  40. func (this *reviewmgr) appExist(appName string) bool {
  41. for _, v := range appSet {
  42. if v == appName {
  43. return true
  44. }
  45. }
  46. return false
  47. }