antispam.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package realname
  2. import (
  3. "context"
  4. "go-common/app/interface/main/account/conf"
  5. dao "go-common/app/interface/main/account/dao/realname"
  6. "go-common/library/log"
  7. )
  8. func (s *Service) alipayAntispamCheck(c context.Context, mid int64) bool {
  9. var (
  10. value *dao.AlipayAntispamValue
  11. err error
  12. )
  13. if value, err = s.realnameDao.AlipayAntispam(c, mid); err != nil {
  14. log.Error("%+v", err)
  15. return true
  16. }
  17. if value == nil {
  18. return true
  19. }
  20. if value.Count() > conf.Conf.Realname.AlipayAntispamThreshold && !value.Pass() {
  21. return false
  22. }
  23. return true
  24. }
  25. // alipayAntispamIncrease 增加用户申请计数
  26. func (s *Service) alipayAntispamIncrease(c context.Context, mid int64) (err error) {
  27. var (
  28. value *dao.AlipayAntispamValue
  29. )
  30. if value, err = s.realnameDao.AlipayAntispam(c, mid); err != nil {
  31. return
  32. }
  33. if value == nil {
  34. value = new(dao.AlipayAntispamValue)
  35. }
  36. value.IncreaseCount()
  37. if err = s.realnameDao.SetAlipayAntispam(c, mid, value); err != nil {
  38. return
  39. }
  40. return
  41. }
  42. // setAlipayAntispamPassFlag 更新用户通过标识位
  43. func (s *Service) setAlipayAntispamPassFlag(c context.Context, mid int64, flag bool) (err error) {
  44. var (
  45. value *dao.AlipayAntispamValue
  46. )
  47. if value, err = s.realnameDao.AlipayAntispam(c, mid); err != nil {
  48. return
  49. }
  50. if value == nil {
  51. value = new(dao.AlipayAntispamValue)
  52. }
  53. value.SetPass(flag)
  54. if err = s.realnameDao.SetAlipayAntispam(c, mid, value); err != nil {
  55. return
  56. }
  57. return
  58. }