package merchant

import (
	"context"
	"github.com/gogf/gf/v2/os/glog"

	"github.com/openai/openai-go/v3"
	"github.com/openai/openai-go/v3/option"
	"testing"
)

func Test_queryAppleResult(t *testing.T) {
	client := openai.NewClient(
		option.WithAPIKey("sk-jYRlGtXAJ3Q82TS_FxWLFX6wn_VubNnyCtfxYZYP32ccqfQaGwQJHMq5I7k"),
		option.WithBaseURL("https://hk.uniapi.io/v1"),
	)

	msg := "[\n            {\n                \"orderNo\": \"\",\n                \"operation\": \"拉取订单\",\n                \"remark\": \"\",\n                \"createdAt\": \"2025-11-28 20:39:32\",\n                \"accountName\": \"\"\n            },\n            {\n                \"orderNo\": \"\",\n                \"operation\": \"用户提交卡密\",\n                \"remark\": \"\",\n                \"createdAt\": \"2025-11-28 20:39:57\",\n                \"accountName\": \"\"\n            },\n            {\n                \"orderNo\": \"019aca7a2f7d73c79f5839417aa63972\",\n                \"operation\": \"创建订单\",\n                \"remark\": \"\",\n                \"createdAt\": \"2025-11-28 20:39:56\",\n                \"accountName\": \"\"\n            },\n            {\n                \"orderNo\": \"019aca7a2f7d73c79f5839417aa63972\",\n                \"operation\": \"iTunes开始处理\",\n                \"remark\": \"分配账户：rintoul.pablo19297@funkybusinez.com\",\n                \"createdAt\": \"2025-11-28 20:39:56\",\n                \"accountName\": \"rintoul.pablo19297@funkybusinez.com\"\n            },\n            {\n                \"orderNo\": \"019aca7a2f7d73c79f5839417aa63972\",\n                \"operation\": \"查询账户余额\",\n                \"remark\": \"账号【rintoul.pablo19297@funkybusinez.com】充值前余额：314.00\",\n                \"createdAt\": \"2025-11-28 20:40:01\",\n                \"accountName\": \"rintoul.pablo19297@funkybusinez.com\"\n            },\n            {\n                \"orderNo\": \"019aca7a2f7d73c79f5839417aa63972\",\n                \"operation\": \"iTunes充值失败\",\n                \"remark\": \"卡密不存在使用卡密【XF5P2KPX9YWTY365】为账号【rintoul.pablo19297@funkybusinez.com】充值失败，卡密不存在\",\n                \"createdAt\": \"2025-11-28 20:40:02\",\n                \"accountName\": \"rintoul.pablo19297@funkybusinez.com\"\n            },\n            {\n                \"orderNo\": \"019aca7a2f7d73c79f5839417aa63972\",\n                \"operation\": \"查询账户余额\",\n                \"remark\": \"账号【rintoul.pablo19297@funkybusinez.com】充值后余额：314.00\",\n                \"createdAt\": \"2025-11-28 20:40:04\",\n                \"accountName\": \"rintoul.pablo19297@funkybusinez.com\"\n            }\n        ]"

	chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
		Messages: []openai.ChatCompletionMessageParamUnion{
			openai.UserMessage(msg + "\n只生成简洁结论，不需要建议，使用中文"),
		},
		Model: "deepseek-v3.2-exp",
	})
	if err != nil {
		glog.Info(t.Context(), err)
	}
	glog.Info(t.Context(), chatCompletion.Choices[0].Message.Content)
}
