associate.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/vip/model"
  6. v1 "go-common/app/service/main/vip/api"
  7. vipmol "go-common/app/service/main/vip/model"
  8. "go-common/library/log"
  9. )
  10. func (s *Service) eleEompensateJob() {
  11. log.Info("ele grant eompensate job start..................")
  12. if succeed := s.dao.AddTransferLock(context.TODO(), "lock:elegrant"); succeed {
  13. if err := s.EleGrantCompensate(context.TODO()); err != nil {
  14. log.Error("error(%+v)", err)
  15. }
  16. }
  17. log.Info("ele grant eompensate job end..................")
  18. }
  19. // EleGrantCompensate ele frant compensate.
  20. func (s *Service) EleGrantCompensate(c context.Context) (err error) {
  21. var res []*model.VipOrderActivityRecord
  22. if res, err = s.dao.NotGrantActOrders(c, vipmol.PanelTypeEle, s.c.Property.NotGrantLimit); err != nil {
  23. return
  24. }
  25. for _, v := range res {
  26. if _, err = s.vipgRPC.EleVipGrant(c, &v1.EleVipGrantReq{OrderNo: v.OrderNo}); err != nil {
  27. log.Error("EleVipGrant a(%s) err(%+v)", v.OrderNo, err)
  28. continue
  29. }
  30. time.Sleep(time.Second)
  31. }
  32. return
  33. }