54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package _72
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"hk/pkg/util/httpUtil"
|
|
)
|
|
|
|
const ()
|
|
|
|
type PickNumberReq struct {
|
|
City string `json:"city"` // 市
|
|
ProductID string `json:"prodID"` // Y 商品ID
|
|
Province string `json:"province"` // 省
|
|
SearchCategory string `json:"searchCategory"` // 查询分类 默认3
|
|
SearchValue string `json:"searchValue"` // 查询关键字2-4位
|
|
BaseParams
|
|
}
|
|
|
|
type PickNumberResp struct {
|
|
Type string `json:"type"` // 号码类型 普通
|
|
Number string `json:"number"` // 号码
|
|
NumberId string `json:"numberId"` // 号码ID
|
|
NumberPoolId string `json:"numberPoolId"` // 号码池ID
|
|
|
|
}
|
|
|
|
// GetPickNumber 商品选号
|
|
func GetPickNumber(params PickNumberReq) (ApiResponse[[]PickNumberResp], error) {
|
|
|
|
formParams := map[string]string{
|
|
"city": params.City,
|
|
"prodID": params.ProductID,
|
|
"province": params.Province,
|
|
"searchCategory": "3",
|
|
"searchValue": params.SearchValue,
|
|
"Timestamp": params.Timestamp,
|
|
"user_id": params.UserID,
|
|
"user_sign": params.UserSign,
|
|
}
|
|
|
|
body, err := httpUtil.NewRequest().SendFormData(pickNumberUrl, nil, formParams)
|
|
|
|
// 解析 JSON 响应
|
|
var apiResponse ApiResponse[[]PickNumberResp]
|
|
err = json.Unmarshal([]byte(body), &apiResponse)
|
|
if err != nil {
|
|
return ApiResponse[[]PickNumberResp]{}, fmt.Errorf("解析响应体时发生错误: %v", err)
|
|
}
|
|
|
|
// 返回解析后的响应
|
|
return apiResponse, nil
|
|
}
|