From d3d73f818bdabe6a29592f42355b97ef79121ef0 Mon Sep 17 00:00:00 2001 From: ShenQiLun <97694732@qq.com> Date: Tue, 30 Jun 2026 11:42:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20kfz=5Ftoken=E8=A1=A8=E5=A2=9E=E5=8A=A0l?= =?UTF-8?q?ogin=5Fname=E5=AD=97=E6=AE=B5,=20=E6=8C=89=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=90=8D=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/database/db.go | 4 +- internal/handler/kfz_handler.go | 4 +- internal/handler/token_handler.go | 4 +- internal/repository/token_repository.go | 68 ++++--- log/2026-06-30.log | 232 ++++++++++++++++++++++++ 5 files changed, 272 insertions(+), 40 deletions(-) diff --git a/internal/database/db.go b/internal/database/db.go index 2b87f1b..fcc4bb3 100644 --- a/internal/database/db.go +++ b/internal/database/db.go @@ -70,6 +70,7 @@ func createTables() error { CREATE TABLE IF NOT EXISTS kfz_token ( id INTEGER PRIMARY KEY AUTOINCREMENT, + login_name TEXT NOT NULL DEFAULT '', username TEXT NOT NULL, password TEXT NOT NULL DEFAULT '', token TEXT NOT NULL, @@ -95,8 +96,9 @@ func createTables() error { return err } - // 兼容旧表:添加 password 列(已存在则忽略) + // 兼容旧表:添加 password / login_name 列(已存在则忽略) DB.Exec(`ALTER TABLE kfz_token ADD COLUMN password TEXT NOT NULL DEFAULT ''`) + DB.Exec(`ALTER TABLE kfz_token ADD COLUMN login_name TEXT NOT NULL DEFAULT ''`) return nil } diff --git a/internal/handler/kfz_handler.go b/internal/handler/kfz_handler.go index b6f4f39..48836a5 100644 --- a/internal/handler/kfz_handler.go +++ b/internal/handler/kfz_handler.go @@ -61,10 +61,10 @@ func (h *KfzHandler) KfzLogin(w http.ResponseWriter, r *http.Request) { userInfo.Token = token // 保存账号密码和token到数据库 - if err := h.tokenRepo.UpsertByUsername(username, password, token); err != nil { + if err := h.tokenRepo.UpsertByLoginName(username, userInfo.Nickname, password, token); err != nil { log.Printf("[KfzLogin] 保存Token记录失败: %v, 来源IP: %s", err, clientIP) } else { - log.Printf("[KfzLogin] 账号密码已保存到数据库: username=%s", username) + log.Printf("[KfzLogin] 账号密码已保存到数据库: login_name=%s, nickname=%s", username, userInfo.Nickname) } log.Printf("[KfzLogin] 登录成功: username=%s, userId=%d, nickname=%s, 来源IP: %s", username, userInfo.UserID, userInfo.Nickname, clientIP) diff --git a/internal/handler/token_handler.go b/internal/handler/token_handler.go index 08d4884..52bc3ff 100644 --- a/internal/handler/token_handler.go +++ b/internal/handler/token_handler.go @@ -71,7 +71,7 @@ func (h *TokenHandler) BatchAddTokens(w http.ResponseWriter, r *http.Request) { continue } - id, err := h.tokenRepo.Insert(input.Username, "", input.Token, true) + id, err := h.tokenRepo.Insert("", input.Username, "", input.Token, true) if err != nil { log.Printf("[Token/BatchAdd] 第%d条插入失败: username=%s, 错误=%v", i+1, input.Username, err) failed = append(failed, input) @@ -196,7 +196,7 @@ func (h *TokenHandler) UpdateToken(w http.ResponseWriter, r *http.Request) { } log.Printf("[Token/Update] 更新: id=%d, username=%s, is_enable=%v, 来源IP: %s", id, username, isEnable, clientIP) - err = h.tokenRepo.Update(id, username, "", token, isEnable) + err = h.tokenRepo.Update(id, "", username, "", token, isEnable) if err != nil { log.Printf("[Token/Update] 更新失败: id=%d, 错误=%v, 来源IP: %s", id, err, clientIP) w.Header().Set("Content-Type", "application/json") diff --git a/internal/repository/token_repository.go b/internal/repository/token_repository.go index 4833b9b..5847720 100644 --- a/internal/repository/token_repository.go +++ b/internal/repository/token_repository.go @@ -11,11 +11,12 @@ import ( // KfzToken Token记录 type KfzToken struct { - ID int64 - Username string - Password string - Token string - IsEnable bool + ID int64 + LoginName string + Username string + Password string + Token string + IsEnable bool } // TokenRepository Token仓储 @@ -32,7 +33,6 @@ func (r *TokenRepository) BatchInsert(tokens []string, username string) (int64, return 0, nil } - // 过滤空字符串 var validTokens []string for _, t := range tokens { t := strings.TrimSpace(t) @@ -44,7 +44,6 @@ func (r *TokenRepository) BatchInsert(tokens []string, username string) (int64, return 0, nil } - // 构建批量插入语句 valuePlaceholders := make([]string, len(validTokens)) args := make([]interface{}, 0, len(validTokens)*2) @@ -68,11 +67,11 @@ func (r *TokenRepository) BatchInsert(tokens []string, username string) (int64, return id, nil } -// Insert 插入单条Token记录(含密码) -func (r *TokenRepository) Insert(username, password, token string, isEnable bool) (int64, error) { - query := `INSERT INTO kfz_token (username, password, token, is_enable) VALUES (?, ?, ?, ?)` +// Insert 插入单条Token记录 +func (r *TokenRepository) Insert(loginName, username, password, token string, isEnable bool) (int64, error) { + query := `INSERT INTO kfz_token (login_name, username, password, token, is_enable) VALUES (?, ?, ?, ?, ?)` - result, err := database.DB.Exec(query, username, password, token, isEnable) + result, err := database.DB.Exec(query, loginName, username, password, token, isEnable) if err != nil { return 0, fmt.Errorf("插入失败: %w", err) } @@ -85,36 +84,35 @@ func (r *TokenRepository) Insert(username, password, token string, isEnable bool return id, nil } -// UpsertByUsername 根据用户名插入或更新记录(含密码和token) -func (r *TokenRepository) UpsertByUsername(username, password, token string) error { - // 先查是否存在 +// UpsertByLoginName 根据登录名插入或更新记录 +func (r *TokenRepository) UpsertByLoginName(loginName, username, password, token string) error { var count int - err := database.DB.QueryRow("SELECT COUNT(*) FROM kfz_token WHERE username = ?", username).Scan(&count) + err := database.DB.QueryRow("SELECT COUNT(*) FROM kfz_token WHERE login_name = ?", loginName).Scan(&count) if err != nil { return fmt.Errorf("查询记录失败: %w", err) } if count == 0 { _, err = database.DB.Exec( - `INSERT INTO kfz_token (username, password, token, is_enable) VALUES (?, ?, ?, 1)`, - username, password, token, + `INSERT INTO kfz_token (login_name, username, password, token, is_enable) VALUES (?, ?, ?, ?, 1)`, + loginName, username, password, token, ) } else { _, err = database.DB.Exec( - `UPDATE kfz_token SET password = ?, token = ?, is_enable = 1 WHERE username = ?`, - password, token, username, + `UPDATE kfz_token SET username = ?, password = ?, token = ?, is_enable = 1 WHERE login_name = ?`, + username, password, token, loginName, ) } if err != nil { return fmt.Errorf("保存Token记录失败: %w", err) } - log.Printf("[Repo/Token] 保存Token成功: username=%s", username) + log.Printf("[Repo/Token] 保存Token成功: login_name=%s, username=%s", loginName, username) return nil } // GetAll 查询所有记录 func (r *TokenRepository) GetAll() ([]*KfzToken, error) { - query := `SELECT id, username, token, is_enable FROM kfz_token ORDER BY id ASC` + query := `SELECT id, login_name, username, token, is_enable FROM kfz_token ORDER BY id ASC` rows, err := database.DB.Query(query) if err != nil { @@ -125,7 +123,7 @@ func (r *TokenRepository) GetAll() ([]*KfzToken, error) { var records []*KfzToken for rows.Next() { var rec KfzToken - err := rows.Scan(&rec.ID, &rec.Username, &rec.Token, &rec.IsEnable) + err := rows.Scan(&rec.ID, &rec.LoginName, &rec.Username, &rec.Token, &rec.IsEnable) if err != nil { return nil, fmt.Errorf("扫描失败: %w", err) } @@ -137,12 +135,12 @@ func (r *TokenRepository) GetAll() ([]*KfzToken, error) { // GetByID 根据ID查询单条记录 func (r *TokenRepository) GetByID(id int64) (*KfzToken, error) { - query := `SELECT id, username, password, token, is_enable FROM kfz_token WHERE id = ?` + query := `SELECT id, login_name, username, password, token, is_enable FROM kfz_token WHERE id = ?` row := database.DB.QueryRow(query, id) var rec KfzToken - err := row.Scan(&rec.ID, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) + err := row.Scan(&rec.ID, &rec.LoginName, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) if err != nil { if err == sql.ErrNoRows { return nil, fmt.Errorf("记录不存在") @@ -153,14 +151,14 @@ func (r *TokenRepository) GetByID(id int64) (*KfzToken, error) { return &rec, nil } -// GetByUsername 根据用户名查询记录(含密码) -func (r *TokenRepository) GetByUsername(username string) (*KfzToken, error) { - query := `SELECT id, username, password, token, is_enable FROM kfz_token WHERE username = ?` +// GetByLoginName 根据登录名查询记录 +func (r *TokenRepository) GetByLoginName(loginName string) (*KfzToken, error) { + query := `SELECT id, login_name, username, password, token, is_enable FROM kfz_token WHERE login_name = ?` - row := database.DB.QueryRow(query, username) + row := database.DB.QueryRow(query, loginName) var rec KfzToken - err := row.Scan(&rec.ID, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) + err := row.Scan(&rec.ID, &rec.LoginName, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -171,11 +169,11 @@ func (r *TokenRepository) GetByUsername(username string) (*KfzToken, error) { return &rec, nil } -// Update 更新记录(完整字段) -func (r *TokenRepository) Update(id int64, username, password, token string, isEnable bool) error { - query := `UPDATE kfz_token SET username = ?, password = ?, token = ?, is_enable = ? WHERE id = ?` +// Update 更新记录 +func (r *TokenRepository) Update(id int64, loginName, username, password, token string, isEnable bool) error { + query := `UPDATE kfz_token SET login_name = ?, username = ?, password = ?, token = ?, is_enable = ? WHERE id = ?` - result, err := database.DB.Exec(query, username, password, token, isEnable, id) + result, err := database.DB.Exec(query, loginName, username, password, token, isEnable, id) if err != nil { return fmt.Errorf("更新失败: %w", err) } @@ -225,7 +223,7 @@ func (r *TokenRepository) Delete(id int64) error { // GetEnabledTokens 获取所有启用状态的Token func (r *TokenRepository) GetEnabledTokens() ([]*KfzToken, error) { - query := `SELECT id, username, password, token, is_enable FROM kfz_token WHERE is_enable = 1 ORDER BY id ASC` + query := `SELECT id, login_name, username, password, token, is_enable FROM kfz_token WHERE is_enable = 1 ORDER BY id ASC` rows, err := database.DB.Query(query) if err != nil { @@ -236,7 +234,7 @@ func (r *TokenRepository) GetEnabledTokens() ([]*KfzToken, error) { var records []*KfzToken for rows.Next() { var rec KfzToken - err := rows.Scan(&rec.ID, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) + err := rows.Scan(&rec.ID, &rec.LoginName, &rec.Username, &rec.Password, &rec.Token, &rec.IsEnable) if err != nil { return nil, fmt.Errorf("扫描失败: %w", err) } diff --git a/log/2026-06-30.log b/log/2026-06-30.log index 5147e9c..2e4bc03 100644 --- a/log/2026-06-30.log +++ b/log/2026-06-30.log @@ -683,3 +683,235 @@ 2026/06/30 11:16:29 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 2026/06/30 11:16:29 [Repo/Goods] 标记失败成功: id=4 2026/06/30 11:16:29 [syncGoodsPricing] 标记失败: id=4, fail_count=137, new_price=0不启用兜底 +2026/06/30 11:16:34 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:34 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=137 +2026/06/30 11:16:34 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:34 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:34 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:34 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:34 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789390264,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:34 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:34 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:34 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:34 [syncGoodsPricing] 标记失败: id=4, fail_count=138, new_price=0不启用兜底 +2026/06/30 11:16:39 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:39 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=138 +2026/06/30 11:16:39 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:39 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:39 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:39 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:39 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789395272,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:39 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:39 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:39 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:39 [syncGoodsPricing] 标记失败: id=4, fail_count=139, new_price=0不启用兜底 +2026/06/30 11:16:44 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:44 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=139 +2026/06/30 11:16:44 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:44 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:44 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:44 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:44 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789400288,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:44 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:44 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:44 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:44 [syncGoodsPricing] 标记失败: id=4, fail_count=140, new_price=0不启用兜底 +2026/06/30 11:16:49 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:49 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=140 +2026/06/30 11:16:49 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:49 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:49 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:49 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:49 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789405274,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:49 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:49 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:49 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:49 [syncGoodsPricing] 标记失败: id=4, fail_count=141, new_price=0不启用兜底 +2026/06/30 11:16:54 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:54 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=141 +2026/06/30 11:16:54 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:54 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:54 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:54 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:54 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789410278,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:54 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:54 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:54 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:54 [syncGoodsPricing] 标记失败: id=4, fail_count=142, new_price=0不启用兜底 +2026/06/30 11:16:59 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:16:59 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=142 +2026/06/30 11:16:59 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:16:59 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:16:59 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:16:59 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:16:59 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789415366,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:16:59 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:16:59 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102 +2026/06/30 11:16:59 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:16:59 [syncGoodsPricing] 标记失败: id=4, fail_count=143, new_price=0不启用兜底 +====== 2026-06-30 11:17:10 日志文件初始化完成 ====== +2026/06/30 11:17:10 孔网商品定价 v1.0.2 启动中... +2026/06/30 11:17:10 配置加载成功: port=8080, timer=5s, rate_limit=2s +2026/06/30 11:17:10 config: {"Port":"8080","TimerInterval":5,"APIRateLimit":2,"CallbackURL":"http://192.168.101.213:9090/api/product/updatePrice","NewPrice":0,"PlaceholderDownPrice":0,"MinShippingFee":0,"MinPrice":0,"QueryIndex":0} +2026/06/30 11:17:10 [DB] 初始化数据库: path=./data/goods_pricing.db +2026/06/30 11:17:10 [DB] 数据库初始化完成 +2026/06/30 11:17:10 数据库初始化成功 +2026/06/30 11:17:10 [TimerScheduler] 定时器启动, 间隔=5秒 +2026/06/30 11:17:10 定时器已启动,5秒后开始首次同步 +2026/06/30 11:17:10 服务器正在启动 8080 +2026/06/30 11:17:15 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:15 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=143 +2026/06/30 11:17:15 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:15 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:15 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:15 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:15 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789431394,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:15 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:15 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:15 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:15 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:15 [syncGoodsPricing] 标记失败: id=4, fail_count=144, new_price=0不启用兜底 +2026/06/30 11:17:20 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:20 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=144 +2026/06/30 11:17:20 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:20 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:20 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:20 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:20 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789436404,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:20 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:20 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:20 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:20 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:20 [syncGoodsPricing] 标记失败: id=4, fail_count=145, new_price=0不启用兜底 +2026/06/30 11:17:25 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:25 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=145 +2026/06/30 11:17:25 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:25 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:25 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:25 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:25 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789441406,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:25 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:25 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:25 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:25 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:25 [syncGoodsPricing] 标记失败: id=4, fail_count=146, new_price=0不启用兜底 +2026/06/30 11:17:30 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:30 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=146 +2026/06/30 11:17:30 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:30 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:30 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:30 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:30 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789446524,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:31 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:31 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:31 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:31 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:31 [syncGoodsPricing] 标记失败: id=4, fail_count=147, new_price=0不启用兜底 +2026/06/30 11:17:35 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:35 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=147 +2026/06/30 11:17:35 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:35 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:35 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:35 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:36 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789451565,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:36 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:36 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:36 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:36 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:36 [syncGoodsPricing] 标记失败: id=4, fail_count=148, new_price=0不启用兜底 +2026/06/30 11:17:40 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:40 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=148 +2026/06/30 11:17:40 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:40 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:40 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:40 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:41 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789456589,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:41 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:41 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:41 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:41 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:41 [syncGoodsPricing] 标记失败: id=4, fail_count=149, new_price=0不启用兜底 +2026/06/30 11:17:45 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:45 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=149 +2026/06/30 11:17:45 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:45 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:45 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:45 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:46 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789461597,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:46 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:46 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:46 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:46 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:46 [syncGoodsPricing] 标记失败: id=4, fail_count=150, new_price=0不启用兜底 +2026/06/30 11:17:50 [Repo/Config] 查询成功: new_price=0.00, placeholder_down_price=0.00, min_shipping_fee=0.00, min_price=0.00, query_index=0 +2026/06/30 11:17:50 [Repo/Goods] 查询到待处理记录: id=4, isbn=112233445566, book_name=测试图书, fail_count=150 +2026/06/30 11:17:50 [syncGoodsPricing] 开始查询孔网数据: id=4, isbn=112233445566, book_name=测试图书 +2026/06/30 11:17:50 [outGetAllGoods] 可用token数量: 1 +2026/06/30 11:17:50 [outGetAllGoods] 使用token索引: 0/1, username=甄选图书 +2026/06/30 11:17:50 [outGetAllGoods] 请求孔网URL: https://search.kongfz.com/pc-gw/search-web/client/pc/product/keyword/list?dataType=0&page=1&sortType=7&userArea=13003000000&quaSelect=2&keyword=112233445566&keyword=测试图书&author=测试作者&quality=100~&actionPath=sortType,quality +2026/06/30 11:17:51 [outGetAllGoods] 孔网响应数据: {"status":0,"errType":"102","message":"请登录后再进行访问。","systemTime":1782789466661,"data":{"requestRejectCause":"请登录后再进行访问。","requestRejectAction":"GO_LOGIN"}} +2026/06/30 11:17:51 [outGetAllGoods] 孔网API返回错误: message=请登录后再进行访问。, errType=102 +2026/06/30 11:17:51 [outGetAllGoods] Token失效但无密码(未保存), 无法自动重新登录 +2026/06/30 11:17:51 [syncGoodsPricing] 查询孔网失败: id=4, 错误=错误信息: 请登录后再进行访问。,状态码: 102, errType=%!s(MISSING) +2026/06/30 11:17:51 [Repo/Goods] 标记失败成功: id=4 +2026/06/30 11:17:51 [syncGoodsPricing] 标记失败: id=4, fail_count=151, new_price=0不启用兜底 +====== 2026-06-30 11:18:35 日志文件初始化完成 ====== +2026/06/30 11:18:35 孔网商品定价 v1.0.2 启动中... +2026/06/30 11:18:35 配置加载成功: port=8080, timer=5s, rate_limit=2s +2026/06/30 11:18:35 config: {"Port":"8080","TimerInterval":5,"APIRateLimit":2,"CallbackURL":"http://192.168.101.213:9090/api/product/updatePrice","NewPrice":0,"PlaceholderDownPrice":0,"MinShippingFee":0,"MinPrice":0,"QueryIndex":0} +2026/06/30 11:18:35 [DB] 初始化数据库: path=./data/goods_pricing.db +2026/06/30 11:18:35 [DB] 数据库初始化完成 +2026/06/30 11:18:35 数据库初始化成功 +2026/06/30 11:18:35 [TimerScheduler] 定时器启动, 间隔=5秒 +2026/06/30 11:18:35 定时器已启动,5秒后开始首次同步 +2026/06/30 11:18:35 服务器正在启动 8080 +2026/06/30 11:18:40 [Repo/Config] kfz_config表无数据 +2026/06/30 11:18:40 [syncGoodsPricing] kfz_config表中无配置数据, 跳过本次同步。请到进销存系统中设置核价器配置 +2026/06/30 11:18:45 [Repo/Config] kfz_config表无数据 +2026/06/30 11:18:45 [syncGoodsPricing] kfz_config表中无配置数据, 跳过本次同步。请到进销存系统中设置核价器配置 +2026/06/30 11:18:47 [SetConfigPrice] 收到请求, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:47 [Repo/Config] kfz_config表无数据 +2026/06/30 11:18:47 [Repo/Config] 插入配置成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:47 [SetConfigPrice] 配置保存成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:50 [Token/GetAll] 收到请求, 来源IP: 127.0.0.1:62766 +2026/06/30 11:18:50 [Token/GetAll] 查询成功: 共0条记录, 来源IP: 127.0.0.1:62766 +2026/06/30 11:18:50 [GetConfigPrice] 收到请求, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:50 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:50 [GetConfigPrice] 返回配置: port=8080, new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:50 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:52 [Token/Delete] 收到请求, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:52 [Token/Delete] 删除失败: id=1, 错误=记录不存在, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:55 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:56 [Token/GetAll] 收到请求, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:56 [GetConfigPrice] 收到请求, 来源IP: 127.0.0.1:62766 +2026/06/30 11:18:56 [Token/GetAll] 查询成功: 共0条记录, 来源IP: 127.0.0.1:62762 +2026/06/30 11:18:56 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:18:56 [GetConfigPrice] 返回配置: port=8080, new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:00 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:05 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:10 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:12 [KfzLogin] 收到登录请求, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:12 [KfzLogin] 开始登录孔网, username=15840388853, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:13 [KfzLogin] 孔网登录成功: username=15840388853, token=6c323cb291..., 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:13 [Repo/Token] 保存Token成功: username=15840388853 +2026/06/30 11:19:13 [KfzLogin] 账号密码已保存到数据库: username=15840388853 +2026/06/30 11:19:13 [KfzLogin] 登录成功: username=15840388853, userId=24959115, nickname=书友kw13235893, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:13 [Token/BatchAdd] 收到请求, 来源IP: 127.0.0.1:62766, token数量: 1 +2026/06/30 11:19:13 [Token/BatchAdd] 第1条插入成功: id=2, username=书友kw13235893 +2026/06/30 11:19:13 [Token/BatchAdd] 全部成功: 1条, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:13 [Token/GetAll] 收到请求, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:13 [Token/GetAll] 查询成功: 共2条记录, 来源IP: 127.0.0.1:62766 +2026/06/30 11:19:15 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:20 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:25 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:30 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:35 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:40 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:45 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:50 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:19:55 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:20:00 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:20:05 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:20:10 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:20:15 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3 +2026/06/30 11:20:20 [Repo/Config] 查询成功: new_price=9999.00, placeholder_down_price=0.01, min_shipping_fee=3.00, min_price=1.00, query_index=3