-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.go
70 lines (60 loc) · 1.86 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package pinduoduo
import (
"github.com/dtapps/go-library/utils/godecimal"
"github.com/dtapps/go-library/utils/golog"
"github.com/dtapps/go-library/utils/gorequest"
"strings"
)
// ClientConfig 实例配置
type ClientConfig struct {
ClientId string // POP分配给应用的client_id
ClientSecret string // POP分配给应用的client_secret
MediaId string // 媒体ID
Pid string // 推广位
}
// Client 实例
type Client struct {
requestClient *gorequest.App // 请求服务
requestClientStatus bool // 请求服务状态
config struct {
clientId string // POP分配给应用的client_id
clientSecret string // POP分配给应用的client_secret
mediaId string // 媒体ID
pid string // 推广位
}
slog struct {
status bool // 状态
client *golog.ApiSLog // 日志服务
}
}
// NewClient 创建实例化
func NewClient(config *ClientConfig) (*Client, error) {
c := &Client{}
c.config.clientId = config.ClientId
c.config.clientSecret = config.ClientSecret
c.config.mediaId = config.MediaId
c.config.pid = config.Pid
return c, nil
}
type ErrResp struct {
ErrorResponse struct {
ErrorMsg string `json:"error_msg"`
SubMsg string `json:"sub_msg"`
SubCode interface{} `json:"sub_code"`
ErrorCode int `json:"error_code"`
RequestId string `json:"request_id"`
} `json:"error_response"`
}
type CustomParametersResult struct {
Sid string `json:"sid"`
Uid string `json:"uid"`
}
func (c *Client) SalesTipParseInt64(salesTip string) int64 {
if strings.Contains(salesTip, "万+") {
return godecimal.NewString(strings.Replace(salesTip, "万+", "0000", -1)).Int64()
} else if strings.Contains(salesTip, "万") {
return godecimal.NewString(strings.Replace(salesTip, "万", "000", -1)).Int64()
} else {
return godecimal.NewString(salesTip).Int64()
}
}