Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ca4fca9a16
|
@ -42,7 +42,7 @@ tools:
|
||||||
zltxProduct:
|
zltxProduct:
|
||||||
enabled: true
|
enabled: true
|
||||||
base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/oursProduct"
|
base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/oursProduct"
|
||||||
add_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/platformProduct/"
|
add_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/platformProduct/getProductsByOfficialProductId"
|
||||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzU2MTgyNTM1LCJuYmYiOjE3NTYxODA3MzUsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.N1xv1PYbcO8_jR5adaczc16YzGsr4z101gwEZdulkRaREBJNYTOnFrvRxTFx3RJTooXsqTqroE1MR84v_1WPX6BS6kKonA-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3E-EXg9VfE1SX8nMcck9Yjnc8NCy7RTWaBIaSeOdZcEl-JfCD0S6GSx3oErp_hk-U9FKGwf60wAuDGTY1R0BP4BYpcEqS-C2LSnsSGyURi54Cuk5xH8r1WuF0Dm5bwAj5d7Hvs77-N_sUF-C5ONqyZJRAEhYLgcmN9RX_WQZfizdQJxizlTczdpzYfy-v-1eQ"
|
||||||
zltxOrderStatistics:
|
zltxOrderStatistics:
|
||||||
base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/direct/ai/search/"
|
base_url: "https://gateway.dev.cdlsxd.cn/zltx_api/admin/direct/ai/search/"
|
||||||
|
|
|
@ -57,7 +57,7 @@ func Test_ProductLog(t *testing.T) {
|
||||||
routerBiz := in()
|
routerBiz := in()
|
||||||
ch := make(chan entitys.Response, 5)
|
ch := make(chan entitys.Response, 5)
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
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": "订单编号/流水号"}}}}`})
|
err := routerBiz.handleTask(ch, nil, &entitys.Match{Index: "order_diagnosis", Parameters: `{"name":"利楚测试"}`}, &model.AiTask{Config: `{"tool": "zltxProduct", "param": {"type": "object", "optional": [], "required": ["order_number"], "properties": {"order_number": {"type": "string", "description": "订单编号/流水号"}}}}`})
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"ai_scheduler/internal/entitys"
|
"ai_scheduler/internal/entitys"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gitea.cdlsxd.cn/self-tools/l_request"
|
"gitea.cdlsxd.cn/self-tools/l_request"
|
||||||
|
@ -190,7 +191,7 @@ func (z ZltxProductTool) getZltxProduct(channel chan entitys.Response, c *websoc
|
||||||
for i := range resp.Data.List {
|
for i := range resp.Data.List {
|
||||||
// 调用 平台商品列表
|
// 调用 平台商品列表
|
||||||
if resp.Data.List[i].AuthProductIds != "" {
|
if resp.Data.List[i].AuthProductIds != "" {
|
||||||
platformProductList := z.ExecutePlatformProductList(auth, resp.Data.List[i].AuthProductIds)
|
platformProductList := z.ExecutePlatformProductList(auth, resp.Data.List[i].AuthProductIds, resp.Data.List[i].OfficialProductID)
|
||||||
resp.Data.List[i].PlatformProductList = platformProductList
|
resp.Data.List[i].PlatformProductList = platformProductList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,20 +208,94 @@ func (z ZltxProductTool) getZltxProduct(channel chan entitys.Response, c *websoc
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z ZltxProductTool) ExecutePlatformProductList(auth string, authProductIds string) []map[string]any {
|
type PlatformProductResponse struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Data []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
PlatformID int `json:"platform_id"`
|
||||||
|
OfficialProductID int `json:"official_product_id"`
|
||||||
|
Weight int `json:"weight"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Discount string `json:"discount"`
|
||||||
|
Price string `json:"price"`
|
||||||
|
Extra string `json:"extra"`
|
||||||
|
AccountType []string `json:"account_type"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CreateTime string `json:"create_time"`
|
||||||
|
UpdateTime string `json:"update_time"`
|
||||||
|
RebatePrice string `json:"rebate_price"`
|
||||||
|
ExchangeType int `json:"exchange_type"`
|
||||||
|
IsReportInfo int `json:"is_report_info"`
|
||||||
|
Describe string `json:"describe"`
|
||||||
|
PlatformAliasID int `json:"platform_alias_id"`
|
||||||
|
Platform struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Tag string `json:"tag"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Weight int `json:"weight"`
|
||||||
|
UpdateTime string `json:"update_time"`
|
||||||
|
SearchTime string `json:"search_time"`
|
||||||
|
Balance string `json:"balance"`
|
||||||
|
BalanceWarning string `json:"balance_warning"`
|
||||||
|
StockType int `json:"stock_type"`
|
||||||
|
IsIndependent int `json:"is_independent"`
|
||||||
|
IndependentDeadline string `json:"independent_deadline"`
|
||||||
|
CreateTime string `json:"create_time"`
|
||||||
|
} `json:"platform"`
|
||||||
|
} `json:"data"`
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PlatformData struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
PlatformID int `json:"platform_id"`
|
||||||
|
OfficialProductID int `json:"official_product_id"`
|
||||||
|
Weight int `json:"weight"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Discount string `json:"discount"`
|
||||||
|
Price string `json:"price"`
|
||||||
|
Extra string `json:"extra"`
|
||||||
|
AccountType []string `json:"account_type"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
CreateTime string `json:"create_time"`
|
||||||
|
UpdateTime string `json:"update_time"`
|
||||||
|
RebatePrice string `json:"rebate_price"`
|
||||||
|
ExchangeType int `json:"exchange_type"`
|
||||||
|
IsReportInfo int `json:"is_report_info"`
|
||||||
|
Describe string `json:"describe"`
|
||||||
|
PlatformAliasID int `json:"platform_alias_id"`
|
||||||
|
Platform struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Tag string `json:"tag"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Weight int `json:"weight"`
|
||||||
|
UpdateTime string `json:"update_time"`
|
||||||
|
SearchTime string `json:"search_time"`
|
||||||
|
Balance string `json:"balance"`
|
||||||
|
BalanceWarning string `json:"balance_warning"`
|
||||||
|
StockType int `json:"stock_type"`
|
||||||
|
IsIndependent int `json:"is_independent"`
|
||||||
|
IndependentDeadline string `json:"independent_deadline"`
|
||||||
|
CreateTime string `json:"create_time"`
|
||||||
|
} `json:"platform"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (z ZltxProductTool) ExecutePlatformProductList(auth string, authProductIds string, officialProductID int) []PlatformData {
|
||||||
if authProductIds == "" {
|
if authProductIds == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//authProductIds 以逗号分割
|
//authProductIds 以逗号分割
|
||||||
authProductIdList := strings.Split(authProductIds, ",")
|
authProductIdList := strings.Split(authProductIds, ",")
|
||||||
var result []map[string]any
|
|
||||||
|
|
||||||
for _, authProductId := range authProductIdList {
|
for _, authProductId := range authProductIdList {
|
||||||
var platformProductResponse map[string]any
|
var platformProductResponse PlatformProductResponse
|
||||||
req := l_request.Request{
|
req := l_request.Request{
|
||||||
//https://gateway.dev.cdlsxd.cn/zltx_api/admin/platformProduct/{product_id}?id={product_id}
|
//https://gateway.dev.cdlsxd.cn/zltx_api/admin/platformProduct/getProductsByOfficialProductId?official_product_id=282&is_all=true
|
||||||
Url: fmt.Sprintf("%s/%s?id=%s", z.config.AddURL, authProductId, authProductId),
|
Url: fmt.Sprintf("%s?official_product_id=%d&is_all=true", z.config.AddURL, officialProductID),
|
||||||
Headers: map[string]string{
|
Headers: map[string]string{
|
||||||
"Authorization": fmt.Sprintf("Bearer %s", auth),
|
"Authorization": fmt.Sprintf("Bearer %s", auth),
|
||||||
},
|
},
|
||||||
|
@ -237,16 +312,19 @@ func (z ZltxProductTool) ExecutePlatformProductList(auth string, authProductIds
|
||||||
// 可以考虑记录日志而不是直接跳过
|
// 可以考虑记录日志而不是直接跳过
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
authProductIdInt, err := strconv.Atoi(authProductId)
|
||||||
// 只提取 data 部分
|
if err != nil {
|
||||||
if data, ok := platformProductResponse["data"]; ok {
|
// 可以考虑记录日志而不是直接跳过
|
||||||
if dataMap, ok := data.(map[string]any); ok {
|
continue
|
||||||
result = append(result, dataMap)
|
}
|
||||||
|
for _, platformProduct := range platformProductResponse.Data {
|
||||||
|
if platformProduct.ID == authProductIdInt {
|
||||||
|
return []PlatformData{platformProduct}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZltxProductPlatformProductList struct {
|
type ZltxProductPlatformProductList struct {
|
||||||
|
|
Loading…
Reference in New Issue