51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
|
|
"bindbox-game/internal/pkg/logger"
|
|
"bindbox-game/internal/repository/mysql"
|
|
"bindbox-game/internal/repository/mysql/dao"
|
|
"bindbox-game/internal/service/douyin"
|
|
syscfgsvc "bindbox-game/internal/service/sysconfig"
|
|
)
|
|
|
|
func main() {
|
|
orderID := flag.String("id", "", "抖音订单号 (order_id)")
|
|
flag.Parse()
|
|
|
|
if *orderID == "" {
|
|
log.Fatal("请提供订单号,例如: -id=6946062444563338504")
|
|
}
|
|
|
|
// 1. 初始化 MySQL
|
|
dbRepo, err := mysql.New()
|
|
if err != nil {
|
|
log.Fatalf("MySQL 初始化失败: %v", err)
|
|
}
|
|
|
|
// 2. 初始化 Logger (简易版)
|
|
customLogger, _ := logger.NewCustomLogger(dao.Use(dbRepo.GetDbW()), logger.WithOutputInConsole())
|
|
|
|
// 3. 初始化 Service
|
|
sysCfgSvc := syscfgsvc.New(customLogger, dbRepo)
|
|
douyinSvc := douyin.New(customLogger, dbRepo, sysCfgSvc, nil)
|
|
|
|
// 4. 执行测试
|
|
fmt.Printf("--- 正在测试订单号: %s ---\n", *orderID)
|
|
ctx := context.Background()
|
|
order, err := douyinSvc.GetOrderByOrderID(ctx, *orderID)
|
|
if err != nil {
|
|
log.Fatalf("查询失败: %v", err)
|
|
}
|
|
|
|
// 5. 打印结果
|
|
fmt.Println("查询成功!返回数据如下:")
|
|
data, _ := json.MarshalIndent(order, "", " ")
|
|
fmt.Println(string(data))
|
|
}
|