exp.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/job/main/coin/dao"
  5. coinmdl "go-common/app/service/main/coin/model"
  6. memmdl "go-common/app/service/main/member/api"
  7. "go-common/library/log"
  8. )
  9. func (s *Service) addExp(c context.Context, mid int64, count float64, reason, ip string) (err error) {
  10. argExp := &memmdl.AddExpReq{
  11. Mid: mid,
  12. Count: count,
  13. Operate: "coin",
  14. Reason: reason,
  15. Ip: ip,
  16. }
  17. if count <= 0 {
  18. log.Errorv(c, log.KV("log", "add exp count < 0"), log.KV("mid", mid), log.KV("err", err), log.KV("reason", reason), log.KV("count", count))
  19. dao.PromError("exp:addExp0")
  20. return
  21. }
  22. if _, err = s.memRPC.UpdateExp(c, argExp); err != nil {
  23. log.Errorv(c, log.KV("log", "s.coinDao.IncrExp()"), log.KV("mid", mid), log.KV("err", err), log.KV("reason", reason), log.KV("count", count))
  24. dao.PromError("exp:addExp")
  25. return
  26. }
  27. return
  28. }
  29. func (s *Service) addCoinExp(c context.Context, mid, tp, number int64, ip string) (err error) {
  30. arg := &coinmdl.ArgAddUserCoinExp{Mid: mid, Business: tp, Number: number, RealIP: ip}
  31. if err = s.coinRPC.AddUserCoinExp(c, arg); err != nil {
  32. log.Errorv(c, log.KV("log", "AddUserCoinExp"), log.KV("err", err))
  33. dao.PromError("exp:addCoinExp")
  34. }
  35. return
  36. }