kfc.go 865 B

123456789101112131415161718192021222324252627282930313233343536
  1. package kfc
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/library/ecode"
  7. "go-common/library/net/metadata"
  8. "github.com/pkg/errors"
  9. )
  10. const (
  11. _kfcDelURI = "/x/internal/activity/kfc/deliver"
  12. )
  13. // KfcDelver .
  14. func (d *Dao) KfcDelver(c context.Context, id, mid int64) (err error) {
  15. var httpRes struct {
  16. Code int `json:"code"`
  17. Data map[string]int64 `json:"data"`
  18. Message string `json:"message"`
  19. }
  20. params := url.Values{}
  21. params.Set("id", strconv.FormatInt(id, 10))
  22. params.Set("mid", strconv.FormatInt(mid, 10))
  23. if err = d.httpClient.Post(c, d.kfcDelURL, metadata.String(c, metadata.RemoteIP), params, &httpRes); err != nil {
  24. err = errors.Wrap(err, "KfcDelver http")
  25. return
  26. }
  27. if httpRes.Code != ecode.OK.Code() {
  28. err = errors.Wrapf(ecode.Int(httpRes.Code), "KfcDelver msg(%s)", httpRes.Message)
  29. }
  30. return
  31. }