合并远程main并保留和平小店功能
This commit is contained in:
+19
-17
@@ -1118,12 +1118,7 @@ func (c *DouyuClient) BatchExchangeLimit(cookie, commodityID string, csrf *strin
|
||||
if csrf != nil {
|
||||
currentCSRF = *csrf
|
||||
}
|
||||
var result struct {
|
||||
types.APIResponse
|
||||
Data struct {
|
||||
Limit string `json:"limit"`
|
||||
} `json:"data"`
|
||||
}
|
||||
var result types.APIResponse
|
||||
if err := c.postMultipart(c.Activity.BatchLimitURL, cookie, csrf, "批量限制", map[string]string{
|
||||
"manualID": c.Activity.ManualID,
|
||||
"commodityID": commodityID,
|
||||
@@ -1135,9 +1130,15 @@ func (c *DouyuClient) BatchExchangeLimit(cookie, commodityID string, csrf *strin
|
||||
if result.Error != 0 {
|
||||
return 0, fmt.Errorf("批量限制接口失败: %s", result.Msg)
|
||||
}
|
||||
limit, err := strconv.Atoi(result.Data.Limit)
|
||||
var data struct {
|
||||
Limit string `json:"limit"`
|
||||
}
|
||||
if err := json.Unmarshal(result.Data, &data); err != nil {
|
||||
return 0, fmt.Errorf("批量限制数据解析失败: %w", err)
|
||||
}
|
||||
limit, err := strconv.Atoi(data.Limit)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("批量限制值无效: %q", result.Data.Limit)
|
||||
return 0, fmt.Errorf("批量限制值无效: %q", data.Limit)
|
||||
}
|
||||
return limit, nil
|
||||
}
|
||||
@@ -1175,14 +1176,7 @@ func (c *DouyuClient) Exchange(cookie, commodityID string, csrf *string) (string
|
||||
if c.Activity.IsXiaodian {
|
||||
return c.xiaodianExchange(cookie, types.Product{CommodityID: commodityID})
|
||||
}
|
||||
var result struct {
|
||||
types.APIResponse
|
||||
Data struct {
|
||||
ExchangeID int `json:"exchangeId"`
|
||||
ExchangeNum string `json:"exchangeNum"`
|
||||
CommodityTyp int `json:"commodityType"`
|
||||
} `json:"data"`
|
||||
}
|
||||
var result types.APIResponse
|
||||
if c.Activity.UseCTN {
|
||||
// 电竞手册:用 ctn(acf_ccn) 鉴权,multipart 表单(与浏览器抓包一致)
|
||||
ctn := ""
|
||||
@@ -1234,7 +1228,15 @@ func (c *DouyuClient) Exchange(cookie, commodityID string, csrf *string) (string
|
||||
}
|
||||
return "", fmt.Errorf("兑换失败: %s", result.Msg)
|
||||
}
|
||||
return fmt.Sprintf("exchangeId=%d,num=%s", result.Data.ExchangeID, result.Data.ExchangeNum), nil
|
||||
var data struct {
|
||||
ExchangeID int `json:"exchangeId"`
|
||||
ExchangeNum string `json:"exchangeNum"`
|
||||
CommodityTyp int `json:"commodityType"`
|
||||
}
|
||||
if err := json.Unmarshal(result.Data, &data); err != nil {
|
||||
return "", fmt.Errorf("兑换数据解析失败: %w", err)
|
||||
}
|
||||
return fmt.Sprintf("exchangeId=%d,num=%s", data.ExchangeID, data.ExchangeNum), nil
|
||||
}
|
||||
|
||||
// ExchangeProduct 正式兑换一个商品。和平小店需要商品支付类型/价格,因此应优先走这个入口。
|
||||
|
||||
Reference in New Issue
Block a user