lottery.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package bws
  2. import (
  3. "context"
  4. bwsmdl "go-common/app/interface/main/activity/model/bws"
  5. accapi "go-common/app/service/main/account/api"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. // Lottery get lottery account.
  10. func (s *Service) Lottery(c context.Context, bid, loginMid, aid int64, day string) (data *bwsmdl.LotteryUser, err error) {
  11. var (
  12. mid int64
  13. accData *accapi.InfoReply
  14. )
  15. if _, ok := s.lotteryMids[loginMid]; !ok {
  16. err = ecode.ActivityNotLotteryAdmin
  17. return
  18. }
  19. if _, ok := s.lotteryAids[aid]; !ok {
  20. err = ecode.ActivityNotLotteryAchieve
  21. return
  22. }
  23. if _, err = s.Achievement(c, &bwsmdl.ParamID{Bid: bid, ID: aid}); err != nil {
  24. return
  25. }
  26. if mid, err = s.dao.CacheLotteryMid(c, aid, day); err != nil || mid == 0 {
  27. err = ecode.ActivityLotteryFail
  28. return
  29. }
  30. log.Warn("Lottery bid(%d) loginMid(%d) aid(%d) lotteryMid(%d)", bid, loginMid, aid, mid)
  31. data = &bwsmdl.LotteryUser{Mid: mid}
  32. if accData, err = s.accClient.Info3(c, &accapi.MidReq{Mid: mid}); err != nil {
  33. log.Error("Lottery s.accRPC.Info3(%d) error(%v)", mid, err)
  34. err = nil
  35. return
  36. }
  37. if accData != nil && accData.Info != nil {
  38. data = &bwsmdl.LotteryUser{Mid: mid, Name: accData.Info.Name, Face: accData.Info.Face}
  39. }
  40. return
  41. }
  42. // LotteryCheck .
  43. func (s *Service) LotteryCheck(c context.Context, mid, aid int64, day string) (data []int64, err error) {
  44. if !s.isAdmin(mid) {
  45. err = ecode.ActivityNotAdmin
  46. return
  47. }
  48. return s.dao.CacheLotteryMids(c, aid, day)
  49. }