72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package mkt
|
||
|
||
import (
|
||
"crypto/md5"
|
||
"encoding/hex"
|
||
"fmt"
|
||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||
"time"
|
||
)
|
||
|
||
const appKey = "fc1f841#@de!!08"
|
||
|
||
type SubjectListRequest struct {
|
||
*requests.RpcRequest
|
||
}
|
||
|
||
type SubjectListResponse struct {
|
||
*responses.BaseResponse
|
||
Status bool `json:"status"`
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Data struct {
|
||
List map[int]Data `json:"list"`
|
||
} `json:"data"`
|
||
}
|
||
|
||
type Data struct {
|
||
Id int `json:"id"` // 主体ID
|
||
Abbr string `json:"abbr"` // 公司简称
|
||
AbbrSign string `json:"abbr_sign"` // 公司英文简写
|
||
Name string `json:"name"` // 公司名全称
|
||
State int `json:"state"` // 状态:0 使用中,1 已停用
|
||
System string `json:"system"` // 结算体系
|
||
Type int `json:"type"` // 主体类型:0 自有,1 其他
|
||
Record string `json:"record"` // 备案/许可证号
|
||
Uscc string `json:"uscc"` // 统一社会信用代码
|
||
Drawer string `json:"drawer"` // 开票人
|
||
}
|
||
|
||
// CreateSubjectListRequest 公司列表请求
|
||
func CreateSubjectListRequest(state int) (req *SubjectListRequest) {
|
||
ts := time.Now().Unix()
|
||
hash := md5.New()
|
||
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
||
hashBytes := hash.Sum(nil)
|
||
|
||
token := hex.EncodeToString(hashBytes)
|
||
|
||
req = &SubjectListRequest{
|
||
RpcRequest: &requests.RpcRequest{},
|
||
}
|
||
|
||
req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/subject/list"))
|
||
|
||
req.FormParams = map[string]string{
|
||
"token": token,
|
||
"ts": fmt.Sprintf("%v", ts),
|
||
"state": fmt.Sprintf("%v", state),
|
||
}
|
||
req.Method = requests.POST
|
||
return
|
||
}
|
||
|
||
// CreateSubjectListResponse 公司列表请求响应
|
||
func CreateSubjectListResponse() (response *SubjectListResponse) {
|
||
response = &SubjectListResponse{
|
||
BaseResponse: &responses.BaseResponse{},
|
||
}
|
||
return
|
||
}
|