From e48ec38a961df9994b0a33d83adec6afb5004395 Mon Sep 17 00:00:00 2001 From: wuchao <1272174216@qq.com> Date: Mon, 29 Sep 2025 10:21:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(biz):=20=E6=9B=B4=E6=96=B0=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E9=80=9A=E9=81=93=E7=B1=BB=E5=9E=8B=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E5=95=86=E5=93=81=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E5=B0=86=20handleTask=20=E4=B8=AD=E7=9A=84=20Respo?= =?UTF-8?q?nseData=E9=80=9A=E9=81=93=E7=BB=9F=E4=B8=80=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20Response=20-=20=E5=9C=A8=E5=95=86=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=B7=A5=E5=85=B7=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E7=9A=84=E5=88=A4=E6=96=AD=E5=B9=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E4=B8=AD=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BB=A5=E5=8C=B9=E9=85=8D=E5=AE=9E=E9=99=85=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=9C=80=E6=B1=82=20-=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=20AiRouterBiz=E6=97=B6=E6=96=B0=E5=A2=9E=20client=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/router_test.go | 14 +++++++------- internal/tools/zltx_product.go | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/biz/router_test.go b/internal/biz/router_test.go index a1bf5c0..bf3ef45 100644 --- a/internal/biz/router_test.go +++ b/internal/biz/router_test.go @@ -33,7 +33,7 @@ type configData struct { func Test_Order(t *testing.T) { routerBiz := in() - ch := make(chan entitys.ResponseData, 5) + ch := make(chan entitys.Response, 5) defer close(ch) err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"order_number":"822895927188791297"}`}, &model.AiTask{Config: `{"tool": "zltxOrderDetail", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`}) select { @@ -47,7 +47,7 @@ func Test_Order(t *testing.T) { func Test_OrderLog(t *testing.T) { routerBiz := in() - ch := make(chan entitys.ResponseData, 5) + ch := make(chan entitys.Response, 5) defer close(ch) err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"order_number":"822979421673758721","serial_number":"822979421979938817"}`}, &model.AiTask{Config: `{"tool": "zltxOrderDirectLog", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`}) t.Log(err) @@ -55,17 +55,17 @@ func Test_OrderLog(t *testing.T) { func Test_ProductLog(t *testing.T) { routerBiz := in() - ch := make(chan entitys.ResponseData, 5) + ch := make(chan entitys.Response, 5) defer close(ch) - err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"id":"101","serial_number":"822979421979938817"}`}, &model.AiTask{Config: `{"tool": "zltxProduct", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`}) + err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"name":"李瑞上游测试20250918002"}`}, &model.AiTask{Config: `{"tool": "zltxProduct", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`}) t.Log(err) } func Test_ZltxStatistics(t *testing.T) { routerBiz := in() - ch := make(chan entitys.ResponseData, 5) + ch := make(chan entitys.Response, 5) defer close(ch) - err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"number":"15583730896"}`}, &model.AiTask{Config: `{"tool": "zltxOrderStatistics", "param": {"type": "object", "optional": [], "required": ["number"], "properties": {"number": {"type": "string", "description": "充值账号/分销商ID"}}}}`}) + err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"number":"13737882067"}`}, &model.AiTask{Config: `{"tool": "zltxOrderStatistics", "param": {"type": "object", "optional": [], "required": ["number"], "properties": {"number": {"type": "string", "description": "充值账号/分销商ID"}}}}`}) t.Log(err) } @@ -93,7 +93,7 @@ func in() *AiRouterBiz { taskImpl := impl.NewTaskImpl(db) chatImpl := impl.NewChatImpl(db) safeChannelPool, _ := pkg.NewSafeChannelPool(configConfig) - routerBiz := NewAiRouterBiz(manager, sessionImpl, sysImpl, taskImpl, chatImpl, configConfig, utilOllama, safeChannelPool) + routerBiz := NewAiRouterBiz(manager, sessionImpl, sysImpl, taskImpl, chatImpl, configConfig, utilOllama, safeChannelPool, client) return routerBiz } diff --git a/internal/tools/zltx_product.go b/internal/tools/zltx_product.go index 915e651..2b3ff29 100644 --- a/internal/tools/zltx_product.go +++ b/internal/tools/zltx_product.go @@ -179,6 +179,9 @@ func (z ZltxProductTool) getZltxProduct(channel chan entitys.Response, c *websoc if err := json.Unmarshal(res.Content, &respData); err != nil { return fmt.Errorf("解析商品数据失败:%w", err) } + if respData.Data.ID == 0 { + return fmt.Errorf("商品查询失败:暂无数据") + } resp.Data.List = []ZltxProductData{respData.Data} resp.Data.DataCount = 1 }