@@ -18,9 +18,19 @@ import (
1818 "qoder2api/logger"
1919)
2020
21- // checkinHost 是签到 API 域名(抓包确认为 openapi.qoder.com.cn)
21+ // checkinHost 是签到 API 的兜底域名(国内)。国际走 openapi.qoder.sh,
22+ // 由 checkinHostFor 按账号区域选择——此前写死国内域名导致国际号签到
23+ // 返回 401 TOKEN_EXPIRE(拿国际 token 打国内端点)。
2224const checkinHost = "openapi.qoder.com.cn"
2325
26+ // checkinHostFor 返回该区域的签到/OpenAPI 主机。
27+ func checkinHostFor (region account.Region ) string {
28+ if h := account .GetEndpoints (region ).OpenAPIHost ; h != "" {
29+ return h
30+ }
31+ return checkinHost
32+ }
33+
2434// CheckinResult 单个账号的签到结果
2535type CheckinResult struct {
2636 Account string `json:"account"`
@@ -70,8 +80,11 @@ func checkinHeaders(deviceToken string) map[string]string {
7080
7181// doCheckinRequest 发送签到相关请求,返回 (httpStatus, parsedJSON, rawBody)
7282// reqBody 为 nil 时发送空 body(抓包确认 campaigns/claim 即为空 body)
73- func doCheckinRequest (method , path , deviceToken string , reqBody interface {}) (int , interface {}, string ) {
74- url := "https://" + checkinHost + path
83+ func doCheckinRequest (method , path , deviceToken string , reqBody interface {}, host string ) (int , interface {}, string ) {
84+ if host == "" {
85+ host = checkinHost
86+ }
87+ url := "https://" + host + path
7588
7689 var body io.Reader
7790 var bodyBytes []byte
@@ -87,7 +100,7 @@ func doCheckinRequest(method, path, deviceToken string, reqBody interface{}) (in
87100 req .Header .Set (k , v )
88101 }
89102 if method == "POST" {
90- req .Header .Set ("origin" , "https://" + checkinHost )
103+ req .Header .Set ("origin" , "https://" + host )
91104 if reqBody == nil {
92105 req .ContentLength = 0 // 抓包确认 claim 无 body
93106 }
@@ -307,10 +320,11 @@ func checkinAccount(acct *account.Account) CheckinResult {
307320 // ========== 权威领取:campaigns 流程(真实发放积分的系统) ==========
308321 // 注意:不走 daily-check-in/claim —— 该 legacy 端点已 DISABLED,
309322 // 却对未领取日也恒返回 409,会误判"已领取"导致跳过真实领取(实测 2026-09-21 不发积分)
310- r := campaignsCheckin (deviceToken , & res )
323+ host := checkinHostFor (acct .Region )
324+ r := campaignsCheckin (deviceToken , & res , host )
311325
312326 // 只读补充 legacy 统计(DISABLED 时恒 0,不影响结果;上游恢复后可提供 streak)
313- readDailyCheckinStats (deviceToken , & r )
327+ readDailyCheckinStats (deviceToken , & r , host )
314328
315329 return finalizeCheckin (acct .ID , r )
316330}
@@ -341,8 +355,8 @@ func finalizeCheckin(accountID string, r CheckinResult) CheckinResult {
341355// 背景:该端点的 legacy 活动已 DISABLED,claim 会恒返回 409 造成误判,
342356// 且不发放任何积分(2026-09-21 实测)。真实领取只走 campaigns 流程。
343357// 上游恢复后若返回非 0 统计,可作为 streak 的补充数据源。
344- func readDailyCheckinStats (deviceToken string , res * CheckinResult ) {
345- status , body , raw := doCheckinRequest ("GET" , "/sash/api/v1/me/daily-check-in/status" , deviceToken , nil )
358+ func readDailyCheckinStats (deviceToken string , res * CheckinResult , host string ) {
359+ status , body , raw := doCheckinRequest ("GET" , "/sash/api/v1/me/daily-check-in/status" , deviceToken , nil , host )
346360 if status != 200 {
347361 if status != 404 && status != 401 {
348362 logger .Info ("[Checkin] daily-check-in/status HTTP %d: %s" , status , truncate (raw , 150 ))
@@ -408,9 +422,9 @@ func windowHint(res *CheckinResult, fallback string) string {
408422}
409423
410424// campaignsCheckin 兜底:走桌面端抓包还原的 campaigns 流程
411- func campaignsCheckin (deviceToken string , res * CheckinResult ) CheckinResult {
425+ func campaignsCheckin (deviceToken string , res * CheckinResult , host string ) CheckinResult {
412426 // Step 1: 查询活动列表
413- status , body , raw := doCheckinRequest ("GET" , "/sash/api/v1/me/campaigns" , deviceToken , nil )
427+ status , body , raw := doCheckinRequest ("GET" , "/sash/api/v1/me/campaigns" , deviceToken , nil , host )
414428 if status != 200 {
415429 res .Message = fmt .Sprintf ("查询活动失败 HTTP %d: %s" , status , truncate (raw , 300 ))
416430 return * res
@@ -473,7 +487,7 @@ func campaignsCheckin(deviceToken string, res *CheckinResult) CheckinResult {
473487
474488 // Step 2: 领取(空 body,抓包确认)
475489 claimPath := fmt .Sprintf ("/sash/api/v1/me/campaigns/%s/claim" , target .CampaignID )
476- status , body , raw = doCheckinRequest ("POST" , claimPath , deviceToken , nil )
490+ status , body , raw = doCheckinRequest ("POST" , claimPath , deviceToken , nil , host )
477491 if status != 200 {
478492 res .Message = fmt .Sprintf ("领取失败 HTTP %d: %s" , status , truncate (raw , 300 ))
479493 return * res
0 commit comments