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 }