medal.go 955 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package service
  2. import (
  3. "context"
  4. "runtime/debug"
  5. "go-common/app/job/main/usersuit/model"
  6. "go-common/library/log"
  7. )
  8. var (
  9. _upTaskMedal = map[int64]int64{1: 4, 2: 3, 3: 1, 4: 7, 5: 6, 6: 5, 7: 10, 8: 9, 9: 8}
  10. )
  11. func (s *Service) cronUpNameplate() {
  12. defer func() {
  13. if x := recover(); x != nil {
  14. log.Error("lrucleanproc panic %v : %s", x, debug.Stack())
  15. go s.cronUpNameplate()
  16. }
  17. }()
  18. var (
  19. err error
  20. res *model.UpInfo
  21. ctx = context.TODO()
  22. )
  23. if res, err = s.medalDao.UpInfoData(ctx); err != nil {
  24. log.Error("s.medalDao.UpInfoData err(%+v)", err)
  25. return
  26. }
  27. for _, item := range res.Data {
  28. var (
  29. nid int64
  30. ok bool
  31. )
  32. if nid, ok = _upTaskMedal[item.ID]; !ok {
  33. continue
  34. }
  35. for _, mid := range item.Mids {
  36. log.Info("s.medalDao.AddMedalOwner(%d, %d)", mid, nid)
  37. if err = s.medalDao.Grant(ctx, mid, nid); err != nil {
  38. log.Error("s.medalDao.AddMedalOwner(%d, %d) err(%+v)", mid, nid, err)
  39. }
  40. }
  41. }
  42. }