credit_log.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package upcrmservice
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/admin/main/up/model/upcrmmodel"
  6. "go-common/library/log"
  7. )
  8. func formatLog(log upcrmmodel.SimpleCreditLogWithContent) (result upcrmmodel.CreditLogInfo) {
  9. var timeStr = log.CTime.Time().Format(upcrmmodel.TimeFmtDate)
  10. switch log.BusinessType {
  11. case upcrmmodel.BusinessTypeArticleAudit:
  12. result.Log = fmt.Sprintf("[%s][aid=%d]%s", timeStr, log.Oid, log.Content)
  13. default:
  14. result.Log = fmt.Sprintf("[%s]%s", timeStr, log.Content)
  15. }
  16. result.Time = log.CTime
  17. return
  18. }
  19. //CreditLogQueryUp query credit log
  20. func (s *Service) CreditLogQueryUp(context context.Context, arg *upcrmmodel.CreditLogQueryArgs) (result upcrmmodel.CreditLogUpResult, err error) {
  21. if arg.Limit <= 0 {
  22. arg.Limit = 20
  23. } else if arg.Limit >= 100 {
  24. arg.Limit = 100
  25. }
  26. logs, e := s.crmdb.GetCreditLog(arg.Mid, arg.Limit)
  27. err = e
  28. if err != nil {
  29. log.Error("credit log get fail, err=%+v", err)
  30. return
  31. }
  32. for _, v := range logs {
  33. //if v == nil {
  34. // continue
  35. //}
  36. result.Logs = append(result.Logs, formatLog(v))
  37. }
  38. log.Info("credit log get ok, mid=%d, length=%d", arg.Mid, len(logs))
  39. return
  40. }