profit.go 991 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package data
  2. import (
  3. "context"
  4. "errors"
  5. "go-common/library/log"
  6. "net/url"
  7. "strconv"
  8. )
  9. const UpProfitStateSigned = 3 //激励计划签约状态
  10. // UpProfitState 获取UP主激励计划状态
  11. // 返回State:
  12. // 1: 未申请; 2: 待审核; 3: 已签约; 4.已驳回; 5.主动退出; 6:被动退出; 7:封禁
  13. func (d *Dao) UpProfitState(c context.Context, mid int64) (state int8, err error) {
  14. params := url.Values{}
  15. params.Set("mid", strconv.FormatInt(mid, 10))
  16. params.Set("type", "0")
  17. var res struct {
  18. Code int `json:"code"`
  19. Msg string `json:"message"`
  20. Data *struct {
  21. Mid int64 `json:"mid"`
  22. State int8 `json:"state"`
  23. } `json:"data"`
  24. }
  25. if err = d.client.Get(c, d.upProfitState, "", params, &res); err != nil {
  26. log.Error("UpProfitState(%d) error(%v)", mid, err)
  27. return
  28. }
  29. if res.Data == nil {
  30. err = errors.New("UP主激励计划状态获取失败")
  31. log.Error("UpProfitState(%d) nil response(%v)", res)
  32. return
  33. }
  34. state = res.Data.State
  35. return
  36. }